mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix restart and shutdown buttons
This commit is contained in:
parent
c516534ce3
commit
6e6467b090
2 changed files with 19 additions and 8 deletions
|
@ -23,10 +23,10 @@
|
||||||
<button is="emby-button" type="button" class="raised btnRefresh">
|
<button is="emby-button" type="button" class="raised btnRefresh">
|
||||||
<span>${ButtonScanAllLibraries}</span>
|
<span>${ButtonScanAllLibraries}</span>
|
||||||
</button>
|
</button>
|
||||||
<button is="emby-button" type="button" id="btnRestartServer" class="raised" onclick="DashboardPage.restart(this);">
|
<button is="emby-button" type="button" id="btnRestartServer" class="raised">
|
||||||
<span>${Restart}</span>
|
<span>${Restart}</span>
|
||||||
</button>
|
</button>
|
||||||
<button is="emby-button" type="button" id="btnShutdown" class="raised" onclick="DashboardPage.shutdown(this);">
|
<button is="emby-button" type="button" id="btnShutdown" class="raised">
|
||||||
<span>${ButtonShutdown}</span>
|
<span>${ButtonShutdown}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -714,30 +714,34 @@ const DashboardPage = {
|
||||||
pollForInfo(page, ApiClient);
|
pollForInfo(page, ApiClient);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
restart: function (btn) {
|
restart: function (event) {
|
||||||
confirm({
|
confirm({
|
||||||
title: globalize.translate('Restart'),
|
title: globalize.translate('Restart'),
|
||||||
text: globalize.translate('MessageConfirmRestart'),
|
text: globalize.translate('MessageConfirmRestart'),
|
||||||
confirmText: globalize.translate('Restart'),
|
confirmText: globalize.translate('Restart'),
|
||||||
primary: 'delete'
|
primary: 'delete'
|
||||||
}).then(function () {
|
}).then(() => {
|
||||||
const page = dom.parentWithClass(btn, 'page');
|
const page = dom.parentWithClass(event.target, 'page');
|
||||||
page.querySelector('#btnRestartServer').disabled = true;
|
page.querySelector('#btnRestartServer').disabled = true;
|
||||||
page.querySelector('#btnShutdown').disabled = true;
|
page.querySelector('#btnShutdown').disabled = true;
|
||||||
ApiClient.restartServer();
|
ApiClient.restartServer();
|
||||||
|
}).catch(() => {
|
||||||
|
// Confirm dialog closed
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
shutdown: function (btn) {
|
shutdown: function (event) {
|
||||||
confirm({
|
confirm({
|
||||||
title: globalize.translate('ButtonShutdown'),
|
title: globalize.translate('ButtonShutdown'),
|
||||||
text: globalize.translate('MessageConfirmShutdown'),
|
text: globalize.translate('MessageConfirmShutdown'),
|
||||||
confirmText: globalize.translate('ButtonShutdown'),
|
confirmText: globalize.translate('ButtonShutdown'),
|
||||||
primary: 'delete'
|
primary: 'delete'
|
||||||
}).then(function () {
|
}).then(() => {
|
||||||
const page = dom.parentWithClass(btn, 'page');
|
const page = dom.parentWithClass(event.target, 'page');
|
||||||
page.querySelector('#btnRestartServer').disabled = true;
|
page.querySelector('#btnRestartServer').disabled = true;
|
||||||
page.querySelector('#btnShutdown').disabled = true;
|
page.querySelector('#btnShutdown').disabled = true;
|
||||||
ApiClient.shutdownServer();
|
ApiClient.shutdownServer();
|
||||||
|
}).catch(() => {
|
||||||
|
// Confirm dialog closed
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -817,7 +821,11 @@ export default function (view) {
|
||||||
taskKey: 'RefreshLibrary',
|
taskKey: 'RefreshLibrary',
|
||||||
button: page.querySelector('.btnRefresh')
|
button: page.querySelector('.btnRefresh')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
page.querySelector('#btnRestartServer').addEventListener('click', DashboardPage.restart);
|
||||||
|
page.querySelector('#btnShutdown').addEventListener('click', DashboardPage.shutdown);
|
||||||
});
|
});
|
||||||
|
|
||||||
view.addEventListener('viewbeforehide', function () {
|
view.addEventListener('viewbeforehide', function () {
|
||||||
const apiClient = ApiClient;
|
const apiClient = ApiClient;
|
||||||
const page = this;
|
const page = this;
|
||||||
|
@ -839,6 +847,9 @@ export default function (view) {
|
||||||
taskKey: 'RefreshLibrary',
|
taskKey: 'RefreshLibrary',
|
||||||
button: page.querySelector('.btnRefresh')
|
button: page.querySelector('.btnRefresh')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
page.querySelector('#btnRestartServer').removeEventListener('click', DashboardPage.restart);
|
||||||
|
page.querySelector('#btnShutdown').removeEventListener('click', DashboardPage.shutdown);
|
||||||
});
|
});
|
||||||
view.addEventListener('viewdestroy', function () {
|
view.addEventListener('viewdestroy', function () {
|
||||||
const page = this;
|
const page = this;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue