mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migrate to ES6
This commit is contained in:
parent
e5f0d77c30
commit
ae5fa9d304
13 changed files with 220 additions and 227 deletions
62
src/controllers/dashboard/quickconnect.js
Normal file
62
src/controllers/dashboard/quickconnect.js
Normal file
|
@ -0,0 +1,62 @@
|
|||
import loading from 'loading';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
let page;
|
||||
export default function(view) {
|
||||
view.addEventListener('viewshow', function () {
|
||||
page = this;
|
||||
loading.show();
|
||||
page.querySelector('#btnQuickConnectSubmit').onclick = onSubmit;
|
||||
updatePage();
|
||||
});
|
||||
}
|
||||
|
||||
function loadPage(status) {
|
||||
let available = status === 'Available' || status === 'Active';
|
||||
|
||||
page.querySelector('#quickConnectStatus').textContent = status.toLocaleLowerCase();
|
||||
page.querySelector('#chkQuickConnectAvailable').checked = available;
|
||||
|
||||
loading.hide();
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
loading.show();
|
||||
|
||||
let newStatus = page.querySelector('#chkQuickConnectAvailable').checked ? 'Available' : 'Unavailable';
|
||||
|
||||
let url = ApiClient.getUrl('/QuickConnect/Available');
|
||||
|
||||
ApiClient.ajax({
|
||||
type: 'POST',
|
||||
data: {
|
||||
'Status': newStatus
|
||||
},
|
||||
url: url
|
||||
}, true).then(() => {
|
||||
require(['toast'], function (toast) {
|
||||
toast('Settings saved');
|
||||
});
|
||||
|
||||
setTimeout(updatePage, 500);
|
||||
|
||||
return true;
|
||||
}).catch((e) => {
|
||||
console.error('Unable to set quick connect status. error:', e);
|
||||
});
|
||||
|
||||
loading.hide();
|
||||
return false;
|
||||
}
|
||||
|
||||
function updatePage() {
|
||||
ApiClient.getQuickConnect('Status').then((response) => {
|
||||
loadPage(response);
|
||||
return true;
|
||||
}).catch((e) => {
|
||||
console.error('Unable to get quick connect status. error:', e);
|
||||
});
|
||||
}
|
||||
|
||||
/* eslint-enable indent */
|
Loading…
Add table
Add a link
Reference in a new issue