fix startup wizard redirect and standalone mode
This commit is contained in:
parent
e06b9ec4d0
commit
cb1d2887fa
8 changed files with 78 additions and 117 deletions
|
@ -1,35 +1,41 @@
|
|||
import * as webSettings from 'webSettings';
|
||||
|
||||
export function getCurrentUser() {
|
||||
return window.ApiClient.getCurrentUser(false);
|
||||
}
|
||||
|
||||
//TODO: investigate url prefix support for serverAddress function
|
||||
export function serverAddress() {
|
||||
if (AppInfo.isNativeApp) {
|
||||
const apiClient = window.ApiClient;
|
||||
// TODO: investigate url prefix support for serverAddress function
|
||||
export async function serverAddress() {
|
||||
const apiClient = window.ApiClient;
|
||||
|
||||
if (apiClient) {
|
||||
return apiClient.serverAddress();
|
||||
if (apiClient) {
|
||||
return Promise.resolve(apiClient.serverAddress());
|
||||
}
|
||||
|
||||
let current = await window.connectionManager.getAvailableServers().then(servers => {
|
||||
if (servers.length !== 0) {
|
||||
return Promise.resolve(servers[0].ManualAddress);
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
if (current) return Promise.resolve(current);
|
||||
|
||||
const urlLower = window.location.href.toLowerCase();
|
||||
const index = urlLower.lastIndexOf('/web');
|
||||
let urls = [];
|
||||
urls.push(`${window.location.origin}/System/Info/Public`);
|
||||
urls.push(`${window.location.protocol}//${window.location.hostname}:8096/System/Info/Public`);
|
||||
|
||||
if (index != -1) {
|
||||
return urlLower.substring(0, index);
|
||||
}
|
||||
let promises = urls.map(url => {
|
||||
return fetch(url).catch(error => {
|
||||
return Promise.resolve();
|
||||
});
|
||||
});
|
||||
|
||||
const loc = window.location;
|
||||
let address = loc.protocol + '//' + loc.hostname;
|
||||
|
||||
if (loc.port) {
|
||||
address += ':' + loc.port;
|
||||
}
|
||||
|
||||
return address;
|
||||
return Promise.all(promises).then(responses => {
|
||||
return responses.find(response => response && response.ok);
|
||||
}).then(response => response.url).catch(error => {
|
||||
console.log(error);
|
||||
return Promise.resolve();
|
||||
});
|
||||
}
|
||||
|
||||
export function getCurrentUserId() {
|
||||
|
@ -49,16 +55,9 @@ export function onServerChanged(userId, accessToken, apiClient) {
|
|||
|
||||
export function logout() {
|
||||
window.connectionManager.logout().then(function () {
|
||||
let loginPage;
|
||||
|
||||
if (AppInfo.isNativeApp) {
|
||||
loginPage = 'selectserver.html';
|
||||
window.ApiClient = null;
|
||||
} else {
|
||||
loginPage = 'login.html';
|
||||
}
|
||||
|
||||
navigate(loginPage);
|
||||
webSettings.getMultiServer().then(multi => {
|
||||
multi ? navigate('selectserver.html') : navigate('login.html');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue