- API GET /api/logs now accepts from_ts / to_ts (unix epoch, half-open [from, to)) so callers can scope by arbitrary time range. - API DELETE /api/logs added. Same from_ts / to_ts semantics. No params = wipe everything and reset the AUTOINCREMENT counter. - Dashboard Logs page: date picker that scopes both the view and the delete button to the selected day in the user's local timezone. The clear button is red and confirms before deleting; label switches between "전체 로그 초기화" and "<날짜> 하루치 삭제".
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
const base = '/api'
|
|
|
|
async function req(path, opts = {}) {
|
|
const res = await fetch(base + path, {
|
|
headers: { 'Content-Type': 'application/json' },
|
|
...opts,
|
|
})
|
|
if (!res.ok) {
|
|
const text = await res.text().catch(() => '')
|
|
throw new Error(`${res.status}: ${text || res.statusText}`)
|
|
}
|
|
if (res.status === 204) return null
|
|
return res.json()
|
|
}
|
|
|
|
export const api = {
|
|
status: () => req('/status'),
|
|
config: () => req('/config'),
|
|
putConfig: (cfg) => req('/config', { method: 'PUT', body: JSON.stringify(cfg) }),
|
|
domains: () => req('/domains'),
|
|
addDomain: (d) => req('/domains', { method: 'POST', body: JSON.stringify(d) }),
|
|
deleteDomain: (name) =>
|
|
req(`/domains/${encodeURIComponent(name)}`, { method: 'DELETE' }),
|
|
patchDomain: (name, body) =>
|
|
req(`/domains/${encodeURIComponent(name)}`, {
|
|
method: 'PATCH',
|
|
body: JSON.stringify(body),
|
|
}),
|
|
logs: (params = {}) => {
|
|
const q = new URLSearchParams(
|
|
Object.fromEntries(Object.entries(params).filter(([, v]) => v !== '' && v != null))
|
|
).toString()
|
|
return req('/logs' + (q ? `?${q}` : ''))
|
|
},
|
|
clearLogs: (params = {}) => {
|
|
const q = new URLSearchParams(
|
|
Object.fromEntries(Object.entries(params).filter(([, v]) => v !== '' && v != null))
|
|
).toString()
|
|
return req('/logs' + (q ? `?${q}` : ''), { method: 'DELETE' })
|
|
},
|
|
restart: () => req('/proxy/restart', { method: 'POST' }),
|
|
}
|