diff --git a/src/apps/wizard/controllers/finish/index.js b/src/apps/wizard/controllers/finish/index.js index 51a3f8ad3..418792978 100644 --- a/src/apps/wizard/controllers/finish/index.js +++ b/src/apps/wizard/controllers/finish/index.js @@ -1,9 +1,11 @@ import loading from 'components/loading/loading'; +import ServerConnections from 'components/ServerConnections'; function onFinish() { loading.show(); - ApiClient.ajax({ - url: ApiClient.getUrl('Startup/Complete'), + const apiClient = ServerConnections.currentApiClient(); + apiClient.ajax({ + url: apiClient.getUrl('Startup/Complete'), type: 'POST' }).then(function () { loading.hide(); diff --git a/src/apps/wizard/controllers/library.js b/src/apps/wizard/controllers/library.js index 19ff51118..ccdc42b13 100644 --- a/src/apps/wizard/controllers/library.js +++ b/src/apps/wizard/controllers/library.js @@ -1,15 +1,17 @@ import escapeHtml from 'escape-html'; -import taskButton from 'scripts/taskbutton'; +import { getDefaultBackgroundClass } from 'components/cardbuilder/cardBuilderUtils'; +import confirm from 'components/confirm/confirm'; import loading from 'components/loading/loading'; +import ServerConnections from 'components/ServerConnections'; import globalize from 'lib/globalize'; import dom from 'scripts/dom'; +import taskButton from 'scripts/taskbutton'; +import Dashboard, { pageClassOn, pageIdOn } from 'utils/dashboard'; import imageHelper from 'utils/image'; + import 'components/cardbuilder/card.scss'; import 'elements/emby-itemrefreshindicator/emby-itemrefreshindicator'; -import Dashboard, { pageClassOn, pageIdOn } from 'utils/dashboard'; -import confirm from 'components/confirm/confirm'; -import { getDefaultBackgroundClass } from 'components/cardbuilder/cardBuilderUtils'; function addVirtualFolder(page) { import('components/mediaLibraryCreator/mediaLibraryCreator').then(({ default: MediaLibraryCreator }) => { @@ -54,9 +56,11 @@ function deleteVirtualFolder(page, virtualFolder) { primary: 'delete' }).then(function () { const refreshAfterChange = shouldRefreshLibraryAfterChanges(page); - ApiClient.removeVirtualFolder(virtualFolder.Name, refreshAfterChange).then(function () { - reloadLibrary(page); - }); + ServerConnections.currentApiClient() + .removeVirtualFolder(virtualFolder.Name, refreshAfterChange) + .then(function () { + reloadLibrary(page); + }); }); } @@ -64,7 +68,7 @@ function refreshVirtualFolder(page, virtualFolder) { import('components/refreshdialog/refreshdialog').then(({ default: RefreshDialog }) => { new RefreshDialog({ itemIds: [virtualFolder.ItemId], - serverId: ApiClient.serverId(), + serverId: ServerConnections.currentApiClient().serverId(), mode: 'scan' }).show(); }); @@ -79,9 +83,11 @@ function renameVirtualFolder(page, virtualFolder) { }).then(function (newName) { if (newName && newName != virtualFolder.Name) { const refreshAfterChange = shouldRefreshLibraryAfterChanges(page); - ApiClient.renameVirtualFolder(virtualFolder.Name, newName, refreshAfterChange).then(function () { - reloadLibrary(page); - }); + ServerConnections.currentApiClient() + .renameVirtualFolder(virtualFolder.Name, newName, refreshAfterChange) + .then(function () { + reloadLibrary(page); + }); } }); }); @@ -150,9 +156,11 @@ function showCardMenu(page, elem, virtualFolders) { function reloadLibrary(page) { loading.show(); - ApiClient.getVirtualFolders().then(function (result) { - reloadVirtualFolders(page, result); - }); + ServerConnections.currentApiClient() + .getVirtualFolders() + .then(function (result) { + reloadVirtualFolders(page, result); + }); } function shouldRefreshLibraryAfterChanges(page) { @@ -210,7 +218,7 @@ function editImages(page, virtualFolder) { import('components/imageeditor/imageeditor').then((imageEditor) => { imageEditor.show({ itemId: virtualFolder.ItemId, - serverId: ApiClient.serverId() + serverId: ServerConnections.currentApiClient().serverId() }).then(function () { reloadLibrary(page); }); @@ -267,10 +275,11 @@ function getVirtualFolderHtml(page, virtualFolder, index) { let imgUrl = ''; if (virtualFolder.PrimaryImageItemId) { - imgUrl = ApiClient.getScaledImageUrl(virtualFolder.PrimaryImageItemId, { - maxWidth: Math.round(dom.getScreenWidth() * 0.40), - type: 'Primary' - }); + imgUrl = ServerConnections.currentApiClient() + .getScaledImageUrl(virtualFolder.PrimaryImageItemId, { + maxWidth: Math.round(dom.getScreenWidth() * 0.40), + type: 'Primary' + }); } let hasCardImageContainer; diff --git a/src/apps/wizard/controllers/remote/index.js b/src/apps/wizard/controllers/remote/index.js index 2948a0824..f836f1fa9 100644 --- a/src/apps/wizard/controllers/remote/index.js +++ b/src/apps/wizard/controllers/remote/index.js @@ -1,12 +1,14 @@ import loading from 'components/loading/loading'; +import ServerConnections from 'components/ServerConnections'; +import Dashboard from 'utils/dashboard'; + import 'elements/emby-checkbox/emby-checkbox'; import 'elements/emby-button/emby-button'; import 'elements/emby-select/emby-select'; -import Dashboard from 'utils/dashboard'; function save(page) { loading.show(); - const apiClient = ApiClient; + const apiClient = ServerConnections.currentApiClient(); const config = { EnableRemoteAccess: page.querySelector('#chkRemoteAccess').checked }; diff --git a/src/apps/wizard/controllers/settings/index.js b/src/apps/wizard/controllers/settings/index.js index 1bf069ec0..f118d83ce 100644 --- a/src/apps/wizard/controllers/settings/index.js +++ b/src/apps/wizard/controllers/settings/index.js @@ -1,12 +1,14 @@ import loading from 'components/loading/loading'; -import 'elements/emby-checkbox/emby-checkbox'; -import 'elements/emby-button/emby-button'; -import 'elements/emby-select/emby-select'; +import ServerConnections from 'components/ServerConnections'; import Dashboard from 'utils/dashboard'; +import 'elements/emby-button/emby-button'; +import 'elements/emby-checkbox/emby-checkbox'; +import 'elements/emby-select/emby-select'; + function save(page) { loading.show(); - const apiClient = ApiClient; + const apiClient = ServerConnections.currentApiClient(); apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) { config.PreferredMetadataLanguage = page.querySelector('#selectLanguage').value; config.MetadataCountryCode = page.querySelector('#selectCountry').value; @@ -56,7 +58,7 @@ function reloadData(page, config, cultures, countries) { function reload(page) { loading.show(); - const apiClient = ApiClient; + const apiClient = ServerConnections.currentApiClient(); const promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration')); const promise2 = apiClient.getCultures(); const promise3 = apiClient.getCountries(); diff --git a/src/apps/wizard/controllers/start/index.js b/src/apps/wizard/controllers/start/index.js index 1ba18df01..abbe00327 100644 --- a/src/apps/wizard/controllers/start/index.js +++ b/src/apps/wizard/controllers/start/index.js @@ -1,9 +1,11 @@ import loading from 'components/loading/loading'; -import 'elements/emby-button/emby-button'; -import 'elements/emby-select/emby-select'; +import ServerConnections from 'components/ServerConnections'; import Dashboard from 'utils/dashboard'; import dom from 'scripts/dom'; +import 'elements/emby-button/emby-button'; +import 'elements/emby-select/emby-select'; + function loadPage(page, config, languageOptions) { const elem = page.querySelector('#selectLocalizationLanguage'); elem.innerHTML = languageOptions.map(function (l) { @@ -15,7 +17,7 @@ function loadPage(page, config, languageOptions) { function save(page) { loading.show(); - const apiClient = ApiClient; + const apiClient = ServerConnections.currentApiClient(); apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) { config.UICulture = page.querySelector('#selectLocalizationLanguage').value; apiClient.ajax({ @@ -40,7 +42,7 @@ export default function (view) { document.querySelector('.skinHeader').classList.add('noHomeButtonHeader'); loading.show(); const page = this; - const apiClient = ApiClient; + const apiClient = ServerConnections.currentApiClient(); const promise1 = apiClient.getJSON(apiClient.getUrl('Startup/Configuration')); const promise2 = apiClient.getJSON(apiClient.getUrl('Localization/Options')); Promise.all([promise1, promise2]).then(function (responses) { diff --git a/src/apps/wizard/controllers/user/index.js b/src/apps/wizard/controllers/user/index.js index 9e2fb68ba..1a13a790b 100644 --- a/src/apps/wizard/controllers/user/index.js +++ b/src/apps/wizard/controllers/user/index.js @@ -1,14 +1,12 @@ import loading from 'components/loading/loading'; +import ServerConnections from 'components/ServerConnections'; +import toast from 'components/toast/toast'; import globalize from 'lib/globalize'; +import Dashboard from 'utils/dashboard'; + import 'styles/dashboard.scss'; import 'elements/emby-input/emby-input'; import 'elements/emby-button/emby-button'; -import Dashboard from 'utils/dashboard'; -import toast from 'components/toast/toast'; - -function getApiClient() { - return ApiClient; -} function nextWizardPage() { Dashboard.navigate('wizard/library') @@ -32,7 +30,7 @@ async function onUpdateUserError(result) { function submit(form) { loading.show(); - const apiClient = getApiClient(); + const apiClient = ServerConnections.currentApiClient(); apiClient .ajax({ type: 'POST', @@ -63,7 +61,7 @@ function onSubmit(e) { function onViewShow() { loading.show(); const page = this; - const apiClient = getApiClient(); + const apiClient = ServerConnections.currentApiClient(); apiClient.getJSON(apiClient.getUrl('Startup/User')).then(function (user) { page.querySelector('#txtUsername').value = user.Name || ''; page.querySelector('#txtManualPassword').value = user.Password || '';