MOBILE-2895 file: Show download status on files
This commit is contained in:
		
							parent
							
								
									99809afbad
								
							
						
					
					
						commit
						5b5dcd8b79
					
				| @ -1,16 +1,13 @@ | |||||||
| ion-app.app-root core-download-refresh { | ion-app.app-root core-download-refresh { | ||||||
|  |     font-size: 1.4rem; | ||||||
|  | 
 | ||||||
|     button, ion-icon { |     button, ion-icon { | ||||||
|         cursor: pointer; |         cursor: pointer; | ||||||
|         pointer-events: auto; |         pointer-events: auto; | ||||||
|         text-align: center; |         text-align: center; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     .core-icon-downloaded { |     ion-icon, .core-icon-downloaded { | ||||||
|         font-size: 1.8em; |         font-size: 1.8em; | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
|     .spinner { |  | ||||||
|         /*@include position(null, 13px, null, null); |  | ||||||
|         position: absolute;*/ |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -3,13 +3,12 @@ | |||||||
|     <h2>{{fileName}}</h2> |     <h2>{{fileName}}</h2> | ||||||
|     <p *ngIf="fileSizeReadable">{{ fileSizeReadable }}</p> |     <p *ngIf="fileSizeReadable">{{ fileSizeReadable }}</p> | ||||||
|     <p *ngIf="showTime">{{ timemodified * 1000 | coreFormatDate }}</p> |     <p *ngIf="showTime">{{ timemodified * 1000 | coreFormatDate }}</p> | ||||||
|  | 
 | ||||||
|     <div class="buttons" item-end> |     <div class="buttons" item-end> | ||||||
|         <button ion-button clear icon-only (click)="download($event)" *ngIf="!isDownloading && showDownload" [attr.aria-label]="'core.download' | translate" color="dark"> |         <core-download-refresh [status]="state" [enabled]="canDownload" [loading]="isDownloading" [canTrustDownload]="!alwaysDownload" (action)="download()"></core-download-refresh> | ||||||
|             <ion-icon [name]="isDownloaded ? 'refresh' : 'cloud-download'"></ion-icon> | 
 | ||||||
|         </button> |  | ||||||
|         <button ion-button clear icon-only (click)="delete($event)" *ngIf="!isDownloading && canDelete" [attr.aria-label]="'core.delete' | translate" color="danger"> |         <button ion-button clear icon-only (click)="delete($event)" *ngIf="!isDownloading && canDelete" [attr.aria-label]="'core.delete' | translate" color="danger"> | ||||||
|             <ion-icon name="trash"></ion-icon> |             <ion-icon name="trash"></ion-icon> | ||||||
|         </button> |         </button> | ||||||
|     </div> |     </div> | ||||||
|     <ion-spinner *ngIf="isDownloading" item-end></ion-spinner> |  | ||||||
| </a> | </a> | ||||||
|  | |||||||
| @ -7,6 +7,10 @@ ion-app.app-root { | |||||||
|     .card-ios core-file + core-file > .item-ios.item-block > .item-inner, |     .card-ios core-file + core-file > .item-ios.item-block > .item-inner, | ||||||
|     core-file + core-file > .item-ios.item-block > .item-inner { |     core-file + core-file > .item-ios.item-block > .item-inner { | ||||||
|         border-top: $hairlines-width solid $list-ios-border-color; |         border-top: $hairlines-width solid $list-ios-border-color; | ||||||
|  |         .buttons { | ||||||
|  |             min-height: 53px; | ||||||
|  |             min-width: 58px; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     .card-wp core-file + core-file > .item-wp.item-block > .item-inner, |     .card-wp core-file + core-file > .item-wp.item-block > .item-inner, | ||||||
| @ -16,5 +20,16 @@ ion-app.app-root { | |||||||
| 
 | 
 | ||||||
|     core-file > .item.item-block > .item-inner { |     core-file > .item.item-block > .item-inner { | ||||||
|         border-bottom: 0; |         border-bottom: 0; | ||||||
|  |         @include padding(null, 0, null, null); | ||||||
|  |         .buttons { | ||||||
|  |             display: flex; | ||||||
|  |             flex-flow: row; | ||||||
|  |             align-items: center; | ||||||
|  |             z-index: 1; | ||||||
|  |             justify-content: space-around; | ||||||
|  |             align-content: center; | ||||||
|  |             min-height: 52px; | ||||||
|  |             min-width: 53px; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -44,9 +44,7 @@ export class CoreFileComponent implements OnInit, OnDestroy { | |||||||
|     @Input() showTime?: boolean | string = true; // Whether show file time modified.
 |     @Input() showTime?: boolean | string = true; // Whether show file time modified.
 | ||||||
|     @Output() onDelete?: EventEmitter<void>; // Will notify when the delete button is clicked.
 |     @Output() onDelete?: EventEmitter<void>; // Will notify when the delete button is clicked.
 | ||||||
| 
 | 
 | ||||||
|     isDownloaded: boolean; |  | ||||||
|     isDownloading: boolean; |     isDownloading: boolean; | ||||||
|     showDownload: boolean; |  | ||||||
|     fileIcon: string; |     fileIcon: string; | ||||||
|     fileName: string; |     fileName: string; | ||||||
|     fileSizeReadable: string; |     fileSizeReadable: string; | ||||||
| @ -110,13 +108,10 @@ export class CoreFileComponent implements OnInit, OnDestroy { | |||||||
|      */ |      */ | ||||||
|     protected calculateState(): Promise<void> { |     protected calculateState(): Promise<void> { | ||||||
|         return this.filepoolProvider.getFileStateByUrl(this.siteId, this.fileUrl, this.timemodified).then((state) => { |         return this.filepoolProvider.getFileStateByUrl(this.siteId, this.fileUrl, this.timemodified).then((state) => { | ||||||
|             const canDownload = this.sitesProvider.getCurrentSite().canDownloadFiles(); |             this.canDownload = this.sitesProvider.getCurrentSite().canDownloadFiles(); | ||||||
| 
 | 
 | ||||||
|             this.state = state; |             this.state = state; | ||||||
|             this.isDownloaded = state === CoreConstants.DOWNLOADED || state === CoreConstants.OUTDATED; |             this.isDownloading = this.canDownload && state === CoreConstants.DOWNLOADING; | ||||||
|             this.isDownloading = canDownload && state === CoreConstants.DOWNLOADING; |  | ||||||
|             this.showDownload = canDownload && (state === CoreConstants.NOT_DOWNLOADED || state === CoreConstants.OUTDATED || |  | ||||||
|                 (this.alwaysDownload && state === CoreConstants.DOWNLOADED)); |  | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -139,12 +134,12 @@ export class CoreFileComponent implements OnInit, OnDestroy { | |||||||
|     /** |     /** | ||||||
|      * Download a file and, optionally, open it afterwards. |      * Download a file and, optionally, open it afterwards. | ||||||
|      * |      * | ||||||
|      * @param {Event} e Click event. |      * @param {Event} [e] Click event. | ||||||
|      * @param {boolean} openAfterDownload Whether the file should be opened after download. |      * @param {boolean} openAfterDownload Whether the file should be opened after download. | ||||||
|      */ |      */ | ||||||
|     download(e: Event, openAfterDownload: boolean): void { |     download(e?: Event, openAfterDownload: boolean = false): void { | ||||||
|         e.preventDefault(); |         e && e.preventDefault(); | ||||||
|         e.stopPropagation(); |         e && e.stopPropagation(); | ||||||
| 
 | 
 | ||||||
|         let promise; |         let promise; | ||||||
| 
 | 
 | ||||||
| @ -168,7 +163,8 @@ export class CoreFileComponent implements OnInit, OnDestroy { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (!this.appProvider.isOnline() && (!openAfterDownload || (openAfterDownload && !this.isDownloaded))) { |         if (!this.appProvider.isOnline() && (!openAfterDownload || (openAfterDownload && | ||||||
|  |                 !(this.state === CoreConstants.DOWNLOADED || this.state === CoreConstants.OUTDATED)))) { | ||||||
|             this.domUtils.showErrorModal('core.networkerrormsg', true); |             this.domUtils.showErrorModal('core.networkerrormsg', true); | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user