|
1 | 1 | <style> |
2 | | - .my-drop-zone { border: dotted 3px lightgray; } |
3 | | - .nv-file-over { border: dotted 3px red; } /* Default class applied to drop zones on over */ |
4 | | - .another-file-over-class { border: dotted 3px green; } |
5 | | - html, body { height: 100%; } |
| 2 | + .my-drop-zone { border: dotted 3px lightgray; } |
| 3 | + .nv-file-over { border: dotted 3px red; } /* Default class applied to drop zones on over */ |
| 4 | + .another-file-over-class { border: dotted 3px green; } |
| 5 | + html, body { height: 100%; } |
6 | 6 | </style> |
7 | 7 |
|
8 | 8 | <div class="container p-0"> |
9 | 9 |
|
10 | | - <div class="navbar"> |
11 | | - <div class="navbar-header"> |
12 | | - <a class="navbar-brand" href>Angular2 File Upload</a> |
13 | | - </div> |
| 10 | + <div class="navbar"> |
| 11 | + <div class="navbar-header"> |
| 12 | + <a class="navbar-brand" href>Angular2 File Upload</a> |
14 | 13 | </div> |
| 14 | + </div> |
15 | 15 |
|
16 | | - <div class="row"> |
| 16 | + <div class="row"> |
17 | 17 |
|
18 | | - <div class="col-md-3"> |
| 18 | + <div class="col-md-3"> |
19 | 19 |
|
20 | | - <h3>Select files</h3> |
| 20 | + <h3>Select files</h3> |
21 | 21 |
|
22 | | - <div ng2FileDrop |
23 | | - [ngClass]="{'nv-file-over': hasBaseDropZoneOver}" |
24 | | - (fileOver)="fileOverBase($event)" |
25 | | - [uploader]="uploader" |
26 | | - class="well my-drop-zone p-2 mb-3"> |
27 | | - Base drop zone |
28 | | - </div> |
| 22 | + <div ng2FileDrop |
| 23 | + [ngClass]="{'nv-file-over': hasBaseDropZoneOver}" |
| 24 | + (fileOver)="fileOverBase($event)" |
| 25 | + [uploader]="uploader" |
| 26 | + class="well my-drop-zone p-2 mb-3"> |
| 27 | + Base drop zone |
| 28 | + </div> |
29 | 29 |
|
30 | | - <div ng2FileDrop |
31 | | - [ngClass]="{'another-file-over-class': hasAnotherDropZoneOver}" |
32 | | - (fileOver)="fileOverAnother($event)" |
33 | | - [uploader]="uploader" |
34 | | - class="well my-drop-zone p-2 mb-3"> |
35 | | - Another drop zone |
36 | | - </div> |
| 30 | + <div ng2FileDrop |
| 31 | + [ngClass]="{'another-file-over-class': hasAnotherDropZoneOver}" |
| 32 | + (fileOver)="fileOverAnother($event)" |
| 33 | + [uploader]="uploader" |
| 34 | + class="well my-drop-zone p-2 mb-3"> |
| 35 | + Another drop zone |
| 36 | + </div> |
37 | 37 |
|
38 | | - Multiple<br> |
39 | | - <input class="mt-2 mb-3" type="file" ng2FileSelect [uploader]="uploader" multiple /><br/> |
| 38 | + Multiple<br> |
| 39 | + <input class="mt-2 mb-3" type="file" ng2FileSelect [uploader]="uploader" multiple /><br/> |
40 | 40 |
|
41 | | - Single<br> |
42 | | - <input class="mt-2 mb-3" type="file" ng2FileSelect [uploader]="uploader" /> |
43 | | - </div> |
| 41 | + Single<br> |
| 42 | + <input class="mt-2 mb-3" type="file" ng2FileSelect [uploader]="uploader" /> |
| 43 | + </div> |
44 | 44 |
|
45 | | - <div class="col-md-9" style="margin-bottom: 40px"> |
46 | | - |
47 | | - <h3>Upload queue</h3> |
48 | | - <p>Queue length: {{ uploader?.queue?.length ? uploader?.queue?.length : 'Empty'}}</p> |
49 | | - |
50 | | - <table class="table"> |
51 | | - <thead> |
52 | | - <tr> |
53 | | - <th width="50%">Name</th> |
54 | | - <th>Size</th> |
55 | | - <th>Progress</th> |
56 | | - <th>Status</th> |
57 | | - <th>Actions</th> |
58 | | - </tr> |
59 | | - </thead> |
60 | | - <tbody *ngIf="uploader?.queue?.length"> |
61 | | - <tr *ngFor="let item of uploader.queue"> |
62 | | - <td data-label="Name"><strong>{{ item?.file?.name }}</strong></td> |
63 | | - <td data-label="Size" *ngIf="uploader.options.isHTML5" nowrap>{{ item?.file?.size/1024/1024 | number:'.2' }} MB</td> |
64 | | - <td data-label="Progress" *ngIf="uploader.options.isHTML5"> |
65 | | - <div class="progress" style="margin-bottom: 0;"> |
66 | | - <div class="progress-bar" role="progressbar" [ngStyle]="{ 'width': item.progress + '%' }"></div> |
67 | | - </div> |
68 | | - </td> |
69 | | - <td data-label="Status" class="text-center"> |
70 | | - <span *ngIf="item.isSuccess"><i class="glyphicon glyphicon-ok"></i></span> |
71 | | - <span *ngIf="item.isCancel"><i class="glyphicon glyphicon-ban-circle"></i></span> |
72 | | - <span *ngIf="item.isError"><i class="glyphicon glyphicon-remove"></i></span> |
73 | | - </td> |
74 | | - <td data-label="Actions" nowrap> |
75 | | - <button type="button" class="btn btn-success btn-xs" |
76 | | - (click)="item.upload()" [disabled]="item.isReady || item.isUploading || item.isSuccess"> |
77 | | - <span class="glyphicon glyphicon-upload"></span> Upload |
78 | | - </button> |
79 | | - <button type="button" class="btn btn-warning btn-xs" |
80 | | - (click)="item.cancel()" [disabled]="!item.isUploading"> |
81 | | - <span class="glyphicon glyphicon-ban-circle"></span> Cancel |
82 | | - </button> |
83 | | - <button type="button" class="btn btn-danger btn-xs" |
84 | | - (click)="item.remove()"> |
85 | | - <span class="glyphicon glyphicon-trash"></span> Remove |
86 | | - </button> |
87 | | - </td> |
88 | | - </tr> |
89 | | - </tbody> |
90 | | - </table> |
91 | | - |
92 | | - <div> |
93 | | - <div> |
94 | | - Queue progress: |
95 | | - <div class="progress mt-2 mb-3" style=""> |
96 | | - <div class="progress-bar" role="progressbar" [ngStyle]="{ 'width': uploader.progress + '%' }"></div> |
| 45 | + <div class="col-md-9" style="margin-bottom: 40px"> |
| 46 | + |
| 47 | + <h3>Upload queue</h3> |
| 48 | + <p>Queue length: {{ uploader?.queue?.length ? uploader?.queue?.length : 'Empty'}}</p> |
| 49 | + |
| 50 | + <table class="table"> |
| 51 | + <thead> |
| 52 | + <tr> |
| 53 | + <th width="50%">Name</th> |
| 54 | + <th>Size</th> |
| 55 | + <th>Progress</th> |
| 56 | + <th>Status</th> |
| 57 | + <th>Actions</th> |
| 58 | + </tr> |
| 59 | + </thead> |
| 60 | + @if (uploader?.queue?.length) { |
| 61 | + <tbody> |
| 62 | + @for (item of uploader.queue; track item) { |
| 63 | + <tr> |
| 64 | + <td data-label="Name"><strong>{{ item?.file?.name }}</strong></td> |
| 65 | + @if (uploader.options.isHTML5) { |
| 66 | + <td data-label="Size" nowrap>{{ item?.file?.size/1024/1024 | number:'.2' }} MB</td> |
| 67 | + } |
| 68 | + @if (uploader.options.isHTML5) { |
| 69 | + <td data-label="Progress"> |
| 70 | + <div class="progress" style="margin-bottom: 0;"> |
| 71 | + <div class="progress-bar" role="progressbar" [ngStyle]="{ 'width': item.progress + '%' }"></div> |
97 | 72 | </div> |
98 | | - </div> |
99 | | - <button type="button" class="btn btn-success btn-s me-2" |
100 | | - (click)="uploader.uploadAll()" [disabled]="!uploader.getNotUploadedItems().length"> |
101 | | - <span class="glyphicon glyphicon-upload"></span> Upload all |
102 | | - </button> |
103 | | - <button type="button" class="btn btn-warning btn-s me-2" |
104 | | - (click)="uploader.cancelAll()" [disabled]="!uploader.isUploading"> |
105 | | - <span class="glyphicon glyphicon-ban-circle"></span> Cancel all |
106 | | - </button> |
107 | | - <button type="button" class="btn btn-danger btn-s" |
108 | | - (click)="uploader.clearQueue()" [disabled]="!uploader.queue.length"> |
109 | | - <span class="glyphicon glyphicon-trash"></span> Remove all |
110 | | - </button> |
111 | | - </div> |
112 | | - |
| 73 | + </td> |
| 74 | + } |
| 75 | + <td data-label="Status" class="text-center"> |
| 76 | + @if (item.isSuccess) { |
| 77 | + <span><i class="glyphicon glyphicon-ok"></i></span> |
| 78 | + } |
| 79 | + @if (item.isCancel) { |
| 80 | + <span><i class="glyphicon glyphicon-ban-circle"></i></span> |
| 81 | + } |
| 82 | + @if (item.isError) { |
| 83 | + <span><i class="glyphicon glyphicon-remove"></i></span> |
| 84 | + } |
| 85 | + </td> |
| 86 | + <td data-label="Actions" nowrap> |
| 87 | + <button type="button" class="btn btn-success btn-xs" |
| 88 | + (click)="item.upload()" [disabled]="item.isReady || item.isUploading || item.isSuccess"> |
| 89 | + <span class="glyphicon glyphicon-upload"></span> Upload |
| 90 | + </button> |
| 91 | + <button type="button" class="btn btn-warning btn-xs" |
| 92 | + (click)="item.cancel()" [disabled]="!item.isUploading"> |
| 93 | + <span class="glyphicon glyphicon-ban-circle"></span> Cancel |
| 94 | + </button> |
| 95 | + <button type="button" class="btn btn-danger btn-xs" |
| 96 | + (click)="item.remove()"> |
| 97 | + <span class="glyphicon glyphicon-trash"></span> Remove |
| 98 | + </button> |
| 99 | + </td> |
| 100 | + </tr> |
| 101 | + } |
| 102 | + </tbody> |
| 103 | + } |
| 104 | + </table> |
| 105 | + |
| 106 | + <div> |
| 107 | + <div> |
| 108 | + Queue progress: |
| 109 | + <div class="progress mt-2 mb-3" style=""> |
| 110 | + <div class="progress-bar" role="progressbar" [ngStyle]="{ 'width': uploader.progress + '%' }"></div> |
| 111 | + </div> |
113 | 112 | </div> |
| 113 | + <button type="button" class="btn btn-success btn-s me-2" |
| 114 | + (click)="uploader.uploadAll()" [disabled]="!uploader.getNotUploadedItems().length"> |
| 115 | + <span class="glyphicon glyphicon-upload"></span> Upload all |
| 116 | + </button> |
| 117 | + <button type="button" class="btn btn-warning btn-s me-2" |
| 118 | + (click)="uploader.cancelAll()" [disabled]="!uploader.isUploading"> |
| 119 | + <span class="glyphicon glyphicon-ban-circle"></span> Cancel all |
| 120 | + </button> |
| 121 | + <button type="button" class="btn btn-danger btn-s" |
| 122 | + (click)="uploader.clearQueue()" [disabled]="!uploader.queue.length"> |
| 123 | + <span class="glyphicon glyphicon-trash"></span> Remove all |
| 124 | + </button> |
| 125 | + </div> |
114 | 126 |
|
115 | 127 | </div> |
116 | 128 |
|
117 | | - <br><br> |
| 129 | + </div> |
| 130 | + |
| 131 | + <br><br> |
118 | 132 |
|
119 | | - <div class="row"> |
120 | | - <div class="col-md-12"> |
121 | | - <div class="card"> |
122 | | - <div class="card-header">Response</div> |
123 | | - <div class="card-body"> |
124 | | - {{ response }} |
125 | | - </div> |
126 | | - </div> |
| 133 | + <div class="row"> |
| 134 | + <div class="col-md-12"> |
| 135 | + <div class="card"> |
| 136 | + <div class="card-header">Response</div> |
| 137 | + <div class="card-body"> |
| 138 | + {{ response }} |
127 | 139 | </div> |
| 140 | + </div> |
128 | 141 | </div> |
| 142 | + </div> |
129 | 143 | </div> |
0 commit comments