dsh-ops-kit 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.js +147 -121
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -687,6 +687,15 @@ window.__ModuleLoader__.load({
|
|
|
687
687
|
h('polyline', { points: d, fill: 'none', stroke: color, strokeWidth: 1.6 }))
|
|
688
688
|
}
|
|
689
689
|
|
|
690
|
+
const sizeText = (bytes, dir) => {
|
|
691
|
+
if (dir) return '—'
|
|
692
|
+
const n = Number(bytes) || 0
|
|
693
|
+
if (n < 1024) return `${n} B`
|
|
694
|
+
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`
|
|
695
|
+
if (n < 1024 * 1024 * 1024) return `${(n / 1048576).toFixed(1)} MB`
|
|
696
|
+
return `${(n / 1073741824).toFixed(1)} GB`
|
|
697
|
+
}
|
|
698
|
+
|
|
690
699
|
const viewHint = (text) => h('p', { className: 'ops-sub', style: { margin: 0, fontSize: '12.5px' } }, text)
|
|
691
700
|
|
|
692
701
|
const hostPicker = (hosts, value, onChange) => h('div', { className: 'ops-chips' },
|
|
@@ -697,6 +706,80 @@ window.__ModuleLoader__.load({
|
|
|
697
706
|
}, host.name)))
|
|
698
707
|
|
|
699
708
|
/** 监控:CPU/内存/磁盘/网络/IO 曲线;自己加载采样,不牵动其它 tab。 */
|
|
709
|
+
/** 诊断卡片:概览页和主机详情页共用。 */
|
|
710
|
+
function renderDiagCard({ diag, askAi, setDiag, setNotice, cleanupHost, doAction, setTab, setCHost }) {
|
|
711
|
+
return diag ? h('div', { className: 'ops-card' },
|
|
712
|
+
h('div', { className: 'ops-card-h' },
|
|
713
|
+
h('span', null, `${T.diagnose}: ${diag.host}`),
|
|
714
|
+
h('span', { className: diag.result?.level === 'ok' ? 'ops-ok' : diag.result?.level === 'warn' ? 'ops-warn' : 'ops-bad', style: { fontSize: '12px' } },
|
|
715
|
+
diag.loading ? T.diagnosing : (diag.result?.headline || ''))),
|
|
716
|
+
h('div', { className: 'ops-card-b' },
|
|
717
|
+
h('div', { className: 'ops-chips' },
|
|
718
|
+
h('input', {
|
|
719
|
+
className: 'ops-input',
|
|
720
|
+
style: { flex: '1 1 260px' },
|
|
721
|
+
placeholder: T.askPh,
|
|
722
|
+
value: diag.question,
|
|
723
|
+
onChange: e => setDiag({ ...diag, question: e.target.value }),
|
|
724
|
+
onKeyDown: e => { if (e.key === 'Enter') void askAi(diag.host, diag.question) },
|
|
725
|
+
}),
|
|
726
|
+
h('button', { className: 'ops-btn ops-btn-primary ops-btn-sm', disabled: diag.loading, onClick: () => { void askAi(diag.host, diag.question) } }, diag.loading ? T.diagnosing : T.ask),
|
|
727
|
+
h('button', {
|
|
728
|
+
className: 'ops-btn ops-btn-sm',
|
|
729
|
+
onClick: () => {
|
|
730
|
+
const text = `用运维工具排查一下 ${diag.host}:${diag.question || L('有什么问题?', 'What is the issue?')}`
|
|
731
|
+
void navigator.clipboard?.writeText(text).then(() => {
|
|
732
|
+
setNotice(L('已复制,粘贴到对话框让 AI 深入分析', 'Copied — paste it into the chat for the AI to dig in'))
|
|
733
|
+
setTimeout(() => setNotice(''), 3000)
|
|
734
|
+
}).catch(() => {})
|
|
735
|
+
},
|
|
736
|
+
}, L('复制到对话', 'Copy to chat')),
|
|
737
|
+
h('button', { className: 'ops-btn ops-btn-sm', onClick: () => setDiag(null) }, T.close2)),
|
|
738
|
+
h('div', { className: 'ops-chips' },
|
|
739
|
+
...T.askPreset.map(text => h('button', { key: text, className: 'ops-btn ops-btn-sm', onClick: () => { void askAi(diag.host, text) } }, text))),
|
|
740
|
+
diag.loading ? h('p', { className: 'ops-empty' }, T.loading) : null,
|
|
741
|
+
!diag.loading && diag.result ? h('div', null,
|
|
742
|
+
diag.result.ai
|
|
743
|
+
? h('div', {
|
|
744
|
+
style: {
|
|
745
|
+
padding: '12px 14px',
|
|
746
|
+
margin: '0 0 10px',
|
|
747
|
+
borderRadius: '10px',
|
|
748
|
+
background: 'var(--dsw-alias-bg,#15181c)',
|
|
749
|
+
border: '1px solid var(--dsw-alias-border,#3a3f45)',
|
|
750
|
+
fontSize: '13px',
|
|
751
|
+
lineHeight: 1.75,
|
|
752
|
+
whiteSpace: 'pre-wrap',
|
|
753
|
+
},
|
|
754
|
+
}, diag.result.ai)
|
|
755
|
+
: (diag.result.summary ? h('p', { className: 'ops-sub', style: { margin: '0 0 10px', lineHeight: 1.7 } }, diag.result.summary) : null),
|
|
756
|
+
...((diag.result.sections || []).map((item, index) => h('div', {
|
|
757
|
+
key: index,
|
|
758
|
+
style: { display: 'flex', gap: '10px', alignItems: 'flex-start', padding: '8px 0', borderTop: index === 0 ? 'none' : '1px solid var(--dsw-alias-border,#3a3f45)' },
|
|
759
|
+
},
|
|
760
|
+
h('i', { className: 'ops-dot ' + (item.status === 'ok' ? 'ok' : item.status === 'warn' ? 'warn' : item.status === 'bad' ? 'bad' : 'unknown'), style: { marginTop: '5px' } }),
|
|
761
|
+
h('div', { style: { minWidth: 0 } },
|
|
762
|
+
h('div', { style: { fontSize: '13px', fontWeight: 600 } }, item.title),
|
|
763
|
+
h('div', { className: 'ops-sub', style: { lineHeight: 1.6 } }, item.detail),
|
|
764
|
+
item.advice ? h('div', { className: 'ops-dim', style: { lineHeight: 1.6 } }, item.advice) : null)))),
|
|
765
|
+
(diag.result.reasons || []).length && !(diag.result.sections || []).length
|
|
766
|
+
? h('div', null, ...diag.result.reasons.map((reason, index) => h('div', { key: 'r' + index, className: 'ops-sub' }, '· ' + reason)))
|
|
767
|
+
: null,
|
|
768
|
+
(diag.result.actions || []).length ? h('div', { className: 'ops-chips', style: { marginTop: '8px' } },
|
|
769
|
+
h('span', { className: 'ops-sub' }, T.next),
|
|
770
|
+
...(diag.result.actions || []).map(action => h('button', {
|
|
771
|
+
key: action.id,
|
|
772
|
+
className: 'ops-btn ops-btn-sm',
|
|
773
|
+
onClick: () => {
|
|
774
|
+
if (action.id === 'cleanup') void cleanupHost(diag.host)
|
|
775
|
+
else if (action.id === 'goto-service') { setTab(3); setCHost(diag.host) }
|
|
776
|
+
else if (action.id.startsWith('restart:')) void doAction('service', action.id.slice(8), 'restart', diag.host)
|
|
777
|
+
},
|
|
778
|
+
}, action.label))) : null,
|
|
779
|
+
diag.result.hint ? h('p', { className: 'ops-warn', style: { fontSize: '12px', margin: '8px 0 0' } }, diag.result.hint) : null) : null))
|
|
780
|
+
: null
|
|
781
|
+
}
|
|
782
|
+
|
|
700
783
|
/** 只有这类 unit 值得推荐给普通用户;dbus/getty/gssproxy 等系统服务不提示。 */
|
|
701
784
|
const BUSINESS_SERVICE = /(nginx|apache|httpd|mysql|mariadb|postgres|redis|mongo|elasticsearch|php|java|tomcat|node|pm2|gunicorn|uwsgi|docker|containerd|supervisor|frp|traefik|caddy|haproxy|kafka|rabbit|memcached|minio|baota)/i
|
|
702
785
|
const BUSINESS_PORTS = new Set([80, 443, 3000, 3306, 5432, 6379, 8000, 8080, 8443, 9000, 9200, 27017])
|
|
@@ -1065,7 +1148,55 @@ window.__ModuleLoader__.load({
|
|
|
1065
1148
|
}
|
|
1066
1149
|
|
|
1067
1150
|
/** 文件管理:浏览/上传/下载/编辑/压缩,状态全部自带。 */
|
|
1068
|
-
|
|
1151
|
+
const CHUNK_BYTES = 4 * 1024 * 1024
|
|
1152
|
+
|
|
1153
|
+
/** 分片下载到本地(文件页与备份下载共用)。 */
|
|
1154
|
+
async function downloadFileTo({ host, path, name, setBusy, setProgress, setError }) {
|
|
1155
|
+
setBusy('dl:' + path)
|
|
1156
|
+
try {
|
|
1157
|
+
const first = await api(`download-chunk?host=${encodeURIComponent(host)}&path=${encodeURIComponent(path)}&offset=0&length=1`, {}, 60_000)
|
|
1158
|
+
const size = Number(first.size) || 0
|
|
1159
|
+
if (size > 100 * 1024 * 1024) { setError(T.fsTooBig); return }
|
|
1160
|
+
const parts = []
|
|
1161
|
+
let offset = 0
|
|
1162
|
+
const started = Date.now()
|
|
1163
|
+
setProgress({ label: T.fsDownloading, name, done: 0, total: size, eta: null, speed: 0 })
|
|
1164
|
+
while (offset < size) {
|
|
1165
|
+
let chunk = null
|
|
1166
|
+
for (let attempt = 0; attempt < 3 && !chunk; attempt += 1) {
|
|
1167
|
+
try {
|
|
1168
|
+
chunk = await api(`download-chunk?host=${encodeURIComponent(host)}&path=${encodeURIComponent(path)}&offset=${offset}&length=${CHUNK_BYTES}`, {}, 300_000)
|
|
1169
|
+
} catch (error) {
|
|
1170
|
+
if (attempt === 2) throw error
|
|
1171
|
+
await new Promise(resolve => setTimeout(resolve, 800))
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
const bytes = Uint8Array.from(atob(chunk.base64 || ''), ch => ch.charCodeAt(0))
|
|
1175
|
+
if (bytes.length === 0) break
|
|
1176
|
+
parts.push(bytes)
|
|
1177
|
+
offset += bytes.length
|
|
1178
|
+
const seconds = Math.max(0.5, (Date.now() - started) / 1000)
|
|
1179
|
+
const speed = offset / seconds
|
|
1180
|
+
setProgress({
|
|
1181
|
+
label: T.fsDownloading,
|
|
1182
|
+
name,
|
|
1183
|
+
done: offset,
|
|
1184
|
+
total: size,
|
|
1185
|
+
speed: Math.round((speed / 1048576) * 10) / 10,
|
|
1186
|
+
eta: speed > 0 ? Math.max(0, Math.round((size - offset) / speed)) : null,
|
|
1187
|
+
})
|
|
1188
|
+
}
|
|
1189
|
+
const url = URL.createObjectURL(new Blob(parts))
|
|
1190
|
+
const a = document.createElement('a')
|
|
1191
|
+
a.href = url
|
|
1192
|
+
a.download = name || 'download'
|
|
1193
|
+
a.click()
|
|
1194
|
+
setTimeout(() => URL.revokeObjectURL(url), 3000)
|
|
1195
|
+
} catch (e) { setError(String(e.message || e)) } finally { setBusy(''); setProgress(null) }
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
function FilesTab({ host, picker, setError, setNotice, confirmDialog, timeoutFor }) {
|
|
1069
1200
|
const [fsPath, setFsPath] = React.useState('/')
|
|
1070
1201
|
const [fsEntries, setFsEntries] = React.useState(null)
|
|
1071
1202
|
const [fsTree, setFsTree] = React.useState({})
|
|
@@ -1108,7 +1239,6 @@ window.__ModuleLoader__.load({
|
|
|
1108
1239
|
} catch (e) { setError(String(e.message || e)) } finally { setFsBusy('') }
|
|
1109
1240
|
}
|
|
1110
1241
|
|
|
1111
|
-
const CHUNK_BYTES = 4 * 1024 * 1024
|
|
1112
1242
|
const IMAGE_EXT = /\.(png|jpe?g|gif|webp|bmp|svg|ico)$/i
|
|
1113
1243
|
|
|
1114
1244
|
const hostFsKey = () => `ops-kit:fs:${host || 'default'}`
|
|
@@ -1142,49 +1272,7 @@ window.__ModuleLoader__.load({
|
|
|
1142
1272
|
saveFavs({ ...fsFavs, favs: has ? fsFavs.favs.filter(item => item !== path) : [path, ...fsFavs.favs].slice(0, 12) })
|
|
1143
1273
|
}
|
|
1144
1274
|
|
|
1145
|
-
const downloadFile =
|
|
1146
|
-
setFsBusy('dl:' + path)
|
|
1147
|
-
try {
|
|
1148
|
-
const first = await api(`download-chunk?host=${encodeURIComponent(host)}&path=${encodeURIComponent(path)}&offset=0&length=1`, {}, 60_000)
|
|
1149
|
-
const size = Number(first.size) || 0
|
|
1150
|
-
if (size > 100 * 1024 * 1024) { setError(T.fsTooBig); return }
|
|
1151
|
-
const parts = []
|
|
1152
|
-
let offset = 0
|
|
1153
|
-
const started = Date.now()
|
|
1154
|
-
setFsProgress({ label: T.fsDownloading, name, done: 0, total: size, eta: null, speed: 0 })
|
|
1155
|
-
while (offset < size) {
|
|
1156
|
-
let chunk = null
|
|
1157
|
-
for (let attempt = 0; attempt < 3 && !chunk; attempt += 1) {
|
|
1158
|
-
try {
|
|
1159
|
-
chunk = await api(`download-chunk?host=${encodeURIComponent(host)}&path=${encodeURIComponent(path)}&offset=${offset}&length=${CHUNK_BYTES}`, {}, 300_000)
|
|
1160
|
-
} catch (error) {
|
|
1161
|
-
if (attempt === 2) throw error
|
|
1162
|
-
await new Promise(resolve => setTimeout(resolve, 800))
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
const bytes = Uint8Array.from(atob(chunk.base64 || ''), ch => ch.charCodeAt(0))
|
|
1166
|
-
if (bytes.length === 0) break
|
|
1167
|
-
parts.push(bytes)
|
|
1168
|
-
offset += bytes.length
|
|
1169
|
-
const seconds = Math.max(0.5, (Date.now() - started) / 1000)
|
|
1170
|
-
const speed = offset / seconds
|
|
1171
|
-
setFsProgress({
|
|
1172
|
-
label: T.fsDownloading,
|
|
1173
|
-
name,
|
|
1174
|
-
done: offset,
|
|
1175
|
-
total: size,
|
|
1176
|
-
speed: Math.round((speed / 1048576) * 10) / 10,
|
|
1177
|
-
eta: speed > 0 ? Math.max(0, Math.round((size - offset) / speed)) : null,
|
|
1178
|
-
})
|
|
1179
|
-
}
|
|
1180
|
-
const url = URL.createObjectURL(new Blob(parts))
|
|
1181
|
-
const a = document.createElement('a')
|
|
1182
|
-
a.href = url
|
|
1183
|
-
a.download = name || 'download'
|
|
1184
|
-
a.click()
|
|
1185
|
-
setTimeout(() => URL.revokeObjectURL(url), 3000)
|
|
1186
|
-
} catch (e) { setError(String(e.message || e)) } finally { setFsBusy(''); setFsProgress(null) }
|
|
1187
|
-
}
|
|
1275
|
+
const downloadFile = (path, name) => downloadFileTo({ host, path, name, setBusy: setFsBusy, setProgress: setFsProgress, setError })
|
|
1188
1276
|
|
|
1189
1277
|
const uploadFile = async (file) => {
|
|
1190
1278
|
if (!file) return
|
|
@@ -1860,7 +1948,7 @@ window.__ModuleLoader__.load({
|
|
|
1860
1948
|
|
|
1861
1949
|
const assistantView = h('div', { style: { display: 'flex', flexDirection: 'column', gap: '10px' } },
|
|
1862
1950
|
h('div', { className: 'ops-chips' },
|
|
1863
|
-
|
|
1951
|
+
picker,
|
|
1864
1952
|
h('span', { className: 'ops-chip' }, T.aiName),
|
|
1865
1953
|
chatNotice ? h('span', { className: 'ops-ok', style: { fontSize: '12px' } }, chatNotice) : null),
|
|
1866
1954
|
h('div', { className: 'ops-chat', id: 'ops-chat' },
|
|
@@ -1890,7 +1978,7 @@ window.__ModuleLoader__.load({
|
|
|
1890
1978
|
}
|
|
1891
1979
|
|
|
1892
1980
|
/** 终端与控制台:控制台输入/历史自带,SSH 会话由 Panel 持有。 */
|
|
1893
|
-
function TerminalTab({ host, picker, term, setTerm, openTerm, closeTerm, busy, aiMode, aiDraft, quickCommands, termKey, sendKey, focusTerm, generateCommand, runGenerated, aiResult, aiIntent, setAiIntent, aiBusy, setAiMode, setAiDraft, askLog, error, output, consoleCmd, setConsoleCmd, consoleOut, consoleHistory, runConsole }) {
|
|
1981
|
+
function TerminalTab({ host, picker, term, setTerm, openTerm, closeTerm, busy, aiMode, aiDraft, quickCommands, termKey, sendKey, focusTerm, generateCommand, runGenerated, aiResult, setAiResult, aiIntent, setAiIntent, aiBusy, setAiMode, setAiDraft, askLog, error, output, consoleCmd, setConsoleCmd, consoleOut, consoleHistory, runConsole }) {
|
|
1894
1982
|
|
|
1895
1983
|
const terminalView = h('div', { style: { display: 'flex', flexDirection: 'column', gap: '10px' } },
|
|
1896
1984
|
viewHint(T.hintTerminal),
|
|
@@ -2350,76 +2438,7 @@ window.__ModuleLoader__.load({
|
|
|
2350
2438
|
h('div', { className: 'ops-num' }, h('b', { className: 'ops-warn' }, String(countOf('warn'))), h('span', null, T.needLook)),
|
|
2351
2439
|
h('div', { className: 'ops-num' }, h('b', { className: 'ops-bad' }, String(countOf('bad'))), h('span', null, T.offline)))
|
|
2352
2440
|
|
|
2353
|
-
const diagView = diag
|
|
2354
|
-
h('div', { className: 'ops-card-h' },
|
|
2355
|
-
h('span', null, `${T.diagnose}: ${diag.host}`),
|
|
2356
|
-
h('span', { className: diag.result?.level === 'ok' ? 'ops-ok' : diag.result?.level === 'warn' ? 'ops-warn' : 'ops-bad', style: { fontSize: '12px' } },
|
|
2357
|
-
diag.loading ? T.diagnosing : (diag.result?.headline || ''))),
|
|
2358
|
-
h('div', { className: 'ops-card-b' },
|
|
2359
|
-
h('div', { className: 'ops-chips' },
|
|
2360
|
-
h('input', {
|
|
2361
|
-
className: 'ops-input',
|
|
2362
|
-
style: { flex: '1 1 260px' },
|
|
2363
|
-
placeholder: T.askPh,
|
|
2364
|
-
value: diag.question,
|
|
2365
|
-
onChange: e => setDiag({ ...diag, question: e.target.value }),
|
|
2366
|
-
onKeyDown: e => { if (e.key === 'Enter') void askAi(diag.host, diag.question) },
|
|
2367
|
-
}),
|
|
2368
|
-
h('button', { className: 'ops-btn ops-btn-primary ops-btn-sm', disabled: diag.loading, onClick: () => { void askAi(diag.host, diag.question) } }, diag.loading ? T.diagnosing : T.ask),
|
|
2369
|
-
h('button', {
|
|
2370
|
-
className: 'ops-btn ops-btn-sm',
|
|
2371
|
-
onClick: () => {
|
|
2372
|
-
const text = `用运维工具排查一下 ${diag.host}:${diag.question || L('有什么问题?', 'What is the issue?')}`
|
|
2373
|
-
void navigator.clipboard?.writeText(text).then(() => {
|
|
2374
|
-
setNotice(L('已复制,粘贴到对话框让 AI 深入分析', 'Copied — paste it into the chat for the AI to dig in'))
|
|
2375
|
-
setTimeout(() => setNotice(''), 3000)
|
|
2376
|
-
}).catch(() => {})
|
|
2377
|
-
},
|
|
2378
|
-
}, L('复制到对话', 'Copy to chat')),
|
|
2379
|
-
h('button', { className: 'ops-btn ops-btn-sm', onClick: () => setDiag(null) }, T.close2)),
|
|
2380
|
-
h('div', { className: 'ops-chips' },
|
|
2381
|
-
...T.askPreset.map(text => h('button', { key: text, className: 'ops-btn ops-btn-sm', onClick: () => { void askAi(diag.host, text) } }, text))),
|
|
2382
|
-
diag.loading ? h('p', { className: 'ops-empty' }, T.loading) : null,
|
|
2383
|
-
!diag.loading && diag.result ? h('div', null,
|
|
2384
|
-
diag.result.ai
|
|
2385
|
-
? h('div', {
|
|
2386
|
-
style: {
|
|
2387
|
-
padding: '12px 14px',
|
|
2388
|
-
margin: '0 0 10px',
|
|
2389
|
-
borderRadius: '10px',
|
|
2390
|
-
background: 'var(--dsw-alias-bg,#15181c)',
|
|
2391
|
-
border: '1px solid var(--dsw-alias-border,#3a3f45)',
|
|
2392
|
-
fontSize: '13px',
|
|
2393
|
-
lineHeight: 1.75,
|
|
2394
|
-
whiteSpace: 'pre-wrap',
|
|
2395
|
-
},
|
|
2396
|
-
}, diag.result.ai)
|
|
2397
|
-
: (diag.result.summary ? h('p', { className: 'ops-sub', style: { margin: '0 0 10px', lineHeight: 1.7 } }, diag.result.summary) : null),
|
|
2398
|
-
...((diag.result.sections || []).map((item, index) => h('div', {
|
|
2399
|
-
key: index,
|
|
2400
|
-
style: { display: 'flex', gap: '10px', alignItems: 'flex-start', padding: '8px 0', borderTop: index === 0 ? 'none' : '1px solid var(--dsw-alias-border,#3a3f45)' },
|
|
2401
|
-
},
|
|
2402
|
-
h('i', { className: 'ops-dot ' + (item.status === 'ok' ? 'ok' : item.status === 'warn' ? 'warn' : item.status === 'bad' ? 'bad' : 'unknown'), style: { marginTop: '5px' } }),
|
|
2403
|
-
h('div', { style: { minWidth: 0 } },
|
|
2404
|
-
h('div', { style: { fontSize: '13px', fontWeight: 600 } }, item.title),
|
|
2405
|
-
h('div', { className: 'ops-sub', style: { lineHeight: 1.6 } }, item.detail),
|
|
2406
|
-
item.advice ? h('div', { className: 'ops-dim', style: { lineHeight: 1.6 } }, item.advice) : null)))),
|
|
2407
|
-
(diag.result.reasons || []).length && !(diag.result.sections || []).length
|
|
2408
|
-
? h('div', null, ...diag.result.reasons.map((reason, index) => h('div', { key: 'r' + index, className: 'ops-sub' }, '· ' + reason)))
|
|
2409
|
-
: null,
|
|
2410
|
-
(diag.result.actions || []).length ? h('div', { className: 'ops-chips', style: { marginTop: '8px' } },
|
|
2411
|
-
h('span', { className: 'ops-sub' }, T.next),
|
|
2412
|
-
...(diag.result.actions || []).map(action => h('button', {
|
|
2413
|
-
key: action.id,
|
|
2414
|
-
className: 'ops-btn ops-btn-sm',
|
|
2415
|
-
onClick: () => {
|
|
2416
|
-
if (action.id === 'cleanup') void cleanupHost(diag.host)
|
|
2417
|
-
else if (action.id === 'goto-service') { setTab(3); setCHost(diag.host) }
|
|
2418
|
-
else if (action.id.startsWith('restart:')) void doAction('service', action.id.slice(8), 'restart', diag.host)
|
|
2419
|
-
},
|
|
2420
|
-
}, action.label))) : null,
|
|
2421
|
-
diag.result.hint ? h('p', { className: 'ops-warn', style: { fontSize: '12px', margin: '8px 0 0' } }, diag.result.hint) : null) : null))
|
|
2422
|
-
: null
|
|
2441
|
+
const diagView = renderDiagCard({ diag, askAi, setDiag, setNotice, cleanupHost, doAction, setTab, setCHost })
|
|
2423
2442
|
|
|
2424
2443
|
const onboardingView = h('div', { className: 'ops-card' },
|
|
2425
2444
|
h('div', { className: 'ops-card-h' },
|
|
@@ -2772,7 +2791,7 @@ window.__ModuleLoader__.load({
|
|
|
2772
2791
|
certsCard,
|
|
2773
2792
|
monitorsCard,
|
|
2774
2793
|
servicesCard,
|
|
2775
|
-
diag && diag.host === host.name ?
|
|
2794
|
+
diag && diag.host === host.name ? renderDiagCard({ diag, askAi, setDiag, setNotice, cleanupHost, doAction, setTab, setCHost }) : null)
|
|
2776
2795
|
})()
|
|
2777
2796
|
|
|
2778
2797
|
return hostDetailView
|
|
@@ -3000,7 +3019,7 @@ window.__ModuleLoader__.load({
|
|
|
3000
3019
|
if (!command) return
|
|
3001
3020
|
setBusy('console')
|
|
3002
3021
|
try {
|
|
3003
|
-
const payload = { command, hosts: [
|
|
3022
|
+
const payload = { command, hosts: [cHost || hosts[0]?.name] }
|
|
3004
3023
|
if (options.confirm) payload.confirm = true
|
|
3005
3024
|
const data = await api('exec', { method: 'POST', body: JSON.stringify(payload) }, timeoutFor('action'))
|
|
3006
3025
|
if (data?.needsConfirm) {
|
|
@@ -3640,7 +3659,14 @@ window.__ModuleLoader__.load({
|
|
|
3640
3659
|
|
|
3641
3660
|
const downloadBackup = async () => {
|
|
3642
3661
|
if (!cleanBackupFile) return
|
|
3643
|
-
await
|
|
3662
|
+
await downloadFileTo({
|
|
3663
|
+
host: cHost || hosts[0]?.name,
|
|
3664
|
+
path: cleanBackupFile.path,
|
|
3665
|
+
name: cleanBackupFile.path.split('/').pop(),
|
|
3666
|
+
setBusy: setBackupBusy,
|
|
3667
|
+
setProgress: () => {},
|
|
3668
|
+
setError,
|
|
3669
|
+
})
|
|
3644
3670
|
}
|
|
3645
3671
|
|
|
3646
3672
|
const confirmClean = async () => {
|
|
@@ -3829,7 +3855,7 @@ window.__ModuleLoader__.load({
|
|
|
3829
3855
|
: ['df -h', 'free -h', 'uptime', 'systemctl --failed', 'docker ps', 'tail -n 30 /var/log/messages']
|
|
3830
3856
|
|
|
3831
3857
|
const subBody = detailHost
|
|
3832
|
-
? ({ monitor: h(MonitorTab, { hosts, detailHost, detailTab, loadingMap, markLoading, setError }), config: h(ConfigTab, { busy, cHost, detailHost, histDiff, histList, histPath, hosts, inv, loadHistory, loadInv, monitorSuggestions, monitors, opBusy, restoreVersion, sectionList, services, setCHost, setHistPath, showDiff }), apps: h(AppsTab, { addSuggestions, busy, cHost, config, confirmDialog, detailHost, doAction, fileState, hosts, inv, loadInv, monBusy, monitorSuggestions, openFile, output, saveFile, setError, setCHost, setDetailTab, setFileState, setLogRequest }), logs: h(LogsTab, { host: cHost || hosts[0]?.name, notice, logRequest, picker: detailHost ? null : hostPicker(hosts, cHost, setCHost), setError, setNotice, timeoutFor, onInventoryRefresh: loadInv, config, logUsageData, loadLogUsage, openCleanPreview, cleanBusyHost, cleanRunBusy, backupBusy }), files: h(FilesTab, { host: cHost || hosts[0]?.name, picker: detailHost ? null : hostPicker(hosts, cHost, setCHost), setError, setNotice, confirmDialog }), terminal: h(TerminalTab, { host: cHost || hosts[0]?.name, picker: detailHost ? null : hostPicker(hosts, cHost, setCHost), term, setTerm, openTerm, closeTerm, busy, aiMode, aiDraft, quickCommands, termKey, sendKey, focusTerm, generateCommand, runGenerated, aiResult, aiIntent, setAiIntent, aiBusy, setAiMode, setAiDraft, askLog, error, output, consoleCmd, setConsoleCmd, consoleOut, consoleHistory, runConsole }), backups: h(BackupsTab, { host: dhost(), confirmDialog, trackJob, setError, refreshTick }), cron: h(CronTab, { host: dhost(), setError, loadingMap, markLoading, refreshTick }), deploy: h(DeployTab, { host: dhost(), trackJob, setError, loadingMap, refreshTick }) }[detailTab] || h(HostDetailTab, { ackAlert: ackAlert, ackMonitorUi: ackMonitorUi, addHost: addHost, addSuggestions: addSuggestions, adding: adding, aiBusy: aiBusy, aiDraft: aiDraft, aiIntent: aiIntent, aiMode: aiMode, aiModels: aiModels, aiResult: aiResult, alerts: alerts, applyTemplateUi: applyTemplateUi, askAi: askAi, askBusy: askBusy, askHost: askHost, askLog: askLog, askQuestion: askQuestion, audit: audit, backupBusy: backupBusy, backupSelected: backupSelected, busy: busy, cHost: cHost, certs: certs, chBusy: chBusy, channelForm: channelForm, channels: channels, chatNotice: chatNotice, cleanBackupFile: cleanBackupFile, cleanBusyHost: cleanBusyHost, cleanPreview: cleanPreview, cleanRunBusy: cleanRunBusy, cleanSel: cleanSel, cleanupHost: cleanupHost, closeTerm: closeTerm, config: config, confirmClean: confirmClean, confirmDialog: confirmDialog, conns: conns, consoleCmd: consoleCmd, consoleHistory: consoleHistory, consoleOut: consoleOut, copyDiagnostics: copyDiagnostics, copyReport: copyReport, copyText: copyText, countOf: countOf, createServiceUi: createServiceUi, detailHost: detailHost, detailTab: detailTab, dhost: dhost, diag: diag, diagnoseMonitorUi: diagnoseMonitorUi, diagnosticsText: diagnosticsText, doAction: doAction, downloadBackup: downloadBackup, editMonitor: editMonitor, editName: editName, error: error, fileState: fileState, focusTerm: focusTerm, form: form, generateCommand: generateCommand, health: health, histDiff: histDiff, histList: histList, histPath: histPath, hosts: hosts, info: info, installKeyOn: installKeyOn, inv: inv, loadBase: loadBase, loadCerts: loadCerts, loadChannels: loadChannels, loadHealth: loadHealth, loadHistory: loadHistory, loadInv: loadInv, loadLogUsage: loadLogUsage, loadMaintenance: loadMaintenance, loadMonitors: loadMonitors, loadServicesUi: loadServicesUi, loadTemplatesUi: loadTemplatesUi, loadingMap: loadingMap, logRequest: logRequest, logUsageData: logUsageData, maintenanceUntil: maintenanceUntil, markLoading: markLoading, metricBox: metricBox, monBusy: monBusy, monEditId: monEditId, monForm: monForm, monitorSuggestions: monitorSuggestions, monitors: monitors, notice: notice, opBusy: opBusy, opOut: opOut, openCleanPreview: openCleanPreview, openFile: openFile, openHost: openHost, openTerm: openTerm, output: output, overview: overview, p2Busy: p2Busy, quickText: quickText, recheckHost: recheckHost, recheckOne: recheckOne, refreshTick: refreshTick, removeChannelUi: removeChannelUi, removeHost: removeHost, removeMonitor: removeMonitor, removeServiceUi: removeServiceUi, removeTemplateUi: removeTemplateUi, renewCertsNow: renewCertsNow, restartWebFor: restartWebFor, restoreVersion: restoreVersion, runConsole: runConsole, runGenerated: runGenerated, runNeedsConfirm: runNeedsConfirm, saveAsTemplate: saveAsTemplate, saveChannel: saveChannel, saveConfig: saveConfig, saveFile: saveFile, saveMonitor: saveMonitor, sectionList: sectionList, selectedLogPaths: selectedLogPaths, sendKey: sendKey, services: services, setAdding: setAdding, setAiDraft: setAiDraft, setAiIntent: setAiIntent, setAiMode: setAiMode, setAiModels: setAiModels, setAlerts: setAlerts, setAskQuestion: setAskQuestion, setBackupBusy: setBackupBusy, setCHost: setCHost, setCerts: setCerts, setChBusy: setChBusy, setChannelForm: setChannelForm, setChannels: setChannels, setChatNotice: setChatNotice, setCleanBackupFile: setCleanBackupFile, setCleanBusyHost: setCleanBusyHost, setCleanPreview: setCleanPreview, setCleanRunBusy: setCleanRunBusy, setCleanSel: setCleanSel, setConfig: setConfig, setConsoleCmd: setConsoleCmd, setDetailHost: setDetailHost, setDetailTab: setDetailTab, setDiag: setDiag, setEditName: setEditName, setError: setError, setFileState: setFileState, setForm: setForm, setHealth: setHealth, setHistDiff: setHistDiff, setHistList: setHistList, setHistPath: setHistPath, setHostCtx: setHostCtx, setLogRequest: setLogRequest, setLogUsageData: setLogUsageData, setMaintenanceUi: setMaintenanceUi, setMaintenanceUntil: setMaintenanceUntil, setMonBusy: setMonBusy, setMonDialog: setMonDialog, setMonEditId: setMonEditId, setMonForm: setMonForm, setMonitors: setMonitors, setNotice: setNotice, setOpBusy: setOpBusy, setOpOut: setOpOut, setP2Busy: setP2Busy, setQuickText: setQuickText, setServices: setServices, setSimpleCtx: setSimpleCtx, setSimpleMonitors: setSimpleMonitors, setSimpleNotice: setSimpleNotice, setTab: setTab, setTemplateId: setTemplateId, setTemplates: setTemplates, setTerm: setTerm, setUiMode: setUiMode, showDiff: showDiff, simpleCtx: simpleCtx, simpleHostState: simpleHostState, simpleMonitors: simpleMonitors, simpleNotice: simpleNotice, startEdit: startEdit, statusOf: statusOf, suggestionFor: suggestionFor, switchMode: switchMode, tab: tab, templateId: templateId, templates: templates, term: term, testChannelUi: testChannelUi, testHost: testHost, testMonitor: testMonitor, timeoutFor: timeoutFor, trackJob: trackJob, uiMode: uiMode }))
|
|
3858
|
+
? ({ monitor: h(MonitorTab, { hosts, detailHost, detailTab, loadingMap, markLoading, setError }), config: h(ConfigTab, { busy, cHost, detailHost, histDiff, histList, histPath, hosts, inv, loadHistory, loadInv, monitorSuggestions, monitors, opBusy, restoreVersion, sectionList, services, setCHost, setHistPath, showDiff }), apps: h(AppsTab, { addSuggestions, busy, cHost, config, confirmDialog, detailHost, doAction, fileState, hosts, inv, loadInv, monBusy, monitorSuggestions, openFile, output, saveFile, setError, setCHost, setDetailTab, setFileState, setLogRequest }), logs: h(LogsTab, { host: cHost || hosts[0]?.name, notice, logRequest, picker: detailHost ? null : hostPicker(hosts, cHost, setCHost), setError, setNotice, timeoutFor, onInventoryRefresh: loadInv, config, logUsageData, loadLogUsage, openCleanPreview, cleanBusyHost, cleanRunBusy, backupBusy }), files: h(FilesTab, { host: cHost || hosts[0]?.name, picker: detailHost ? null : hostPicker(hosts, cHost, setCHost), setError, setNotice, confirmDialog, timeoutFor }), terminal: h(TerminalTab, { host: cHost || hosts[0]?.name, picker: detailHost ? null : hostPicker(hosts, cHost, setCHost), term, setTerm, openTerm, closeTerm, busy, aiMode, aiDraft, quickCommands, termKey, sendKey, focusTerm, generateCommand, runGenerated, aiResult, setAiResult, aiIntent, setAiIntent, aiBusy, setAiMode, setAiDraft, askLog, error, output, consoleCmd, setConsoleCmd, consoleOut, consoleHistory, runConsole }), backups: h(BackupsTab, { host: dhost(), confirmDialog, trackJob, setError, refreshTick }), cron: h(CronTab, { host: dhost(), setError, loadingMap, markLoading, refreshTick }), deploy: h(DeployTab, { host: dhost(), trackJob, setError, loadingMap, refreshTick }) }[detailTab] || h(HostDetailTab, { ackAlert: ackAlert, ackMonitorUi: ackMonitorUi, addHost: addHost, addSuggestions: addSuggestions, adding: adding, aiBusy: aiBusy, aiDraft: aiDraft, aiIntent: aiIntent, aiMode: aiMode, aiModels: aiModels, aiResult: aiResult, alerts: alerts, applyTemplateUi: applyTemplateUi, askAi: askAi, askBusy: askBusy, askHost: askHost, askLog: askLog, askQuestion: askQuestion, audit: audit, backupBusy: backupBusy, backupSelected: backupSelected, busy: busy, cHost: cHost, certs: certs, chBusy: chBusy, channelForm: channelForm, channels: channels, chatNotice: chatNotice, cleanBackupFile: cleanBackupFile, cleanBusyHost: cleanBusyHost, cleanPreview: cleanPreview, cleanRunBusy: cleanRunBusy, cleanSel: cleanSel, cleanupHost: cleanupHost, closeTerm: closeTerm, config: config, confirmClean: confirmClean, confirmDialog: confirmDialog, conns: conns, consoleCmd: consoleCmd, consoleHistory: consoleHistory, consoleOut: consoleOut, copyDiagnostics: copyDiagnostics, copyReport: copyReport, copyText: copyText, countOf: countOf, createServiceUi: createServiceUi, detailHost: detailHost, detailTab: detailTab, dhost: dhost, diag: diag, diagnoseMonitorUi: diagnoseMonitorUi, diagnosticsText: diagnosticsText, doAction: doAction, downloadBackup: downloadBackup, editMonitor: editMonitor, editName: editName, error: error, fileState: fileState, focusTerm: focusTerm, form: form, generateCommand: generateCommand, health: health, histDiff: histDiff, histList: histList, histPath: histPath, hosts: hosts, info: info, installKeyOn: installKeyOn, inv: inv, loadBase: loadBase, loadCerts: loadCerts, loadChannels: loadChannels, loadHealth: loadHealth, loadHistory: loadHistory, loadInv: loadInv, loadLogUsage: loadLogUsage, loadMaintenance: loadMaintenance, loadMonitors: loadMonitors, loadServicesUi: loadServicesUi, loadTemplatesUi: loadTemplatesUi, loadingMap: loadingMap, logRequest: logRequest, logUsageData: logUsageData, maintenanceUntil: maintenanceUntil, markLoading: markLoading, metricBox: metricBox, monBusy: monBusy, monEditId: monEditId, monForm: monForm, monitorSuggestions: monitorSuggestions, monitors: monitors, notice: notice, opBusy: opBusy, opOut: opOut, openCleanPreview: openCleanPreview, openFile: openFile, openHost: openHost, openTerm: openTerm, output: output, overview: overview, p2Busy: p2Busy, quickText: quickText, recheckHost: recheckHost, recheckOne: recheckOne, refreshTick: refreshTick, removeChannelUi: removeChannelUi, removeHost: removeHost, removeMonitor: removeMonitor, removeServiceUi: removeServiceUi, removeTemplateUi: removeTemplateUi, renewCertsNow: renewCertsNow, restartWebFor: restartWebFor, restoreVersion: restoreVersion, runConsole: runConsole, runGenerated: runGenerated, runNeedsConfirm: runNeedsConfirm, saveAsTemplate: saveAsTemplate, saveChannel: saveChannel, saveConfig: saveConfig, saveFile: saveFile, saveMonitor: saveMonitor, sectionList: sectionList, selectedLogPaths: selectedLogPaths, sendKey: sendKey, services: services, setAdding: setAdding, setAiDraft: setAiDraft, setAiIntent: setAiIntent, setAiMode: setAiMode, setAiModels: setAiModels, setAlerts: setAlerts, setAskQuestion: setAskQuestion, setBackupBusy: setBackupBusy, setCHost: setCHost, setCerts: setCerts, setChBusy: setChBusy, setChannelForm: setChannelForm, setChannels: setChannels, setChatNotice: setChatNotice, setCleanBackupFile: setCleanBackupFile, setCleanBusyHost: setCleanBusyHost, setCleanPreview: setCleanPreview, setCleanRunBusy: setCleanRunBusy, setCleanSel: setCleanSel, setConfig: setConfig, setConsoleCmd: setConsoleCmd, setDetailHost: setDetailHost, setDetailTab: setDetailTab, setDiag: setDiag, setEditName: setEditName, setError: setError, setFileState: setFileState, setForm: setForm, setHealth: setHealth, setHistDiff: setHistDiff, setHistList: setHistList, setHistPath: setHistPath, setHostCtx: setHostCtx, setLogRequest: setLogRequest, setLogUsageData: setLogUsageData, setMaintenanceUi: setMaintenanceUi, setMaintenanceUntil: setMaintenanceUntil, setMonBusy: setMonBusy, setMonDialog: setMonDialog, setMonEditId: setMonEditId, setMonForm: setMonForm, setMonitors: setMonitors, setNotice: setNotice, setOpBusy: setOpBusy, setOpOut: setOpOut, setP2Busy: setP2Busy, setQuickText: setQuickText, setServices: setServices, setSimpleCtx: setSimpleCtx, setSimpleMonitors: setSimpleMonitors, setSimpleNotice: setSimpleNotice, setTab: setTab, setTemplateId: setTemplateId, setTemplates: setTemplates, setTerm: setTerm, setUiMode: setUiMode, showDiff: showDiff, simpleCtx: simpleCtx, simpleHostState: simpleHostState, simpleMonitors: simpleMonitors, simpleNotice: simpleNotice, startEdit: startEdit, statusOf: statusOf, suggestionFor: suggestionFor, switchMode: switchMode, tab: tab, templateId: templateId, templates: templates, term: term, testChannelUi: testChannelUi, testHost: testHost, testMonitor: testMonitor, timeoutFor: timeoutFor, trackJob: trackJob, uiMode: uiMode }))
|
|
3833
3859
|
: null
|
|
3834
3860
|
|
|
3835
3861
|
const topTabs = [[0, T.tabs[0]], [1, T.tabs[8]], [2, T.tabs[9]]]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ops-kit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "OPC-运维工作台 (dsh-ops-kit) — Server operations kit for DeepSeek Harness: server cards, health charts, config browser, app manager and plain-language AI diagnosis — over SSH, no agent install.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|