fix reboot and updater
This commit is contained in:
parent
6495186a15
commit
fa7bfc32b3
|
|
@ -50,7 +50,7 @@ public class AppUpdateService extends AppService {
|
||||||
this.appLibraryPath = context.getLauncherConfig().getAppLibrary().toPath();
|
this.appLibraryPath = context.getLauncherConfig().getAppLibrary().toPath();
|
||||||
this.anchorClass = context.getClass();
|
this.anchorClass = context.getClass();
|
||||||
this.httpClient = HttpClient.newBuilder()
|
this.httpClient = HttpClient.newBuilder()
|
||||||
.followRedirects(HttpClient.Redirect.NORMAL)
|
.followRedirects(HttpClient.Redirect.ALWAYS)
|
||||||
.connectTimeout(Duration.ofSeconds(10))
|
.connectTimeout(Duration.ofSeconds(10))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import { LogsPage } from '../pages/Logs.js';
|
||||||
import { NetworkResourcesPage } from '../pages/NetworkResources.js';
|
import { NetworkResourcesPage } from '../pages/NetworkResources.js';
|
||||||
import { UnlockSitePage } from '../pages/UnlockSite.js';
|
import { UnlockSitePage } from '../pages/UnlockSite.js';
|
||||||
import { LocalStoragesPage } from '../pages/LocalStorages.js';
|
import { LocalStoragesPage } from '../pages/LocalStorages.js';
|
||||||
|
import { RestartPage } from '../pages/Restart.js';
|
||||||
|
|
||||||
|
|
||||||
// Переменная для отслеживания текущего активного хеша (для корректного unmount)
|
// Переменная для отслеживания текущего активного хеша (для корректного unmount)
|
||||||
|
|
@ -118,6 +119,11 @@ const routes = {
|
||||||
render: LocalStoragesPage.render,
|
render: LocalStoragesPage.render,
|
||||||
mount: LocalStoragesPage.mount,
|
mount: LocalStoragesPage.mount,
|
||||||
unmount: LocalStoragesPage.unmount
|
unmount: LocalStoragesPage.unmount
|
||||||
|
},
|
||||||
|
'#restart': {
|
||||||
|
render: RestartPage.render,
|
||||||
|
mount: RestartPage.mount,
|
||||||
|
unmount: RestartPage.unmount
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
import $ from 'jquery';
|
||||||
|
import { JSONRPC } from '@/json-rpc.js';
|
||||||
|
|
||||||
|
const REDIRECT_DELAY = 10000;
|
||||||
|
|
||||||
|
function mountRestartPage() {
|
||||||
|
$('#sidebar').hide();
|
||||||
|
|
||||||
|
JSONRPC.System.restart().finally(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.href = '/';
|
||||||
|
}, REDIRECT_DELAY);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export const RestartPage = {
|
||||||
|
render: () => `
|
||||||
|
<div class="flex-center" style="height: calc(100vh - 60px);">
|
||||||
|
<div class="card" style="min-width: 380px;">
|
||||||
|
<h2 style="margin: 0; color: var(--color-text); text-align: center;">Приложение перезапускается...</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
mount: mountRestartPage,
|
||||||
|
unmount: () => {
|
||||||
|
$('#sidebar').show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -234,10 +234,8 @@ function attachEventHandlers() {
|
||||||
alert('Обновление ПО запущено!');
|
alert('Обновление ПО запущено!');
|
||||||
await updatePromise;
|
await updatePromise;
|
||||||
if (confirm('Обновление завершено. Перезагрузить?')) {
|
if (confirm('Обновление завершено. Перезагрузить?')) {
|
||||||
await JSONRPC.System.restart();
|
window.location.hash = 'restart';
|
||||||
setTimeout(() => {
|
return;
|
||||||
window.location.reload();
|
|
||||||
}, 10000);
|
|
||||||
}
|
}
|
||||||
await renderSystemAndManagerStatus();
|
await renderSystemAndManagerStatus();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -246,21 +244,8 @@ function attachEventHandlers() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#restart-system-btn').off('click').on('click', async function () {
|
$('#restart-system-btn').off('click').on('click', function () {
|
||||||
const $btn = $(this);
|
window.location.hash = 'restart';
|
||||||
|
|
||||||
$btn.prop('disabled', true).text('Перезагрузка...');
|
|
||||||
|
|
||||||
try {
|
|
||||||
await JSONRPC.System.restart();
|
|
||||||
alert('Перезагрузка системы инициирована!');
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.reload();
|
|
||||||
}, 10000);
|
|
||||||
} catch (e) {
|
|
||||||
alert('Ошибка при перезагрузке системы!');
|
|
||||||
$btn.prop('disabled', false).text('Перезагрузить');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#save-config-btn').off('click').on('click', async function () {
|
$('#save-config-btn').off('click').on('click', async function () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue