From fa72fa4f026bb19539f35eb29df88b9d203bc587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 28 Jan 2020 11:53:32 +0100 Subject: [PATCH 1/7] MOBILE-3325 settings: Divide app and site settings --- scripts/langindex.json | 3 +- src/assets/lang/en.json | 5 +- .../login/pages/credentials/credentials.html | 4 +- src/core/login/pages/site/site.html | 4 +- src/core/login/pages/site/site.module.ts | 2 + src/core/login/pages/sites/sites.html | 4 +- src/core/login/pages/sites/sites.module.ts | 2 + src/core/mainmenu/lang/en.json | 1 - src/core/mainmenu/pages/more/more.html | 10 ++- src/core/mainmenu/pages/more/more.ts | 13 +++- src/core/settings/lang/en.json | 2 + .../pages/{list/list.html => app/app.html} | 8 +-- .../list.module.ts => app/app.module.ts} | 8 +-- src/core/settings/pages/app/app.ts | 63 +++++++++++++++++++ src/core/settings/pages/site/site.html | 30 +++++++++ src/core/settings/pages/site/site.module.ts | 33 ++++++++++ .../pages/{list/list.ts => site/site.ts} | 10 +-- 17 files changed, 170 insertions(+), 32 deletions(-) rename src/core/settings/pages/{list/list.html => app/app.html} (80%) rename src/core/settings/pages/{list/list.module.ts => app/app.module.ts} (85%) create mode 100644 src/core/settings/pages/app/app.ts create mode 100644 src/core/settings/pages/site/site.html create mode 100644 src/core/settings/pages/site/site.module.ts rename src/core/settings/pages/{list/list.ts => site/site.ts} (90%) diff --git a/scripts/langindex.json b/scripts/langindex.json index 71c85af4c..c9e4446ad 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -1760,7 +1760,6 @@ "core.login.visitchangepassword": "local_moodlemobileapp", "core.login.webservicesnotenabled": "local_moodlemobileapp", "core.lostconnection": "local_moodlemobileapp", - "core.mainmenu.appsettings": "local_moodlemobileapp", "core.mainmenu.changesite": "local_moodlemobileapp", "core.mainmenu.help": "moodle", "core.mainmenu.logout": "moodle", @@ -1891,6 +1890,7 @@ "core.sending": "chat", "core.serverconnection": "error", "core.settings.about": "local_moodlemobileapp", + "core.settings.appsettings": "local_moodlemobileapp", "core.settings.appversion": "local_moodlemobileapp", "core.settings.cannotsyncoffline": "local_moodlemobileapp", "core.settings.cannotsyncwithoutwifi": "local_moodlemobileapp", @@ -1950,6 +1950,7 @@ "core.settings.showdownloadoptions": "local_moodlemobileapp", "core.settings.siteinfo": "local_moodlemobileapp", "core.settings.sites": "moodle", + "core.settings.sitesettings": "moodle", "core.settings.spaceusage": "local_moodlemobileapp", "core.settings.synchronization": "local_moodlemobileapp", "core.settings.synchronizenow": "local_moodlemobileapp", diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 215946d1a..5b69400d2 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -1760,7 +1760,6 @@ "core.login.visitchangepassword": "Do you want to visit the site to change the password?", "core.login.webservicesnotenabled": "Web services are not enabled in your site. Please contact your site administrator if you think they should be enabled.", "core.lostconnection": "Your authentication token is invalid or has expired. You will have to reconnect to the site.", - "core.mainmenu.appsettings": "App settings", "core.mainmenu.changesite": "Change site", "core.mainmenu.help": "Help", "core.mainmenu.logout": "Log out", @@ -1891,6 +1890,7 @@ "core.sending": "Sending", "core.serverconnection": "Error connecting to the server", "core.settings.about": "About", + "core.settings.appsettings": "App settings", "core.settings.appversion": "App version", "core.settings.cannotsyncoffline": "Cannot synchronise offline.", "core.settings.cannotsyncwithoutwifi": "Cannot synchronise because the current settings only allow to synchronise when connected to Wi-Fi. Please connect to a Wi-Fi network.", @@ -1950,6 +1950,7 @@ "core.settings.showdownloadoptions": "Show download options", "core.settings.siteinfo": "Site info", "core.settings.sites": "Sites", + "core.settings.sitesettings": "Site settings", "core.settings.spaceusage": "Space usage", "core.settings.synchronization": "Synchronisation", "core.settings.synchronizenow": "Synchronise now", @@ -2078,4 +2079,4 @@ "core.yes": "Yes", "core.youreoffline": "You are offline", "core.youreonline": "You are back online" -} \ No newline at end of file +} diff --git a/src/core/login/pages/credentials/credentials.html b/src/core/login/pages/credentials/credentials.html index 467bb49dd..d2659a77f 100644 --- a/src/core/login/pages/credentials/credentials.html +++ b/src/core/login/pages/credentials/credentials.html @@ -3,8 +3,8 @@ {{ 'core.login.login' | translate }} - diff --git a/src/core/login/pages/site/site.html b/src/core/login/pages/site/site.html index 9503d5335..ac2c2bae8 100644 --- a/src/core/login/pages/site/site.html +++ b/src/core/login/pages/site/site.html @@ -3,8 +3,8 @@ {{ 'core.login.connecttomoodle' | translate }} - + + + +

{{ 'core.settings.synchronization' | translate }}

+
+ + +

{{ 'core.sharedfiles.sharedfiles' | translate }}

+
+ + + +

{{ handler.title | translate}}

+
+ + diff --git a/src/core/settings/pages/site/site.module.ts b/src/core/settings/pages/site/site.module.ts index f085cea30..753dcbf37 100644 --- a/src/core/settings/pages/site/site.module.ts +++ b/src/core/settings/pages/site/site.module.ts @@ -18,6 +18,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { CoreSiteSettingsPage } from './site'; import { CoreComponentsModule } from '@components/components.module'; import { CoreDirectivesModule } from '@directives/directives.module'; +import { CorePipesModule } from '@pipes/pipes.module'; @NgModule({ declarations: [ @@ -26,6 +27,7 @@ import { CoreDirectivesModule } from '@directives/directives.module'; imports: [ CoreComponentsModule, CoreDirectivesModule, + CorePipesModule, IonicPageModule.forChild(CoreSiteSettingsPage), TranslateModule.forChild() ], diff --git a/src/core/settings/pages/site/site.ts b/src/core/settings/pages/site/site.ts index 9924b3182..5517736af 100644 --- a/src/core/settings/pages/site/site.ts +++ b/src/core/settings/pages/site/site.ts @@ -15,6 +15,9 @@ import { Component, ViewChild } from '@angular/core'; import { IonicPage, NavParams, Platform } from 'ionic-angular'; import { CoreSettingsDelegate, CoreSettingsHandlerData } from '../../providers/delegate'; +import { CoreSite } from '@classes/site'; +import { CoreSitesProvider } from '@providers/sites'; +import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../providers/helper'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; /** @@ -31,24 +34,78 @@ export class CoreSiteSettingsPage { handlers: CoreSettingsHandlerData[]; isIOS: boolean; selectedPage: string; + currentSite: CoreSite; + siteInfo: any; + siteName: string; + siteUrl: string; + spaceUsage: CoreSiteSpaceUsage = { + cacheEntries: 0, + spaceUsage: 0 + }; + loaded = false; + + constructor(protected settingsDelegate: CoreSettingsDelegate, + protected settingsHelper: CoreSettingsHelper, + protected sitesProvider: CoreSitesProvider, + platorm: Platform, + navParams: NavParams) { - constructor(private settingsDelegate: CoreSettingsDelegate, platorm: Platform, navParams: NavParams) { this.isIOS = platorm.is('ios'); this.selectedPage = navParams.get('page') || false; + } /** * View loaded. */ ionViewDidLoad(): void { - this.handlers = this.settingsDelegate.getHandlers(); + this.fetchData().finally(() => { + this.loaded = true; + }); + if (this.selectedPage) { this.openHandler(this.selectedPage); - } else if (this.splitviewCtrl.isOn()) { - this.openHandler('CoreSettingsGeneralPage'); } + } + /** + * View loaded. + */ + protected async fetchData(): Promise { + this.handlers = this.settingsDelegate.getHandlers(); + this.currentSite = this.sitesProvider.getCurrentSite(); + this.siteInfo = this.currentSite.getInfo(); + this.siteName = this.currentSite.getSiteName(); + this.siteUrl = this.currentSite.getURL(); + + return this.settingsHelper.getSiteSpaceUsage(this.sitesProvider.getCurrentSiteId()).then((spaceUsage) => { + this.spaceUsage = spaceUsage; + }); + } + + /** + * Refresh the data. + * + * @param refresher Refresher. + */ + refreshData(refresher: any): void { + this.fetchData().finally(() => { + refresher.complete(); + }); + } + + /** + * Deletes files of a site and the tables that can be cleared. + * + * @param siteData Site object with space usage. + */ + deleteSiteStorage(): void { + this.settingsHelper.deleteSiteStorage(this.currentSite.getSiteName(), this.currentSite.getId()).then((newInfo) => { + this.spaceUsage = newInfo; + }).catch(() => { + // Ignore cancelled confirmation modal. + }); } /** diff --git a/src/core/settings/pages/space-usage/space-usage.html b/src/core/settings/pages/space-usage/space-usage.html index f4d247a89..27c950fb0 100644 --- a/src/core/settings/pages/space-usage/space-usage.html +++ b/src/core/settings/pages/space-usage/space-usage.html @@ -4,10 +4,10 @@ - + - +

{{ site.fullName }}

@@ -19,11 +19,11 @@
- +

{{ 'core.settings.total' | translate }}

-

{{ totalUsage | coreBytesToSize }}

-

{{ 'core.settings.entriesincache' | translate: { $a: totalEntries } }}

+

{{ totals.spaceUsage | coreBytesToSize }}

+

{{ 'core.settings.entriesincache' | translate: { $a: totals.cacheEntries } }}

diff --git a/src/core/settings/pages/space-usage/space-usage.ts b/src/core/settings/pages/space-usage/space-usage.ts index 8b8254837..3e6a74be2 100644 --- a/src/core/settings/pages/space-usage/space-usage.ts +++ b/src/core/settings/pages/space-usage/space-usage.ts @@ -14,15 +14,8 @@ import { Component, } from '@angular/core'; import { IonicPage } from 'ionic-angular'; -import { TranslateService } from '@ngx-translate/core'; -import { CoreAppProvider } from '@providers/app'; -import { CoreEventsProvider } from '@providers/events'; -import { CoreFilepoolProvider } from '@providers/filepool'; -import { CoreSitesProvider } from '@providers/sites'; -import { CoreDomUtilsProvider } from '@providers/utils/dom'; -import { CoreCourseProvider } from '@core/course/providers/course'; -import { CoreFilterProvider } from '@core/filter/providers/filter'; -import { CoreSite } from '@classes/site'; +import { CoreSitesProvider, CoreSiteBasicInfo } from '@providers/sites'; +import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../providers/helper'; /** * Page that displays the space usage settings. @@ -34,20 +27,16 @@ import { CoreSite } from '@classes/site'; }) export class CoreSettingsSpaceUsagePage { - usageLoaded = false; + loaded = false; sites = []; currentSiteId = ''; - totalUsage = 0; - totalEntries = 0; + totals: CoreSiteSpaceUsage = { + cacheEntries: 0, + spaceUsage: 0 + }; - constructor(private filePoolProvider: CoreFilepoolProvider, - private eventsProvider: CoreEventsProvider, - private sitesProvider: CoreSitesProvider, - private filterProvider: CoreFilterProvider, - private translate: TranslateService, - private domUtils: CoreDomUtilsProvider, - appProvider: CoreAppProvider, - private courseProvider: CoreCourseProvider) { + constructor(protected sitesProvider: CoreSitesProvider, + protected settingsHelper: CoreSettingsHelper) { this.currentSiteId = this.sitesProvider.getCurrentSiteId(); } @@ -55,8 +44,8 @@ export class CoreSettingsSpaceUsagePage { * View loaded. */ ionViewDidLoad(): void { - this.fetchData().finally(() => { - this.usageLoaded = true; + this.calculateSizeUsage().finally(() => { + this.loaded = true; }); } @@ -65,154 +54,62 @@ export class CoreSettingsSpaceUsagePage { * * @return Resolved when done. */ - protected calculateSizeUsage(): Promise { + protected async calculateSizeUsage(): Promise { + // Calculate total usage. + let totalSize = 0, + totalEntries = 0; + return this.sitesProvider.getSortedSites().then((sites) => { this.sites = sites; // Get space usage. - const promises = this.sites.map((siteEntry) => { - return this.sitesProvider.getSite(siteEntry.id).then((site) => { - const proms2 = []; + return Promise.all(this.sites.map((site) => { + return this.settingsHelper.getSiteSpaceUsage(site.id).then((siteInfo) => { + site.cacheEntries = siteInfo.cacheEntries; + site.spaceUsage = siteInfo.spaceUsage; - proms2.push(this.calcSiteClearRows(site).then((rows) => { - siteEntry.cacheEntries = rows; - })); - - proms2.push(site.getSpaceUsage().then((size) => { - siteEntry.spaceUsage = size; - })); - - return Promise.all(proms2); + totalSize += (site.spaceUsage ? parseInt(site.spaceUsage, 10) : 0); + totalEntries += (site.cacheEntries ? parseInt(site.cacheEntries, 10) : 0); }); - }); - - return Promise.all(promises); + })); + }).then(() => { + this.totals.spaceUsage = totalSize; + this.totals.cacheEntries = totalEntries; }); } - /** - * Convenience function to calculate total usage. - */ - protected calculateTotalUsage(): void { - let totalSize = 0, - totalEntries = 0; - this.sites.forEach((site) => { - totalSize += (site.spaceUsage ? parseInt(site.spaceUsage, 10) : 0); - totalEntries += (site.cacheEntries ? parseInt(site.cacheEntries, 10) : 0); - }); - this.totalUsage = totalSize; - this.totalEntries = totalEntries; - } - - /** - * Convenience function to calculate space usage. - * - * @return Resolved when done. - */ - protected fetchData(): Promise { - const promises = [ - this.calculateSizeUsage().then(() => this.calculateTotalUsage()), - ]; - - return Promise.all(promises); - } - /** * Refresh the data. * * @param refresher Refresher. */ refreshData(refresher: any): void { - this.fetchData().finally(() => { + this.calculateSizeUsage().finally(() => { refresher.complete(); }); } - /** - * Convenience function to update site size, along with total usage. - * - * @param site Site object with space usage. - * @param newUsage New space usage of the site in bytes. - */ - protected updateSiteUsage(site: any, newUsage: number): void { - const oldUsage = site.spaceUsage; - site.spaceUsage = newUsage; - this.totalUsage -= oldUsage - newUsage; - } - - /** - * Calculate the number of rows to be deleted on a site. - * - * @param site Site object. - * @return If there are rows to delete or not. - */ - protected calcSiteClearRows(site: CoreSite): Promise { - const clearTables = this.sitesProvider.getSiteTableSchemasToClear(site); - - let totalEntries = 0; - - const promises = clearTables.map((name) => { - return site.getDb().countRecords(name).then((rows) => { - totalEntries += rows; - }); - }); - - return Promise.all(promises).then(() => { - return totalEntries; - }); - } - /** * Deletes files of a site and the tables that can be cleared. * * @param siteData Site object with space usage. */ - deleteSiteStorage(siteData: any): void { - this.filterProvider.formatText(siteData.siteName, {clean: true, singleLine: true, filter: false}, [], siteData.id) - .then((siteName) => { - - const title = this.translate.instant('core.settings.deletesitefilestitle'); - const message = this.translate.instant('core.settings.deletesitefiles', {sitename: siteName}); - - this.domUtils.showConfirm(message, title).then(() => { - return this.sitesProvider.getSite(siteData.id); - }).then((site) => { - - // Clear cache tables. - const cleanSchemas = this.sitesProvider.getSiteTableSchemasToClear(site); - const promises = cleanSchemas.map((name) => { - return site.getDb().deleteRecords(name); - }); - - promises.push(site.deleteFolder().then(() => { - this.filePoolProvider.clearAllPackagesStatus(site.id); - this.filePoolProvider.clearFilepool(site.id); - this.updateSiteUsage(siteData, 0); - this.courseProvider.clearAllCoursesStatus(site.id); - }).catch((error) => { - if (error && error.code === FileError.NOT_FOUND_ERR) { - // Not found, set size 0. - this.filePoolProvider.clearAllPackagesStatus(site.id); - this.updateSiteUsage(siteData, 0); - } else { - // Error, recalculate the site usage. - this.domUtils.showErrorModal('core.settings.errordeletesitefiles', true); - site.getSpaceUsage().then((size) => { - this.updateSiteUsage(siteData, size); - }); - } - }).finally(() => { - this.eventsProvider.trigger(CoreEventsProvider.SITE_STORAGE_DELETED, {}, site.getId()); - - this.calcSiteClearRows(site).then((rows) => { - siteData.cacheEntries = rows; - }); - })); - - return Promise.all(promises); - }).catch(() => { - // Ignore cancelled confirmation modal. - }); + deleteSiteStorage(siteData: CoreSiteBasicInfoWithUsage): void { + this.settingsHelper.deleteSiteStorage(siteData.siteName, siteData.id).then((newInfo) => { + this.totals.spaceUsage -= siteData.spaceUsage - newInfo.spaceUsage; + this.totals.spaceUsage -= siteData.cacheEntries - newInfo.cacheEntries; + siteData.spaceUsage = newInfo.spaceUsage; + siteData.cacheEntries = newInfo.cacheEntries; + }).catch(() => { + // Ignore cancelled confirmation modal. }); } } + +/** + * Basic site info with space usage and cache entries that can be erased. + */ +export interface CoreSiteBasicInfoWithUsage extends CoreSiteBasicInfo { + cacheEntries?: number; // Number of cached entries that can be cleared. + spaceUsage?: number; // Space used in this site. +} diff --git a/src/core/settings/providers/helper.ts b/src/core/settings/providers/helper.ts index 41b5ddd4d..2a0d698ef 100644 --- a/src/core/settings/providers/helper.ts +++ b/src/core/settings/providers/helper.ts @@ -18,14 +18,26 @@ import { CoreCronDelegate } from '@providers/cron'; import { CoreEventsProvider } from '@providers/events'; import { CoreFilepoolProvider } from '@providers/filepool'; import { CoreLoggerProvider } from '@providers/logger'; +import { CoreSite } from '@classes/site'; import { CoreSitesProvider } from '@providers/sites'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreConstants } from '@core/constants'; import { CoreConfigProvider } from '@providers/config'; +import { CoreFilterProvider } from '@core/filter/providers/filter'; +import { CoreDomUtilsProvider } from '@providers/utils/dom'; +import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreConfigConstants } from '../../../configconstants'; import { TranslateService } from '@ngx-translate/core'; import { CoreSite } from '@classes/site'; +/** + * Object with space usage and cache entries that can be erased. + */ +export interface CoreSiteSpaceUsage { + cacheEntries?: number; // Number of cached entries that can be cleared. + spaceUsage?: number; // Space used in this site. +} + /** * Settings helper service. */ @@ -34,10 +46,18 @@ export class CoreSettingsHelper { protected logger; protected syncPromises = {}; - constructor(loggerProvider: CoreLoggerProvider, private appProvider: CoreAppProvider, private cronDelegate: CoreCronDelegate, - private eventsProvider: CoreEventsProvider, private filePoolProvider: CoreFilepoolProvider, - private sitesProvider: CoreSitesProvider, private utils: CoreUtilsProvider, private translate: TranslateService, - private configProvider: CoreConfigProvider) { + constructor(loggerProvider: CoreLoggerProvider, + protected appProvider: CoreAppProvider, + protected cronDelegate: CoreCronDelegate, + protected domUtils: CoreDomUtilsProvider, + protected eventsProvider: CoreEventsProvider, + protected filePoolProvider: CoreFilepoolProvider, + protected sitesProvider: CoreSitesProvider, + protected utils: CoreUtilsProvider, + protected translate: TranslateService, + protected configProvider: CoreConfigProvider, + protected filterProvider: CoreFilterProvider, + protected courseProvider: CoreCourseProvider) { this.logger = loggerProvider.getInstance('CoreSettingsHelper'); if (!CoreConfigConstants.forceColorScheme) { @@ -63,6 +83,120 @@ export class CoreSettingsHelper { } } + /** + * Deletes files of a site and the tables that can be cleared. + * + * @param siteName Site Name. + * @param siteId: Site ID. + * @return Resolved with detailed new info when done. + */ + async deleteSiteStorage(siteName: string, siteId: string): Promise { + const siteInfo: CoreSiteSpaceUsage = { + cacheEntries: 0, + spaceUsage: 0 + }; + + return this.filterProvider.formatText(siteName, {clean: true, singleLine: true, filter: false}, [], siteId) + .then((siteName) => { + + const title = this.translate.instant('core.settings.deletesitefilestitle'); + const message = this.translate.instant('core.settings.deletesitefiles', {sitename: siteName}); + + return this.domUtils.showConfirm(message, title).then(() => { + return this.sitesProvider.getSite(siteId); + }).then((site) => { + + // Clear cache tables. + const cleanSchemas = this.sitesProvider.getSiteTableSchemasToClear(); + const promises = cleanSchemas.map((name) => { + return site.getDb().deleteRecords(name); + }); + + promises.push(site.deleteFolder().then(() => { + this.filePoolProvider.clearAllPackagesStatus(site.id); + this.filePoolProvider.clearFilepool(site.id); + this.courseProvider.clearAllCoursesStatus(site.id); + + siteInfo.spaceUsage = 0; + }).catch((error) => { + if (error && error.code === FileError.NOT_FOUND_ERR) { + // Not found, set size 0. + this.filePoolProvider.clearAllPackagesStatus(site.id); + siteInfo.spaceUsage = 0; + } else { + // Error, recalculate the site usage. + this.domUtils.showErrorModal('core.settings.errordeletesitefiles', true); + + return site.getSpaceUsage().then((size) => { + siteInfo.spaceUsage = size; + }); + } + }).then(() => { + this.eventsProvider.trigger(CoreEventsProvider.SITE_STORAGE_DELETED, {}, site.getId()); + + return this.calcSiteClearRows(site).then((rows) => { + siteInfo.cacheEntries = rows; + }); + })); + + return Promise.all(promises).then(() => { + return siteInfo; + }); + }); + }); + } + + /** + * Calculates each site's usage, and the total usage. + * + * @param siteId ID of the site. Current site if undefined. + * @return Resolved with detailed info when done. + */ + async getSiteSpaceUsage(siteId?: string): Promise { + return this.sitesProvider.getSite(siteId).then((site) => { + // Get space usage. + const promises = []; + const siteInfo: CoreSiteSpaceUsage = { + cacheEntries: 0, + spaceUsage: 0 + }; + + promises.push(this.calcSiteClearRows(site).then((rows) => { + siteInfo.cacheEntries = rows; + })); + + promises.push(site.getSpaceUsage().then((size) => { + siteInfo.spaceUsage = size; + })); + + return Promise.all(promises).then(() => { + return siteInfo; + }); + }); + } + + /** + * Calculate the number of rows to be deleted on a site. + * + * @param site Site object. + * @return If there are rows to delete or not. + */ + protected async calcSiteClearRows(site: CoreSite): Promise { + const clearTables = this.sitesProvider.getSiteTableSchemasToClear(); + + let totalEntries = 0; + + const promises = clearTables.map((name) => { + return site.getDb().countRecords(name).then((rows) => { + totalEntries += rows; + }); + }); + + return Promise.all(promises).then(() => { + return totalEntries; + }); + } + /** * Get a certain processor from a list of processors. * From 3140b1c9667929f98042ecbc8dc1bda08b77f05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 28 Jan 2020 15:41:46 +0100 Subject: [PATCH 3/7] MOBILE-3325 settings: Move sync site on site settings --- src/core/settings/pages/site/site.html | 14 +++-- src/core/settings/pages/site/site.ts | 60 ++++++++++++++++--- .../pages/synchronization/synchronization.ts | 13 ++-- 3 files changed, 69 insertions(+), 18 deletions(-) diff --git a/src/core/settings/pages/site/site.html b/src/core/settings/pages/site/site.html index ba1879057..31965d843 100644 --- a/src/core/settings/pages/site/site.html +++ b/src/core/settings/pages/site/site.html @@ -12,12 +12,12 @@
- +

{{siteInfo.fullname}}

{{ siteUrl }} -
+ @@ -30,10 +30,14 @@ - + -

{{ 'core.settings.synchronization' | translate }}

-
+

{{ 'core.settings.synchronization' | translate }}

+ + +

{{ 'core.sharedfiles.sharedfiles' | translate }}

diff --git a/src/core/settings/pages/site/site.ts b/src/core/settings/pages/site/site.ts index 5517736af..78a265e6c 100644 --- a/src/core/settings/pages/site/site.ts +++ b/src/core/settings/pages/site/site.ts @@ -16,9 +16,11 @@ import { Component, ViewChild } from '@angular/core'; import { IonicPage, NavParams, Platform } from 'ionic-angular'; import { CoreSettingsDelegate, CoreSettingsHandlerData } from '../../providers/delegate'; import { CoreSite } from '@classes/site'; -import { CoreSitesProvider } from '@providers/sites'; -import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../providers/helper'; +import { CoreEventsProvider } from '@providers/events'; +import { CoreSitesProvider, CoreSiteBasicInfo } from '@providers/sites'; +import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; +import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../providers/helper'; /** * Page that displays the list of site settings pages. @@ -35,7 +37,7 @@ export class CoreSiteSettingsPage { isIOS: boolean; selectedPage: string; currentSite: CoreSite; - siteInfo: any; + siteInfo: CoreSiteBasicInfo[] = []; siteName: string; siteUrl: string; spaceUsage: CoreSiteSpaceUsage = { @@ -43,10 +45,14 @@ export class CoreSiteSettingsPage { spaceUsage: 0 }; loaded = false; + protected sitesObserver: any; + protected isDestroyed = false; constructor(protected settingsDelegate: CoreSettingsDelegate, protected settingsHelper: CoreSettingsHelper, protected sitesProvider: CoreSitesProvider, + protected domUtils: CoreDomUtilsProvider, + protected eventsProvider: CoreEventsProvider, platorm: Platform, navParams: NavParams) { @@ -54,6 +60,11 @@ export class CoreSiteSettingsPage { this.selectedPage = navParams.get('page') || false; + this.sitesObserver = this.eventsProvider.on(CoreEventsProvider.SITE_UPDATED, (data) => { + if (data.siteId == this.currentSite.id) { + this.refreshData(); + } + }); } /** @@ -70,28 +81,54 @@ export class CoreSiteSettingsPage { } /** - * View loaded. + * Fetch Data. */ - protected async fetchData(): Promise { + protected async fetchData(): Promise { + const promises = []; + this.handlers = this.settingsDelegate.getHandlers(); this.currentSite = this.sitesProvider.getCurrentSite(); this.siteInfo = this.currentSite.getInfo(); this.siteName = this.currentSite.getSiteName(); this.siteUrl = this.currentSite.getURL(); - return this.settingsHelper.getSiteSpaceUsage(this.sitesProvider.getCurrentSiteId()).then((spaceUsage) => { + promises.push(this.settingsHelper.getSiteSpaceUsage(this.sitesProvider.getCurrentSiteId()).then((spaceUsage) => { this.spaceUsage = spaceUsage; + })); + + return Promise.all(promises); + } + + /** + * Syncrhonizes the site. + */ + synchronize(siteId: string): void { + // Using syncOnlyOnWifi false to force manual sync. + this.settingsHelper.synchronizeSite(false, this.currentSite.id).catch((error) => { + if (this.isDestroyed) { + return; + } + this.domUtils.showErrorModalDefault(error, 'core.settings.errorsyncsite', true); }); } + /** + * Returns true if site is beeing synchronized. + * + * @return True if site is beeing synchronized, false otherwise. + */ + isSynchronizing(): boolean { + return this.currentSite && !!this.settingsHelper.getSiteSyncPromise(this.currentSite.id); + } + /** * Refresh the data. * * @param refresher Refresher. */ - refreshData(refresher: any): void { + refreshData(refresher?: any): void { this.fetchData().finally(() => { - refresher.complete(); + refresher && refresher.complete(); }); } @@ -119,4 +156,11 @@ export class CoreSiteSettingsPage { this.splitviewCtrl.push(page, params); } + /** + * Page destroyed. + */ + ngOnDestroy(): void { + this.isDestroyed = true; + this.sitesObserver && this.sitesObserver.off(); + } } diff --git a/src/core/settings/pages/synchronization/synchronization.ts b/src/core/settings/pages/synchronization/synchronization.ts index c478c4ad8..97672e93e 100644 --- a/src/core/settings/pages/synchronization/synchronization.ts +++ b/src/core/settings/pages/synchronization/synchronization.ts @@ -36,11 +36,13 @@ export class CoreSettingsSynchronizationPage implements OnDestroy { sitesObserver: any; currentSiteId = ''; syncOnlyOnWifi = false; - isDestroyed = false; + protected isDestroyed = false; - constructor(private configProvider: CoreConfigProvider, private eventsProvider: CoreEventsProvider, - private sitesProvider: CoreSitesProvider, private domUtils: CoreDomUtilsProvider, - private settingsHelper: CoreSettingsHelper) { + constructor(protected configProvider: CoreConfigProvider, + protected eventsProvider: CoreEventsProvider, + protected sitesProvider: CoreSitesProvider, + protected domUtils: CoreDomUtilsProvider, + protected settingsHelper: CoreSettingsHelper) { this.currentSiteId = this.sitesProvider.getCurrentSiteId(); @@ -85,7 +87,8 @@ export class CoreSettingsSynchronizationPage implements OnDestroy { * @param siteId Site ID. */ synchronize(siteId: string): void { - this.settingsHelper.synchronizeSite(this.syncOnlyOnWifi, siteId).catch((error) => { + // Using syncOnlyOnWifi false to force manual sync. + this.settingsHelper.synchronizeSite(false, siteId).catch((error) => { if (this.isDestroyed) { return; } From 721f7c6f3664cca2ce5f04e115febf4967c92c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 28 Jan 2020 16:06:22 +0100 Subject: [PATCH 4/7] MOBILE-3325 settings: Move ios shared files to site settings --- src/core/mainmenu/pages/more/more.html | 16 ++++----- src/core/settings/pages/app/app.html | 10 +++--- src/core/settings/pages/site/site.html | 18 +++++----- src/core/settings/pages/site/site.ts | 33 ++++++++++++------- .../pages/space-usage/space-usage.html | 2 +- .../synchronization/synchronization.html | 4 +-- src/core/sharedfiles/pages/list/list.html | 2 +- src/core/sharedfiles/pages/list/list.ts | 2 ++ 8 files changed, 48 insertions(+), 39 deletions(-) diff --git a/src/core/mainmenu/pages/more/more.html b/src/core/mainmenu/pages/more/more.html index fa55b5103..349b956d6 100644 --- a/src/core/mainmenu/pages/more/more.html +++ b/src/core/mainmenu/pages/more/more.html @@ -17,39 +17,39 @@
-

{{ handler.title | translate}}

+

{{ handler.title | translate}}

{{handler.badge}}
-

{{ 'core.mainmenu.website' | translate }}

+

{{ 'core.mainmenu.website' | translate }}

-

{{ 'core.mainmenu.help' | translate }}

+

{{ 'core.mainmenu.help' | translate }}

-

{{ 'core.settings.sitesettings' | translate }}

+

{{ 'core.settings.sitesettings' | translate }}

-

{{ 'core.settings.appsettings' | translate }}

+

{{ 'core.settings.appsettings' | translate }}

-

{{ logoutLabel | translate }}

+

{{ logoutLabel | translate }}

diff --git a/src/core/settings/pages/app/app.html b/src/core/settings/pages/app/app.html index 90d11ade8..4d79ded29 100644 --- a/src/core/settings/pages/app/app.html +++ b/src/core/settings/pages/app/app.html @@ -10,23 +10,23 @@ -

{{ 'core.settings.general' | translate }}

+

{{ 'core.settings.general' | translate }}

-

{{ 'core.settings.spaceusage' | translate }}

+

{{ 'core.settings.spaceusage' | translate }}

-

{{ 'core.settings.synchronization' | translate }}

+

{{ 'core.settings.synchronization' | translate }}

-

{{ 'core.sharedfiles.sharedfiles' | translate }}

+

{{ 'core.sharedfiles.sharedfiles' | translate }}

-

{{ 'core.settings.about' | translate }}

+

{{ 'core.settings.about' | translate }}

diff --git a/src/core/settings/pages/site/site.html b/src/core/settings/pages/site/site.html index 31965d843..c511caa7b 100644 --- a/src/core/settings/pages/site/site.html +++ b/src/core/settings/pages/site/site.html @@ -12,20 +12,17 @@ - - +

{{siteInfo.fullname}}

{{ siteUrl }}
- +

{{ 'core.settings.spaceusage' | translate }}

-
-

{{ spaceUsage.spaceUsage | coreBytesToSize }}

-

{{ 'core.settings.entriesincache' | translate: { $a: spaceUsage.cacheEntries } }}

-
+

{{ spaceUsage.spaceUsage | coreBytesToSize }}

+

{{ 'core.settings.entriesincache' | translate: { $a: spaceUsage.cacheEntries } }}

@@ -38,14 +35,15 @@
- + -

{{ 'core.sharedfiles.sharedfiles' | translate }}

+

{{ 'core.sharedfiles.sharedfiles' | translate }}

+ {{ iosSharedFiles }}
-

{{ handler.title | translate}}

+

{{ handler.title | translate}}

diff --git a/src/core/settings/pages/site/site.ts b/src/core/settings/pages/site/site.ts index 78a265e6c..96616b2b1 100644 --- a/src/core/settings/pages/site/site.ts +++ b/src/core/settings/pages/site/site.ts @@ -15,11 +15,11 @@ import { Component, ViewChild } from '@angular/core'; import { IonicPage, NavParams, Platform } from 'ionic-angular'; import { CoreSettingsDelegate, CoreSettingsHandlerData } from '../../providers/delegate'; -import { CoreSite } from '@classes/site'; import { CoreEventsProvider } from '@providers/events'; import { CoreSitesProvider, CoreSiteBasicInfo } from '@providers/sites'; import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; +import { CoreSharedFilesProvider } from '@core/sharedfiles/providers/sharedfiles'; import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../providers/helper'; /** @@ -36,7 +36,7 @@ export class CoreSiteSettingsPage { handlers: CoreSettingsHandlerData[]; isIOS: boolean; selectedPage: string; - currentSite: CoreSite; + siteId: string; siteInfo: CoreSiteBasicInfo[] = []; siteName: string; siteUrl: string; @@ -45,7 +45,8 @@ export class CoreSiteSettingsPage { spaceUsage: 0 }; loaded = false; - protected sitesObserver: any; + iosSharedFiles: number; + protected sitesObserver: any; protected isDestroyed = false; constructor(protected settingsDelegate: CoreSettingsDelegate, @@ -53,6 +54,7 @@ export class CoreSiteSettingsPage { protected sitesProvider: CoreSitesProvider, protected domUtils: CoreDomUtilsProvider, protected eventsProvider: CoreEventsProvider, + protected sharedFilesProvider: CoreSharedFilesProvider, platorm: Platform, navParams: NavParams) { @@ -61,7 +63,7 @@ export class CoreSiteSettingsPage { this.selectedPage = navParams.get('page') || false; this.sitesObserver = this.eventsProvider.on(CoreEventsProvider.SITE_UPDATED, (data) => { - if (data.siteId == this.currentSite.id) { + if (data.siteId == this.siteId) { this.refreshData(); } }); @@ -87,15 +89,22 @@ export class CoreSiteSettingsPage { const promises = []; this.handlers = this.settingsDelegate.getHandlers(); - this.currentSite = this.sitesProvider.getCurrentSite(); - this.siteInfo = this.currentSite.getInfo(); - this.siteName = this.currentSite.getSiteName(); - this.siteUrl = this.currentSite.getURL(); + const currentSite = this.sitesProvider.getCurrentSite(); + this.siteId = currentSite.id; + this.siteInfo = currentSite.getInfo(); + this.siteName = currentSite.getSiteName(); + this.siteUrl = currentSite.getURL(); - promises.push(this.settingsHelper.getSiteSpaceUsage(this.sitesProvider.getCurrentSiteId()).then((spaceUsage) => { + promises.push(this.settingsHelper.getSiteSpaceUsage(this.siteId).then((spaceUsage) => { this.spaceUsage = spaceUsage; })); + if (this.isIOS) { + promises.push(this.sharedFilesProvider.getSiteSharedFiles(this.siteId).then((files) => { + this.iosSharedFiles = files.length; + })); + } + return Promise.all(promises); } @@ -104,7 +113,7 @@ export class CoreSiteSettingsPage { */ synchronize(siteId: string): void { // Using syncOnlyOnWifi false to force manual sync. - this.settingsHelper.synchronizeSite(false, this.currentSite.id).catch((error) => { + this.settingsHelper.synchronizeSite(false, this.siteId).catch((error) => { if (this.isDestroyed) { return; } @@ -118,7 +127,7 @@ export class CoreSiteSettingsPage { * @return True if site is beeing synchronized, false otherwise. */ isSynchronizing(): boolean { - return this.currentSite && !!this.settingsHelper.getSiteSyncPromise(this.currentSite.id); + return this.siteId && !!this.settingsHelper.getSiteSyncPromise(this.siteId); } /** @@ -138,7 +147,7 @@ export class CoreSiteSettingsPage { * @param siteData Site object with space usage. */ deleteSiteStorage(): void { - this.settingsHelper.deleteSiteStorage(this.currentSite.getSiteName(), this.currentSite.getId()).then((newInfo) => { + this.settingsHelper.deleteSiteStorage(this.siteName, this.siteId).then((newInfo) => { this.spaceUsage = newInfo; }).catch(() => { // Ignore cancelled confirmation modal. diff --git a/src/core/settings/pages/space-usage/space-usage.html b/src/core/settings/pages/space-usage/space-usage.html index 27c950fb0..e32dc0bc4 100644 --- a/src/core/settings/pages/space-usage/space-usage.html +++ b/src/core/settings/pages/space-usage/space-usage.html @@ -20,7 +20,7 @@ -

{{ 'core.settings.total' | translate }}

+

{{ 'core.settings.total' | translate }}

{{ totals.spaceUsage | coreBytesToSize }}

{{ 'core.settings.entriesincache' | translate: { $a: totals.cacheEntries } }}

diff --git a/src/core/settings/pages/synchronization/synchronization.html b/src/core/settings/pages/synchronization/synchronization.html index 3f7a6a2a1..839172551 100644 --- a/src/core/settings/pages/synchronization/synchronization.html +++ b/src/core/settings/pages/synchronization/synchronization.html @@ -6,7 +6,7 @@ -

{{ 'core.settings.syncsettings' | translate }}

+

{{ 'core.settings.syncsettings' | translate }}

{{ 'core.settings.enablesyncwifi' | translate }} @@ -14,7 +14,7 @@ -

{{ 'core.settings.sites' | translate }}

+

{{ 'core.settings.sites' | translate }}

diff --git a/src/core/sharedfiles/pages/list/list.html b/src/core/sharedfiles/pages/list/list.html index 5f210c99a..06bbf5228 100644 --- a/src/core/sharedfiles/pages/list/list.html +++ b/src/core/sharedfiles/pages/list/list.html @@ -14,7 +14,7 @@ - + diff --git a/src/core/sharedfiles/pages/list/list.ts b/src/core/sharedfiles/pages/list/list.ts index ec408963c..66c8b199c 100644 --- a/src/core/sharedfiles/pages/list/list.ts +++ b/src/core/sharedfiles/pages/list/list.ts @@ -35,6 +35,7 @@ export class CoreSharedFilesListPage implements OnInit, OnDestroy { isModal: boolean; manage: boolean; pick: boolean; // To pick a file you MUST use a modal. + showSitePicker: boolean; path = ''; title: string; filesLoaded: boolean; @@ -52,6 +53,7 @@ export class CoreSharedFilesListPage implements OnInit, OnDestroy { this.manage = !!navParams.get('manage'); this.pick = !!navParams.get('pick'); this.path = navParams.get('path') || ''; + this.showSitePicker = !navParams.get('hideSitePicker'); } /** From 7c9d8cddbcc935a4329116d9d3b1ee33a9dba347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 28 Jan 2020 16:49:57 +0100 Subject: [PATCH 5/7] MOBILE-3325 settings: Polish interface --- scripts/langindex.json | 4 +- .../messages/pages/settings/settings.html | 2 +- .../messages/providers/settings-handler.ts | 2 +- .../pages/settings/settings.html | 2 +- .../providers/settings-handler.ts | 2 +- src/app/app.scss | 3 ++ src/assets/lang/en.json | 6 ++- src/core/mainmenu/pages/more/more.html | 17 +++++---- src/core/mainmenu/pages/more/more.ts | 4 +- src/core/settings/lang/en.json | 4 +- src/core/settings/pages/site/site.html | 37 +++++++++--------- src/core/settings/pages/site/site.module.ts | 8 ++-- src/core/settings/pages/site/site.ts | 38 +++++++++++++++---- .../pages/space-usage/space-usage.html | 7 ++++ .../settings/pages/space-usage/space-usage.ts | 14 ++++++- .../synchronization/synchronization.html | 7 ++++ .../pages/synchronization/synchronization.ts | 12 +++++- src/core/settings/providers/helper.ts | 5 +-- 18 files changed, 123 insertions(+), 51 deletions(-) diff --git a/scripts/langindex.json b/scripts/langindex.json index c9e4446ad..0a13d4d3c 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -1941,6 +1941,7 @@ "core.settings.navigatoruseragent": "local_moodlemobileapp", "core.settings.networkstatus": "local_moodlemobileapp", "core.settings.opensourcelicenses": "local_moodlemobileapp", + "core.settings.preferences": "moodle", "core.settings.privacypolicy": "local_moodlemobileapp", "core.settings.publisher": "local_moodlemobileapp", "core.settings.pushid": "local_moodlemobileapp", @@ -1950,8 +1951,9 @@ "core.settings.showdownloadoptions": "local_moodlemobileapp", "core.settings.siteinfo": "local_moodlemobileapp", "core.settings.sites": "moodle", - "core.settings.sitesettings": "moodle", "core.settings.spaceusage": "local_moodlemobileapp", + "core.settings.spaceusagehelp": "local_moodlemobileapp", + "core.settings.synchelp": "local_moodlemobileapp", "core.settings.synchronization": "local_moodlemobileapp", "core.settings.synchronizenow": "local_moodlemobileapp", "core.settings.syncsettings": "local_moodlemobileapp", diff --git a/src/addon/messages/pages/settings/settings.html b/src/addon/messages/pages/settings/settings.html index 0172888d9..c955efb2e 100644 --- a/src/addon/messages/pages/settings/settings.html +++ b/src/addon/messages/pages/settings/settings.html @@ -1,6 +1,6 @@ - {{ 'addon.messages.messagepreferences' | translate }} + {{ 'addon.messages.messages' | translate }} diff --git a/src/addon/messages/providers/settings-handler.ts b/src/addon/messages/providers/settings-handler.ts index 6c4d35447..0375ec36b 100644 --- a/src/addon/messages/providers/settings-handler.ts +++ b/src/addon/messages/providers/settings-handler.ts @@ -44,7 +44,7 @@ export class AddonMessagesSettingsHandler implements CoreSettingsHandler { getDisplayData(): CoreSettingsHandlerData { return { icon: 'chatbubbles', - title: 'addon.messages.messagepreferences', + title: 'addon.messages.messages', page: 'AddonMessagesSettingsPage', class: 'addon-messages-settings-handler' }; diff --git a/src/addon/notifications/pages/settings/settings.html b/src/addon/notifications/pages/settings/settings.html index b6502c2c0..66c94edf3 100644 --- a/src/addon/notifications/pages/settings/settings.html +++ b/src/addon/notifications/pages/settings/settings.html @@ -1,6 +1,6 @@ - {{ 'addon.notifications.notificationpreferences' | translate }} + {{ 'addon.notifications.notifications' | translate }} diff --git a/src/addon/notifications/providers/settings-handler.ts b/src/addon/notifications/providers/settings-handler.ts index 95036ef59..b34f5f15f 100644 --- a/src/addon/notifications/providers/settings-handler.ts +++ b/src/addon/notifications/providers/settings-handler.ts @@ -49,7 +49,7 @@ export class AddonNotificationsSettingsHandler implements CoreSettingsHandler { getDisplayData(): CoreSettingsHandlerData { return { icon: 'notifications', - title: 'addon.notifications.notificationpreferences', + title: 'addon.notifications.notifications', page: 'AddonNotificationsSettingsPage', class: 'addon-notifications-settings-handler' }; diff --git a/src/app/app.scss b/src/app/app.scss index fbe62a90c..d7a61db1b 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -106,6 +106,9 @@ ion-app.app-root { .item h2 { text-overflow: inherit; overflow: inherit; + ion-icon, core-icon { + vertical-align: bottom; + } } .core-nav-item-selected, .item.core-nav-item-selected { diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 5b69400d2..daa597d0d 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -1941,6 +1941,7 @@ "core.settings.navigatoruseragent": "Navigator userAgent", "core.settings.networkstatus": "Internet connection status", "core.settings.opensourcelicenses": "Open Source Licences", + "core.settings.preferences": "Preferences", "core.settings.privacypolicy": "Privacy policy", "core.settings.publisher": "Publisher", "core.settings.pushid": "Push notifications ID", @@ -1950,8 +1951,9 @@ "core.settings.showdownloadoptions": "Show download options", "core.settings.siteinfo": "Site info", "core.settings.sites": "Sites", - "core.settings.sitesettings": "Site settings", "core.settings.spaceusage": "Space usage", + "core.settings.spaceusagehelp": "Deleting the stored information of the site will remove all the site offline data. This information allows you to use the app when offline. ", + "core.settings.synchelp": "Synchronising a site will send pending changes and all offline activity stored in the device and will synchronise some data like messages and notifications.", "core.settings.synchronization": "Synchronisation", "core.settings.synchronizenow": "Synchronise now", "core.settings.syncsettings": "Synchronisation settings", @@ -2079,4 +2081,4 @@ "core.yes": "Yes", "core.youreoffline": "You are offline", "core.youreonline": "You are back online" -} +} \ No newline at end of file diff --git a/src/core/mainmenu/pages/more/more.html b/src/core/mainmenu/pages/more/more.html index 349b956d6..608eb4915 100644 --- a/src/core/mainmenu/pages/more/more.html +++ b/src/core/mainmenu/pages/more/more.html @@ -39,17 +39,20 @@

{{ 'core.mainmenu.help' | translate }}

- - -

{{ 'core.settings.sitesettings' | translate }}

+
+ +

{{ 'core.settings.preferences' | translate }}

+ + +

{{ logoutLabel | translate }}

+
+ +

{{ 'core.settings.appsettings' | translate }}

- - -

{{ logoutLabel | translate }}

-
+
diff --git a/src/core/mainmenu/pages/more/more.ts b/src/core/mainmenu/pages/more/more.ts index 8f9bec1c8..864402eef 100644 --- a/src/core/mainmenu/pages/more/more.ts +++ b/src/core/mainmenu/pages/more/more.ts @@ -151,8 +151,8 @@ export class CoreMainMenuMorePage implements OnDestroy { /** * Open site settings page. */ - openSiteSettings(): void { - this.navCtrl.push('CoreSiteSettingsPage'); + openSitePreferences(): void { + this.navCtrl.push('CoreSitePreferencesPage'); } /** diff --git a/src/core/settings/lang/en.json b/src/core/settings/lang/en.json index fbb892251..1713ce651 100644 --- a/src/core/settings/lang/en.json +++ b/src/core/settings/lang/en.json @@ -57,11 +57,13 @@ "entriesincache": "{{$a}} entries in cache", "screen": "Screen information", "settings": "Settings", - "sitesettings": "Site settings", + "preferences": "Preferences", "showdownloadoptions": "Show download options", "siteinfo": "Site info", "sites": "Sites", "spaceusage": "Space usage", + "spaceusagehelp": "Deleting the stored information of the site will remove all the site offline data. This information allows you to use the app when offline. ", + "synchelp": "Synchronising a site will send pending changes and all offline activity stored in the device and will synchronise some data like messages and notifications.", "synchronization": "Synchronisation", "synchronizenow": "Synchronise now", "syncsettings": "Synchronisation settings", diff --git a/src/core/settings/pages/site/site.html b/src/core/settings/pages/site/site.html index c511caa7b..6c932d246 100644 --- a/src/core/settings/pages/site/site.html +++ b/src/core/settings/pages/site/site.html @@ -1,6 +1,6 @@ - {{ 'core.settings.sitesettings' | translate}} + {{ 'core.settings.preferences' | translate}} @@ -18,23 +18,6 @@ {{ siteUrl }} - - -

{{ 'core.settings.spaceusage' | translate }}

-

{{ spaceUsage.spaceUsage | coreBytesToSize }}

-

{{ 'core.settings.entriesincache' | translate: { $a: spaceUsage.cacheEntries } }}

- -
- - -

{{ 'core.settings.synchronization' | translate }}

- - -

{{ 'core.sharedfiles.sharedfiles' | translate }}

@@ -45,6 +28,24 @@

{{ handler.title | translate}}

+ + + +

{{ 'core.settings.spaceusage' | translate }}

+

{{ spaceUsage.spaceUsage | coreBytesToSize }}

+

{{ 'core.settings.entriesincache' | translate: { $a: spaceUsage.cacheEntries } }}

+ +
+ +

{{ 'core.settings.synchronizenow' | translate }}

+ + +
+
diff --git a/src/core/settings/pages/site/site.module.ts b/src/core/settings/pages/site/site.module.ts index 753dcbf37..2ce44ef26 100644 --- a/src/core/settings/pages/site/site.module.ts +++ b/src/core/settings/pages/site/site.module.ts @@ -15,21 +15,21 @@ import { NgModule } from '@angular/core'; import { IonicPageModule } from 'ionic-angular'; import { TranslateModule } from '@ngx-translate/core'; -import { CoreSiteSettingsPage } from './site'; +import { CoreSitePreferencesPage } from './site'; import { CoreComponentsModule } from '@components/components.module'; import { CoreDirectivesModule } from '@directives/directives.module'; import { CorePipesModule } from '@pipes/pipes.module'; @NgModule({ declarations: [ - CoreSiteSettingsPage + CoreSitePreferencesPage ], imports: [ CoreComponentsModule, CoreDirectivesModule, CorePipesModule, - IonicPageModule.forChild(CoreSiteSettingsPage), + IonicPageModule.forChild(CoreSitePreferencesPage), TranslateModule.forChild() ], }) -export class CoreSiteSettingsPageModule {} +export class CoreSitePreferencesPageModule {} diff --git a/src/core/settings/pages/site/site.ts b/src/core/settings/pages/site/site.ts index 96616b2b1..6f484dd44 100644 --- a/src/core/settings/pages/site/site.ts +++ b/src/core/settings/pages/site/site.ts @@ -14,6 +14,7 @@ import { Component, ViewChild } from '@angular/core'; import { IonicPage, NavParams, Platform } from 'ionic-angular'; +import { TranslateService } from '@ngx-translate/core'; import { CoreSettingsDelegate, CoreSettingsHandlerData } from '../../providers/delegate'; import { CoreEventsProvider } from '@providers/events'; import { CoreSitesProvider, CoreSiteBasicInfo } from '@providers/sites'; @@ -25,12 +26,12 @@ import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../providers/helper'; /** * Page that displays the list of site settings pages. */ -@IonicPage({segment: 'core-settings-site'}) +@IonicPage({segment: 'core-site-preferences'}) @Component({ - selector: 'page-core-settings-site', + selector: 'page-core-site-preferences', templateUrl: 'site.html', }) -export class CoreSiteSettingsPage { +export class CoreSitePreferencesPage { @ViewChild(CoreSplitViewComponent) splitviewCtrl: CoreSplitViewComponent; handlers: CoreSettingsHandlerData[]; @@ -55,6 +56,7 @@ export class CoreSiteSettingsPage { protected domUtils: CoreDomUtilsProvider, protected eventsProvider: CoreEventsProvider, protected sharedFilesProvider: CoreSharedFilesProvider, + protected translate: TranslateService, platorm: Platform, navParams: NavParams) { @@ -75,11 +77,17 @@ export class CoreSiteSettingsPage { ionViewDidLoad(): void { this.fetchData().finally(() => { this.loaded = true; - }); - if (this.selectedPage) { - this.openHandler(this.selectedPage); - } + if (this.selectedPage) { + this.openHandler(this.selectedPage); + } else if (this.splitviewCtrl.isOn()) { + if (this.isIOS) { + this.openHandler('CoreSharedFilesListPage', {manage: true, siteId: this.siteId, hideSitePicker: true}); + } else if (this.handlers.length > 0) { + this.openHandler(this.handlers[0].page, this.handlers[0].params); + } + } + }); } /** @@ -165,6 +173,22 @@ export class CoreSiteSettingsPage { this.splitviewCtrl.push(page, params); } + /** + * Show information about space usage actions. + */ + showSpaceInfo(): void { + this.domUtils.showAlert(this.translate.instant('core.help'), + this.translate.instant('core.settings.spaceusagehelp')); + } + + /** + * Show information about sync actions. + */ + showSyncInfo(): void { + this.domUtils.showAlert(this.translate.instant('core.help'), + this.translate.instant('core.settings.synchelp')); + } + /** * Page destroyed. */ diff --git a/src/core/settings/pages/space-usage/space-usage.html b/src/core/settings/pages/space-usage/space-usage.html index e32dc0bc4..29dac4705 100644 --- a/src/core/settings/pages/space-usage/space-usage.html +++ b/src/core/settings/pages/space-usage/space-usage.html @@ -1,8 +1,15 @@ {{ 'core.settings.spaceusage' | translate }} + + + + + diff --git a/src/core/settings/pages/space-usage/space-usage.ts b/src/core/settings/pages/space-usage/space-usage.ts index 3e6a74be2..31b3fd9a9 100644 --- a/src/core/settings/pages/space-usage/space-usage.ts +++ b/src/core/settings/pages/space-usage/space-usage.ts @@ -14,7 +14,9 @@ import { Component, } from '@angular/core'; import { IonicPage } from 'ionic-angular'; +import { TranslateService } from '@ngx-translate/core'; import { CoreSitesProvider, CoreSiteBasicInfo } from '@providers/sites'; +import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../providers/helper'; /** @@ -36,7 +38,9 @@ export class CoreSettingsSpaceUsagePage { }; constructor(protected sitesProvider: CoreSitesProvider, - protected settingsHelper: CoreSettingsHelper) { + protected settingsHelper: CoreSettingsHelper, + protected domUtils: CoreDomUtilsProvider, + protected translate: TranslateService) { this.currentSiteId = this.sitesProvider.getCurrentSiteId(); } @@ -104,6 +108,14 @@ export class CoreSettingsSpaceUsagePage { // Ignore cancelled confirmation modal. }); } + + /** + * Show information about space usage actions. + */ + showInfo(): void { + this.domUtils.showAlert(this.translate.instant('core.help'), + this.translate.instant('core.settings.spaceusagehelp')); + } } /** diff --git a/src/core/settings/pages/synchronization/synchronization.html b/src/core/settings/pages/synchronization/synchronization.html index 839172551..bb5b62e0f 100644 --- a/src/core/settings/pages/synchronization/synchronization.html +++ b/src/core/settings/pages/synchronization/synchronization.html @@ -1,8 +1,15 @@ {{ 'core.settings.synchronization' | translate }} + + + + + diff --git a/src/core/settings/pages/synchronization/synchronization.ts b/src/core/settings/pages/synchronization/synchronization.ts index 97672e93e..1a31b32e1 100644 --- a/src/core/settings/pages/synchronization/synchronization.ts +++ b/src/core/settings/pages/synchronization/synchronization.ts @@ -14,6 +14,7 @@ import { Component, OnDestroy } from '@angular/core'; import { IonicPage } from 'ionic-angular'; +import { TranslateService } from '@ngx-translate/core'; import { CoreConstants } from '@core/constants'; import { CoreEventsProvider } from '@providers/events'; import { CoreSitesProvider, CoreSiteBasicInfo } from '@providers/sites'; @@ -42,7 +43,8 @@ export class CoreSettingsSynchronizationPage implements OnDestroy { protected eventsProvider: CoreEventsProvider, protected sitesProvider: CoreSitesProvider, protected domUtils: CoreDomUtilsProvider, - protected settingsHelper: CoreSettingsHelper) { + protected settingsHelper: CoreSettingsHelper, + protected translate: TranslateService) { this.currentSiteId = this.sitesProvider.getCurrentSiteId(); @@ -106,6 +108,14 @@ export class CoreSettingsSynchronizationPage implements OnDestroy { return !!this.settingsHelper.getSiteSyncPromise(siteId); } + /** + * Show information about sync actions. + */ + showInfo(): void { + this.domUtils.showAlert(this.translate.instant('core.help'), + this.translate.instant('core.settings.synchelp')); + } + /** * Page destroyed. */ diff --git a/src/core/settings/providers/helper.ts b/src/core/settings/providers/helper.ts index 2a0d698ef..14b026588 100644 --- a/src/core/settings/providers/helper.ts +++ b/src/core/settings/providers/helper.ts @@ -28,7 +28,6 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreConfigConstants } from '../../../configconstants'; import { TranslateService } from '@ngx-translate/core'; -import { CoreSite } from '@classes/site'; /** * Object with space usage and cache entries that can be erased. @@ -107,7 +106,7 @@ export class CoreSettingsHelper { }).then((site) => { // Clear cache tables. - const cleanSchemas = this.sitesProvider.getSiteTableSchemasToClear(); + const cleanSchemas = this.sitesProvider.getSiteTableSchemasToClear(site); const promises = cleanSchemas.map((name) => { return site.getDb().deleteRecords(name); }); @@ -182,7 +181,7 @@ export class CoreSettingsHelper { * @return If there are rows to delete or not. */ protected async calcSiteClearRows(site: CoreSite): Promise { - const clearTables = this.sitesProvider.getSiteTableSchemasToClear(); + const clearTables = this.sitesProvider.getSiteTableSchemasToClear(site); let totalEntries = 0; From 496a0a42a6ed4a3f3ae841d526c15ab38366de18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 30 Jan 2020 09:48:43 +0100 Subject: [PATCH 6/7] MOBILE-3325 other: Change navPush string usage --- .../components/activitymodules/addon-block-activitymodules.html | 2 +- src/addon/files/pages/list/list.html | 2 +- .../mod/folder/components/index/addon-mod-folder-index.html | 2 +- .../mod/lesson/components/index/addon-mod-lesson-index.html | 2 +- src/addon/mod/quiz/components/index/addon-mod-quiz-index.html | 2 +- src/addon/mod/quiz/pages/attempt/attempt.html | 2 +- src/core/login/pages/credentials/credentials.html | 2 +- src/core/login/pages/site/site.html | 2 +- src/core/login/pages/sites/sites.html | 2 +- .../all-course-list/core-sitehome-all-course-list.html | 2 +- .../components/categories/core-sitehome-categories.html | 2 +- .../components/course-search/core-sitehome-course-search.html | 2 +- .../core-sitehome-enrolled-course-list.html | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/addon/block/activitymodules/components/activitymodules/addon-block-activitymodules.html b/src/addon/block/activitymodules/components/activitymodules/addon-block-activitymodules.html index 342e38924..fc407eb4b 100644 --- a/src/addon/block/activitymodules/components/activitymodules/addon-block-activitymodules.html +++ b/src/addon/block/activitymodules/components/activitymodules/addon-block-activitymodules.html @@ -2,7 +2,7 @@

{{ 'addon.block_activitymodules.pluginname' | translate }}

- + {{ entry.name }} diff --git a/src/addon/files/pages/list/list.html b/src/addon/files/pages/list/list.html index b119855ca..3b9207168 100644 --- a/src/addon/files/pages/list/list.html +++ b/src/addon/files/pages/list/list.html @@ -23,7 +23,7 @@ - +

{{file.filename}}

diff --git a/src/addon/mod/folder/components/index/addon-mod-folder-index.html b/src/addon/mod/folder/components/index/addon-mod-folder-index.html index eb68f6b4c..3f91c8cfc 100644 --- a/src/addon/mod/folder/components/index/addon-mod-folder-index.html +++ b/src/addon/mod/folder/components/index/addon-mod-folder-index.html @@ -17,7 +17,7 @@ - +

{{file.name}}

diff --git a/src/addon/mod/lesson/components/index/addon-mod-lesson-index.html b/src/addon/mod/lesson/components/index/addon-mod-lesson-index.html index 2bf84b83a..440d7f383 100644 --- a/src/addon/mod/lesson/components/index/addon-mod-lesson-index.html +++ b/src/addon/mod/lesson/components/index/addon-mod-lesson-index.html @@ -244,7 +244,7 @@ {{ 'addon.mod_lesson.overview' | translate }} - +

{{ student.fullname }}

diff --git a/src/addon/mod/quiz/components/index/addon-mod-quiz-index.html b/src/addon/mod/quiz/components/index/addon-mod-quiz-index.html index a522eae7b..88de59576 100644 --- a/src/addon/mod/quiz/components/index/addon-mod-quiz-index.html +++ b/src/addon/mod/quiz/components/index/addon-mod-quiz-index.html @@ -52,7 +52,7 @@ -
+ {{ 'addon.mod_quiz.preview' | translate }} {{ attempt.attempt }} diff --git a/src/addon/mod/quiz/pages/attempt/attempt.html b/src/addon/mod/quiz/pages/attempt/attempt.html index 2998605d7..791991ada 100644 --- a/src/addon/mod/quiz/pages/attempt/attempt.html +++ b/src/addon/mod/quiz/pages/attempt/attempt.html @@ -31,7 +31,7 @@

- diff --git a/src/core/login/pages/credentials/credentials.html b/src/core/login/pages/credentials/credentials.html index d2659a77f..a1b2f1069 100644 --- a/src/core/login/pages/credentials/credentials.html +++ b/src/core/login/pages/credentials/credentials.html @@ -3,7 +3,7 @@ {{ 'core.login.login' | translate }} - diff --git a/src/core/login/pages/site/site.html b/src/core/login/pages/site/site.html index ac2c2bae8..6a4b40f36 100644 --- a/src/core/login/pages/site/site.html +++ b/src/core/login/pages/site/site.html @@ -3,7 +3,7 @@ {{ 'core.login.connecttomoodle' | translate }} -