1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge remote-tracking branch 'origin/master' into standalone

Conflicts:
	package.json
	src/components/appRouter.js
	src/components/require/requiretext.js
	src/config.json
	src/scripts/clientUtils.js
	src/scripts/settings/webSettings.js
	src/scripts/site.js
This commit is contained in:
Dmitry Lyzo 2020-11-21 21:03:18 +03:00
commit 5592cb7d4e
310 changed files with 7707 additions and 6701 deletions

View file

@ -1,14 +1,18 @@
import appHost from 'apphost';
import appSettings from 'appSettings';
import backdrop from 'backdrop';
import browser from 'browser';
import events from 'events';
import globalize from 'globalize';
import itemHelper from 'itemHelper';
import loading from 'loading';
import { appHost } from './apphost';
import appSettings from '../scripts/settings/appSettings';
import backdrop from './backdrop/backdrop';
import browser from '../scripts/browser';
import { Events } from 'jellyfin-apiclient';
import globalize from '../scripts/globalize';
import itemHelper from './itemHelper';
import loading from './loading/loading';
import page from 'page';
import viewManager from 'viewManager';
import * as webSettings from 'webSettings';
import viewManager from './viewManager/viewManager';
import AppInfo from './AppInfo';
import Dashboard from '../scripts/clientUtils';
import ServerConnections from './ServerConnections';
import alert from './alert';
import * as webSettings from '../scripts/settings/webSettings';
class AppRouter {
allRoutes = [];
@ -91,7 +95,7 @@ class AppRouter {
beginConnectionWizard() {
backdrop.clearBackdrop();
loading.show();
window.connectionManager.connect({
ServerConnections.connect({
enableAutoLogin: appSettings.enableAutoLogin()
}).then((result) => {
this.handleConnectionResult(result);
@ -147,10 +151,10 @@ class AppRouter {
loading.show();
this.initApiClients();
events.on(appHost, 'beforeexit', this.onBeforeExit);
events.on(appHost, 'resume', this.onAppResume);
Events.on(appHost, 'beforeexit', this.onBeforeExit);
Events.on(appHost, 'resume', this.onAppResume);
window.connectionManager.connect({
ServerConnections.connect({
enableAutoLogin: appSettings.enableAutoLogin()
}).then((result) => {
this.firstConnectionResult = result;
@ -206,7 +210,7 @@ class AppRouter {
showItem(item, serverId, options) {
// TODO: Refactor this so it only gets items, not strings.
if (typeof (item) === 'string') {
const apiClient = serverId ? window.connectionManager.getApiClient(serverId) : window.connectionManager.currentApiClient();
const apiClient = serverId ? ServerConnections.getApiClient(serverId) : ServerConnections.currentApiClient();
apiClient.getItem(apiClient.getCurrentUserId(), item).then((itemObject) => {
this.showItem(itemObject, options);
});
@ -265,7 +269,7 @@ class AppRouter {
switch (result.State) {
case 'SignedIn':
loading.hide();
Emby.Page.goHome();
this.goHome();
break;
case 'ServerSignIn':
result.ApiClient.getPublicUsers().then((users) => {
@ -280,13 +284,11 @@ class AppRouter {
this.showSelectServer();
break;
case 'ServerUpdateNeeded':
import('alert').then(({default: 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:
@ -302,22 +304,20 @@ class AppRouter {
url = route.contentPath || route.path;
}
if (url.includes('configurationpage')) {
url = ApiClient.getUrl('/web' + url);
} else if (url.indexOf('://') === -1) {
// Put a slash at the beginning but make sure to avoid a double slash
if (url.indexOf('/') !== 0) {
url = '/' + url;
}
url = this.baseUrl() + url;
}
if (ctx.querystring && route.enableContentQueryString) {
url += '?' + ctx.querystring;
}
import('text!' + url).then(({default: html}) => {
let promise;
if (route.serverRequest) {
const apiClient = ServerConnections.currentApiClient();
url = apiClient.getUrl(`/web${url}`);
promise = apiClient.get(url);
} else {
promise = import(/* webpackChunkName: "[request]" */ `../controllers/${url}`);
}
promise.then((html) => {
this.loadContent(ctx, route, html, request);
});
}
@ -334,7 +334,7 @@ class AppRouter {
};
if (route.controller) {
import('controllers/' + route.controller).then(onInitComplete);
import('../controllers/' + route.controller).then(onInitComplete);
} else {
onInitComplete();
}
@ -401,9 +401,7 @@ class AppRouter {
this.forcedLogoutMsg = null;
if (msg) {
import('alert').then((alert) => {
alert(msg);
});
alert(msg);
}
}
@ -478,8 +476,8 @@ class AppRouter {
newApiClient.getMaxBandwidth = this.getMaxBandwidth;
}
events.off(newApiClient, 'requestfail', this.onRequestFail);
events.on(newApiClient, 'requestfail', this.onRequestFail);
Events.off(newApiClient, 'requestfail', this.onRequestFail);
Events.on(newApiClient, 'requestfail', this.onRequestFail);
}
initApiClient(apiClient, instance) {
@ -487,15 +485,15 @@ class AppRouter {
}
initApiClients() {
window.connectionManager.getApiClients().forEach((apiClient) => {
ServerConnections.getApiClients().forEach((apiClient) => {
this.initApiClient(apiClient, this);
});
events.on(window.connectionManager, 'apiclientcreated', this.onApiClientCreated);
Events.on(ServerConnections, 'apiclientcreated', this.onApiClientCreated);
}
onAppResume() {
const apiClient = window.connectionManager.currentApiClient();
const apiClient = ServerConnections.currentApiClient();
if (apiClient) {
apiClient.ensureWebSocket();
@ -524,7 +522,7 @@ class AppRouter {
return;
}
const apiClient = window.connectionManager.currentApiClient();
const apiClient = ServerConnections.currentApiClient();
const pathname = ctx.pathname.toLowerCase();
console.debug('processing path request: ' + pathname);
@ -550,7 +548,7 @@ class AppRouter {
if (route.isDefaultRoute) {
console.debug('loading home page');
Emby.Page.goHome();
this.goHome();
return;
} else if (route.roles) {
this.validateRoles(apiClient, route.roles).then(() => {
@ -850,4 +848,8 @@ class AppRouter {
}
}
export default new AppRouter();
export const appRouter = new AppRouter();
window.Emby = window.Emby || {};
window.Emby.Page = appRouter;