MOBILE-3833 module-summary: format file size to readable size only when requires it
parent
771ee90d6a
commit
ab95e1d759
|
@ -153,7 +153,7 @@
|
|||
</ion-list>
|
||||
</ion-card>
|
||||
|
||||
<ion-card *ngIf="(canPrefetch && displayOptions.displayPrefetch) || (sizeReadable && displayOptions.displaySize)">
|
||||
<ion-card *ngIf="(canPrefetch && displayOptions.displayPrefetch) || (size && displayOptions.displaySize)">
|
||||
<ion-item lines="full" class="ion-text-wrap card-header">
|
||||
<ion-label>
|
||||
<h2>
|
||||
|
@ -162,13 +162,13 @@
|
|||
</h2>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
<ion-item *ngIf="sizeReadable && displayOptions.displaySize" class="ion-text-wrap">
|
||||
<ion-item *ngIf="size && displayOptions.displaySize" class="ion-text-wrap">
|
||||
<ion-label>
|
||||
<p class="item-heading ion-text-wrap">{{ 'addon.storagemanager.totalspaceusage' | translate }}</p>
|
||||
<ion-badge color="light">{{ sizeReadable | coreBytesToSize }}</ion-badge>
|
||||
<ion-badge color="light">{{ size | coreBytesToSize }}</ion-badge>
|
||||
</ion-label>
|
||||
<ion-button *ngIf="!removeFilesLoading" [disabled]="prefetchLoading" (click)="removeFiles()" color="danger" fill="clear"
|
||||
[attr.aria-label]="'core.clearstoreddata' | translate:{$a: sizeReadable}" slot="end">
|
||||
[attr.aria-label]="'core.clearstoreddata' | translate:{$a: size | coreBytesToSize}" slot="end">
|
||||
<ion-icon name="fas-trash" slot="icon-only" aria-hidden="true"></ion-icon>
|
||||
</ion-button>
|
||||
<ion-spinner *ngIf="removeFilesLoading" slot="end" aria-hidden="true"></ion-spinner>
|
||||
|
|
|
@ -62,7 +62,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
|
|||
prefetchLoading = false;
|
||||
canPrefetch = false;;
|
||||
prefetchDisabled = false;
|
||||
sizeReadable = '';
|
||||
size?: number; // Size in bytes
|
||||
downloadTimeReadable = ''; // Last download time in a readable format.
|
||||
grades?: CoreGradesFormattedRow[];
|
||||
blog = false; // If blog is available.
|
||||
|
@ -137,7 +137,9 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
|
|||
|
||||
const moduleSize = await CoreCourseModulePrefetchDelegate.getModuleStoredSize(this.module, this.courseId);
|
||||
|
||||
this.sizeReadable = moduleSize > 0 ? CoreTextUtils.bytesToSize(moduleSize, 2) : '';
|
||||
if (moduleSize) {
|
||||
this.size = moduleSize;
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
this.fileStatusObserver = CoreEvents.on(
|
||||
|
@ -211,9 +213,9 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
|
|||
this.prefetchDisabled = moduleInfo.status == CoreConstants.DOWNLOADED;
|
||||
}
|
||||
|
||||
this.sizeReadable = moduleInfo.size && moduleInfo.size > 0
|
||||
? moduleInfo.sizeReadable
|
||||
: '';
|
||||
if (moduleInfo.size && moduleInfo.size > 0) {
|
||||
this.size = moduleInfo.size;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue