Add basic support for bulk deleting all devices
Make it easier to purge all devices from the device list. Api calls are done in parallel, without error handling, but it should be a relatively fast operation Fixes #1435
This commit is contained in:
parent
8f9afee17c
commit
9dc9bdcbed
3 changed files with 43 additions and 10 deletions
|
@ -5,6 +5,7 @@
|
|||
<div class="sectionTitleContainer sectionTitleContainer-cards flex align-items-center">
|
||||
<h2 class="sectionTitle sectionTitle-cards">${HeaderDevices}</h2>
|
||||
<a is="emby-linkbutton" rel="noopener noreferrer" class="raised button-alt headerHelpButton" target="_blank" href="https://docs.jellyfin.org/general/server/devices.html">${Help}</a>
|
||||
<button id="deviceDeleteAll" is="emby-button" type="button" class="raised button-alt">${DeleteAll}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div is="emby-itemscontainer" class="devicesList vertical-wrap" data-multiselect="false"></div>
|
||||
|
|
|
@ -10,10 +10,41 @@ import 'cardStyle';
|
|||
|
||||
/* eslint-disable indent */
|
||||
|
||||
// Local cache of loaded
|
||||
let deviceIds = [];
|
||||
|
||||
function canDelete(deviceId) {
|
||||
return deviceId !== ApiClient.deviceId();
|
||||
}
|
||||
|
||||
function deleteViaApi(id) {
|
||||
return ApiClient.ajax({
|
||||
type: 'DELETE',
|
||||
url: ApiClient.getUrl('Devices', {
|
||||
Id: id
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function deleteAllDevices(page) {
|
||||
let msg = globalize.translate('DeleteDevicesConfirmation');
|
||||
|
||||
require(['confirm'], async function (confirm) {
|
||||
await confirm({
|
||||
text: msg,
|
||||
title: globalize.translate('HeaderDeleteDevices'),
|
||||
confirmText: globalize.translate('ButtonDelete'),
|
||||
primary: 'delete'
|
||||
});
|
||||
|
||||
loading.show();
|
||||
await Promise.all(
|
||||
deviceIds.filter(canDelete).map((id) => deleteViaApi(id))
|
||||
);
|
||||
loadData(page);
|
||||
});
|
||||
}
|
||||
|
||||
function deleteDevice(page, id) {
|
||||
const msg = globalize.translate('DeleteDeviceConfirmation');
|
||||
|
||||
|
@ -23,16 +54,10 @@ import 'cardStyle';
|
|||
title: globalize.translate('HeaderDeleteDevice'),
|
||||
confirmText: globalize.translate('Delete'),
|
||||
primary: 'delete'
|
||||
}).then(function () {
|
||||
}).then(async () => {
|
||||
loading.show();
|
||||
ApiClient.ajax({
|
||||
type: 'DELETE',
|
||||
url: ApiClient.getUrl('Devices', {
|
||||
Id: id
|
||||
})
|
||||
}).then(function () {
|
||||
loadData(page);
|
||||
});
|
||||
await deleteViaApi(id);
|
||||
loadData(page);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -129,6 +154,7 @@ import 'cardStyle';
|
|||
loading.show();
|
||||
ApiClient.getJSON(ApiClient.getUrl('Devices')).then(function (result) {
|
||||
load(page, result.Items);
|
||||
deviceIds = result.Items.map((device) => device.Id);
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
|
@ -145,6 +171,9 @@ import 'cardStyle';
|
|||
view.addEventListener('viewshow', function () {
|
||||
loadData(this);
|
||||
});
|
||||
}
|
||||
|
||||
view.querySelector('#deviceDeleteAll').addEventListener('click', function() {
|
||||
deleteAllDevices(view);
|
||||
});
|
||||
}
|
||||
/* eslint-enable indent */
|
||||
|
|
|
@ -150,6 +150,8 @@
|
|||
"DefaultSubtitlesHelp": "Subtitles are loaded based on the default and forced flags in the embedded metadata. Language preferences are considered when multiple options are available.",
|
||||
"DeinterlaceMethodHelp": "Select the deinterlacing method to use when software transcoding interlaced content. When hardware acceleration supporting hardware deinterlacing is enabled the hardware deinterlacer will be used instead of this setting.",
|
||||
"Delete": "Delete",
|
||||
"DeleteAll": "Delete All",
|
||||
"DeleteDevicesConfirmation": "Are you sure you wish to delete all devices? All other sessions will be logged out. Devices will reappear the next time a user signs in.",
|
||||
"DeleteDeviceConfirmation": "Are you sure you wish to delete this device? It will reappear the next time a user signs in with it.",
|
||||
"DeleteImage": "Delete Image",
|
||||
"DeleteImageConfirmation": "Are you sure you wish to delete this image?",
|
||||
|
@ -298,6 +300,7 @@
|
|||
"HeaderDateIssued": "Date Issued",
|
||||
"HeaderDefaultRecordingSettings": "Default Recording Settings",
|
||||
"HeaderDeleteDevice": "Delete Device",
|
||||
"HeaderDeleteDevices": "Delete All Devices",
|
||||
"HeaderDeleteItem": "Delete Item",
|
||||
"HeaderDeleteItems": "Delete Items",
|
||||
"HeaderDeleteProvider": "Delete Provider",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue