gateway: add local backend update action
This commit is contained in:
@@ -37,6 +37,7 @@ const LOCAL_BACKEND_ACTION_LABELS = {
|
||||
start: 'Start',
|
||||
restart: 'Restart',
|
||||
stop: 'Stop',
|
||||
update: 'Update',
|
||||
};
|
||||
const SERVICE_TOGGLE_PATCH_PATHS = {
|
||||
heartbeat: 'automation.heartbeat.enabled',
|
||||
@@ -1569,7 +1570,7 @@ function updateLocalBackends(localBackendsData) {
|
||||
const loadText = backend.loadState || 'unknown';
|
||||
const resultText = backend.result || 'unknown';
|
||||
const availableActions = Array.isArray(backend.availableActions)
|
||||
? backend.availableActions.filter((value) => ['start', 'restart', 'stop'].includes(String(value)))
|
||||
? backend.availableActions.filter((value) => ['start', 'restart', 'stop', 'update'].includes(String(value)))
|
||||
: [];
|
||||
const actionMessage = actionState?.message
|
||||
? `<div class="text-xs ${actionState.tone === 'error' ? 'text-red-400' : actionState.tone === 'success' ? 'text-green-400' : 'text-zinc-400'}">${escapeHtml(String(actionState.message))}</div>`
|
||||
@@ -1623,6 +1624,7 @@ async function handleLocalBackendAction(backendId, action) {
|
||||
action,
|
||||
});
|
||||
const status = result?.status;
|
||||
const resultMessage = typeof result?.message === 'string' ? result.message : null;
|
||||
if (status && typeof status === 'object') {
|
||||
_lastLocalBackends = _lastLocalBackends.map((backend) =>
|
||||
backend.id === backendId ? status : backend);
|
||||
@@ -1630,7 +1632,7 @@ async function handleLocalBackendAction(backendId, action) {
|
||||
_localBackendActionState.set(backendId, {
|
||||
pending: false,
|
||||
tone: 'success',
|
||||
message: `${actionLabel} completed`,
|
||||
message: resultMessage ? `${actionLabel} completed: ${resultMessage}` : `${actionLabel} completed`,
|
||||
});
|
||||
updateLocalBackends({ backends: _lastLocalBackends });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user