commit
b6e6a3c32b
|
@ -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, Input, OnInit, OnDestroy, ElementRef } from '@angular/core';
|
import { Component, Input, OnChanges, OnDestroy, ElementRef, SimpleChange } from '@angular/core';
|
||||||
import { Config } from 'ionic-angular';
|
import { Config } from 'ionic-angular';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,7 @@ import { Config } from 'ionic-angular';
|
||||||
selector: 'core-icon',
|
selector: 'core-icon',
|
||||||
templateUrl: 'core-icon.html',
|
templateUrl: 'core-icon.html',
|
||||||
})
|
})
|
||||||
export class CoreIconComponent implements OnInit, OnDestroy {
|
export class CoreIconComponent implements OnChanges, OnDestroy {
|
||||||
// Common params.
|
// Common params.
|
||||||
@Input() name: string;
|
@Input() name: string;
|
||||||
@Input('color') color?: string;
|
@Input('color') color?: string;
|
||||||
|
@ -49,9 +49,15 @@ export class CoreIconComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component being initialized.
|
* Detect changes on input properties.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnChanges(changes: {[name: string]: SimpleChange}): void {
|
||||||
|
if (!changes.name || !this.name) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const oldElement = this.newElement ? this.newElement : this.element;
|
||||||
|
|
||||||
// Use a new created element to avoid ion-icon working.
|
// Use a new created element to avoid ion-icon working.
|
||||||
// This is necessary to make the FontAwesome stuff work.
|
// This is necessary to make the FontAwesome stuff work.
|
||||||
// It is also required to stop Ionic overriding the aria-label attribute.
|
// It is also required to stop Ionic overriding the aria-label attribute.
|
||||||
|
@ -99,7 +105,7 @@ export class CoreIconComponent implements OnInit, OnDestroy {
|
||||||
this.newElement.classList.add('icon-slash');
|
this.newElement.classList.add('icon-slash');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.element.parentElement.replaceChild(this.newElement, this.element);
|
oldElement.parentElement.replaceChild(this.newElement, oldElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -114,7 +114,7 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
if (this.downloadCourseEnabled) {
|
if (this.downloadCourseEnabled) {
|
||||||
// Listen for changes in course status.
|
// Listen for changes in course status.
|
||||||
this.courseStatusObserver = eventsProvider.on(CoreEventsProvider.COURSE_STATUS_CHANGED, (data) => {
|
this.courseStatusObserver = eventsProvider.on(CoreEventsProvider.COURSE_STATUS_CHANGED, (data) => {
|
||||||
if (data.courseId == this.course.id) {
|
if (data.courseId == this.course.id || data.courseId == CoreCourseProvider.ALL_COURSES_CLEARED) {
|
||||||
this.updateCourseStatus(data.status);
|
this.updateCourseStatus(data.status);
|
||||||
}
|
}
|
||||||
}, sitesProvider.getCurrentSiteId());
|
}, sitesProvider.getCurrentSiteId());
|
||||||
|
|
|
@ -38,6 +38,7 @@ export class CoreCourseProvider {
|
||||||
static STEALTH_MODULES_SECTION_ID = -1;
|
static STEALTH_MODULES_SECTION_ID = -1;
|
||||||
static ACCESS_GUEST = 'courses_access_guest';
|
static ACCESS_GUEST = 'courses_access_guest';
|
||||||
static ACCESS_DEFAULT = 'courses_access_default';
|
static ACCESS_DEFAULT = 'courses_access_default';
|
||||||
|
static ALL_COURSES_CLEARED = -1;
|
||||||
|
|
||||||
static COMPLETION_TRACKING_NONE = 0;
|
static COMPLETION_TRACKING_NONE = 0;
|
||||||
static COMPLETION_TRACKING_MANUAL = 1;
|
static COMPLETION_TRACKING_MANUAL = 1;
|
||||||
|
@ -158,7 +159,7 @@ export class CoreCourseProvider {
|
||||||
this.logger.debug('Clear all course status for site ' + site.id);
|
this.logger.debug('Clear all course status for site ' + site.id);
|
||||||
|
|
||||||
return site.getDb().deleteRecords(this.COURSE_STATUS_TABLE).then(() => {
|
return site.getDb().deleteRecords(this.COURSE_STATUS_TABLE).then(() => {
|
||||||
this.triggerCourseStatusChanged(-1, CoreConstants.NOT_DOWNLOADED, site.id);
|
this.triggerCourseStatusChanged(CoreCourseProvider.ALL_COURSES_CLEARED, CoreConstants.NOT_DOWNLOADED, site.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
// Listen for status change in course.
|
// Listen for status change in course.
|
||||||
this.courseStatusObserver = this.eventsProvider.on(CoreEventsProvider.COURSE_STATUS_CHANGED, (data) => {
|
this.courseStatusObserver = this.eventsProvider.on(CoreEventsProvider.COURSE_STATUS_CHANGED, (data) => {
|
||||||
if (data.courseId == this.course.id) {
|
if (data.courseId == this.course.id || data.courseId == CoreCourseProvider.ALL_COURSES_CLEARED) {
|
||||||
this.updateCourseStatus(data.status);
|
this.updateCourseStatus(data.status);
|
||||||
}
|
}
|
||||||
}, this.sitesProvider.getCurrentSiteId());
|
}, this.sitesProvider.getCurrentSiteId());
|
||||||
|
|
|
@ -81,7 +81,7 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
||||||
if (this.downloadCourseEnabled) {
|
if (this.downloadCourseEnabled) {
|
||||||
// Listen for status change in course.
|
// Listen for status change in course.
|
||||||
this.courseStatusObserver = this.eventsProvider.on(CoreEventsProvider.COURSE_STATUS_CHANGED, (data) => {
|
this.courseStatusObserver = this.eventsProvider.on(CoreEventsProvider.COURSE_STATUS_CHANGED, (data) => {
|
||||||
if (data.courseId == this.course.id) {
|
if (data.courseId == this.course.id || data.courseId == CoreCourseProvider.ALL_COURSES_CLEARED) {
|
||||||
this.updateCourseStatus(data.status);
|
this.updateCourseStatus(data.status);
|
||||||
}
|
}
|
||||||
}, this.sitesProvider.getCurrentSiteId());
|
}, this.sitesProvider.getCurrentSiteId());
|
||||||
|
|
|
@ -20,6 +20,7 @@ import { CoreFilepoolProvider } from '@providers/filepool';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
|
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays the space usage settings.
|
* Page that displays the space usage settings.
|
||||||
|
@ -39,7 +40,8 @@ export class CoreSettingsSpaceUsagePage {
|
||||||
|
|
||||||
constructor(private filePoolProvider: CoreFilepoolProvider,
|
constructor(private filePoolProvider: CoreFilepoolProvider,
|
||||||
private sitesProvider: CoreSitesProvider, private textUtils: CoreTextUtilsProvider,
|
private sitesProvider: CoreSitesProvider, private textUtils: CoreTextUtilsProvider,
|
||||||
private translate: TranslateService, private domUtils: CoreDomUtilsProvider, appProvider: CoreAppProvider) {
|
private translate: TranslateService, private domUtils: CoreDomUtilsProvider, appProvider: CoreAppProvider,
|
||||||
|
private courseProvider: CoreCourseProvider) {
|
||||||
this.currentSiteId = this.sitesProvider.getCurrentSiteId();
|
this.currentSiteId = this.sitesProvider.getCurrentSiteId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +180,7 @@ export class CoreSettingsSpaceUsagePage {
|
||||||
this.filePoolProvider.clearAllPackagesStatus(site.id);
|
this.filePoolProvider.clearAllPackagesStatus(site.id);
|
||||||
this.filePoolProvider.clearFilepool(site.id);
|
this.filePoolProvider.clearFilepool(site.id);
|
||||||
this.updateSiteUsage(siteData, 0);
|
this.updateSiteUsage(siteData, 0);
|
||||||
|
this.courseProvider.clearAllCoursesStatus(site.id);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (error && error.code === FileError.NOT_FOUND_ERR) {
|
if (error && error.code === FileError.NOT_FOUND_ERR) {
|
||||||
// Not found, set size 0.
|
// Not found, set size 0.
|
||||||
|
|
|
@ -2573,7 +2573,7 @@ export class CoreFilepoolProvider {
|
||||||
// Some Android devices restrict the amount of usable storage using quotas.
|
// Some Android devices restrict the amount of usable storage using quotas.
|
||||||
// If this quota would be exceeded by the download, it throws an exception.
|
// If this quota would be exceeded by the download, it throws an exception.
|
||||||
// We catch this exception here, and report a meaningful error message to the user.
|
// We catch this exception here, and report a meaningful error message to the user.
|
||||||
if (errorObject instanceof FileTransferError && errorObject.exception.includes('EDQUOT')) {
|
if (errorObject instanceof FileTransferError && errorObject.exception && errorObject.exception.includes('EDQUOT')) {
|
||||||
errorMessage = 'core.course.insufficientavailablequota';
|
errorMessage = 'core.course.insufficientavailablequota';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,17 +84,19 @@ export class CoreUtilsProvider {
|
||||||
return new Promise((resolve, reject): void => {
|
return new Promise((resolve, reject): void => {
|
||||||
const total = promises.length;
|
const total = promises.length;
|
||||||
let count = 0,
|
let count = 0,
|
||||||
|
hasFailed = false,
|
||||||
error;
|
error;
|
||||||
|
|
||||||
promises.forEach((promise) => {
|
promises.forEach((promise) => {
|
||||||
promise.catch((err) => {
|
promise.catch((err) => {
|
||||||
|
hasFailed = true;
|
||||||
error = err;
|
error = err;
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (count === total) {
|
if (count === total) {
|
||||||
// All promises have finished, reject/resolve.
|
// All promises have finished, reject/resolve.
|
||||||
if (error) {
|
if (hasFailed) {
|
||||||
reject(error);
|
reject(error);
|
||||||
} else {
|
} else {
|
||||||
resolve();
|
resolve();
|
||||||
|
|
Loading…
Reference in New Issue