Merge pull request #2317 from crazyserver/MOBILE-3269

Mobile 3269
main
Juan Leyva 2020-03-13 17:06:54 +01:00 committed by GitHub
commit 91e180a8b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 33 deletions

View File

@ -9,12 +9,12 @@
<ion-card-header>
<h1 text-wrap>{{ course.displayname }}</h1>
<p text-wrap>{{ 'addon.storagemanager.info' | translate }}</p>
<ion-item no-padding padding-top>
<ion-row class="size">
<ion-icon name="cube"></ion-icon>
{{ 'addon.storagemanager.storageused' | translate }}
{{ totalSize | coreBytesToSize }}
</ion-row>
<ion-item no-padding padding-top class="size" text-wrap>
<ion-icon name="cube" item-start></ion-icon>
<h2 text-wrap>{{ 'addon.storagemanager.storageused' | translate }}</h2>
<div item-end>
<p text-end>{{ totalSize | coreBytesToSize }}</p>
</div>
<button ion-button icon-only item-end no-padding (click)="deleteForCourse()" [disabled]="totalSize == 0">
<core-icon name="trash" label="{{ 'addon.storagemanager.deletecourse' | translate }}"></core-icon>
</button>
@ -25,13 +25,11 @@
<ion-card *ngIf="section.totalSize > 0" class="section">
<ion-card-header>
<ion-item no-padding>
<ion-row>
<h2 text-wrap>{{ section.name }}</h2>
</ion-row>
<ion-row class="size">
<ion-icon name="cube"></ion-icon>
<h2 text-wrap>{{ section.name }}</h2>
<p>
<ion-icon name="cube" item-start></ion-icon>
{{ section.totalSize | coreBytesToSize }}
</ion-row>
</p>
<button ion-button icon-only item-end no-padding (click)="deleteForSection(section)">
<core-icon name="trash" label="{{ 'addon.storagemanager.deletedatafrom' | translate: { name: section.name } }}"></core-icon>
</button>
@ -39,21 +37,20 @@
</ion-card-header>
<ion-card-content>
<ng-container *ngFor="let module of section.modules">
<div *ngIf="module.totalSize > 0">
<ion-item no-padding>
<ion-row class="{{module.handlerData.class}}">
<img *ngIf="module.handlerData.icon" [src]="module.handlerData.icon" alt="" role="presentation" class="core-module-icon"
>{{ module.name }}
</ion-row>
<ion-row class="size">
<ion-icon name="cube"></ion-icon>
{{ module.totalSize | coreBytesToSize }}
</ion-row>
<button ion-button icon-only outline item-end (click)="deleteForModule(module)">
<core-icon name="trash" label="{{ 'addon.storagemanager.deletedatafrom' | translate: { name: module.name } }}"></core-icon>
</button>
</ion-item>
</div>
<ion-item no-padding *ngIf="module.totalSize > 0">
<h2 class="{{module.handlerData.class}} addon-storagemanager-module-size">
<img *ngIf="module.handlerData.icon" [src]="module.handlerData.icon" alt="" role="presentation" class="core-module-icon"
>
{{ module.name }}
</h2>
<p>
<ion-icon name="cube" item-start></ion-icon>
{{ module.totalSize | coreBytesToSize }}
</p>
<button ion-button icon-only outline item-end (click)="deleteForModule(module)">
<core-icon name="trash" label="{{ 'addon.storagemanager.deletedatafrom' | translate: { name: module.name } }}"></core-icon>
</button>
</ion-item>
</ng-container>
</ion-card-content>
</ion-card>

View File

@ -13,12 +13,7 @@ ion-app.app-root page-addon-storagemanager-course-storage {
font-weight: bold;
font-size: 2rem;
}
.size {
margin-top: 4px;
}
.size ion-icon {
margin-right: 4px;
}
.core-module-icon {
margin-right: 4px;
width: 16px;

View File

@ -19,6 +19,7 @@ import { CoreCourseModulePrefetchDelegate } from '@core/course/providers/module-
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { TranslateService } from '@ngx-translate/core';
import { CoreConstants } from '@core/constants';
/**
* Page that displays the amount of file storage used by each activity on the course, and allows
@ -84,6 +85,10 @@ export class AddonStorageManagerCourseStoragePage {
Promise.all(allPromises).then(() => {
this.loaded = true;
if (this.totalSize == 0) {
this.markCourseAsNotDownloaded();
}
});
});
}
@ -162,6 +167,25 @@ export class AddonStorageManagerCourseStoragePage {
modal.dismiss();
this.domUtils.showErrorModalDefault(error, this.translate.instant('core.errordeletefile'));
}).finally(() => {
// @TODO This is a workaround that should be more specific solving MOBILE-3305.
// Also should take into account all modules are not downloaded.
// Mark course as not downloaded if course size is 0.
if (this.totalSize == 0) {
this.markCourseAsNotDownloaded();
}
});
}
/**
* Mark course as not downloaded.
*/
protected markCourseAsNotDownloaded(): void {
// @TODO This is a workaround that should be more specific solving MOBILE-3305.
// Also should take into account all modules are not downloaded.
// Check after MOBILE-3188 is integrated.
this.courseProvider.setCourseStatus(this.course.id, CoreConstants.NOT_DOWNLOADED);
}
}

View File

@ -490,6 +490,7 @@ export class CoreTabsComponent implements OnInit, AfterViewInit, OnChanges, OnDe
this.originalTabsContainer.style.paddingBottom = this.tabBarHeight + 'px';
this.tabBarElement.classList.remove('tabs-hidden');
this.tabsShown = true;
this.lastScroll = 0;
return;
}