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

Merge pull request #1918 from jellyfin/standalone

Fix startup wizard redirect and standalone mode
This commit is contained in:
Joshua M. Boniface 2020-11-21 22:25:50 -05:00 committed by GitHub
commit 3961657c70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 104 additions and 134 deletions

View file

@ -1,4 +0,0 @@
export default {
isNativeApp: false
};

View file

@ -1,7 +1,6 @@
import { ConnectionManager, Credentials, ApiClient, Events } from 'jellyfin-apiclient';
import { appHost } from './apphost';
import Dashboard from '../scripts/clientUtils';
import AppInfo from './AppInfo';
import { setUserInfo } from '../scripts/settings/userSettings';
class ServerConnections extends ConnectionManager {
@ -14,27 +13,25 @@ class ServerConnections extends ConnectionManager {
});
}
initApiClient() {
if (!AppInfo.isNativeApp) {
console.debug('creating ApiClient singleton');
initApiClient(server) {
console.debug('creating ApiClient singleton');
const apiClient = new ApiClient(
Dashboard.serverAddress(),
appHost.appName(),
appHost.appVersion(),
appHost.deviceName(),
appHost.deviceId()
);
const apiClient = new ApiClient(
server,
appHost.appName(),
appHost.appVersion(),
appHost.deviceName(),
appHost.deviceId()
);
apiClient.enableAutomaticNetworking = false;
apiClient.manualAddressOnly = true;
apiClient.enableAutomaticNetworking = false;
apiClient.manualAddressOnly = true;
this.addApiClient(apiClient);
this.addApiClient(apiClient);
this.setLocalApiClient(apiClient);
this.setLocalApiClient(apiClient);
console.debug('loaded ApiClient singleton');
}
console.debug('loaded ApiClient singleton');
}
setLocalApiClient(apiClient) {

View file

@ -8,7 +8,6 @@ import itemHelper from './itemHelper';
import loading from './loading/loading';
import page from 'page';
import viewManager from './viewManager/viewManager';
import AppInfo from './AppInfo';
import Dashboard from '../scripts/clientUtils';
import ServerConnections from './ServerConnections';
import alert from './alert';
@ -80,11 +79,7 @@ class AppRouter {
}
showSelectServer() {
Dashboard.navigate(AppInfo.isNativeApp ? 'selectserver.html' : 'login.html');
}
showWelcome() {
Dashboard.navigate(AppInfo.isNativeApp ? 'selectserver.html' : 'login.html');
Dashboard.navigate('selectserver.html');
}
showSettings() {
@ -286,9 +281,6 @@ class AppRouter {
case 'ServerSelection':
this.showSelectServer();
break;
case 'ConnectSignIn':
this.showWelcome();
break;
case 'ServerUpdateNeeded':
alert({
text: globalize.translate('ServerUpdateNeeded', 'https://github.com/jellyfin/jellyfin'),
@ -508,25 +500,35 @@ class AppRouter {
authenticate(ctx, route, callback) {
const firstResult = this.firstConnectionResult;
if (firstResult) {
this.firstConnectionResult = null;
if (firstResult.State !== 'SignedIn' && !route.anonymous) {
this.handleConnectionResult(firstResult);
return;
}
this.firstConnectionResult = null;
if (firstResult && firstResult.State === 'ServerSignIn') {
const url = ApiClient.serverAddress() + '/System/Info/Public';
fetch(url).then(response => {
if (!response.ok) return Promise.reject('fetch failed');
return response.json();
}).then(data => {
if (data !== null && data.StartupWizardCompleted === false) {
Dashboard.navigate('wizardstart.html');
} else {
this.handleConnectionResult(firstResult);
}
}).catch(error => {
console.error(error);
});
return;
}
const apiClient = ServerConnections.currentApiClient();
const pathname = ctx.pathname.toLowerCase();
console.debug('appRouter - processing path request ' + pathname);
console.debug('processing path request: ' + pathname);
const isCurrentRouteStartup = this.currentRouteInfo ? this.currentRouteInfo.route.startup : true;
const shouldExitApp = ctx.isBack && route.isDefaultRoute && isCurrentRouteStartup;
if (!shouldExitApp && (!apiClient || !apiClient.isLoggedIn()) && !route.anonymous) {
console.debug('appRouter - route does not allow anonymous access, redirecting to login');
console.debug('route does not allow anonymous access: redirecting to login');
this.beginConnectionWizard();
return;
}
@ -534,16 +536,16 @@ class AppRouter {
if (shouldExitApp) {
if (appHost.supports('exit')) {
appHost.exit();
return;
}
return;
}
if (apiClient && apiClient.isLoggedIn()) {
console.debug('appRouter - user is authenticated');
console.debug('user is authenticated');
if (route.isDefaultRoute) {
console.debug('appRouter - loading skin home page');
console.debug('loading home page');
this.goHome();
return;
} else if (route.roles) {
@ -554,7 +556,7 @@ class AppRouter {
}
}
console.debug('appRouter - proceeding to ' + pathname);
console.debug('proceeding to page: ' + pathname);
callback();
}