-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module:upload): add picture preview
close #9
- Loading branch information
1 parent
b8a03fd
commit 7c7e40d
Showing
8 changed files
with
232 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,58 @@ | ||
<div #upload class="x-upload" [class.x-disabled]="disabled"> | ||
<div class="x-upload-buttons"> | ||
<x-button icon="fto-upload" [disabled]="disabled" (click)="uploadClick()" type="primary">{{ 'upload.uploadText' | xI18n }}</x-button> | ||
<div #upload class="x-upload x-upload-{{ type }}" [class.x-disabled]="disabled"> | ||
<input type="file" #file (change)="change($event)" [attr.accept]="accept" [multiple]="multiple" style="display: none" /> | ||
<div class="x-upload-buttons" [class.x-upload-buttons-template]="isTemplateLabel" (click)="uploadClick()"> | ||
<ng-container *xOutlet="getLabel"> | ||
<x-button icon="fto-upload" [disabled]="disabled" type="primary">{{ getLabel }}</x-button> | ||
</ng-container> | ||
</div> | ||
<input type="file" #file (change)="change($event)" [attr.accept]="accept" [multiple]="multiple" style="display: none;" /> | ||
<ul class="x-upload-files"> | ||
<li *ngFor="let file of files; index as i; trackBy: trackByItem"> | ||
<a [href]="file.url" target="_blank" [title]="file.name"> | ||
<x-icon type="fto-file-text"></x-icon> | ||
<span class="x-upload-filename">{{ file.name }}</span> | ||
</a> | ||
<ng-container [ngSwitch]="file.state"> | ||
<x-icon class="x-upload-state" *ngSwitchCase="'ready'" type="fto-clock"></x-icon> | ||
<span class="x-upload-percent" *ngSwitchCase="'uploading'">{{ file.percent }}%</span> | ||
<x-icon class="x-upload-state success" *ngSwitchCase="'success'" type="fto-check"></x-icon> | ||
<x-icon class="x-upload-state error" *ngSwitchCase="'error'" type="fto-info"></x-icon> | ||
</ng-container> | ||
<x-button *ngIf="file.state !== 'uploading'" icon="fto-x" (click)="remove(file, i)" onlyIcon closable></x-button> | ||
</li> | ||
</ul> | ||
<ng-container [ngSwitch]="type"> | ||
<ng-container *ngSwitchCase="'list'"> | ||
<ul class="x-upload-files"> | ||
<li *ngFor="let file of files; index as i; trackBy: trackByItem"> | ||
<a [href]="file.url" target="_blank" [title]="file.name"> | ||
<x-icon type="fto-file-text"></x-icon> | ||
<span class="x-upload-filename">{{ file.name }}</span> | ||
</a> | ||
<ng-container [ngSwitch]="file.state"> | ||
<x-icon class="x-upload-state" *ngSwitchCase="'ready'" type="fto-clock"></x-icon> | ||
<span class="x-upload-percent" *ngSwitchCase="'uploading'">{{ file.percent }}%</span> | ||
<x-icon class="x-upload-state success" *ngSwitchCase="'success'" type="fto-check"></x-icon> | ||
<x-icon class="x-upload-state error" *ngSwitchCase="'error'" type="fto-info"></x-icon> | ||
</ng-container> | ||
<x-button *ngIf="file.state !== 'uploading'" icon="fto-x" (click)="remove(file, i)" onlyIcon closable></x-button> | ||
</li> | ||
</ul> | ||
</ng-container> | ||
<ng-container *ngSwitchCase="'img'"> | ||
<div class="x-upload-img-item" *ngFor="let file of files; index as i; trackBy: trackByItem" [title]="file.name"> | ||
<div class="x-upload-img-inner"> | ||
<img [src]="file.url" /> | ||
</div> | ||
<div class="x-upload-img-btns"> | ||
<div class="x-upload-img-btns-inner"> | ||
<ng-container [ngSwitch]="file.state"> | ||
<x-icon class="x-upload-state" *ngSwitchCase="'ready'" type="fto-clock"></x-icon> | ||
<span class="x-upload-percent" *ngSwitchCase="'uploading'">{{ file.percent }}%</span> | ||
<x-icon class="x-upload-state error" *ngSwitchCase="'error'" type="fto-info"></x-icon> | ||
<a [href]="file.url" target="_blank" *ngSwitchCase="'success'"> | ||
<x-icon type="fto-eye"></x-icon> | ||
</a> | ||
</ng-container> | ||
<x-icon *ngIf="file.state !== 'uploading'" type="fto-trash-2" (click)="remove(file, i)"></x-icon> | ||
</div> | ||
</div> | ||
<!-- <a [href]="file.url" target="_blank" [title]="file.name"> | ||
<x-icon type="fto-file-text"></x-icon> | ||
<span class="x-upload-filename">{{ file.name }}</span> | ||
</a> | ||
<ng-container [ngSwitch]="file.state"> | ||
<x-icon class="x-upload-state" *ngSwitchCase="'ready'" type="fto-clock"></x-icon> | ||
<span class="x-upload-percent" *ngSwitchCase="'uploading'">{{ file.percent }}%</span> | ||
<x-icon class="x-upload-state success" *ngSwitchCase="'success'" type="fto-check"></x-icon> | ||
<x-icon class="x-upload-state error" *ngSwitchCase="'error'" type="fto-info"></x-icon> | ||
</ng-container> | ||
<x-button *ngIf="file.state !== 'uploading'" icon="fto-x" (click)="remove(file, i)" onlyIcon closable></x-button> --> | ||
</div> | ||
</ng-container> | ||
</ng-container> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters