당직근무 0.16.0 (웹 2026-12-01.1): 관리자 공지 메뉴와 앱 첫 화면 공지 띠
This commit is contained in:
1 parent
2116ef5607
commit
5f2e2f6952
22 files changed
+265
-27
No files matched your search
@@ -126,3 +126,7 @@ dialog h3{font-size:15px;margin:22px 0 4px}
|
||||
.data-table td.clip{max-width:320px;overflow-wrap:anywhere}
|
||||
.data-table td a{color:var(--ink);font-weight:650}
|
||||
@media(max-width:900px){.head-actions{width:100%}.board-row{flex-direction:column;align-items:flex-start}}
|
||||
/* 공지 화면: 공지 띠 미리보기는 홈페이지 공지 띠와 같은 색 */
|
||||
.card-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.card-head h2{margin-bottom:0}
|
||||
.notice-preview-label{margin-top:14px}.notice-preview{display:flex;align-items:center;gap:10px;margin:6px 0 14px;padding:11px 16px;font-size:13px;line-height:1.6;background:#e9eef5;color:var(--ink);border:1px solid #cfd8e3;border-radius:5px;overflow-wrap:anywhere}.notice-preview::before{content:'';flex:none;width:8px;height:8px;border-radius:50%;background:#365fad}.notice-preview.warn{background:#f8ece5;border-color:#e8cbbb}.notice-preview.warn::before{background:#b65b3c}.notice-preview.off{background:transparent;border-style:dashed;color:var(--muted)}.notice-preview.off::before{background:#c6cbd0}
|
||||
#notice-rows td:first-child{min-width:170px}
|
||||
@@ -8,6 +8,7 @@
|
||||
<a class="side-brand" href="./"><img src="brand/logo" alt="" width="36" height="36"><span><b>당직근무</b><small>관리자</small></span></a>
|
||||
<nav class="side-nav" aria-label="관리 메뉴">
|
||||
<button data-view="overview" class="active"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 13h6V4H4zM14 20h6v-9h-6zM4 20h6v-4H4zM14 7h6V4h-6z"/></svg>현황</button>
|
||||
<button data-view="notice"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 10v4h3l6 4V6L7 10zM16.5 9a4 4 0 0 1 0 6M19 6.5a7.5 7.5 0 0 1 0 11"/></svg>공지</button>
|
||||
<button data-view="members"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM2 21a7 7 0 0 1 14 0M17 11a3 3 0 1 0-1-5.8M22 21a6 6 0 0 0-4-5.7"/></svg>회원</button>
|
||||
<button data-view="companies"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 21V5l8-2v18M12 8l8 2v11M3 21h18M8 9v.01M8 13v.01M8 17v.01M16 13v.01M16 17v.01"/></svg>소속</button>
|
||||
<button data-view="site"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 5h18v14H3zM3 9h18M7 13h6M7 16h4"/></svg>홈페이지</button>
|
||||
@@ -32,6 +33,18 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="view-notice" class="view" hidden>
|
||||
<header class="view-head"><div><p class="eyebrow">공지 관리</p><h1>공지</h1></div><div class="head-actions"><a class="secondary-link" href="./" target="_blank" rel="noopener">홈페이지 열기</a><a class="secondary-link" href="board" target="_blank" rel="noopener">게시판 열기</a></div></header>
|
||||
<section class="card stack"><h2>공지 띠</h2><p class="small">켜 두면 홈페이지 맨 위와 앱 첫 화면에 한 줄로 보입니다. 앱은 0.16.0부터 보이고 다음에 앱을 열 때 바뀝니다.</p>
|
||||
<p class="eyebrow notice-preview-label">미리보기</p><div id="notice-preview" class="notice-preview"></div>
|
||||
<form id="notice-form" class="site-form single compact"></form><button id="notice-save" form="notice-form" type="submit">공지 띠 저장</button></section>
|
||||
<section class="card stack"><div class="card-head"><h2>공지사항 글</h2><button id="notice-new" type="button">새 공지 쓰기</button></div>
|
||||
<p class="small">홈페이지 게시판의 공지사항에 올라갑니다. 누구나 읽을 수 있고 관리자만 씁니다. 고정한 글은 목록 맨 위에 보입니다.</p>
|
||||
<div class="table-wrap"><table class="data-table"><thead><tr><th>제목</th><th>상태</th><th>쓴 때</th><th>관리</th></tr></thead><tbody id="notice-rows"></tbody></table></div>
|
||||
<div class="pager"><button id="notice-prev" class="secondary">이전</button><span id="notice-page"></span><button id="notice-next" class="secondary">다음</button></div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="view-members" class="view" hidden>
|
||||
<header class="view-head"><div><p class="eyebrow">회원 관리</p><h1>회원</h1></div><p id="member-total" class="count"></p></header>
|
||||
<form id="member-filter" class="toolbar"><input id="member-q" type="search" maxlength="40" placeholder="아이디 또는 이름" aria-label="회원 검색"><select id="member-show" aria-label="회원 범위"><option value="all">전체</option><option value="admin">관리자</option><option value="suspended">이용 중지</option><option value="mustChange">비밀번호 변경 필요</option><option value="idle">30일 넘게 미접속</option><option value="company">소속 있음</option></select><select id="member-sort" aria-label="정렬"><option value="created">가입 최신순</option><option value="login">최근 접속순</option><option value="name">이름순</option></select><button type="submit">찾기</button></form>
|
||||
@@ -112,6 +125,12 @@
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<dialog id="notice-dialog" class="wide-dialog"><form id="notice-post-form"><div class="dialog-heading"><h2 id="notice-heading">새 공지</h2><button type="button" class="icon-button close" aria-label="닫기">×</button></div>
|
||||
<label>제목<input id="np-title" maxlength="80" required></label>
|
||||
<label>본문<textarea id="np-body" rows="10" maxlength="20000" required></textarea></label>
|
||||
<label id="np-pin-label" class="check-label"><input id="np-pin" type="checkbox">공지사항 맨 위에 고정</label>
|
||||
<p id="np-error" class="form-error" role="alert"></p>
|
||||
<div class="dialog-actions"><button type="button" class="secondary close">취소</button><button id="np-submit" type="submit">올리기</button></div></form></dialog>
|
||||
<dialog id="board-dialog"><form id="board-form"><div class="dialog-heading"><h2 id="board-heading">게시판</h2><button type="button" class="icon-button close" aria-label="닫기">×</button></div>
|
||||
<label>주소 이름 (영어 소문자·숫자·-, 만든 뒤에는 바꿀 수 없음)<input id="bd-id" maxlength="20" pattern="[a-z][a-z0-9-]{1,19}" required></label>
|
||||
<label>게시판 이름<input id="bd-name" maxlength="20" required></label>
|
||||
|
||||
+87
-5
@@ -112,7 +112,7 @@ async function start() {
|
||||
const view = (location.hash || '#overview').slice(1);
|
||||
show(Object.keys(loaders).includes(view) ? view : 'overview');
|
||||
}
|
||||
const loaders = { overview: loadOverview, members: loadMembers, companies: loadCompanies, site: loadSite, guide: loadGuide, board: loadBoard, brand: loadBrand, log: loadLog };
|
||||
const loaders = { overview: loadOverview, notice: loadNotice, members: loadMembers, companies: loadCompanies, site: loadSite, guide: loadGuide, board: loadBoard, brand: loadBrand, log: loadLog };
|
||||
function show(view) {
|
||||
document.querySelectorAll('.view').forEach(section => { section.hidden = section.id !== 'view-' + view; });
|
||||
document.querySelectorAll('.side-nav button').forEach(button => button.classList.toggle('active', button.dataset.view === view));
|
||||
@@ -384,8 +384,8 @@ $('cd-revoke').onclick = () => companyAction({ action: 'revoke-invite' }, '지
|
||||
$('cd-delete').onclick = () => companyAction({ action: 'delete-company' }, state.editingCompany.name + ' 소속을 삭제할까요? 구성원 연결과 교환·인수인계 기록이 지워집니다. 회원과 개인 달력은 남습니다.', '소속 삭제', true);
|
||||
|
||||
// ------------------------------------------------------------ 홈페이지 설정
|
||||
// 설정 칸은 서버의 SITE_FIELDS가 정한다. page(site 홈페이지 · guide 연동 안내 · board 게시판)마다 다른 화면에 그린다.
|
||||
const SETTING_FORMS = { 'site-form': 'site', 'guide-form': 'guide', 'board-settings-form': 'board' };
|
||||
// 설정 칸은 서버의 SITE_FIELDS가 정한다. page(site 홈페이지 · notice 공지 · guide 연동 안내 · board 게시판)마다 다른 화면에 그린다.
|
||||
const SETTING_FORMS = { 'site-form': 'site', 'notice-form': 'notice', 'guide-form': 'guide', 'board-settings-form': 'board' };
|
||||
async function loadSettings(formId) {
|
||||
const data = await api('admin/settings');
|
||||
state.fields = data.fields;
|
||||
@@ -435,7 +435,7 @@ function fieldControl(field) {
|
||||
}
|
||||
input.id = id;
|
||||
input.dataset.key = field.key;
|
||||
const update = () => { markChanged(field); if ((field.page || 'site') === 'site') preview(); };
|
||||
const update = () => { markChanged(field); const page = field.page || 'site'; if (page === 'site') preview(); if (page === 'notice') noticePreview(); };
|
||||
input.addEventListener('input', update);
|
||||
input.addEventListener('change', update);
|
||||
const wrap = el('div', null, 'field' + (field.kind === 'longtext' ? ' long' : ''));
|
||||
@@ -518,14 +518,96 @@ async function saveSettings(formId, button) {
|
||||
button.disabled = true;
|
||||
try {
|
||||
const result = await api('admin/settings', { values: changed });
|
||||
notify(result.changed.length ? result.changed.length + '개 항목을 저장했습니다. 홈페이지에 바로 반영됩니다.' : '바뀐 항목이 없습니다.');
|
||||
const where = page === 'notice' ? '홈페이지는 바로 바뀌고 앱은 다음에 열 때 바뀝니다.' : '홈페이지에 바로 반영됩니다.';
|
||||
notify(result.changed.length ? result.changed.length + '개 항목을 저장했습니다. ' + where : '바뀐 항목이 없습니다.');
|
||||
reloadCurrent();
|
||||
} catch (error) { failed(error); } finally { button.disabled = false; }
|
||||
}
|
||||
$('site-form').onsubmit = event => { event.preventDefault(); saveSettings('site-form', $('site-save')); };
|
||||
$('notice-form').onsubmit = event => { event.preventDefault(); saveSettings('notice-form', $('notice-save')); };
|
||||
$('guide-form').onsubmit = event => { event.preventDefault(); saveSettings('guide-form', $('guide-save')); };
|
||||
$('board-settings-form').onsubmit = event => { event.preventDefault(); saveSettings('board-settings-form', $('board-settings-save')); };
|
||||
|
||||
// ------------------------------------------------------------ 공지
|
||||
// 공지 띠는 SITE_FIELDS의 notice 칸이다. 공지사항 글은 게시판 'notice'에 쓰고 게시판 API를 그대로 쓴다.
|
||||
const NOTICE_BOARD = 'notice';
|
||||
const noticeState = { page: 1, editing: null };
|
||||
async function loadNotice() {
|
||||
try { await loadSettings('notice-form'); } catch (error) { failed(error); return; }
|
||||
noticePreview();
|
||||
loadNoticePosts();
|
||||
}
|
||||
function noticePreview() {
|
||||
const values = {};
|
||||
for (const field of state.fields) values[field.key] = readField(field);
|
||||
const text = String(values.noticeText || '').trim();
|
||||
const box = $('notice-preview');
|
||||
box.classList.toggle('warn', values.noticeTone === 'warn');
|
||||
box.classList.toggle('off', !(values.noticeOn && text));
|
||||
box.textContent = values.noticeOn && text ? text : (text ? '꺼져 있어 보이지 않습니다.' : '공지 내용이 비어 있습니다.');
|
||||
}
|
||||
async function loadNoticePosts() {
|
||||
let data;
|
||||
try { data = await api('admin/board-posts?board=' + NOTICE_BOARD + '&state=all&page=' + noticeState.page); } catch (error) { failed(error); return; }
|
||||
pager('notice', data.page, data.total, data.pageSize);
|
||||
const body = $('notice-rows');
|
||||
if (!data.posts.length) { emptyRow(body, 4, '아직 올린 공지사항 글이 없습니다.'); return; }
|
||||
body.replaceChildren();
|
||||
for (const row of data.posts) {
|
||||
const tr = el('tr');
|
||||
const title = el('td'); const link = el('a', row.title); link.href = 'board#/p/' + row.id; link.target = '_blank'; link.rel = 'noopener'; title.append(link);
|
||||
if (row.pinned) title.append(' ', badge('고정', 'admin'));
|
||||
const stateCell = el('td'); stateCell.append(badge(...STATE_BADGES[row.state]));
|
||||
const tools = el('td', null, 'row-tools');
|
||||
const act = (label, action, ask) => { const b = el('button', label, 'secondary'); b.type = 'button'; b.onclick = async () => {
|
||||
if (ask && !await confirmAction(ask, label)) return;
|
||||
try { await api('admin/board-post/' + row.id, { action }); notify(DONE_MESSAGES[action]); loadNoticePosts(); } catch (error) { failed(error); }
|
||||
}; tools.append(b); };
|
||||
if (row.state !== 'deleted') { const edit = el('button', '고치기', 'secondary'); edit.type = 'button'; edit.onclick = () => openNoticeEditor(row); tools.append(edit); }
|
||||
act(row.pinned ? '고정 해제' : '고정', row.pinned ? 'unpin' : 'pin');
|
||||
if (row.state === 'open') { act('숨기기', 'hide'); act('지우기', 'delete', '"' + row.title + '" 공지를 지울까요? 목록에서 빠지고 나중에 되살릴 수 있습니다.'); }
|
||||
else act(row.state === 'hidden' ? '다시 보이기' : '되살리기', row.state === 'hidden' ? 'show' : 'restore');
|
||||
tr.append(title, stateCell, el('td', when(row.created)), tools);
|
||||
body.append(tr);
|
||||
}
|
||||
}
|
||||
async function openNoticeEditor(row) {
|
||||
noticeState.editing = row ? row.id : null;
|
||||
$('notice-heading').textContent = row ? '공지 고치기' : '새 공지';
|
||||
$('np-submit').textContent = row ? '저장' : '올리기';
|
||||
$('np-error').textContent = '';
|
||||
$('np-title').value = ''; $('np-body').value = ''; $('np-pin').checked = false;
|
||||
$('np-pin-label').hidden = Boolean(row);
|
||||
if (row) {
|
||||
try { const data = await api('posts/' + row.id); $('np-title').value = data.post.title; $('np-body').value = data.post.body; } catch (error) { failed(error); return; }
|
||||
}
|
||||
$('notice-dialog').showModal();
|
||||
$('np-title').focus();
|
||||
}
|
||||
$('notice-new').onclick = () => openNoticeEditor(null);
|
||||
$('notice-post-form').onsubmit = async event => {
|
||||
event.preventDefault();
|
||||
const title = $('np-title').value.trim(), body = $('np-body').value.trim();
|
||||
if (!title || !body) { $('np-error').textContent = '제목과 본문을 써 주세요.'; return; }
|
||||
const editing = noticeState.editing;
|
||||
$('np-submit').disabled = true;
|
||||
try {
|
||||
if (editing) await api('posts/' + editing, { action: 'edit', title, body });
|
||||
else {
|
||||
const result = await api('boards/' + NOTICE_BOARD + '/posts', { title, body });
|
||||
if ($('np-pin').checked) await api('admin/board-post/' + result.id, { action: 'pin' });
|
||||
}
|
||||
$('notice-dialog').close();
|
||||
notify(editing ? '공지를 고쳤습니다.' : '공지를 올렸습니다.');
|
||||
if (!editing) noticeState.page = 1;
|
||||
loadNoticePosts();
|
||||
} catch (error) {
|
||||
if (error.status === 401) failed(error); else $('np-error').textContent = error.message;
|
||||
} finally { $('np-submit').disabled = false; }
|
||||
};
|
||||
$('notice-prev').onclick = () => { noticeState.page--; loadNoticePosts(); };
|
||||
$('notice-next').onclick = () => { noticeState.page++; loadNoticePosts(); };
|
||||
|
||||
// ------------------------------------------------------------ 게시판
|
||||
const boardState = { boards: [], levels: null, post: { page: 1 }, comment: { page: 1 }, editing: null };
|
||||
const DONE_MESSAGES = { pin: '맨 위에 고정했습니다.', unpin: '고정을 풀었습니다.', hide: '숨겼습니다.', show: '다시 보이게 했습니다.', delete: '지웠습니다. 나중에 되살릴 수 있습니다.', restore: '되살렸습니다.' };
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<main>
|
||||
<section id="welcome" class="welcome">
|
||||
<div class="welcome-hero">
|
||||
<div class="welcome-copy"><p class="eyebrow" data-site="heroEyebrow">당직 · 교대근무 · 개인 일정</p><h1 data-site="heroTitle">다음 당직,<br>달력에서 바로.</h1><p class="intro" data-site="heroIntro">내 근무 순서대로 채워지는 달력.<br>휴대폰을 켜면 홈 화면에서 바로 확인하세요.</p><div class="welcome-actions"><a class="download-button" data-site-href="downloadUrl" href="https://forum.itosm.co.kr/c/web-apps/duty-calendar/47"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3v12m-5-5 5 5 5-5M5 16v5h14v-5"/></svg><span data-site="downloadLabel">안드로이드 앱 받기</span></a><a class="install-link" href="#install-guide">설치 안내</a></div><p class="download-meta"><a data-site-href="downloadUrl" href="https://forum.itosm.co.kr/c/web-apps/duty-calendar/47">공식 배포 · 소스 · 제작 매뉴얼</a><br>Android 8.0 이상 · 미리보기 0.15.9</p><div class="welcome-caption"><strong data-site="captionTitle">내 달력은 로그인 없이.</strong><p data-site="captionText">함께 보는 근무표와 소속 공유는 <br>회원 로그인 후 이용할 수 있습니다.</p></div></div>
|
||||
<div class="welcome-copy"><p class="eyebrow" data-site="heroEyebrow">당직 · 교대근무 · 개인 일정</p><h1 data-site="heroTitle">다음 당직,<br>달력에서 바로.</h1><p class="intro" data-site="heroIntro">내 근무 순서대로 채워지는 달력.<br>휴대폰을 켜면 홈 화면에서 바로 확인하세요.</p><div class="welcome-actions"><a class="download-button" data-site-href="downloadUrl" href="https://forum.itosm.co.kr/c/web-apps/duty-calendar/47"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3v12m-5-5 5 5 5-5M5 16v5h14v-5"/></svg><span data-site="downloadLabel">안드로이드 앱 받기</span></a><a class="install-link" href="#install-guide">설치 안내</a></div><p class="download-meta"><a data-site-href="downloadUrl" href="https://forum.itosm.co.kr/c/web-apps/duty-calendar/47">공식 배포 · 소스 · 제작 매뉴얼</a><br>Android 8.0 이상 · 미리보기 0.16.0</p><div class="welcome-caption"><strong data-site="captionTitle">내 달력은 로그인 없이.</strong><p data-site="captionText">함께 보는 근무표와 소속 공유는 <br>회원 로그인 후 이용할 수 있습니다.</p></div></div>
|
||||
<figure class="calendar-preview" aria-label="3당직근무 화면 예시">
|
||||
<figcaption><span>홈 화면에 두는 나의 근무표</span><span>화면 예시</span></figcaption>
|
||||
<div class="calendar-paper"><div class="paper-heading"><div><span class="paper-year">2026</span><strong>11<span>월</span></strong></div><div class="paper-note"><b>당직근무</b><span>당직 · 비번 · 일반근무</span></div></div><div class="sample-week"><span>일</span><span>월</span><span>화</span><span>수</span><span>목</span><span>금</span><span>토</span></div><div class="sample-grid"><div class="sample-day sun"><span>1</span><em class="off">비번</em></div><div class="sample-day"><span>2</span><em class="regular">일반</em></div><div class="sample-day"><span>3</span><em class="duty">당직</em></div><div class="sample-day"><span>4</span><em class="off">비번</em></div><div class="sample-day"><span>5</span><em class="regular">일반</em></div><div class="sample-day"><span>6</span><em class="duty">당직</em></div><div class="sample-day sat"><span>7</span><em class="off">비번</em></div><div class="sample-day sun"><span>8</span><em class="regular">일반</em></div><div class="sample-day"><span>9</span><em class="duty">당직</em></div><div class="sample-day"><span>10</span><em class="off">비번</em></div><div class="sample-day"><span>11</span><em class="regular">일반</em></div><div class="sample-day"><span>12</span><em class="duty">당직</em></div><div class="sample-day"><span>13</span><em class="off">비번</em></div><div class="sample-day sat"><span>14</span><em class="regular">일반</em></div><div class="sample-day sun"><span>15</span><em class="duty">당직</em></div><div class="sample-day"><span>16</span><em class="off">비번</em></div><div class="sample-day"><span>17</span><em class="regular">일반</em></div><div class="sample-day"><span>18</span><em class="duty">당직</em></div><div class="sample-day"><span>19</span><em class="off">비번</em></div><div class="sample-day"><span>20</span><em class="regular">일반</em></div><div class="sample-day sat picked"><span>21</span><em class="duty">당직</em></div><div class="sample-day sun"><span>22</span><em class="off">비번</em></div><div class="sample-day"><span>23</span><em class="regular">일반</em></div><div class="sample-day"><span>24</span><em class="duty">당직</em></div><div class="sample-day"><span>25</span><em class="off">비번</em></div><div class="sample-day"><span>26</span><em class="regular">일반</em></div><div class="sample-day"><span>27</span><em class="duty">당직</em></div><div class="sample-day sat"><span>28</span><em class="off">비번</em></div><div class="sample-day sun"><span>29</span><em class="regular">일반</em></div><div class="sample-day"><span>30</span><em class="duty">당직</em></div><div class="sample-day empty-day" aria-hidden="true"></div><div class="sample-day empty-day" aria-hidden="true"></div><div class="sample-day empty-day" aria-hidden="true"></div><div class="sample-day empty-day" aria-hidden="true"></div><div class="sample-day empty-day" aria-hidden="true"></div></div><div class="paper-footer"><span><i></i>선택한 날 · 11월 21일 당직</span><span>3일 반복</span></div></div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
const WEB_BUILD = '2026-11-26.4';
|
||||
const WEB_BUILD = '2026-12-01.1';
|
||||
let offeredRelease=null, versionChecking=false;
|
||||
const versionDeferKey='duty-web-update-later';
|
||||
const versionSeenKey='duty-web-update-seen';
|
||||
|
||||
Reference in new issue
Block a user