MOBILE-4245 Site: Remove load staging sites from site page
parent
856a8a4957
commit
7a78bb9375
|
@ -261,7 +261,8 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const siteName = CoreSites.getRequiredCurrentSite().getSiteName();
|
const site = CoreSites.getRequiredCurrentSite();
|
||||||
|
const siteName = await site.getSiteName();
|
||||||
|
|
||||||
this.spaceUsage = await CoreSettingsHelper.deleteSiteStorage(siteName, this.siteId);
|
this.spaceUsage = await CoreSettingsHelper.deleteSiteStorage(siteName, this.siteId);
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -290,14 +290,18 @@ export class CoreSite {
|
||||||
*
|
*
|
||||||
* @returns Site name.
|
* @returns Site name.
|
||||||
*/
|
*/
|
||||||
getSiteName(): string {
|
async getSiteName(): Promise<string> {
|
||||||
if (this.infos?.sitename) {
|
if (this.infos?.sitename) {
|
||||||
return this.infos?.sitename;
|
return this.infos?.sitename;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback.
|
// Fallback.
|
||||||
if (CoreLoginHelper.isUniqueFixedSite()) {
|
const isSigleFixedSite = await CoreLoginHelper.isSingleFixedSite();
|
||||||
return CoreConstants.CONFIG.sites[0].name ;
|
|
||||||
|
if (isSigleFixedSite) {
|
||||||
|
const sites = await CoreLoginHelper.getAvailableSites();
|
||||||
|
|
||||||
|
return sites[0].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
|
|
@ -61,9 +61,9 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective {
|
||||||
|
|
||||||
constructor(protected loadsManager: PageLoadsManager) {
|
constructor(protected loadsManager: PageLoadsManager) {
|
||||||
// Refresh the enabled flags if site is updated.
|
// Refresh the enabled flags if site is updated.
|
||||||
this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => {
|
this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, async () => {
|
||||||
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
|
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
|
||||||
this.loadSiteName();
|
await this.loadSiteName();
|
||||||
|
|
||||||
}, CoreSites.getCurrentSiteId());
|
}, CoreSites.getCurrentSiteId());
|
||||||
|
|
||||||
|
@ -78,13 +78,13 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective {
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
async ngOnInit(): Promise<void> {
|
||||||
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
|
this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite();
|
||||||
|
|
||||||
const deepLinkManager = new CoreMainMenuDeepLinkManager();
|
const deepLinkManager = new CoreMainMenuDeepLinkManager();
|
||||||
deepLinkManager.treatLink();
|
deepLinkManager.treatLink();
|
||||||
|
|
||||||
this.loadSiteName();
|
await this.loadSiteName();
|
||||||
|
|
||||||
this.loadContent(true);
|
this.loadContent(true);
|
||||||
}
|
}
|
||||||
|
@ -143,8 +143,9 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective {
|
||||||
/**
|
/**
|
||||||
* Load the site name.
|
* Load the site name.
|
||||||
*/
|
*/
|
||||||
protected loadSiteName(): void {
|
protected async loadSiteName(): Promise<void> {
|
||||||
this.siteName = CoreSites.getRequiredCurrentSite().getSiteName() || '';
|
const site = CoreSites.getRequiredCurrentSite();
|
||||||
|
this.siteName = await site.getSiteName() || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,7 +50,7 @@ export class CoreLoginHasSitesGuard implements CanActivate, CanLoad {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [path, params] = CoreLoginHelper.getAddSiteRouteInfo();
|
const [path, params] = await CoreLoginHelper.getAddSiteRouteInfo();
|
||||||
const route = Router.parseUrl(path);
|
const route = Router.parseUrl(path);
|
||||||
|
|
||||||
route.queryParams = params;
|
route.queryParams = params;
|
||||||
|
|
|
@ -99,7 +99,9 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy {
|
||||||
this.treatSiteConfig();
|
this.treatSiteConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CoreLoginHelper.isUniqueFixedSite() || !this.siteConfig) {
|
const isSingleFixedSite = await CoreLoginHelper.isSingleFixedSite();
|
||||||
|
|
||||||
|
if (isSingleFixedSite || !this.siteConfig) {
|
||||||
// Fixed URL or not siteConfig retrieved from params, we need to check if it uses browser SSO login.
|
// Fixed URL or not siteConfig retrieved from params, we need to check if it uses browser SSO login.
|
||||||
this.checkSite(this.siteUrl, true);
|
this.checkSite(this.siteUrl, true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -196,12 +198,12 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy {
|
||||||
/**
|
/**
|
||||||
* Treat the site configuration (if it exists).
|
* Treat the site configuration (if it exists).
|
||||||
*/
|
*/
|
||||||
protected treatSiteConfig(): void {
|
protected async treatSiteConfig(): Promise<void> {
|
||||||
if (this.siteConfig) {
|
if (this.siteConfig) {
|
||||||
this.siteName = this.siteConfig.sitename;
|
this.siteName = this.siteConfig.sitename;
|
||||||
this.logoUrl = CoreLoginHelper.getLogoUrl(this.siteConfig);
|
this.logoUrl = CoreLoginHelper.getLogoUrl(this.siteConfig);
|
||||||
this.authInstructions = this.siteConfig.authinstructions || Translate.instant('core.login.loginsteps');
|
this.authInstructions = this.siteConfig.authinstructions || Translate.instant('core.login.loginsteps');
|
||||||
this.showScanQR = CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype);
|
this.showScanQR = await CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype);
|
||||||
|
|
||||||
const disabledFeatures = CoreLoginHelper.getDisabledFeatures(this.siteConfig);
|
const disabledFeatures = CoreLoginHelper.getDisabledFeatures(this.siteConfig);
|
||||||
this.identityProviders = CoreLoginHelper.getValidIdentityProviders(this.siteConfig, disabledFeatures);
|
this.identityProviders = CoreLoginHelper.getValidIdentityProviders(this.siteConfig, disabledFeatures);
|
||||||
|
|
|
@ -31,7 +31,6 @@ import { CoreUserSupportConfig } from '@features/user/classes/support/support-co
|
||||||
import { CoreUserAuthenticatedSupportConfig } from '@features/user/classes/support/authenticated-support-config';
|
import { CoreUserAuthenticatedSupportConfig } from '@features/user/classes/support/authenticated-support-config';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
import { SafeHtml } from '@angular/platform-browser';
|
import { SafeHtml } from '@angular/platform-browser';
|
||||||
import { CoreConstants } from '@/core/constants';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page to enter the user password to reconnect to a site.
|
* Page to enter the user password to reconnect to a site.
|
||||||
|
@ -109,14 +108,16 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
|
||||||
this.userFullName = site.infos.fullname;
|
this.userFullName = site.infos.fullname;
|
||||||
this.userAvatar = site.infos.userpictureurl;
|
this.userAvatar = site.infos.userpictureurl;
|
||||||
this.siteUrl = site.infos.siteurl;
|
this.siteUrl = site.infos.siteurl;
|
||||||
this.siteName = site.getSiteName();
|
this.siteName = await site.getSiteName();
|
||||||
this.supportConfig = new CoreUserAuthenticatedSupportConfig(site);
|
this.supportConfig = new CoreUserAuthenticatedSupportConfig(site);
|
||||||
|
|
||||||
// If login was OAuth we should only reach this page if the OAuth method ID has changed.
|
// If login was OAuth we should only reach this page if the OAuth method ID has changed.
|
||||||
this.isOAuth = site.isOAuth();
|
this.isOAuth = site.isOAuth();
|
||||||
|
|
||||||
|
const sites = await CoreLoginHelper.getAvailableSites();
|
||||||
|
|
||||||
// Show logo instead of avatar if it's a fixed site.
|
// Show logo instead of avatar if it's a fixed site.
|
||||||
this.showUserAvatar = !!this.userAvatar && !CoreConstants.CONFIG.sites.length;
|
this.showUserAvatar = !!this.userAvatar && !sites.length;
|
||||||
|
|
||||||
this.checkSiteConfig(site);
|
this.checkSiteConfig(site);
|
||||||
|
|
||||||
|
@ -181,8 +182,12 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isBrowserSSO = !this.isOAuth && CoreLoginHelper.isSSOLoginNeeded(this.siteConfig.typeoflogin);
|
this.isBrowserSSO = !this.isOAuth && CoreLoginHelper.isSSOLoginNeeded(this.siteConfig.typeoflogin);
|
||||||
this.showScanQR = CoreLoginHelper.displayQRInSiteScreen() ||
|
|
||||||
CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype);
|
this.showScanQR = CoreLoginHelper.displayQRInSiteScreen();
|
||||||
|
|
||||||
|
if (!this.showScanQR) {
|
||||||
|
this.showScanQR = await CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype);
|
||||||
|
}
|
||||||
|
|
||||||
await CoreSites.checkApplication(this.siteConfig);
|
await CoreSites.checkApplication(this.siteConfig);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<div class="ion-text-center ion-padding ion-margin-bottom core-login-site-logo" [class.hidden]="hasSites || enteredSiteUrl">
|
<div class="ion-text-center ion-padding ion-margin-bottom core-login-site-logo" [class.hidden]="hasSites || enteredSiteUrl">
|
||||||
<img src="assets/img/login_logo.png" class="avatar-full login-logo" role="presentation" alt="">
|
<img src="assets/img/login_logo.png" class="avatar-full login-logo" role="presentation" alt="">
|
||||||
</div>
|
</div>
|
||||||
<form [formGroup]="siteForm" (ngSubmit)="connect($event, siteForm.value.siteUrl)" *ngIf="!fixedSites" #siteFormEl>
|
<form [formGroup]="siteForm" (ngSubmit)="connect($event, siteForm.value.siteUrl)" *ngIf="!fixedSites && siteForm" #siteFormEl>
|
||||||
<!-- Form to input the site URL if there are no fixed sites. -->
|
<!-- Form to input the site URL if there are no fixed sites. -->
|
||||||
<ng-container *ngIf=" siteSelector=='url'">
|
<ng-container *ngIf=" siteSelector=='url'">
|
||||||
<ion-item>
|
<ion-item>
|
||||||
|
@ -101,7 +101,8 @@
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container *ngIf="showScanQR && !hasSites && !enteredSiteUrl">
|
<ng-container *ngIf="showScanQR && !hasSites && !enteredSiteUrl">
|
||||||
<div class="ion-text-center ion-padding ion-margin-top core-login-site-qrcode-separator">{{ 'core.login.or' | translate }}</div>
|
<div class="ion-text-center ion-padding ion-margin-top core-login-site-qrcode-separator">{{ 'core.login.or' | translate }}
|
||||||
|
</div>
|
||||||
<ion-button expand="block" fill="outline" class="ion-margin core-login-site-qrcode" (click)="showInstructionsAndScanQR()"
|
<ion-button expand="block" fill="outline" class="ion-margin core-login-site-qrcode" (click)="showInstructionsAndScanQR()"
|
||||||
aria-haspopup="dialog">
|
aria-haspopup="dialog">
|
||||||
<ion-icon slot="start" name="fas-qrcode" aria-hidden="true"></ion-icon>
|
<ion-icon slot="start" name="fas-qrcode" aria-hidden="true"></ion-icon>
|
||||||
|
@ -119,7 +120,7 @@
|
||||||
|
|
||||||
<!-- Template site selector. -->
|
<!-- Template site selector. -->
|
||||||
<ng-template #sitelisting let-site="site">
|
<ng-template #sitelisting let-site="site">
|
||||||
<ion-item button (click)="connect($event, site.url, site)" [attr.aria-label]="site.name" detail="true">
|
<ion-item button (click)="connect($event, site.url, site)" [ngClass]="site.className" [attr.aria-label]="site.name" detail="true">
|
||||||
<ion-thumbnail *ngIf="siteFinderSettings.displayimage" slot="start">
|
<ion-thumbnail *ngIf="siteFinderSettings.displayimage" slot="start">
|
||||||
<img [src]="site.imageurl" *ngIf="site.imageurl" onError="this.src='assets/icon/icon.png'" alt="" role="presentation">
|
<img [src]="site.imageurl" *ngIf="site.imageurl" onError="this.src='assets/icon/icon.png'" alt="" role="presentation">
|
||||||
<img src="assets/icon/icon.png" *ngIf="!site.imageurl" class="core-login-default-icon" alt="" role="presentation">
|
<img src="assets/icon/icon.png" *ngIf="!site.imageurl" class="core-login-default-icon" alt="" role="presentation">
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, OnInit, ViewChild, ElementRef, OnDestroy } from '@angular/core';
|
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, ValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms';
|
import { FormBuilder, FormGroup, ValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms';
|
||||||
|
|
||||||
import { CoreApp } from '@services/app';
|
import { CoreApp } from '@services/app';
|
||||||
|
@ -46,7 +46,6 @@ import { CoreUserSupportConfig } from '@features/user/classes/support/support-co
|
||||||
import { CoreUserGuestSupportConfig } from '@features/user/classes/support/guest-support-config';
|
import { CoreUserGuestSupportConfig } from '@features/user/classes/support/guest-support-config';
|
||||||
import { CoreLoginError } from '@classes/errors/loginerror';
|
import { CoreLoginError } from '@classes/errors/loginerror';
|
||||||
import { CorePlatform } from '@services/platform';
|
import { CorePlatform } from '@services/platform';
|
||||||
import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Site (url) chooser when adding a new site.
|
* Site (url) chooser when adding a new site.
|
||||||
|
@ -56,7 +55,7 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events';
|
||||||
templateUrl: 'site.html',
|
templateUrl: 'site.html',
|
||||||
styleUrls: ['site.scss', '../../login.scss'],
|
styleUrls: ['site.scss', '../../login.scss'],
|
||||||
})
|
})
|
||||||
export class CoreLoginSitePage implements OnInit, OnDestroy {
|
export class CoreLoginSitePage implements OnInit {
|
||||||
|
|
||||||
@ViewChild('siteFormEl') formElement?: ElementRef;
|
@ViewChild('siteFormEl') formElement?: ElementRef;
|
||||||
|
|
||||||
|
@ -73,10 +72,13 @@ export class CoreLoginSitePage implements OnInit, OnDestroy {
|
||||||
showScanQR!: boolean;
|
showScanQR!: boolean;
|
||||||
enteredSiteUrl?: CoreLoginSiteInfoExtended;
|
enteredSiteUrl?: CoreLoginSiteInfoExtended;
|
||||||
siteFinderSettings!: CoreLoginSiteFinderSettings;
|
siteFinderSettings!: CoreLoginSiteFinderSettings;
|
||||||
stagingSitesChangeListener: CoreEventObserver;
|
|
||||||
|
|
||||||
constructor(protected formBuilder: FormBuilder) {
|
constructor(protected formBuilder: FormBuilder) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the component.
|
||||||
|
*/
|
||||||
|
async ngOnInit(): Promise<void> {
|
||||||
let url = '';
|
let url = '';
|
||||||
this.siteSelector = CoreConstants.CONFIG.multisitesdisplay;
|
this.siteSelector = CoreConstants.CONFIG.multisitesdisplay;
|
||||||
|
|
||||||
|
@ -92,8 +94,10 @@ export class CoreLoginSitePage implements OnInit, OnDestroy {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load fixed sites if they're set.
|
// Load fixed sites if they're set.
|
||||||
if (CoreConstants.CONFIG.sites.length) {
|
const sites = await CoreLoginHelper.getAvailableSites();
|
||||||
url = this.initSiteSelector();
|
|
||||||
|
if (sites.length) {
|
||||||
|
url = await this.initSiteSelector();
|
||||||
} else if (CoreConstants.CONFIG.enableonboarding && !CorePlatform.isIOS()) {
|
} else if (CoreConstants.CONFIG.enableonboarding && !CorePlatform.isIOS()) {
|
||||||
this.initOnboarding();
|
this.initOnboarding();
|
||||||
}
|
}
|
||||||
|
@ -123,35 +127,7 @@ export class CoreLoginSitePage implements OnInit, OnDestroy {
|
||||||
this.loadingSites = false;
|
this.loadingSites = false;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
this.stagingSitesChangeListener = CoreEvents.on(
|
|
||||||
CoreEvents.STAGING_SITES_CHANGE,
|
|
||||||
async ({ enabled }: { enabled: boolean }) => {
|
|
||||||
if (enabled) {
|
|
||||||
await this.loadStagingSites();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CoreLoginHelper.hasSeveralFixedSites()) {
|
|
||||||
this.siteForm = this.formBuilder.group({
|
|
||||||
siteUrl: [this.initSiteSelector(), this.moodleUrlValidator()],
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.filteredSites = undefined;
|
|
||||||
this.fixedSites = undefined;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the component.
|
|
||||||
*/
|
|
||||||
async ngOnInit(): Promise<void> {
|
|
||||||
this.showKeyboard = !!CoreNavigator.getRouteBooleanParam('showKeyboard');
|
this.showKeyboard = !!CoreNavigator.getRouteBooleanParam('showKeyboard');
|
||||||
await this.loadStagingSites();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,8 +135,9 @@ export class CoreLoginSitePage implements OnInit, OnDestroy {
|
||||||
*
|
*
|
||||||
* @returns URL of the first site.
|
* @returns URL of the first site.
|
||||||
*/
|
*/
|
||||||
protected initSiteSelector(): string {
|
protected async initSiteSelector(): Promise<string> {
|
||||||
this.fixedSites = this.extendCoreLoginSiteInfo(<CoreLoginSiteInfoExtended[]> CoreConstants.CONFIG.sites);
|
const availableSites = await CoreLoginHelper.getAvailableSites();
|
||||||
|
this.fixedSites = this.extendCoreLoginSiteInfo(<CoreLoginSiteInfoExtended[]> availableSites);
|
||||||
this.siteSelector = 'list'; // In case it's not defined
|
this.siteSelector = 'list'; // In case it's not defined
|
||||||
|
|
||||||
// Do not show images if none are set.
|
// Do not show images if none are set.
|
||||||
|
@ -173,35 +150,6 @@ export class CoreLoginSitePage implements OnInit, OnDestroy {
|
||||||
return this.fixedSites[0].url;
|
return this.fixedSites[0].url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load staging sites list if they are enabled.
|
|
||||||
*/
|
|
||||||
protected async loadStagingSites(): Promise<void> {
|
|
||||||
const stagingSites = await CoreLoginHelper.getStagingSites();
|
|
||||||
|
|
||||||
if (!stagingSites.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const sites = this.extendCoreLoginSiteInfo(<CoreLoginSiteInfoExtended[]> stagingSites);
|
|
||||||
this.siteSelector = 'list';
|
|
||||||
|
|
||||||
if (!this.fixedSites) {
|
|
||||||
this.fixedSites = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const site of sites) {
|
|
||||||
if (this.fixedSites.some(item => item.url === site.url)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.fixedSites.push(site);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.siteFinderSettings.displayimage = false;
|
|
||||||
this.filteredSites = this.fixedSites;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize and show onboarding if needed.
|
* Initialize and show onboarding if needed.
|
||||||
*
|
*
|
||||||
|
@ -664,13 +612,6 @@ export class CoreLoginSitePage implements OnInit, OnDestroy {
|
||||||
CoreNavigator.navigate('/settings');
|
CoreNavigator.navigate('/settings');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this.stagingSitesChangeListener.off();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -380,25 +380,23 @@ export class CoreLoginHelperProvider {
|
||||||
* Get fixed site or sites.
|
* Get fixed site or sites.
|
||||||
*
|
*
|
||||||
* @returns Fixed site or list of fixed sites.
|
* @returns Fixed site or list of fixed sites.
|
||||||
* @deprecated 4.2.0 use CoreConstants.CONFIG.sites instead.
|
* @deprecated since 4.2.0. Use CoreConstants.CONFIG.sites or getAvailableSites() instead.
|
||||||
*/
|
*/
|
||||||
getFixedSites(): string | CoreLoginSiteInfo[] {
|
getFixedSites(): string | CoreLoginSiteInfo[] {
|
||||||
return CoreLoginHelper.isUniqueFixedSite() ? CoreConstants.CONFIG.sites[0].url : CoreConstants.CONFIG.sites;
|
const notStagingSites = CoreConstants.CONFIG.sites.filter(site => !site.staging);
|
||||||
|
|
||||||
|
return notStagingSites.length === 1 ? notStagingSites[0].url : notStagingSites;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get staging sites.
|
* Get Available sites (includes staging sites if are enabled).
|
||||||
*
|
*
|
||||||
* @returns Staging sites.
|
* @returns Available sites.
|
||||||
*/
|
*/
|
||||||
async getStagingSites(): Promise<CoreLoginSiteInfo[]> {
|
async getAvailableSites(): Promise<CoreLoginSiteInfo[]> {
|
||||||
const hasEnabledStagingSites = await CoreSettingsHelper.hasEnabledStagingSites();
|
const hasEnabledStagingSites = await CoreSettingsHelper.hasEnabledStagingSites();
|
||||||
|
|
||||||
if (!hasEnabledStagingSites) {
|
return hasEnabledStagingSites ? CoreConstants.CONFIG.sites : CoreConstants.CONFIG.sites.filter(site => !site.staging);
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return CoreConstants.CONFIG.stagingsites;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -457,7 +455,7 @@ export class CoreLoginHelperProvider {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
[path, params] = this.getAddSiteRouteInfo(showKeyboard);
|
[path, params] = await this.getAddSiteRouteInfo(showKeyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
await CoreNavigator.navigate(path, { params, reset: setRoot });
|
await CoreNavigator.navigate(path, { params, reset: setRoot });
|
||||||
|
@ -469,10 +467,12 @@ export class CoreLoginHelperProvider {
|
||||||
* @param showKeyboard Whether to show keyboard in the new page. Only if no fixed URL set.
|
* @param showKeyboard Whether to show keyboard in the new page. Only if no fixed URL set.
|
||||||
* @returns Path and params.
|
* @returns Path and params.
|
||||||
*/
|
*/
|
||||||
getAddSiteRouteInfo(showKeyboard?: boolean): [string, Params] {
|
async getAddSiteRouteInfo(showKeyboard?: boolean): Promise<[string, Params]> {
|
||||||
if (CoreLoginHelper.isUniqueFixedSite()) {
|
const sites = await this.getAvailableSites();
|
||||||
|
|
||||||
|
if (sites.length === 1) {
|
||||||
// Fixed URL is set, go to credentials page.
|
// Fixed URL is set, go to credentials page.
|
||||||
return ['/login/credentials', { siteUrl: CoreConstants.CONFIG.sites[0].url }];
|
return ['/login/credentials', { siteUrl: sites[0].url }];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['/login/site', { showKeyboard }];
|
return ['/login/site', { showKeyboard }];
|
||||||
|
@ -534,8 +534,10 @@ export class CoreLoginHelperProvider {
|
||||||
* @returns Whether there are several fixed URLs.
|
* @returns Whether there are several fixed URLs.
|
||||||
* @deprecated 4.2.0 Use CoreConstants.CONFIG.sites.length > 1 instead.
|
* @deprecated 4.2.0 Use CoreConstants.CONFIG.sites.length > 1 instead.
|
||||||
*/
|
*/
|
||||||
hasSeveralFixedSites(): boolean {
|
async hasSeveralFixedSites(): Promise<boolean> {
|
||||||
return CoreConstants.CONFIG.sites.length > 1;
|
const sites = await this.getAvailableSites();
|
||||||
|
|
||||||
|
return sites.length > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -571,10 +573,10 @@ export class CoreLoginHelperProvider {
|
||||||
* Check if the app is configured to use a fixed URL (only 1).
|
* Check if the app is configured to use a fixed URL (only 1).
|
||||||
*
|
*
|
||||||
* @returns Whether there is 1 fixed URL.
|
* @returns Whether there is 1 fixed URL.
|
||||||
* @deprecated 4.2.0 Use isUniqueFixedSite instead.
|
* @deprecated 4.2.0 Use isSingleFixedSite instead.
|
||||||
*/
|
*/
|
||||||
isFixedUrlSet(): boolean {
|
isFixedUrlSet(): boolean {
|
||||||
return this.isUniqueFixedSite();
|
return CoreConstants.CONFIG.sites.filter(site => !site.staging).length === 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -582,8 +584,10 @@ export class CoreLoginHelperProvider {
|
||||||
*
|
*
|
||||||
* @returns Whether there is 1 fixed URL.
|
* @returns Whether there is 1 fixed URL.
|
||||||
*/
|
*/
|
||||||
isUniqueFixedSite(): boolean {
|
async isSingleFixedSite(): Promise<boolean> {
|
||||||
return CoreConstants.CONFIG.sites.length === 1;
|
const sites = await this.getAvailableSites();
|
||||||
|
|
||||||
|
return sites.length === 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -626,8 +630,10 @@ export class CoreLoginHelperProvider {
|
||||||
* @returns Promise resolved with boolean: whether is one of the fixed sites.
|
* @returns Promise resolved with boolean: whether is one of the fixed sites.
|
||||||
*/
|
*/
|
||||||
async isSiteUrlAllowed(siteUrl: string, checkSiteFinder = true): Promise<boolean> {
|
async isSiteUrlAllowed(siteUrl: string, checkSiteFinder = true): Promise<boolean> {
|
||||||
if (CoreConstants.CONFIG.sites.length) {
|
const sites = await this.getAvailableSites();
|
||||||
return CoreConstants.CONFIG.sites.some((site) => CoreUrl.sameDomainAndPath(siteUrl, site.url));
|
|
||||||
|
if (sites.length) {
|
||||||
|
return sites.some((site) => CoreUrl.sameDomainAndPath(siteUrl, site.url));
|
||||||
} else if (CoreConstants.CONFIG.multisitesdisplay == 'sitefinder' && CoreConstants.CONFIG.onlyallowlistedsites &&
|
} else if (CoreConstants.CONFIG.multisitesdisplay == 'sitefinder' && CoreConstants.CONFIG.onlyallowlistedsites &&
|
||||||
checkSiteFinder) {
|
checkSiteFinder) {
|
||||||
// Call the sites finder to validate the site.
|
// Call the sites finder to validate the site.
|
||||||
|
@ -1318,12 +1324,14 @@ export class CoreLoginHelperProvider {
|
||||||
* @param qrCodeType QR Code type from public config, assuming enabled if undefined.
|
* @param qrCodeType QR Code type from public config, assuming enabled if undefined.
|
||||||
* @returns Whether the QR reader should be displayed in credentials screen.
|
* @returns Whether the QR reader should be displayed in credentials screen.
|
||||||
*/
|
*/
|
||||||
displayQRInCredentialsScreen(qrCodeType = CoreSiteQRCodeType.QR_CODE_LOGIN): boolean {
|
async displayQRInCredentialsScreen(qrCodeType = CoreSiteQRCodeType.QR_CODE_LOGIN): Promise<boolean> {
|
||||||
if (!CoreUtils.canScanQR()) {
|
if (!CoreUtils.canScanQR()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((CoreConstants.CONFIG.displayqroncredentialscreen === undefined && CoreLoginHelper.isUniqueFixedSite()) ||
|
const isSingleFixedSite = await this.isSingleFixedSite();
|
||||||
|
|
||||||
|
if ((CoreConstants.CONFIG.displayqroncredentialscreen === undefined && isSingleFixedSite) ||
|
||||||
(CoreConstants.CONFIG.displayqroncredentialscreen !== undefined &&
|
(CoreConstants.CONFIG.displayqroncredentialscreen !== undefined &&
|
||||||
!!CoreConstants.CONFIG.displayqroncredentialscreen)) {
|
!!CoreConstants.CONFIG.displayqroncredentialscreen)) {
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ export class CoreMainMenuUserMenuComponent implements OnInit, OnDestroy {
|
||||||
const currentSite = CoreSites.getRequiredCurrentSite();
|
const currentSite = CoreSites.getRequiredCurrentSite();
|
||||||
this.siteId = currentSite.getId();
|
this.siteId = currentSite.getId();
|
||||||
this.siteInfo = currentSite.getInfo();
|
this.siteInfo = currentSite.getInfo();
|
||||||
this.siteName = currentSite.getSiteName();
|
this.siteName = await currentSite.getSiteName();
|
||||||
this.siteUrl = currentSite.getURL();
|
this.siteUrl = currentSite.getURL();
|
||||||
this.displaySwitchAccount = !currentSite.isFeatureDisabled('NoDelegate_SwitchAccount');
|
this.displaySwitchAccount = !currentSite.isFeatureDisabled('NoDelegate_SwitchAccount');
|
||||||
this.displayContactSupport = new CoreUserAuthenticatedSupportConfig(currentSite).canContactSupport();
|
this.displayContactSupport = new CoreUserAuthenticatedSupportConfig(currentSite).canContactSupport();
|
||||||
|
|
|
@ -45,18 +45,18 @@ export class CoreMainMenuHomePage implements OnInit {
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
async ngOnInit(): Promise<void> {
|
||||||
this.deepLinkManager = new CoreMainMenuDeepLinkManager();
|
this.deepLinkManager = new CoreMainMenuDeepLinkManager();
|
||||||
|
|
||||||
this.loadSiteName();
|
await this.loadSiteName();
|
||||||
|
|
||||||
this.subscription = CoreMainMenuHomeDelegate.getHandlersObservable().subscribe((handlers) => {
|
this.subscription = CoreMainMenuHomeDelegate.getHandlersObservable().subscribe((handlers) => {
|
||||||
handlers && this.initHandlers(handlers);
|
handlers && this.initHandlers(handlers);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Refresh the enabled flags if site is updated.
|
// Refresh the enabled flags if site is updated.
|
||||||
this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => {
|
this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, async () => {
|
||||||
this.loadSiteName();
|
await this.loadSiteName();
|
||||||
}, CoreSites.getCurrentSiteId());
|
}, CoreSites.getCurrentSiteId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +99,9 @@ export class CoreMainMenuHomePage implements OnInit {
|
||||||
/**
|
/**
|
||||||
* Load the site name.
|
* Load the site name.
|
||||||
*/
|
*/
|
||||||
protected loadSiteName(): void {
|
protected async loadSiteName(): Promise<void> {
|
||||||
this.siteName = CoreSites.getRequiredCurrentSite().getSiteName() || '';
|
const site = CoreSites.getRequiredCurrentSite();
|
||||||
|
this.siteName = await site.getSiteName() || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
<ion-label>
|
<ion-label>
|
||||||
<h2>Enable staging sites ({{stagingSitesCount}})</h2>
|
<h2>Enable staging sites ({{stagingSitesCount}})</h2>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
<ion-toggle [checked]="enableStagingSites" (ionChange)="setEnabledStagingSites($event.detail.checked)"></ion-toggle>
|
<ion-toggle [(ngModel)]="enableStagingSites" (ionChange)="setEnabledStagingSites($event.detail.checked)"></ion-toggle>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ng-container *ngIf="siteId">
|
<ng-container *ngIf="siteId">
|
||||||
<ion-item class="ion-text-wrap">
|
<ion-item class="ion-text-wrap">
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { CoreLoginHelper, CoreLoginHelperProvider } from '@features/login/services/login-helper';
|
import { CoreLoginHelperProvider } from '@features/login/services/login-helper';
|
||||||
import { CoreSettingsHelper } from '@features/settings/services/settings-helper';
|
import { CoreSettingsHelper } from '@features/settings/services/settings-helper';
|
||||||
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
|
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
|
||||||
import { CoreUserTours } from '@features/usertours/services/user-tours';
|
import { CoreUserTours } from '@features/usertours/services/user-tours';
|
||||||
|
@ -45,6 +45,7 @@ export class CoreSettingsDevPage implements OnInit {
|
||||||
userToursEnabled = true;
|
userToursEnabled = true;
|
||||||
stagingSitesCount = 0;
|
stagingSitesCount = 0;
|
||||||
enableStagingSites?: boolean;
|
enableStagingSites?: boolean;
|
||||||
|
listenStagingSitesChanges = false;
|
||||||
|
|
||||||
disabledFeatures: string[] = [];
|
disabledFeatures: string[] = [];
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ export class CoreSettingsDevPage implements OnInit {
|
||||||
|
|
||||||
if (this.stagingSitesCount) {
|
if (this.stagingSitesCount) {
|
||||||
this.enableStagingSites = await CoreSettingsHelper.hasEnabledStagingSites();
|
this.enableStagingSites = await CoreSettingsHelper.hasEnabledStagingSites();
|
||||||
|
this.listenStagingSitesChanges = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.siteId) {
|
if (!this.siteId) {
|
||||||
|
@ -168,7 +170,19 @@ export class CoreSettingsDevPage implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
async setEnabledStagingSites(enabled: boolean): Promise<void> {
|
async setEnabledStagingSites(enabled: boolean): Promise<void> {
|
||||||
await CoreSettingsHelper.setEnabledStagingSites(enabled);
|
if (!this.listenStagingSitesChanges) {
|
||||||
|
this.listenStagingSitesChanges = true;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await CoreSettingsHelper.setEnabledStagingSites(enabled);
|
||||||
|
} catch (error) {
|
||||||
|
this.enableStagingSites = !enabled;
|
||||||
|
this.listenStagingSitesChanges = false;
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,10 +168,6 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentSite = sitesProvider.getCurrentSite();
|
const currentSite = sitesProvider.getCurrentSite();
|
||||||
const firstUrl = CoreLoginHelper.isUniqueFixedSite() && CoreConstants.CONFIG.sites[0].url;
|
|
||||||
|
|
||||||
this.deviceInfo.siteUrl = currentSite?.getURL() || firstUrl || undefined;
|
|
||||||
this.deviceInfo.isPrefixedUrl = !!CoreConstants.CONFIG.sites.length;
|
|
||||||
this.deviceInfo.siteId = currentSite?.getId();
|
this.deviceInfo.siteId = currentSite?.getId();
|
||||||
this.deviceInfo.siteVersion = currentSite?.getInfo()?.release;
|
this.deviceInfo.siteVersion = currentSite?.getInfo()?.release;
|
||||||
|
|
||||||
|
@ -190,12 +186,21 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
|
||||||
* Async part of the constructor.
|
* Async part of the constructor.
|
||||||
*/
|
*/
|
||||||
protected async asyncInit(): Promise<void> {
|
protected async asyncInit(): Promise<void> {
|
||||||
|
const sitesProvider = CoreSites.instance;
|
||||||
const fileProvider = CoreFile.instance;
|
const fileProvider = CoreFile.instance;
|
||||||
|
|
||||||
const lang = await CoreLang.getCurrentLanguage();
|
const lang = await CoreLang.getCurrentLanguage();
|
||||||
this.deviceInfo.currentLanguage = lang;
|
this.deviceInfo.currentLanguage = lang;
|
||||||
this.currentLangName = CoreConstants.CONFIG.languages[lang];
|
this.currentLangName = CoreConstants.CONFIG.languages[lang];
|
||||||
|
|
||||||
|
const currentSite = sitesProvider.getCurrentSite();
|
||||||
|
const isSingleFixedSite = await CoreLoginHelper.isSingleFixedSite();
|
||||||
|
const sites = await CoreLoginHelper.getAvailableSites();
|
||||||
|
const firstUrl = isSingleFixedSite && sites[0].url;
|
||||||
|
|
||||||
|
this.deviceInfo.siteUrl = currentSite?.getURL() || firstUrl || undefined;
|
||||||
|
this.deviceInfo.isPrefixedUrl = !!sites.length;
|
||||||
|
|
||||||
if (fileProvider.isAvailable()) {
|
if (fileProvider.isAvailable()) {
|
||||||
const basepath = await fileProvider.getBasePath();
|
const basepath = await fileProvider.getBasePath();
|
||||||
this.deviceInfo.fileSystemRoot = basepath;
|
this.deviceInfo.fileSystemRoot = basepath;
|
||||||
|
|
|
@ -66,7 +66,7 @@ export class CoreSettingsSpaceUsagePage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
const site = await CoreSites.getSite(siteId);
|
const site = await CoreSites.getSite(siteId);
|
||||||
const siteInfo = site.getInfo();
|
const siteInfo = site.getInfo();
|
||||||
siteEntry.siteName = site.getSiteName();
|
siteEntry.siteName = await site.getSiteName();
|
||||||
|
|
||||||
if (siteInfo) {
|
if (siteInfo) {
|
||||||
siteEntry.siteUrl = siteInfo.siteurl;
|
siteEntry.siteUrl = siteInfo.siteurl;
|
||||||
|
|
|
@ -80,7 +80,7 @@ export class CoreSettingsSynchronizationPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
const siteInfo = site.getInfo();
|
const siteInfo = site.getInfo();
|
||||||
|
|
||||||
siteEntry.siteName = site.getSiteName();
|
siteEntry.siteName = await site.getSiteName();
|
||||||
|
|
||||||
if (siteInfo) {
|
if (siteInfo) {
|
||||||
siteEntry.siteUrl = siteInfo.siteurl;
|
siteEntry.siteUrl = siteInfo.siteurl;
|
||||||
|
|
|
@ -495,10 +495,15 @@ export class CoreSettingsHelperProvider {
|
||||||
* @param enabled Enabled or disabled staging sites.
|
* @param enabled Enabled or disabled staging sites.
|
||||||
*/
|
*/
|
||||||
async setEnabledStagingSites(enabled: boolean): Promise<void> {
|
async setEnabledStagingSites(enabled: boolean): Promise<void> {
|
||||||
try {
|
const reloadApp = !CoreSites.isLoggedIn();
|
||||||
await CoreConfig.set('stagingSites', enabled ? 1 : 0);
|
|
||||||
|
if (reloadApp) {
|
||||||
await CoreDomUtils.showConfirm('Are you sure that you want to enable/disable staging sites?');
|
await CoreDomUtils.showConfirm('Are you sure that you want to enable/disable staging sites?');
|
||||||
} catch {
|
}
|
||||||
|
|
||||||
|
await CoreConfig.set('stagingSites', enabled ? 1 : 0);
|
||||||
|
|
||||||
|
if (!reloadApp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,9 @@ export class CoreUpdateManagerProvider {
|
||||||
* @returns Promise resolved when done.
|
* @returns Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected async checkCurrentSiteAllowed(): Promise<void> {
|
protected async checkCurrentSiteAllowed(): Promise<void> {
|
||||||
if (!CoreConstants.CONFIG.sites.length) {
|
const sites = await CoreLoginHelper.getAvailableSites();
|
||||||
|
|
||||||
|
if (!sites.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue