dsh-ops-kit 0.4.4 → 0.4.5
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 +37 -5
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -2738,11 +2738,11 @@ window.__ModuleLoader__.load({
|
|
|
2738
2738
|
return hostDetailView
|
|
2739
2739
|
}
|
|
2740
2740
|
|
|
2741
|
-
function Panel() {
|
|
2741
|
+
function Panel({ initialHosts = [], initialDetailHost = null, initialDetailTab = 'summary' } = {}) {
|
|
2742
2742
|
const [tab, setTab] = React.useState(0)
|
|
2743
|
-
const [detailHost, setDetailHost] = React.useState(
|
|
2744
|
-
const [detailTab, setDetailTab] = React.useState(
|
|
2745
|
-
const [hosts, setHosts] = React.useState(
|
|
2743
|
+
const [detailHost, setDetailHost] = React.useState(initialDetailHost)
|
|
2744
|
+
const [detailTab, setDetailTab] = React.useState(initialDetailTab)
|
|
2745
|
+
const [hosts, setHosts] = React.useState(initialHosts)
|
|
2746
2746
|
const [config, setConfig] = React.useState({ enabled: true, intervalMinutes: 10, diskWarnPercent: 90, metricsMinutes: 5 })
|
|
2747
2747
|
const [overview, setOverview] = React.useState({})
|
|
2748
2748
|
const [cHost, setCHost] = React.useState('')
|
|
@@ -3278,6 +3278,34 @@ window.__ModuleLoader__.load({
|
|
|
3278
3278
|
})
|
|
3279
3279
|
})()
|
|
3280
3280
|
|
|
3281
|
+
const termKey = (event) => {
|
|
3282
|
+
if (!term?.id) return
|
|
3283
|
+
if (aiMode) {
|
|
3284
|
+
if (event.key === 'Escape') { event.preventDefault(); setAiMode(false); setAiDraft(''); return }
|
|
3285
|
+
if (event.key === 'Enter') { event.preventDefault(); void aiFill(aiDraft); return }
|
|
3286
|
+
if (event.key === 'Backspace') { event.preventDefault(); setAiDraft(current => current.slice(0, -1)); return }
|
|
3287
|
+
if (!event.ctrlKey && !event.metaKey && !event.altKey && event.key.length === 1) {
|
|
3288
|
+
event.preventDefault(); setAiDraft(current => current + event.key); return
|
|
3289
|
+
}
|
|
3290
|
+
return
|
|
3291
|
+
}
|
|
3292
|
+
if (event.key === '?' && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
3293
|
+
event.preventDefault(); setAiMode(true); setAiDraft(''); return
|
|
3294
|
+
}
|
|
3295
|
+
const map = {
|
|
3296
|
+
Enter: '\r', Backspace: '\x7f', Tab: '\t', Escape: '\x1b',
|
|
3297
|
+
ArrowUp: '\x1b[A', ArrowDown: '\x1b[B', ArrowRight: '\x1b[C', ArrowLeft: '\x1b[D',
|
|
3298
|
+
Home: '\x1b[H', End: '\x1b[F', Delete: '\x1b[3~', PageUp: '\x1b[5~', PageDown: '\x1b[6~',
|
|
3299
|
+
}
|
|
3300
|
+
let data
|
|
3301
|
+
if (map[event.key]) data = map[event.key]
|
|
3302
|
+
else if (event.ctrlKey && event.key.length === 1) data = String.fromCharCode(event.key.toUpperCase().charCodeAt(0) - 64)
|
|
3303
|
+
else if (!event.metaKey && !event.altKey && event.key.length === 1) data = event.key
|
|
3304
|
+
if (data === undefined) return
|
|
3305
|
+
event.preventDefault()
|
|
3306
|
+
void sendKey(data)
|
|
3307
|
+
}
|
|
3308
|
+
|
|
3281
3309
|
const loadChannels = async () => {
|
|
3282
3310
|
markLoading('channels', true)
|
|
3283
3311
|
try { const data = await api('channels', {}, 20_000); setChannels(data.channels || []) } catch { setChannels([]) }
|
|
@@ -3754,6 +3782,10 @@ window.__ModuleLoader__.load({
|
|
|
3754
3782
|
try { await api('config', { method: 'POST', body: JSON.stringify({ uiMode: next }) }, 15_000) } catch (e) { setError(String(e.message || e)) }
|
|
3755
3783
|
}
|
|
3756
3784
|
|
|
3785
|
+
const quickCommands = (Array.isArray(config.quickCommands) && config.quickCommands.length > 0)
|
|
3786
|
+
? config.quickCommands
|
|
3787
|
+
: ['df -h', 'free -h', 'uptime', 'systemctl --failed', 'docker ps', 'tail -n 30 /var/log/messages']
|
|
3788
|
+
|
|
3757
3789
|
const subBody = detailHost
|
|
3758
3790
|
? ({ 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, detailHost, doAction, fileState, hosts, inv, loadInv, monBusy, monitorSuggestions, openFile, output, saveFile, 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 }))
|
|
3759
3791
|
: null
|
|
@@ -3992,6 +4024,6 @@ window.__ModuleLoader__.load({
|
|
|
3992
4024
|
ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: PANEL }, PanelRoot))
|
|
3993
4025
|
}
|
|
3994
4026
|
|
|
3995
|
-
return { isPlugin: true, inject: ['slots'], apply, __test: { PanelRoot, MonitorTab, BackupsTab, CronTab, DeployTab, FilesTab, LogsTab, AssistantTab, TerminalTab, SettingsTab, ConfigTab, AppsTab, OverviewTab, HostDetailTab, Chart } }
|
|
4027
|
+
return { isPlugin: true, inject: ['slots'], apply, __test: { PanelRoot, Panel, MonitorTab, BackupsTab, CronTab, DeployTab, FilesTab, LogsTab, AssistantTab, TerminalTab, SettingsTab, ConfigTab, AppsTab, OverviewTab, HostDetailTab, Chart } }
|
|
3996
4028
|
},
|
|
3997
4029
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ops-kit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
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",
|