|
|
@@ -80,6 +80,39 @@ export default function PanelUpdateModal({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async function runPanelUpdate() {
|
|
|
+ const baseTip = t('pages.index.dontRefresh');
|
|
|
+ const tip = info.latestVersion ? `${baseTip} (${info.latestVersion})` : baseTip;
|
|
|
+ onClose();
|
|
|
+ onBusy({ busy: true, tip });
|
|
|
+ const result = await HttpUtil.post<{ runId: string }>('/panel/api/server/updatePanel');
|
|
|
+ if (!result?.success) {
|
|
|
+ onBusy({ busy: false });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const outcome = await pollUpdateStatus(result.obj?.runId ?? '');
|
|
|
+ onBusy({ busy: false });
|
|
|
+ if (outcome === 'success') {
|
|
|
+ await PromiseUtil.sleep(800);
|
|
|
+ window.location.reload();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ modal[outcome === 'failed' ? 'error' : 'warning']({
|
|
|
+ title: t(
|
|
|
+ outcome === 'failed'
|
|
|
+ ? 'pages.index.panelUpdateFailedTitle'
|
|
|
+ : 'pages.index.panelUpdateUnknownTitle',
|
|
|
+ ),
|
|
|
+ content: t(
|
|
|
+ outcome === 'failed'
|
|
|
+ ? 'pages.index.panelUpdateFailedDesc'
|
|
|
+ : 'pages.index.panelUpdateUnknownDesc',
|
|
|
+ ),
|
|
|
+ okText: t('refresh'),
|
|
|
+ onOk: () => window.location.reload(),
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
function updatePanel() {
|
|
|
modal.confirm({
|
|
|
title: t('pages.index.panelUpdateDialog'),
|
|
|
@@ -89,37 +122,8 @@ export default function PanelUpdateModal({
|
|
|
),
|
|
|
okText: t('confirm'),
|
|
|
cancelText: t('cancel'),
|
|
|
- onOk: async () => {
|
|
|
- const baseTip = t('pages.index.dontRefresh');
|
|
|
- const tip = info.latestVersion ? `${baseTip} (${info.latestVersion})` : baseTip;
|
|
|
- onClose();
|
|
|
- onBusy({ busy: true, tip });
|
|
|
- const result = await HttpUtil.post<{ runId: string }>('/panel/api/server/updatePanel');
|
|
|
- if (!result?.success) {
|
|
|
- onBusy({ busy: false });
|
|
|
- return;
|
|
|
- }
|
|
|
- const outcome = await pollUpdateStatus(result.obj?.runId ?? '');
|
|
|
- onBusy({ busy: false });
|
|
|
- if (outcome === 'success') {
|
|
|
- await PromiseUtil.sleep(800);
|
|
|
- window.location.reload();
|
|
|
- return;
|
|
|
- }
|
|
|
- modal[outcome === 'failed' ? 'error' : 'warning']({
|
|
|
- title: t(
|
|
|
- outcome === 'failed'
|
|
|
- ? 'pages.index.panelUpdateFailedTitle'
|
|
|
- : 'pages.index.panelUpdateUnknownTitle',
|
|
|
- ),
|
|
|
- content: t(
|
|
|
- outcome === 'failed'
|
|
|
- ? 'pages.index.panelUpdateFailedDesc'
|
|
|
- : 'pages.index.panelUpdateUnknownDesc',
|
|
|
- ),
|
|
|
- okText: t('refresh'),
|
|
|
- onOk: () => window.location.reload(),
|
|
|
- });
|
|
|
+ onOk: () => {
|
|
|
+ void runPanelUpdate();
|
|
|
},
|
|
|
});
|
|
|
}
|