solved imports for alert, toast and confirm

This commit is contained in:
vitorsemeano 2020-10-18 15:18:15 +01:00
parent 4b42afcd7a
commit 86a9f4e36f
49 changed files with 417 additions and 550 deletions

View File

@ -7,6 +7,7 @@ import serverNotifications from '../scripts/serverNotifications';
import '../elements/emby-button/emby-button';
import './listview/listview.css';
import ServerConnections from './ServerConnections';
import alert from './alert';
/* eslint-disable indent */
@ -128,10 +129,8 @@ import ServerConnections from './ServerConnections';
}
function showItemOverview(item) {
import('./alert').then((alert) => {
alert({
text: item.Overview
});
alert({
text: item.Overview
});
}

View File

@ -11,6 +11,7 @@ import viewManager from './viewManager/viewManager';
import AppInfo from './AppInfo';
import Dashboard from '../scripts/clientUtils';
import ServerConnections from './ServerConnections';
import alert from './alert';
class AppRouter {
allRoutes = [];
@ -289,13 +290,11 @@ class AppRouter {
this.showWelcome();
break;
case 'ServerUpdateNeeded':
import('./alert').then((alert) =>{
alert({
text: globalize.translate('ServerUpdateNeeded', 'https://github.com/jellyfin/jellyfin'),
html: globalize.translate('ServerUpdateNeeded', '<a href="https://github.com/jellyfin/jellyfin">https://github.com/jellyfin/jellyfin</a>')
}).then(() => {
this.showSelectServer();
});
alert({
text: globalize.translate('ServerUpdateNeeded', 'https://github.com/jellyfin/jellyfin'),
html: globalize.translate('ServerUpdateNeeded', '<a href="https://github.com/jellyfin/jellyfin">https://github.com/jellyfin/jellyfin</a>')
}).then(() => {
this.showSelectServer();
});
break;
default:
@ -410,9 +409,7 @@ class AppRouter {
this.forcedLogoutMsg = null;
if (msg) {
import('./alert').then((alert) => {
alert(msg);
});
alert(msg);
}
}

View File

@ -2,68 +2,64 @@ import browser from '../../scripts/browser';
import dialog from '../dialog/dialog';
import globalize from '../../scripts/globalize';
/* eslint-disable indent */
export default (() => {
function replaceAll(str, find, replace) {
return str.split(find).join(replace);
function replaceAll(str, find, replace) {
return str.split(find).join(replace);
}
function nativeConfirm(options) {
if (typeof options === 'string') {
options = {
title: '',
text: options
};
}
if (browser.tv && window.confirm) {
// Use the native confirm dialog
return options => {
if (typeof options === 'string') {
options = {
title: '',
text: options
};
}
const text = replaceAll(options.text || '', '<br/>', '\n');
const result = window.confirm(text);
const text = replaceAll(options.text || '', '<br/>', '\n');
const result = window.confirm(text);
if (result) {
return Promise.resolve();
} else {
return Promise.reject();
}
}
if (result) {
return Promise.resolve();
} else {
return Promise.reject();
}
function customConfirm(text, title) {
let options;
if (typeof text === 'string') {
options = {
title: title,
text: text
};
} else {
// Use our own dialog
return (text, title) => {
let options;
if (typeof text === 'string') {
options = {
title: title,
text: text
};
} else {
options = text;
}
const items = [];
items.push({
name: options.cancelText || globalize.translate('ButtonCancel'),
id: 'cancel',
type: 'cancel'
});
items.push({
name: options.confirmText || globalize.translate('ButtonOk'),
id: 'ok',
type: options.primary === 'delete' ? 'delete' : 'submit'
});
options.buttons = items;
return dialog.show(options).then(result => {
if (result === 'ok') {
return Promise.resolve();
}
return Promise.reject();
});
};
options = text;
}
})();
/* eslint-enable indent */
const items = [];
items.push({
name: options.cancelText || globalize.translate('ButtonCancel'),
id: 'cancel',
type: 'cancel'
});
items.push({
name: options.confirmText || globalize.translate('ButtonOk'),
id: 'ok',
type: options.primary === 'delete' ? 'delete' : 'submit'
});
options.buttons = items;
return dialog.show(options).then(result => {
if (result === 'ok') {
return Promise.resolve();
}
return Promise.reject();
});
}
const baseConfirm = browser.tv && window.confirm ? nativeConfirm : customConfirm;
export default baseConfirm;

View File

@ -8,6 +8,7 @@ import '../../elements/emby-button/paper-icon-button-light';
import './directorybrowser.css';
import '../formdialog.css';
import '../../elements/emby-button/emby-button';
import alert from '../alert';
/* eslint-disable indent */
@ -157,9 +158,7 @@ import '../../elements/emby-button/emby-button';
}
function alertTextWithOptions(options) {
import('../alert').then((alert) => {
alert(options);
});
alert(options);
}
function validatePath(path, validateWriteable, apiClient) {

View File

@ -14,6 +14,8 @@ import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import './imageeditor.css';
import ServerConnections from '../ServerConnections';
import alert from '../alert';
import confirm from '../confirm/confirm';
/* eslint-disable indent */
@ -200,15 +202,11 @@ import ServerConnections from '../ServerConnections';
return;
}
import('../confirm/confirm').then(({default: confirm}) => {
confirm({
text: globalize.translate('ConfirmDeleteImage'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(afterConfirm);
});
confirm({
text: globalize.translate('ConfirmDeleteImage'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(afterConfirm);
}
function moveImage(context, apiClient, itemId, type, index, newIndex, focusContext) {
@ -216,9 +214,7 @@ import ServerConnections from '../ServerConnections';
hasChanges = true;
reload(context, null, focusContext);
}, function () {
import('../alert').then((alert) => {
alert(globalize.translate('ErrorDefault'));
});
alert(globalize.translate('ErrorDefault'));
});
}

View File

@ -20,6 +20,7 @@ import '../listview/listview.css';
import '../formdialog.css';
import '../../assets/css/flexstyles.css';
import toast from '../toast/toast';
import alert from '../alert';
function onAddLibrary() {
if (isCreating) {
@ -27,11 +28,9 @@ import toast from '../toast/toast';
}
if (pathInfos.length == 0) {
import('../alert').then((alert) => {
alert({
text: globalize.translate('PleaseAddAtLeastOneFolder'),
type: 'error'
});
alert({
text: globalize.translate('PleaseAddAtLeastOneFolder'),
type: 'error'
});
return false;

View File

@ -18,6 +18,7 @@ import '../formdialog.css';
import '../../elements/emby-toggle/emby-toggle';
import '../../assets/css/flexstyles.css';
import toast from '../toast/toast';
import confirm from '../confirm/confirm';
function onEditLibrary() {
if (isCreating) {
@ -69,20 +70,18 @@ import toast from '../toast/toast';
const button = btnRemovePath;
const virtualFolder = currentOptions.library;
import('../confirm/confirm').then(({default: confirm}) => {
confirm({
title: globalize.translate('HeaderRemoveMediaLocation'),
text: globalize.translate('MessageConfirmRemoveMediaLocation'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(() => {
const refreshAfterChange = currentOptions.refresh;
ApiClient.removeMediaPath(virtualFolder.Name, location, refreshAfterChange).then(() => {
hasChanges = true;
refreshLibraryFromServer(dom.parentWithClass(button, 'dlg-libraryeditor'));
}, () => {
toast(globalize.translate('ErrorDefault'));
});
confirm({
title: globalize.translate('HeaderRemoveMediaLocation'),
text: globalize.translate('MessageConfirmRemoveMediaLocation'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(() => {
const refreshAfterChange = currentOptions.refresh;
ApiClient.removeMediaPath(virtualFolder.Name, location, refreshAfterChange).then(() => {
hasChanges = true;
refreshLibraryFromServer(dom.parentWithClass(button, 'dlg-libraryeditor'));
}, () => {
toast(globalize.translate('ErrorDefault'));
});
});
}

View File

@ -17,6 +17,7 @@ import '../formdialog.css';
import '../../assets/css/clearbutton.css';
import '../../assets/css/flexstyles.css';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/* eslint-disable indent */
@ -36,9 +37,7 @@ import ServerConnections from '../ServerConnections';
function submitUpdatedItem(form, item) {
function afterContentTypeUpdated() {
import('../toast/toast').then(({default: toast}) => {
toast(globalize.translate('MessageItemSaved'));
});
toast(globalize.translate('MessageItemSaved'));
loading.hide();
closeDialog(true);

View File

@ -5,6 +5,9 @@ import globalize from '../../scripts/globalize';
import dom from '../../scripts/dom';
import './multiSelect.css';
import ServerConnections from '../ServerConnections';
import alert from '../alert';
import playlistEditor from '../playlisteditor/playlisteditor';
import confirm from '../confirm/confirm';
/* eslint-disable indent */
@ -138,10 +141,8 @@ import ServerConnections from '../ServerConnections';
}
function alertText(options) {
return new Promise((resolve, reject) => {
import('../alert').then((alert) => {
alert(options).then(resolve, resolve);
});
return new Promise((resolve) => {
alert(options).then(resolve, resolve);
});
}
@ -155,17 +156,15 @@ import ServerConnections from '../ServerConnections';
title = globalize.translate('HeaderDeleteItems');
}
import('../confirm/confirm').then((confirm) => {
confirm(msg, title).then(() => {
const promises = itemIds.map(itemId => {
apiClient.deleteItem(itemId);
});
confirm(msg, title).then(() => {
const promises = itemIds.map(itemId => {
apiClient.deleteItem(itemId);
});
Promise.all(promises).then(resolve, () => {
alertText(globalize.translate('ErrorDeletingItem')).then(reject, reject);
});
}, reject);
});
Promise.all(promises).then(resolve, () => {
alertText(globalize.translate('ErrorDeletingItem')).then(reject, reject);
});
}, reject);
});
}
@ -318,11 +317,8 @@ import ServerConnections from '../ServerConnections';
function combineVersions(apiClient, selection) {
if (selection.length < 2) {
import('../alert').then((alert) => {
alert({
text: globalize.translate('PleaseSelectTwoItems')
});
alert({
text: globalize.translate('PleaseSelectTwoItems')
});
return;
}

View File

@ -10,6 +10,7 @@ import loading from '../loading/loading';
import { appHost } from '../apphost';
import * as Screenfull from 'screenfull';
import ServerConnections from '../ServerConnections';
import alert from '../alert';
function enableLocalPlaylistManagement(player) {
if (player.getPlaylist) {
@ -648,11 +649,9 @@ function validatePlaybackInfoResult(instance, result) {
}
function showPlaybackInfoErrorMessage(instance, errorCode) {
import('../alert').then(({ default: alert }) => {
alert({
text: globalize.translate(errorCode),
title: globalize.translate('HeaderPlaybackError')
});
alert({
text: globalize.translate(errorCode),
title: globalize.translate('HeaderPlaybackError')
});
}

View File

@ -9,6 +9,7 @@ import { Events } from 'jellyfin-apiclient';
import '../../elements/emby-select/emby-select';
import '../../elements/emby-checkbox/emby-checkbox';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/* eslint-disable indent */
@ -244,9 +245,7 @@ import ServerConnections from '../ServerConnections';
saveUser(context, user, userSettings, apiClient).then(() => {
loading.hide();
if (enableSaveConfirmation) {
import('../toast/toast').then((toast) => {
toast(globalize.translate('SettingsSaved'));
});
toast(globalize.translate('SettingsSaved'));
}
Events.trigger(instance, 'saved');

View File

@ -9,6 +9,7 @@ import '../../elements/emby-button/paper-icon-button-light';
import './recordingfields.css';
import '../../assets/css/flexstyles.css';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/*eslint prefer-const: "error"*/
@ -226,9 +227,7 @@ function onRecordChange(e) {
}
function sendToast(msg) {
import('../toast/toast').then((toast) => {
toast(msg);
});
toast(msg);
}
function onRecordSeriesChange(e) {

View File

@ -1,6 +1,8 @@
import globalize from '../../scripts/globalize';
import loading from '../loading/loading';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
import confirm from '../confirm/confirm';
/*eslint prefer-const: "error"*/
@ -29,48 +31,42 @@ function changeRecordingToSeries(apiClient, timerId, programId, confirmTimerCanc
function cancelTimerWithConfirmation(timerId, serverId) {
return new Promise(function (resolve, reject) {
import('../confirm/confirm').then((confirm) => {
confirm.default({
confirm.default({
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'delete',
confirmText: globalize.translate('HeaderCancelRecording'),
cancelText: globalize.translate('HeaderKeepRecording')
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'delete',
confirmText: globalize.translate('HeaderCancelRecording'),
cancelText: globalize.translate('HeaderKeepRecording')
}).then(function () {
loading.show();
}).then(function () {
loading.show();
const apiClient = ServerConnections.getApiClient(serverId);
cancelTimer(apiClient, timerId, true).then(resolve, reject);
}, reject);
});
const apiClient = ServerConnections.getApiClient(serverId);
cancelTimer(apiClient, timerId, true).then(resolve, reject);
}, reject);
});
}
function cancelSeriesTimerWithConfirmation(timerId, serverId) {
return new Promise(function (resolve, reject) {
import('../confirm/confirm').then((confirm) => {
confirm.default({
confirm.default({
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'delete',
confirmText: globalize.translate('HeaderCancelSeries'),
cancelText: globalize.translate('HeaderKeepSeries')
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'delete',
confirmText: globalize.translate('HeaderCancelSeries'),
cancelText: globalize.translate('HeaderKeepSeries')
}).then(function () {
loading.show();
}).then(function () {
loading.show();
const apiClient = ServerConnections.getApiClient(serverId);
apiClient.cancelLiveTvSeriesTimer(timerId).then(function () {
import('../toast/toast').then((toast) => {
toast(globalize.translate('SeriesCancelled'));
});
const apiClient = ServerConnections.getApiClient(serverId);
apiClient.cancelLiveTvSeriesTimer(timerId).then(function () {
toast(globalize.translate('SeriesCancelled'));
loading.hide();
resolve();
}, reject);
loading.hide();
resolve();
}, reject);
});
}, reject);
});
}
@ -99,9 +95,7 @@ function createRecording(apiClient, programId, isSeries) {
}
function sendToast(msg) {
import('../toast/toast').then((toast) => {
toast(msg);
});
toast(msg);
}
function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId) {
@ -151,10 +145,7 @@ function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus,
loading.show();
apiClient.cancelLiveTvSeriesTimer(seriesTimerId).then(function () {
import('../toast/toast').then((toast) => {
toast(globalize.translate('SeriesCancelled'));
});
toast(globalize.translate('SeriesCancelled'));
loading.hide();
resolve();
}, reject);

View File

@ -11,6 +11,7 @@ import '../../elements/emby-select/emby-select';
import 'material-design-icons-iconfont';
import '../formdialog.css';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/*eslint prefer-const: "error"*/
@ -86,9 +87,7 @@ function onSubmit(e) {
dialogHelper.close(dlg);
import('../toast/toast').then((toast) => {
toast(globalize.translate('RefreshQueued'));
});
toast(globalize.translate('RefreshQueued'));
loading.hide();

View File

@ -16,6 +16,7 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer';
import './remotecontrol.css';
import '../../elements/emby-ratingbutton/emby-ratingbutton';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/*eslint prefer-const: "error"*/
@ -864,9 +865,7 @@ export default function () {
}, currentPlayer);
form.querySelector('input').value = '';
import('../toast/toast').then((toast) => {
toast('Message sent.');
});
toast('Message sent.');
e.preventDefault();
e.stopPropagation();
@ -883,9 +882,7 @@ export default function () {
}, currentPlayer);
form.querySelector('input').value = '';
import('../toast/toast').then((toast) => {
toast('Text sent.');
});
toast('Text sent.');
e.preventDefault();
e.stopPropagation();

View File

@ -15,6 +15,8 @@ import './subtitleeditor.css';
import '../../elements/emby-button/emby-button';
import '../../assets/css/flexstyles.css';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
import confirm from '../confirm/confirm';
let currentItem;
let hasChanges;
@ -31,9 +33,7 @@ function downloadRemoteSubtitles(context, id) {
}).then(function () {
hasChanges = true;
import('../toast/toast').then((toast) => {
toast(globalize.translate('MessageDownloadQueued'));
});
toast(globalize.translate('MessageDownloadQueued'));
focusManager.autoFocus(context);
});
@ -42,31 +42,29 @@ function downloadRemoteSubtitles(context, id) {
function deleteLocalSubtitle(context, index) {
const msg = globalize.translate('MessageAreYouSureDeleteSubtitles');
import('../confirm/confirm').then((confirm) => {
confirm({
confirm({
title: globalize.translate('ConfirmDeletion'),
text: msg,
confirmText: globalize.translate('Delete'),
primary: 'delete'
title: globalize.translate('ConfirmDeletion'),
text: msg,
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(function () {
loading.show();
const itemId = currentItem.Id;
const url = 'Videos/' + itemId + '/Subtitles/' + index;
const apiClient = ServerConnections.getApiClient(currentItem.ServerId);
apiClient.ajax({
type: 'DELETE',
url: apiClient.getUrl(url)
}).then(function () {
loading.show();
const itemId = currentItem.Id;
const url = 'Videos/' + itemId + '/Subtitles/' + index;
const apiClient = ServerConnections.getApiClient(currentItem.ServerId);
apiClient.ajax({
type: 'DELETE',
url: apiClient.getUrl(url)
}).then(function () {
hasChanges = true;
reload(context, apiClient, itemId);
});
hasChanges = true;
reload(context, apiClient, itemId);
});
});
}

View File

@ -16,6 +16,7 @@ import '../../elements/emby-checkbox/emby-checkbox';
import '../../assets/css/flexstyles.css';
import './subtitlesettings.css';
import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
/**
* Subtitle settings.
@ -88,9 +89,7 @@ function save(instance, context, userId, userSettings, apiClient, enableSaveConf
saveUser(context, user, userSettings, instance.appearanceKey, apiClient).then(function () {
loading.hide();
if (enableSaveConfirmation) {
import('../toast/toast').then((toast) => {
toast(globalize.translate('SettingsSaved'));
});
toast(globalize.translate('SettingsSaved'));
}
Events.trigger(instance, 'saved');

View File

@ -3,19 +3,18 @@ import loading from '../../components/loading/loading';
import dom from '../../scripts/dom';
import globalize from '../../scripts/globalize';
import '../../elements/emby-button/emby-button';
import confirm from '../../components/confirm/confirm';
/* eslint-disable indent */
function revoke(page, key) {
import('../../components/confirm/confirm').then(({default: confirm}) => {
confirm(globalize.translate('MessageConfirmRevokeApiKey'), globalize.translate('HeaderConfirmRevokeApiKey')).then(function () {
loading.show();
ApiClient.ajax({
type: 'DELETE',
url: ApiClient.getUrl('Auth/Keys/' + key)
}).then(function () {
loadData(page);
});
confirm(globalize.translate('MessageConfirmRevokeApiKey'), globalize.translate('HeaderConfirmRevokeApiKey')).then(function () {
loading.show();
ApiClient.ajax({
type: 'DELETE',
url: ApiClient.getUrl('Auth/Keys/' + key)
}).then(function () {
loadData(page);
});
});
}

View File

@ -20,37 +20,37 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer';
import taskButton from '../../scripts/taskbutton';
import Dashboard from '../../scripts/clientUtils';
import ServerConnections from '../../components/ServerConnections';
import alert from '../../components/alert';
import confirm from '../../components/confirm/confirm';
/* eslint-disable indent */
function showPlaybackInfo(btn, session) {
import('../../components/alert').then(({default: alert}) => {
let title;
const text = [];
const displayPlayMethod = playMethodHelper.getDisplayPlayMethod(session);
let title;
const text = [];
const displayPlayMethod = playMethodHelper.getDisplayPlayMethod(session);
if (displayPlayMethod === 'DirectStream') {
title = globalize.translate('DirectStreaming');
text.push(globalize.translate('DirectStreamHelp1'));
if (displayPlayMethod === 'DirectStream') {
title = globalize.translate('DirectStreaming');
text.push(globalize.translate('DirectStreamHelp1'));
text.push('<br/>');
text.push(globalize.translate('DirectStreamHelp2'));
} else if (displayPlayMethod === 'Transcode') {
title = globalize.translate('Transcoding');
text.push(globalize.translate('MediaIsBeingConverted'));
if (session.TranscodingInfo && session.TranscodingInfo.TranscodeReasons && session.TranscodingInfo.TranscodeReasons.length) {
text.push('<br/>');
text.push(globalize.translate('DirectStreamHelp2'));
} else if (displayPlayMethod === 'Transcode') {
title = globalize.translate('Transcoding');
text.push(globalize.translate('MediaIsBeingConverted'));
if (session.TranscodingInfo && session.TranscodingInfo.TranscodeReasons && session.TranscodingInfo.TranscodeReasons.length) {
text.push('<br/>');
text.push(globalize.translate('LabelReasonForTranscoding'));
session.TranscodingInfo.TranscodeReasons.forEach(function (transcodeReason) {
text.push(globalize.translate(transcodeReason));
});
}
text.push(globalize.translate('LabelReasonForTranscoding'));
session.TranscodingInfo.TranscodeReasons.forEach(function (transcodeReason) {
text.push(globalize.translate(transcodeReason));
});
}
}
alert({
text: text.join('<br/>'),
title: title
});
alert({
text: text.join('<br/>'),
title: title
});
}
@ -722,33 +722,29 @@ import ServerConnections from '../../components/ServerConnections';
});
},
restart: function (btn) {
import('../../components/confirm/confirm').then(({default: confirm}) => {
confirm({
title: globalize.translate('Restart'),
text: globalize.translate('MessageConfirmRestart'),
confirmText: globalize.translate('Restart'),
primary: 'delete'
}).then(function () {
const page = dom.parentWithClass(btn, 'page');
page.querySelector('#btnRestartServer').disabled = true;
page.querySelector('#btnShutdown').disabled = true;
ApiClient.restartServer();
});
confirm({
title: globalize.translate('Restart'),
text: globalize.translate('MessageConfirmRestart'),
confirmText: globalize.translate('Restart'),
primary: 'delete'
}).then(function () {
const page = dom.parentWithClass(btn, 'page');
page.querySelector('#btnRestartServer').disabled = true;
page.querySelector('#btnShutdown').disabled = true;
ApiClient.restartServer();
});
},
shutdown: function (btn) {
import('../../components/confirm/confirm').then(({default: confirm}) => {
confirm({
title: globalize.translate('ButtonShutdown'),
text: globalize.translate('MessageConfirmShutdown'),
confirmText: globalize.translate('ButtonShutdown'),
primary: 'delete'
}).then(function () {
const page = dom.parentWithClass(btn, 'page');
page.querySelector('#btnRestartServer').disabled = true;
page.querySelector('#btnShutdown').disabled = true;
ApiClient.shutdownServer();
});
confirm({
title: globalize.translate('ButtonShutdown'),
text: globalize.translate('MessageConfirmShutdown'),
confirmText: globalize.translate('ButtonShutdown'),
primary: 'delete'
}).then(function () {
const page = dom.parentWithClass(btn, 'page');
page.querySelector('#btnRestartServer').disabled = true;
page.querySelector('#btnShutdown').disabled = true;
ApiClient.shutdownServer();
});
}
};

View File

@ -8,6 +8,7 @@ import '../../../elements/emby-button/emby-button';
import '../../../elements/emby-itemscontainer/emby-itemscontainer';
import '../../../components/cardbuilder/card.css';
import Dashboard from '../../../scripts/clientUtils';
import confirm from '../../../components/confirm/confirm';
/* eslint-disable indent */
@ -40,17 +41,15 @@ import Dashboard from '../../../scripts/clientUtils';
function deleteDevice(page, id) {
const msg = globalize.translate('DeleteDeviceConfirmation');
import('../../../components/confirm/confirm').then(({default: confirm}) => {
confirm({
text: msg,
title: globalize.translate('HeaderDeleteDevice'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(async () => {
loading.show();
await ApiClient.deleteDevice(id);
loadData(page);
});
confirm({
text: msg,
title: globalize.translate('HeaderDeleteDevice'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(async () => {
loading.show();
await ApiClient.deleteDevice(id);
loadData(page);
});
}

View File

@ -7,6 +7,7 @@ import '../../../elements/emby-input/emby-input';
import '../../../elements/emby-checkbox/emby-checkbox';
import '../../../components/listview/listview.css';
import Dashboard from '../../../scripts/clientUtils';
import toast from '../../../components/toast/toast';
/* eslint-disable indent */
@ -634,9 +635,7 @@ import Dashboard from '../../../scripts/clientUtils';
data: JSON.stringify(profile),
contentType: 'application/json'
}).then(function () {
import('../../../components/toast/toast').then((toast) => {
toast('Settings saved.');
});
toast('Settings saved.');
}, Dashboard.processErrorResponse);
} else {
ApiClient.ajax({

View File

@ -4,6 +4,7 @@ import loading from '../../../components/loading/loading';
import libraryMenu from '../../../scripts/libraryMenu';
import '../../../components/listview/listview.css';
import '../../../elements/emby-button/emby-button';
import confirm from '../../../components/confirm/confirm';
/* eslint-disable indent */
@ -64,16 +65,14 @@ import '../../../elements/emby-button/emby-button';
}
function deleteProfile(page, id) {
import('../../../components/confirm/confirm').then(({default: confirm}) => {
confirm(globalize.translate('MessageConfirmProfileDeletion'), globalize.translate('HeaderConfirmProfileDeletion')).then(function () {
loading.show();
ApiClient.ajax({
type: 'DELETE',
url: ApiClient.getUrl('Dlna/Profiles/' + id)
}).then(function () {
loading.hide();
loadProfiles(page);
});
confirm(globalize.translate('MessageConfirmProfileDeletion'), globalize.translate('HeaderConfirmProfileDeletion')).then(function () {
loading.show();
ApiClient.ajax({
type: 'DELETE',
url: ApiClient.getUrl('Dlna/Profiles/' + id)
}).then(function () {
loading.hide();
loadProfiles(page);
});
});
}

View File

@ -4,6 +4,7 @@ import globalize from '../../scripts/globalize';
import dom from '../../scripts/dom';
import libraryMenu from '../../scripts/libraryMenu';
import Dashboard from '../../scripts/clientUtils';
import alert from '../../components/alert';
/* eslint-disable indent */
@ -43,12 +44,7 @@ import Dashboard from '../../scripts/clientUtils';
function onSaveEncodingPathFailure(response) {
loading.hide();
let msg = '';
msg = globalize.translate('FFmpegSavePathNotFound');
import('../../components/alert').then(({default: alert}) => {
alert(msg);
});
alert(globalize.translate('FFmpegSavePathNotFound'));
}
function updateEncoder(form) {
@ -102,22 +98,17 @@ import Dashboard from '../../scripts/clientUtils';
ApiClient.updateNamedConfiguration('encoding', config).then(function () {
updateEncoder(form);
}, function () {
import('../../components/alert').then(({default: alert}) => {
alert(globalize.translate('ErrorDefault'));
});
alert(globalize.translate('ErrorDefault'));
Dashboard.processServerConfigurationUpdateResult();
});
});
};
if ($('#selectVideoDecoder', form).val()) {
import('../../components/alert').then(({default: alert}) => {
alert({
title: globalize.translate('TitleHardwareAcceleration'),
text: globalize.translate('HardwareAccelerationWarning')
}).then(onDecoderConfirmed);
});
alert({
title: globalize.translate('TitleHardwareAcceleration'),
text: globalize.translate('HardwareAccelerationWarning')
}).then(onDecoderConfirmed);
} else {
onDecoderConfirmed();
}

View File

@ -8,6 +8,7 @@ import '../../elements/emby-select/emby-select';
import '../../elements/emby-button/emby-button';
import AppInfo from '../../components/AppInfo';
import Dashboard from '../../scripts/clientUtils';
import alert from '../../components/alert';
/* eslint-disable indent */
@ -53,10 +54,7 @@ import Dashboard from '../../scripts/clientUtils';
});
});
}, function () {
import('../../components/alert').then(({default: alert}) => {
alert(globalize.translate('ErrorDefault'));
});
alert(globalize.translate('ErrorDefault'));
Dashboard.processServerConfigurationUpdateResult();
});
});

View File

@ -8,6 +8,7 @@ import imageHelper from '../../scripts/imagehelper';
import '../../components/cardbuilder/card.css';
import '../../elements/emby-itemrefreshindicator/emby-itemrefreshindicator';
import Dashboard from '../../scripts/clientUtils';
import confirm from '../../components/confirm/confirm';
/* eslint-disable indent */
@ -47,17 +48,15 @@ import Dashboard from '../../scripts/clientUtils';
msg += virtualFolder.Locations.join('<br/>');
}
import('../../components/confirm/confirm').then((confirm) => {
confirm({
text: msg,
title: globalize.translate('HeaderRemoveMediaFolder'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(function () {
const refreshAfterChange = shouldRefreshLibraryAfterChanges(page);
ApiClient.removeVirtualFolder(virtualFolder.Name, refreshAfterChange).then(function () {
reloadLibrary(page);
});
confirm({
text: msg,
title: globalize.translate('HeaderRemoveMediaFolder'),
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(function () {
const refreshAfterChange = shouldRefreshLibraryAfterChanges(page);
ApiClient.removeVirtualFolder(virtualFolder.Name, refreshAfterChange).then(function () {
reloadLibrary(page);
});
});
}

View File

@ -3,6 +3,7 @@ import loading from '../../components/loading/loading';
import libraryMenu from '../../scripts/libraryMenu';
import globalize from '../../scripts/globalize';
import Dashboard from '../../scripts/clientUtils';
import alert from '../../components/alert';
/* eslint-disable indent */
@ -39,11 +40,8 @@ import Dashboard from '../../scripts/clientUtils';
function showConfirmMessage(config) {
const msg = [];
msg.push(globalize.translate('MetadataSettingChangeHelp'));
import('../../components/alert').then(({default: alert}) => {
alert({
text: msg.join('<br/><br/>')
});
alert({
text: msg.join('<br/><br/>')
});
}

View File

@ -3,6 +3,7 @@ import globalize from '../../scripts/globalize';
import '../../elements/emby-checkbox/emby-checkbox';
import '../../elements/emby-select/emby-select';
import Dashboard from '../../scripts/clientUtils';
import alert from '../../components/alert';
/* eslint-disable indent */
@ -90,9 +91,7 @@ import Dashboard from '../../scripts/clientUtils';
function showAlertText(options) {
return new Promise(function (resolve, reject) {
import('../../components/alert').then(({default: alert}) => {
alert(options).then(resolve, reject);
});
alert(options).then(resolve, reject);
});
}

View File

@ -3,6 +3,8 @@ import loading from '../../../../components/loading/loading';
import globalize from '../../../../scripts/globalize';
import '../../../../elements/emby-button/emby-button';
import Dashboard from '../../../../scripts/clientUtils';
import alert from '../../../../components/alert';
import confirm from '../../../../components/confirm/confirm';
function populateHistory(packageInfo, page) {
let html = '';
@ -69,9 +71,7 @@ function renderPackage(pkg, installedPlugins, page) {
}
function alertText(options) {
import('../../../../components/alert').then(({default: alert}) => {
alert(options);
});
alert(options);
}
function performInstallation(page, name, guid, version) {
@ -95,12 +95,10 @@ function performInstallation(page, name, guid, version) {
msg += '<br/>';
msg += globalize.translate('PleaseConfirmPluginInstallation');
import('../../../../components/confirm/confirm').then(({default: confirm}) => {
confirm(msg, globalize.translate('HeaderConfirmPluginInstallation')).then(function () {
alertCallback();
}).catch(() => {
console.debug('plugin not installed');
});
confirm(msg, globalize.translate('HeaderConfirmPluginInstallation')).then(function () {
alertCallback();
}).catch(() => {
console.debug('plugin not installed');
});
} else {
alertCallback();

View File

@ -5,21 +5,20 @@ import globalize from '../../../../scripts/globalize';
import '../../../../components/cardbuilder/card.css';
import '../../../../elements/emby-button/emby-button';
import Dashboard from '../../../../scripts/clientUtils';
import confirm from '../../../../components/confirm/confirm';
function deletePlugin(page, uniqueid, name) {
const msg = globalize.translate('UninstallPluginConfirmation', name);
import('../../../../components/confirm/confirm').then((confirm) => {
confirm.default({
title: globalize.translate('HeaderUninstallPlugin'),
text: msg,
primary: 'delete',
confirmText: globalize.translate('HeaderUninstallPlugin')
}).then(function () {
loading.show();
ApiClient.uninstallPlugin(uniqueid).then(function () {
reloadList(page);
});
confirm.default({
title: globalize.translate('HeaderUninstallPlugin'),
text: msg,
primary: 'delete',
confirmText: globalize.translate('HeaderUninstallPlugin')
}).then(function () {
loading.show();
ApiClient.uninstallPlugin(uniqueid).then(function () {
reloadList(page);
});
});
}

View File

@ -6,6 +6,7 @@ import globalize from '../../../scripts/globalize';
import '../../../elements/emby-input/emby-input';
import '../../../elements/emby-button/emby-button';
import '../../../elements/emby-select/emby-select';
import confirm from '../../../components/confirm/confirm';
/* eslint-disable indent */
@ -135,10 +136,8 @@ import '../../../elements/emby-select/emby-select';
$('#popupAddTrigger', view).removeClass('hide');
},
confirmDeleteTrigger: function (view, index) {
import('../../../components/confirm/confirm').then(({default: confirm}) => {
confirm(globalize.translate('MessageDeleteTaskTrigger'), globalize.translate('HeaderDeleteTaskTrigger')).then(function () {
ScheduledTaskPage.deleteTrigger(view, index);
});
confirm(globalize.translate('MessageDeleteTaskTrigger'), globalize.translate('HeaderDeleteTaskTrigger')).then(function () {
ScheduledTaskPage.deleteTrigger(view, index);
});
},
deleteTrigger: function (view, index) {

View File

@ -3,6 +3,7 @@ import loading from '../../../components/loading/loading';
import libraryMenu from '../../../scripts/libraryMenu';
import globalize from '../../../scripts/globalize';
import Dashboard from '../../../scripts/clientUtils';
import toast from '../../../components/toast/toast';
/* eslint-disable indent */
@ -110,10 +111,7 @@ import Dashboard from '../../../scripts/clientUtils';
function onSaveComplete(page, user) {
Dashboard.navigate('userprofiles.html');
loading.hide();
import('../../../components/toast/toast').then((toast) => {
toast(globalize.translate('SettingsSaved'));
});
toast(globalize.translate('SettingsSaved'));
}
function saveUser(user, page) {

View File

@ -3,6 +3,7 @@ import loading from '../../../components/loading/loading';
import libraryMenu from '../../../scripts/libraryMenu';
import globalize from '../../../scripts/globalize';
import Dashboard from '../../../scripts/clientUtils';
import toast from '../../../components/toast/toast';
/* eslint-disable indent */
@ -92,10 +93,7 @@ import Dashboard from '../../../scripts/clientUtils';
function onSaveComplete(page) {
loading.hide();
import('../../../components/toast/toast').then((toast) => {
toast(globalize.translate('SettingsSaved'));
});
toast(globalize.translate('SettingsSaved'));
}
function saveUser(user, page) {

View File

@ -3,6 +3,7 @@ import loading from '../../../components/loading/loading';
import globalize from '../../../scripts/globalize';
import '../../../elements/emby-checkbox/emby-checkbox';
import Dashboard from '../../../scripts/clientUtils';
import toast from '../../../components/toast/toast';
/* eslint-disable indent */
@ -89,10 +90,7 @@ import Dashboard from '../../../scripts/clientUtils';
Dashboard.navigate('useredit.html?userId=' + user.Id);
});
}, function (response) {
import('../../../components/toast/toast').then((toast) => {
toast(globalize.translate('ErrorDefault'));
});
toast(globalize.translate('ErrorDefault'));
loading.hide();
});
}

View File

@ -5,6 +5,7 @@ import libraryMenu from '../../../scripts/libraryMenu';
import globalize from '../../../scripts/globalize';
import '../../../components/listview/listview.css';
import '../../../elements/emby-button/paper-icon-button-light';
import toast from '../../../components/toast/toast';
/* eslint-disable indent */
@ -162,10 +163,7 @@ import '../../../elements/emby-button/paper-icon-button-light';
function onSaveComplete(page) {
loading.hide();
import('../../../components/toast/toast').then((toast) => {
toast(globalize.translate('SettingsSaved'));
});
toast(globalize.translate('SettingsSaved'));
}
function saveUser(user, page) {

View File

@ -3,6 +3,8 @@ import libraryMenu from '../../../scripts/libraryMenu';
import globalize from '../../../scripts/globalize';
import '../../../elements/emby-button/emby-button';
import Dashboard from '../../../scripts/clientUtils';
import toast from '../../../components/toast/toast';
import confirm from '../../../components/confirm/confirm';
/* eslint-disable indent */
@ -82,10 +84,7 @@ import Dashboard from '../../../scripts/clientUtils';
user.Configuration.EnableLocalPassword = view.querySelector('.chkEnableLocalEasyPassword').checked;
ApiClient.updateUserConfiguration(user.Id, user.Configuration).then(function () {
loading.hide();
import('../../../components/toast/toast').then((toast) => {
toast(globalize.translate('SettingsSaved'));
});
toast(globalize.translate('SettingsSaved'));
loadUser(view, params);
});
@ -105,10 +104,7 @@ import Dashboard from '../../../scripts/clientUtils';
ApiClient.updateUserPassword(userId, currentPassword, newPassword).then(function () {
loading.hide();
import('../../../components/toast/toast').then((toast) => {
toast(globalize.translate('PasswordSaved'));
});
toast(globalize.translate('PasswordSaved'));
loadUser(view, params);
}, function () {
@ -124,9 +120,7 @@ import Dashboard from '../../../scripts/clientUtils';
const form = this;
if (form.querySelector('#txtNewPassword').value != form.querySelector('#txtNewPasswordConfirm').value) {
import('../../../components/toast/toast').then((toast) => {
toast(globalize.translate('PasswordMatchError'));
});
toast(globalize.translate('PasswordMatchError'));
} else {
loading.show();
savePassword();
@ -145,18 +139,16 @@ import Dashboard from '../../../scripts/clientUtils';
function resetPassword() {
const msg = globalize.translate('PasswordResetConfirmation');
import('../../../components/confirm/confirm').then(({default: confirm}) => {
confirm(msg, globalize.translate('ResetPassword')).then(function () {
const userId = params.userId;
loading.show();
ApiClient.resetUserPassword(userId).then(function () {
loading.hide();
Dashboard.alert({
message: globalize.translate('PasswordResetComplete'),
title: globalize.translate('ResetPassword')
});
loadUser(view, params);
confirm(msg, globalize.translate('ResetPassword')).then(function () {
const userId = params.userId;
loading.show();
ApiClient.resetUserPassword(userId).then(function () {
loading.hide();
Dashboard.alert({
message: globalize.translate('PasswordResetComplete'),
title: globalize.translate('ResetPassword')
});
loadUser(view, params);
});
});
}
@ -164,18 +156,16 @@ import Dashboard from '../../../scripts/clientUtils';
function resetEasyPassword() {
const msg = globalize.translate('PinCodeResetConfirmation');
import('../../../components/confirm/confirm').then(({default: confirm}) => {
confirm(msg, globalize.translate('HeaderPinCodeReset')).then(function () {
const userId = params.userId;
loading.show();
ApiClient.resetEasyPassword(userId).then(function () {
loading.hide();
Dashboard.alert({
message: globalize.translate('PinCodeResetComplete'),
title: globalize.translate('HeaderPinCodeReset')
});
loadUser(view, params);
confirm(msg, globalize.translate('HeaderPinCodeReset')).then(function () {
const userId = params.userId;
loading.show();
ApiClient.resetEasyPassword(userId).then(function () {
loading.hide();
Dashboard.alert({
message: globalize.translate('PinCodeResetComplete'),
title: globalize.translate('HeaderPinCodeReset')
});
loadUser(view, params);
});
});
}

View File

@ -9,23 +9,22 @@ import '../../../elements/emby-button/emby-button';
import '../../../components/indicators/indicators.css';
import '../../../assets/css/flexstyles.css';
import Dashboard from '../../../scripts/clientUtils';
import confirm from '../../../components/confirm/confirm';
/* eslint-disable indent */
function deleteUser(page, id) {
const msg = globalize.translate('DeleteUserConfirmation');
import('../../../components/confirm/confirm').then(({default: confirm}) => {
confirm({
title: globalize.translate('DeleteUser'),
text: msg,
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(function () {
loading.show();
ApiClient.deleteUser(id).then(function () {
loadData(page);
});
confirm({
title: globalize.translate('DeleteUser'),
text: msg,
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(function () {
loading.show();
ApiClient.deleteUser(id).then(function () {
loadData(page);
});
});
}

View File

@ -29,6 +29,7 @@ import '../../elements/emby-select/emby-select';
import itemShortcuts from '../../components/shortcuts';
import Dashboard from '../../scripts/clientUtils';
import ServerConnections from '../../components/ServerConnections';
import confirm from '../../components/confirm/confirm';
function getPromise(apiClient, params) {
const id = params.id;
@ -1869,16 +1870,14 @@ export default function (view, params) {
}
function splitVersions(instance, page, apiClient, params) {
import('../../components/confirm/confirm').then(({ default: confirm }) => {
confirm('Are you sure you wish to split the media sources into separate items?', 'Split Media Apart').then(function () {
loading.show();
apiClient.ajax({
type: 'DELETE',
url: apiClient.getUrl('Videos/' + params.id + '/AlternateSources')
}).then(function () {
loading.hide();
reload(instance, page, params);
});
confirm('Are you sure you wish to split the media sources into separate items?', 'Split Media Apart').then(function () {
loading.show();
apiClient.ajax({
type: 'DELETE',
url: apiClient.getUrl('Videos/' + params.id + '/AlternateSources')
}).then(function () {
loading.hide();
reload(instance, page, params);
});
});
}

View File

@ -3,6 +3,7 @@ import loading from '../components/loading/loading';
import globalize from '../scripts/globalize';
import '../elements/emby-button/emby-button';
import Dashboard from '../scripts/clientUtils';
import alert from '../components/alert';
function loadPage(page, config) {
$('.liveTvSettingsForm', page).show();
@ -51,9 +52,7 @@ function showSaveMessage(recordingPathChanged) {
}
if (msg) {
import('../components/alert').then(({default: alert}) => {
alert(msg);
});
alert(msg);
}
}

View File

@ -12,6 +12,7 @@ import '../components/cardbuilder/card.css';
import 'material-design-icons-iconfont';
import '../elements/emby-button/emby-button';
import Dashboard from '../scripts/clientUtils';
import confirm from '../components/confirm/confirm';
const enableFocusTransform = !browser.slow && !browser.edge;
@ -57,17 +58,15 @@ function renderDevices(page, devices) {
function deleteDevice(page, id) {
const message = globalize.translate('MessageConfirmDeleteTunerDevice');
import('../components/confirm/confirm').then(({default: confirm}) => {
confirm(message, globalize.translate('HeaderDeleteDevice')).then(function () {
loading.show();
ApiClient.ajax({
type: 'DELETE',
url: ApiClient.getUrl('LiveTv/TunerHosts', {
Id: id
})
}).then(function () {
reload(page);
});
confirm(message, globalize.translate('HeaderDeleteDevice')).then(function () {
loading.show();
ApiClient.ajax({
type: 'DELETE',
url: ApiClient.getUrl('LiveTv/TunerHosts', {
Id: id
})
}).then(function () {
reload(page);
});
});
}
@ -175,19 +174,17 @@ function mapChannels(page, providerId) {
function deleteProvider(page, id) {
const message = globalize.translate('MessageConfirmDeleteGuideProvider');
import('../components/confirm/confirm').then(({default: confirm}) => {
confirm(message, globalize.translate('HeaderDeleteProvider')).then(function () {
loading.show();
ApiClient.ajax({
type: 'DELETE',
url: ApiClient.getUrl('LiveTv/ListingProviders', {
Id: id
})
}).then(function () {
reload(page);
}, function () {
reload(page);
});
confirm(message, globalize.translate('HeaderDeleteProvider')).then(function () {
loading.show();
ApiClient.ajax({
type: 'DELETE',
url: ApiClient.getUrl('LiveTv/ListingProviders', {
Id: id
})
}).then(function () {
reload(page);
}, function () {
reload(page);
});
});
}

View File

@ -10,6 +10,7 @@ import '../../../components/cardbuilder/card.css';
import '../../../elements/emby-checkbox/emby-checkbox';
import Dashboard from '../../../scripts/clientUtils';
import ServerConnections from '../../../components/ServerConnections';
import toast from '../../../components/toast/toast';
/* eslint-disable indent */
@ -29,10 +30,8 @@ import ServerConnections from '../../../components/ServerConnections';
const UnauthorizedOrForbidden = [401, 403];
if (UnauthorizedOrForbidden.includes(response.status)) {
import('../../../components/toast/toast').then((toast) => {
const messageKey = response.status === 401 ? 'MessageInvalidUser' : 'MessageUnauthorizedUser';
toast(globalize.translate(messageKey));
});
const messageKey = response.status === 401 ? 'MessageInvalidUser' : 'MessageUnauthorizedUser';
toast(globalize.translate(messageKey));
} else {
Dashboard.alert({
message: globalize.translate('MessageUnableToConnectToServer'),

View File

@ -16,6 +16,7 @@ import '../../../components/cardbuilder/card.css';
import '../../../elements/emby-button/emby-button';
import Dashboard from '../../../scripts/clientUtils';
import ServerConnections from '../../../components/ServerConnections';
import alert from '../../../components/alert';
/* eslint-disable indent */
@ -102,9 +103,7 @@ import ServerConnections from '../../../components/ServerConnections';
}
function alertTextWithOptions(options) {
import('../../../components/alert').then(({default: alert}) => {
alert(options);
});
alert(options);
}
function showServerConnectionFailure() {

View File

@ -5,6 +5,8 @@ import { appHost } from '../../../components/apphost';
import globalize from '../../../scripts/globalize';
import '../../../elements/emby-button/emby-button';
import Dashboard from '../../../scripts/clientUtils';
import toast from '../../../components/toast/toast';
import confirm from '../../../components/confirm/confirm';
function reloadUser(page) {
const userId = getParameterByName('userId');
@ -41,26 +43,20 @@ function onFileReaderError(evt) {
loading.hide();
switch (evt.target.error.code) {
case evt.target.error.NOT_FOUND_ERR:
import('../../../components/toast/toast').then((toast) => {
toast(globalize.translate('FileNotFound'));
});
toast(globalize.translate('FileNotFound'));
break;
case evt.target.error.ABORT_ERR:
onFileReaderAbort();
break;
case evt.target.error.NOT_READABLE_ERR:
default:
import('../../../components/toast/toast').then((toast) => {
toast(globalize.translate('FileReadError'));
});
toast(globalize.translate('FileReadError'));
}
}
function onFileReaderAbort(evt) {
loading.hide();
import('../../../components/toast/toast').then((toast) => {
toast(globalize.translate('FileReadCancelled'));
});
toast(globalize.translate('FileReadCancelled'));
}
function setFiles(page, files) {
@ -90,14 +86,12 @@ export default function (view, params) {
reloadUser(view);
new UserPasswordPage(view, params);
view.querySelector('#btnDeleteImage').addEventListener('click', function () {
import('../../../components/confirm/confirm').then(({default: confirm}) => {
confirm(globalize.translate('DeleteImageConfirmation'), globalize.translate('DeleteImage')).then(function () {
loading.show();
const userId = getParameterByName('userId');
ApiClient.deleteUserImage(userId, 'primary').then(function () {
loading.hide();
reloadUser(view);
});
confirm(globalize.translate('DeleteImageConfirmation'), globalize.translate('DeleteImage')).then(function () {
loading.show();
const userId = getParameterByName('userId');
ApiClient.deleteUserImage(userId, 'primary').then(function () {
loading.hide();
reloadUser(view);
});
});
});

View File

@ -4,6 +4,7 @@ import '../../../assets/css/dashboard.css';
import '../../../elements/emby-input/emby-input';
import '../../../elements/emby-button/emby-button';
import Dashboard from '../../../scripts/clientUtils';
import toast from '../../../components/toast/toast';
function getApiClient() {
return ApiClient;
@ -37,9 +38,7 @@ function onSubmit(e) {
const form = this;
if (form.querySelector('#txtManualPassword').value != form.querySelector('#txtPasswordConfirm').value) {
import('../../../components/toast/toast').then((toast) => {
toast(globalize.translate('PasswordMatchError'));
});
toast(globalize.translate('PasswordMatchError'));
} else {
submit(form);
}

View File

@ -5,6 +5,7 @@ import globalize from '../../scripts/globalize';
import { Events } from 'jellyfin-apiclient';
import castSenderApiLoader from '../../components/castSenderApi';
import ServerConnections from '../../components/ServerConnections';
import alert from '../../components/alert';
// Based on https://github.com/googlecast/CastVideos-chrome/blob/master/CastVideos.js
@ -440,11 +441,9 @@ class CastPlayer {
}
function alertText(text, title) {
import('../../components/alert').then(({default: alert}) => {
alert({
text: text,
title: title
});
alert({
text,
title
});
}

View File

@ -1,6 +1,7 @@
import globalize from '../../scripts/globalize';
import * as userSettings from '../../scripts/settings/userSettings';
import { appHost } from '../../components/apphost';
import alert from '../../components/alert';
// TODO: Replace with date-fns
// https://stackoverflow.com/questions/6117814/get-week-of-year-in-javascript-like-in-php
@ -26,13 +27,8 @@ function showMessage(text, userSettingsKey, appHostFeature) {
return Promise.resolve();
}
return new Promise(function (resolve, reject) {
userSettings.set(userSettingsKey, '1', false);
import('../../components/alert').then(({default: alert}) => {
return alert(text).then(resolve, resolve);
});
});
userSettings.set(userSettingsKey, '1', false);
return alert(text);
}
function showBlurayMessage() {

View File

@ -1,10 +1,9 @@
import globalize from '../../scripts/globalize';
import ServerConnections from '../../components/ServerConnections';
import alert from '../../components/alert';
function showErrorMessage() {
return import('../../components/alert').then(({default: alert}) => {
return alert(globalize.translate('MessagePlayAccessRestricted'));
});
return alert(globalize.translate('MessagePlayAccessRestricted'));
}
class PlayAccessValidation {

View File

@ -1,5 +1,10 @@
import AppInfo from '../components/AppInfo';
import ServerConnections from '../components/ServerConnections';
import toast from '../components/toast/toast';
import loading from '../components/loading/loading';
import { appRouter } from '../components/appRouter';
import baseAlert from '../components/alert';
import baseConfirm from '../components/confirm/confirm';
export function getCurrentUser() {
return window.ApiClient.getCurrentUser(false);
@ -78,39 +83,21 @@ export function navigate(url, preserveQueryString) {
url += queryString;
}
return new Promise(function (resolve, reject) {
import('../components/appRouter').then(({ appRouter }) => {
return appRouter.show(url).then(resolve, reject);
});
});
return appRouter.show(url);
}
export function processPluginConfigurationUpdateResult() {
Promise.all([
import('../components/loading/loading'),
import('../components/toast/toast')
])
.then(([loading, toast]) => {
loading.hide();
toast(Globalize.translate('MessageSettingsSaved'));
});
loading.hide();
toast(Globalize.translate('MessageSettingsSaved'));
}
export function processServerConfigurationUpdateResult(result) {
Promise.all([
import('../components/loading/loading'),
import('../components/toast/toast')
])
.then(([loading, toast]) => {
loading.hide();
toast.default(Globalize.translate('MessageSettingsSaved'));
});
loading.hide();
toast.default(Globalize.translate('MessageSettingsSaved'));
}
export function processErrorResponse(response) {
import('../components/loading/loading').then((loading) => {
loading.hide();
});
loading.hide();
let status = '' + response.status;
@ -126,19 +113,15 @@ export function processErrorResponse(response) {
export function alert(options) {
if (typeof options == 'string') {
return void import('../components/toast/toast').then((toast) => {
toast.default({
text: options
});
toast.default({
text: options
});
}
import('../components/alert').then((alert) => {
alert.default({
} else {
baseAlert.default({
title: options.title || Globalize.translate('HeaderAlert'),
text: options.message
}).then(options.callback || function () {});
});
}
}
export function capabilities(appHost) {
@ -161,24 +144,18 @@ export function selectServer() {
}
export function hideLoadingMsg() {
import('../components/loading/loading').then(({default: loading}) => {
loading.hide();
});
loading.hide();
}
export function showLoadingMsg() {
import('../components/loading/loading').then(({default: loading}) => {
loading.show();
});
loading.show();
}
export function confirm(message, title, callback) {
import('../components/confirm/confirm').then((confirm) => {
confirm(message, title).then(function() {
callback(!0);
}).catch(function() {
callback(!1);
});
baseConfirm(message, title).then(function() {
callback(!0);
}).catch(function() {
callback(!1);
});
}

View File

@ -3,13 +3,10 @@ import confirm from '../components/confirm/confirm';
import { appRouter } from '../components/appRouter';
import globalize from './globalize';
import ServerConnections from '../components/ServerConnections';
import alert from '../components/alert';
function alertText(options) {
return new Promise(function (resolve, reject) {
import('../components/alert').then((alert) => {
alert(options).then(resolve, resolve);
});
});
return alert(options);
}
export function deleteItem(options) {

View File

@ -5,6 +5,8 @@ import inputManager from '../scripts/inputManager';
import focusManager from '../components/focusManager';
import { appRouter } from '../components/appRouter';
import ServerConnections from '../components/ServerConnections';
import toast from '../components/toast/toast';
import alert from '../components/alert';
const serverNotifications = {};
@ -15,13 +17,9 @@ function notifyApp() {
function displayMessage(cmd) {
const args = cmd.Arguments;
if (args.TimeoutMs) {
import('../components/toast/toast').then((toast) => {
toast({ title: args.Header, text: args.Text });
});
toast({ title: args.Header, text: args.Text });
} else {
import('../components/alert').then(({default: alert}) => {
alert({ title: args.Header, text: args.Text });
});
alert({ title: args.Header, text: args.Text });
}
}