@rs-pk/asset-management 1.0.30 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/rs-pk-asset-management.umd.js +269 -45
- package/bundles/rs-pk-asset-management.umd.js.map +1 -1
- package/bundles/rs-pk-asset-management.umd.min.js +1 -1
- package/bundles/rs-pk-asset-management.umd.min.js.map +1 -1
- package/esm2015/lib/components/partial/asset-list/asset-list.component.js +73 -30
- package/esm2015/lib/components/partial/file-item/file-item.component.js +9 -3
- package/esm2015/lib/components/partial/upload-dialog/upload-dialog.component.js +121 -3
- package/esm2015/lib/services/upload-assets.service.js +17 -12
- package/esm5/lib/components/partial/asset-list/asset-list.component.js +95 -31
- package/esm5/lib/components/partial/file-item/file-item.component.js +13 -3
- package/esm5/lib/components/partial/upload-dialog/upload-dialog.component.js +144 -3
- package/esm5/lib/services/upload-assets.service.js +21 -12
- package/fesm2015/rs-pk-asset-management.js +216 -44
- package/fesm2015/rs-pk-asset-management.js.map +1 -1
- package/fesm5/rs-pk-asset-management.js +269 -45
- package/fesm5/rs-pk-asset-management.js.map +1 -1
- package/lib/components/partial/asset-list/asset-list.component.d.ts +7 -1
- package/lib/components/partial/file-item/file-item.component.d.ts +1 -0
- package/lib/components/partial/upload-dialog/upload-dialog.component.d.ts +7 -0
- package/lib/services/upload-assets.service.d.ts +2 -0
- package/package.json +1 -1
- package/rs-pk-asset-management.metadata.json +1 -1
|
@@ -16,6 +16,7 @@ var UploadAssetsService = /** @class */ (function () {
|
|
|
16
16
|
this._api = _api;
|
|
17
17
|
this.files = [];
|
|
18
18
|
this.fileNames = [];
|
|
19
|
+
this.uploadErrors = new Map();
|
|
19
20
|
this.supportedSize = 10 * 1024 * 1024; // 10MB
|
|
20
21
|
// 10MB
|
|
21
22
|
this.documentExtension = ['.pdf', '.csv'];
|
|
@@ -118,9 +119,25 @@ var UploadAssetsService = /** @class */ (function () {
|
|
|
118
119
|
* @return {?}
|
|
119
120
|
*/
|
|
120
121
|
function (index) {
|
|
122
|
+
this.uploadErrors.delete(this.files[index]);
|
|
121
123
|
this.files.splice(index, 1);
|
|
122
124
|
this.fileNames.splice(index, 1);
|
|
123
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* @param {?} index
|
|
128
|
+
* @return {?}
|
|
129
|
+
*/
|
|
130
|
+
UploadAssetsService.prototype.getUploadName = /**
|
|
131
|
+
* @param {?} index
|
|
132
|
+
* @return {?}
|
|
133
|
+
*/
|
|
134
|
+
function (index) {
|
|
135
|
+
/** @type {?} */
|
|
136
|
+
var nameSplit = this.files[index].name.split('.');
|
|
137
|
+
/** @type {?} */
|
|
138
|
+
var ext = "." + nameSplit.splice(nameSplit.length - 1, 1)[0];
|
|
139
|
+
return "" + this.fileNames[index].name + ext;
|
|
140
|
+
};
|
|
124
141
|
/**
|
|
125
142
|
* @param {?} parentAssetId
|
|
126
143
|
* @return {?}
|
|
@@ -132,21 +149,11 @@ var UploadAssetsService = /** @class */ (function () {
|
|
|
132
149
|
function (parentAssetId) {
|
|
133
150
|
var files = this.files;
|
|
134
151
|
/** @type {?} */
|
|
135
|
-
var fileNames = this.fileNames.map((/**
|
|
136
|
-
* @param {?} file
|
|
137
|
-
* @return {?}
|
|
138
|
-
*/
|
|
139
|
-
function (file) { return file.name; }));
|
|
140
|
-
/** @type {?} */
|
|
141
152
|
var formData = new FormData();
|
|
142
153
|
formData.append('parentAssetId', parentAssetId);
|
|
143
154
|
formData.append('companyId', '732DA8D2-04EC-4BE0-A168-63EE0DCF50D8');
|
|
144
155
|
for (var i = 0; i < files.length; i++) {
|
|
145
|
-
|
|
146
|
-
var nameSplit = files[i].name.split('.');
|
|
147
|
-
/** @type {?} */
|
|
148
|
-
var ext = "." + nameSplit.splice(nameSplit.length - 1, 1)[0];
|
|
149
|
-
formData.append('files', files[i], "" + fileNames[i] + ext);
|
|
156
|
+
formData.append('files', files[i], this.getUploadName(i));
|
|
150
157
|
}
|
|
151
158
|
return this._api.post(this.baseUrl + "/File/Upload", formData);
|
|
152
159
|
};
|
|
@@ -171,6 +178,8 @@ if (false) {
|
|
|
171
178
|
/** @type {?} */
|
|
172
179
|
UploadAssetsService.prototype.fileNames;
|
|
173
180
|
/** @type {?} */
|
|
181
|
+
UploadAssetsService.prototype.uploadErrors;
|
|
182
|
+
/** @type {?} */
|
|
174
183
|
UploadAssetsService.prototype.supportedSize;
|
|
175
184
|
/** @type {?} */
|
|
176
185
|
UploadAssetsService.prototype.documentExtension;
|
|
@@ -205,4 +214,4 @@ if (false) {
|
|
|
205
214
|
*/
|
|
206
215
|
UploadAssetsService.prototype._api;
|
|
207
216
|
}
|
|
208
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
217
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXBsb2FkLWFzc2V0cy5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQHJzLXBrL2Fzc2V0LW1hbmFnZW1lbnQvIiwic291cmNlcyI6WyJsaWIvc2VydmljZXMvdXBsb2FkLWFzc2V0cy5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ25ELE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUNyRCxPQUFPLEVBQUUsZUFBZSxFQUFjLE1BQU0sTUFBTSxDQUFDO0FBQ25ELE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUNoRCxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFFakQ7SUEyQkUsNkJBQzZCLElBQUksRUFDeEIsTUFBaUIsRUFDaEIsSUFBb0I7UUFGRCxTQUFJLEdBQUosSUFBSSxDQUFBO1FBQ3hCLFdBQU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|
|
|
1263
1263
|
this._api = _api;
|
|
1264
1264
|
this.files = [];
|
|
1265
1265
|
this.fileNames = [];
|
|
1266
|
+
this.uploadErrors = new Map();
|
|
1266
1267
|
this.supportedSize = 10 * 1024 * 1024; // 10MB
|
|
1267
1268
|
// 10MB
|
|
1268
1269
|
this.documentExtension = ['.pdf', '.csv'];
|
|
@@ -1338,9 +1339,21 @@ class UploadAssetsService {
|
|
|
1338
1339
|
* @return {?}
|
|
1339
1340
|
*/
|
|
1340
1341
|
deleteFile(index) {
|
|
1342
|
+
this.uploadErrors.delete(this.files[index]);
|
|
1341
1343
|
this.files.splice(index, 1);
|
|
1342
1344
|
this.fileNames.splice(index, 1);
|
|
1343
1345
|
}
|
|
1346
|
+
/**
|
|
1347
|
+
* @param {?} index
|
|
1348
|
+
* @return {?}
|
|
1349
|
+
*/
|
|
1350
|
+
getUploadName(index) {
|
|
1351
|
+
/** @type {?} */
|
|
1352
|
+
const nameSplit = this.files[index].name.split('.');
|
|
1353
|
+
/** @type {?} */
|
|
1354
|
+
const ext = `.${nameSplit.splice(nameSplit.length - 1, 1)[0]}`;
|
|
1355
|
+
return `${this.fileNames[index].name}${ext}`;
|
|
1356
|
+
}
|
|
1344
1357
|
/**
|
|
1345
1358
|
* @param {?} parentAssetId
|
|
1346
1359
|
* @return {?}
|
|
@@ -1348,21 +1361,11 @@ class UploadAssetsService {
|
|
|
1348
1361
|
uploadMultipleAssets(parentAssetId) {
|
|
1349
1362
|
const { files } = this;
|
|
1350
1363
|
/** @type {?} */
|
|
1351
|
-
const fileNames = this.fileNames.map((/**
|
|
1352
|
-
* @param {?} file
|
|
1353
|
-
* @return {?}
|
|
1354
|
-
*/
|
|
1355
|
-
file => file.name));
|
|
1356
|
-
/** @type {?} */
|
|
1357
1364
|
const formData = new FormData();
|
|
1358
1365
|
formData.append('parentAssetId', parentAssetId);
|
|
1359
1366
|
formData.append('companyId', '732DA8D2-04EC-4BE0-A168-63EE0DCF50D8');
|
|
1360
1367
|
for (let i = 0; i < files.length; i++) {
|
|
1361
|
-
|
|
1362
|
-
const nameSplit = files[i].name.split('.');
|
|
1363
|
-
/** @type {?} */
|
|
1364
|
-
const ext = `.${nameSplit.splice(nameSplit.length - 1, 1)[0]}`;
|
|
1365
|
-
formData.append('files', files[i], `${fileNames[i]}${ext}`);
|
|
1368
|
+
formData.append('files', files[i], this.getUploadName(i));
|
|
1366
1369
|
}
|
|
1367
1370
|
return this._api.post(`${this.baseUrl}/File/Upload`, formData);
|
|
1368
1371
|
}
|
|
@@ -1385,6 +1388,8 @@ if (false) {
|
|
|
1385
1388
|
/** @type {?} */
|
|
1386
1389
|
UploadAssetsService.prototype.fileNames;
|
|
1387
1390
|
/** @type {?} */
|
|
1391
|
+
UploadAssetsService.prototype.uploadErrors;
|
|
1392
|
+
/** @type {?} */
|
|
1388
1393
|
UploadAssetsService.prototype.supportedSize;
|
|
1389
1394
|
/** @type {?} */
|
|
1390
1395
|
UploadAssetsService.prototype.documentExtension;
|
|
@@ -2103,6 +2108,12 @@ class FileItemComponent {
|
|
|
2103
2108
|
ngOnInit() {
|
|
2104
2109
|
this.initDataFile();
|
|
2105
2110
|
}
|
|
2111
|
+
/**
|
|
2112
|
+
* @return {?}
|
|
2113
|
+
*/
|
|
2114
|
+
get uploadErrors() {
|
|
2115
|
+
return this.uploadAssetService.uploadErrors.get(this.file);
|
|
2116
|
+
}
|
|
2106
2117
|
/**
|
|
2107
2118
|
* @private
|
|
2108
2119
|
* @return {?}
|
|
@@ -2202,8 +2213,8 @@ class FileItemComponent {
|
|
|
2202
2213
|
FileItemComponent.decorators = [
|
|
2203
2214
|
{ type: Component, args: [{
|
|
2204
2215
|
selector: 'lib-file-item',
|
|
2205
|
-
template: "<div class=\"file-item__img\">\n <ng-container\n *ngIf=\"\n file.type.indexOf('image') > -1 || documentExts.indexOf(dataFile.ext) > -1;\n else defaultFile\n \"\n >\n <img\n [class.image]=\"file.type.indexOf('image') > -1\"\n *ngIf=\"documentExts.indexOf(dataFile.ext) > -1 || dataFile.data\"\n [src]=\"documentExts.indexOf(dataFile.ext) > -1 ? base64PNG[dataFile.ext] : dataFile.data\"\n />\n </ng-container>\n <ng-template #defaultFile>\n <mat-icon>attach_file</mat-icon>\n </ng-template>\n</div>\n<div class=\"file-item__content\">\n <input\n class=\"file-item__content--name\"\n matInput\n placeholder=\"Enter file name\"\n [value]=\"dataFile.name\"\n required\n (input)=\"onChange($event)\"\n />\n <div class=\"file-item__content--info\">\n <div class=\"file-item__content--info__item\">\n Extension: <span>{{ dataFile.ext }}</span>\n </div>\n <div class=\"file-item__content--info__item\">\n Size: <span>{{ dataFile.size | fileSize }}</span>\n </div>\n </div>\n <div *ngIf=\"dataFile.errors.ext\" class=\"file-item__error\">\n {{ uploadAssetService.messageErrors['ext'] }}\n
|
|
2206
|
-
styles: [":host::ng-deep{padding:10px 5%;display:flex;justify-content:space-between;align-items:center;background-color:#f9f9f9;border-radius:10px}:host::ng-deep .file-item__img{display:flex;justify-content:center;align-items:center;width:250px;height:150px;border-radius:10px}:host::ng-deep .file-item__img img{max-width:100%;max-height:100%;-o-object-fit:contain;object-fit:contain}:host::ng-deep .file-item__img img.image{background-image:url(data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAAUABQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+/ivFPFOf+EjvxzjbBgdv+PeDp+OfxzSt4q18AkageASB9ntu3OM+Vn8c5rsdG0fT9d06DVdUgN1f3XmefP5ksO/ypXhj/dwvHGu2ONF+VF3bQSM0AeYUV7IPCWgjgWRA/wCvi4P85SaKAPGm5Vh7H+VeyeERjQLEDoPP/WeQ/wAzRRQB0tFFFAH/2Q==)}:host::ng-deep .file-item__img mat-icon{font-size:100px;width:auto;height:auto}:host::ng-deep .file-item__content{flex:1;padding-left:5%;padding-right:5%}:host::ng-deep .file-item__content--name{width:100%;padding:10px;border:1px solid #d8d8d8;border-radius:5px}:host::ng-deep .file-item__content--info{margin-top:10px;display:flex}:host::ng-deep .file-item__content--info__item:not(:last-child){margin-right:50px}:host::ng-deep .file-item__content--info__item span{color:#000;text-transform:uppercase}:host::ng-deep .file-item__error{margin-top:10px;color:#
|
|
2216
|
+
template: "<div class=\"file-item__img\">\n <ng-container\n *ngIf=\"\n file.type.indexOf('image') > -1 || documentExts.indexOf(dataFile.ext) > -1;\n else defaultFile\n \"\n >\n <img\n [class.image]=\"file.type.indexOf('image') > -1\"\n *ngIf=\"documentExts.indexOf(dataFile.ext) > -1 || dataFile.data\"\n [src]=\"documentExts.indexOf(dataFile.ext) > -1 ? base64PNG[dataFile.ext] : dataFile.data\"\n />\n </ng-container>\n <ng-template #defaultFile>\n <mat-icon>attach_file</mat-icon>\n </ng-template>\n</div>\n<div class=\"file-item__content\">\n <input\n class=\"file-item__content--name\"\n matInput\n placeholder=\"Enter file name\"\n [value]=\"dataFile.name\"\n required\n (input)=\"onChange($event)\"\n />\n <div class=\"file-item__content--info\">\n <div class=\"file-item__content--info__item\">\n Extension: <span>{{ dataFile.ext }}</span>\n </div>\n <div class=\"file-item__content--info__item\">\n Size: <span>{{ dataFile.size | fileSize }}</span>\n </div>\n </div>\n <div *ngIf=\"dataFile.errors.ext\" class=\"file-item__error\">\n <mat-icon class=\"file-item__error--icon\">error_outline</mat-icon>\n <span>\n {{ uploadAssetService.messageErrors['ext'] }}\n {{ uploadAssetService.supportedTypes.join(', ') }}\n </span>\n </div>\n <div *ngIf=\"dataFile.errors.size\" class=\"file-item__error\">\n <mat-icon class=\"file-item__error--icon\">error_outline</mat-icon>\n <span>\n {{ uploadAssetService.messageErrors['size'] }}\n {{ uploadAssetService.supportedSize | fileSize: 0 }}\n </span>\n </div>\n <div *ngIf=\"dataFile.errors.maxLength\" class=\"file-item__error\">\n <mat-icon class=\"file-item__error--icon\">error_outline</mat-icon>\n <span>{{ uploadAssetService.messageErrors['maxLength'] }}</span>\n </div>\n <div *ngFor=\"let message of uploadErrors\" class=\"file-item__error\" role=\"alert\">\n <mat-icon class=\"file-item__error--icon\">error_outline</mat-icon>\n <span>{{ message }}</span>\n </div>\n</div>\n<div class=\"file-item__action\">\n <mat-icon (click)=\"onRemove()\">delete_outline</mat-icon>\n</div>\n",
|
|
2217
|
+
styles: [":host::ng-deep{padding:10px 5%;display:flex;justify-content:space-between;align-items:center;background-color:#f9f9f9;border-radius:10px}:host::ng-deep .file-item__img{display:flex;justify-content:center;align-items:center;width:250px;height:150px;border-radius:10px}:host::ng-deep .file-item__img img{max-width:100%;max-height:100%;-o-object-fit:contain;object-fit:contain}:host::ng-deep .file-item__img img.image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{font-size:100px;width:auto;height:auto}:host::ng-deep .file-item__content{flex:1;padding-left:5%;padding-right:5%}:host::ng-deep .file-item__content--name{width:100%;padding:10px;border:1px solid #d8d8d8;border-radius:5px}:host::ng-deep .file-item__content--info{margin-top:10px;display:flex}:host::ng-deep .file-item__content--info__item:not(:last-child){margin-right:50px}:host::ng-deep .file-item__content--info__item span{color:#000;text-transform:uppercase}:host::ng-deep .file-item__error{display:flex;align-items:center;width:-moz-fit-content;width:fit-content;max-width:100%;margin-top:8px;padding:4px 10px;border-radius:6px;background-color:#fdecea;color:#d32f2f;font-size:13px;line-height:18px;word-break:break-word}:host::ng-deep .file-item__error--icon{flex-shrink:0;margin-right:6px;font-size:16px;width:16px;height:16px}:host::ng-deep .file-item__action{color:#f44336;cursor:pointer}"]
|
|
2207
2218
|
}] }
|
|
2208
2219
|
];
|
|
2209
2220
|
/** @nocollapse */
|
|
@@ -2847,6 +2858,9 @@ class UploadDialogComponent {
|
|
|
2847
2858
|
this.uploadAssetsService = uploadAssetsService;
|
|
2848
2859
|
this.isLoading = false;
|
|
2849
2860
|
this.disabled = true;
|
|
2861
|
+
this.errorMessages = [];
|
|
2862
|
+
this.defaultErrorMessage = 'Something went wrong while uploading. Please try again.';
|
|
2863
|
+
this.isDestroyed = false;
|
|
2850
2864
|
this.destroy$ = new Subject();
|
|
2851
2865
|
if (this.data.fileType) {
|
|
2852
2866
|
this.uploadAssetsService.supportedTypes =
|
|
@@ -2871,6 +2885,7 @@ class UploadDialogComponent {
|
|
|
2871
2885
|
*/
|
|
2872
2886
|
error => {
|
|
2873
2887
|
this.disabled = error;
|
|
2888
|
+
this.clearErrors();
|
|
2874
2889
|
this.changeDetectorRef.detectChanges();
|
|
2875
2890
|
}));
|
|
2876
2891
|
}
|
|
@@ -2880,12 +2895,15 @@ class UploadDialogComponent {
|
|
|
2880
2895
|
*/
|
|
2881
2896
|
onValidate(hasError) {
|
|
2882
2897
|
this.disabled = hasError;
|
|
2898
|
+
this.clearErrors();
|
|
2883
2899
|
}
|
|
2884
2900
|
/**
|
|
2885
2901
|
* @return {?}
|
|
2886
2902
|
*/
|
|
2887
2903
|
uploadFiles() {
|
|
2888
2904
|
this.isLoading = true;
|
|
2905
|
+
this.clearErrors();
|
|
2906
|
+
this.dialogRef.disableClose = true;
|
|
2889
2907
|
this.uploadAssetsService
|
|
2890
2908
|
.uploadMultipleAssets(this.data.currentAssetId)
|
|
2891
2909
|
.pipe(takeUntil(this.destroy$))
|
|
@@ -2897,8 +2915,106 @@ class UploadDialogComponent {
|
|
|
2897
2915
|
if (res) {
|
|
2898
2916
|
this.closeDialog(true);
|
|
2899
2917
|
}
|
|
2918
|
+
}), (/**
|
|
2919
|
+
* @param {?} err
|
|
2920
|
+
* @return {?}
|
|
2921
|
+
*/
|
|
2922
|
+
err => {
|
|
2923
|
+
this.setUploadErrors(this.getErrorMessages(err));
|
|
2924
|
+
this.stopLoading();
|
|
2925
|
+
}), (
|
|
2926
|
+
// the request can complete without a truthy response (or be swallowed by an interceptor)
|
|
2927
|
+
/**
|
|
2928
|
+
* @return {?}
|
|
2929
|
+
*/
|
|
2930
|
+
() => this.stopLoading()));
|
|
2931
|
+
}
|
|
2932
|
+
/**
|
|
2933
|
+
* @private
|
|
2934
|
+
* @return {?}
|
|
2935
|
+
*/
|
|
2936
|
+
stopLoading() {
|
|
2937
|
+
// takeUntil also completes the upload when the dialog is destroyed, its view can't be checked anymore
|
|
2938
|
+
if (this.isDestroyed) {
|
|
2939
|
+
return;
|
|
2940
|
+
}
|
|
2941
|
+
this.isLoading = false;
|
|
2942
|
+
this.dialogRef.disableClose = false;
|
|
2943
|
+
this.changeDetectorRef.detectChanges();
|
|
2944
|
+
}
|
|
2945
|
+
/**
|
|
2946
|
+
* @private
|
|
2947
|
+
* @return {?}
|
|
2948
|
+
*/
|
|
2949
|
+
clearErrors() {
|
|
2950
|
+
this.errorMessages = [];
|
|
2951
|
+
this.uploadAssetsService.uploadErrors.clear();
|
|
2952
|
+
}
|
|
2953
|
+
// show each message on the file it mentions, the rest stay under the list
|
|
2954
|
+
/**
|
|
2955
|
+
* @private
|
|
2956
|
+
* @param {?} messages
|
|
2957
|
+
* @return {?}
|
|
2958
|
+
*/
|
|
2959
|
+
setUploadErrors(messages) {
|
|
2960
|
+
const { getFiles: files, uploadErrors } = this.uploadAssetsService;
|
|
2961
|
+
/** @type {?} */
|
|
2962
|
+
const uploadNames = files.map((/**
|
|
2963
|
+
* @param {?} file
|
|
2964
|
+
* @param {?} index
|
|
2965
|
+
* @return {?}
|
|
2966
|
+
*/
|
|
2967
|
+
(file, index) => this.uploadAssetsService.getUploadName(index)));
|
|
2968
|
+
this.errorMessages = messages.filter((/**
|
|
2969
|
+
* @param {?} message
|
|
2970
|
+
* @return {?}
|
|
2971
|
+
*/
|
|
2972
|
+
message => {
|
|
2973
|
+
/** @type {?} */
|
|
2974
|
+
let index = uploadNames.findIndex((/**
|
|
2975
|
+
* @param {?} name
|
|
2976
|
+
* @return {?}
|
|
2977
|
+
*/
|
|
2978
|
+
name => message.indexOf(name) > -1));
|
|
2979
|
+
if (index < 0 && files.length === 1) {
|
|
2980
|
+
index = 0;
|
|
2981
|
+
}
|
|
2982
|
+
if (index < 0) {
|
|
2983
|
+
return true;
|
|
2984
|
+
}
|
|
2985
|
+
uploadErrors.set(files[index], [...(uploadErrors.get(files[index]) || []), message]);
|
|
2986
|
+
return false;
|
|
2900
2987
|
}));
|
|
2901
2988
|
}
|
|
2989
|
+
/**
|
|
2990
|
+
* @private
|
|
2991
|
+
* @param {?} err
|
|
2992
|
+
* @return {?}
|
|
2993
|
+
*/
|
|
2994
|
+
getErrorMessages(err) {
|
|
2995
|
+
// HttpErrorResponse keeps the API body in `error`, an interceptor may already unwrap it
|
|
2996
|
+
/** @type {?} */
|
|
2997
|
+
const body = err && err.error && typeof err.error === 'object' ? err.error : err || {};
|
|
2998
|
+
/** @type {?} */
|
|
2999
|
+
const messages = (body.Messages || [])
|
|
3000
|
+
.map((/**
|
|
3001
|
+
* @param {?} message
|
|
3002
|
+
* @return {?}
|
|
3003
|
+
*/
|
|
3004
|
+
message => (typeof message === 'string' ? message : message && message.Text)))
|
|
3005
|
+
.filter(Boolean);
|
|
3006
|
+
if (!messages.length && body.ResponseMessage) {
|
|
3007
|
+
messages.push(body.ResponseMessage);
|
|
3008
|
+
}
|
|
3009
|
+
return messages.length
|
|
3010
|
+
? messages.filter((/**
|
|
3011
|
+
* @param {?} message
|
|
3012
|
+
* @param {?} index
|
|
3013
|
+
* @return {?}
|
|
3014
|
+
*/
|
|
3015
|
+
(message, index) => messages.indexOf(message) === index))
|
|
3016
|
+
: [this.defaultErrorMessage];
|
|
3017
|
+
}
|
|
2902
3018
|
/**
|
|
2903
3019
|
* @param {?=} res
|
|
2904
3020
|
* @return {?}
|
|
@@ -2910,6 +3026,7 @@ class UploadDialogComponent {
|
|
|
2910
3026
|
* @return {?}
|
|
2911
3027
|
*/
|
|
2912
3028
|
ngOnDestroy() {
|
|
3029
|
+
this.isDestroyed = true;
|
|
2913
3030
|
this.destroy$.next(true);
|
|
2914
3031
|
this.destroy$.complete();
|
|
2915
3032
|
}
|
|
@@ -2917,9 +3034,9 @@ class UploadDialogComponent {
|
|
|
2917
3034
|
UploadDialogComponent.decorators = [
|
|
2918
3035
|
{ type: Component, args: [{
|
|
2919
3036
|
selector: 'lib-upload-dialog',
|
|
2920
|
-
template: "<lib-modal heading=\"Add new assets\">\n <ng-container content>\n <lib-upload-file\n *ngIf=\"!uploadAssetsService?.getFiles?.length\"\n (revalidate)=\"onValidate($event)\"\n ></lib-upload-file>\n <lib-file-list\n *ngIf=\"uploadAssetsService?.getFiles?.length\"\n (revalidate)=\"onValidate($event)\"\n ></lib-file-list>\n </ng-container>\n <ng-container actions>\n <button mat-raised-button mat-dialog-close>Cancel</button>\n <button\n class=\"upload__action\"\n [class.loading]=\"isLoading\"\n mat-raised-button\n color=\"primary\"\n (click)=\"uploadFiles()\"\n [disabled]=\"disabled || isLoading\"\n >\n <ng-container *ngIf=\"isLoading\">\n <mat-spinner [diameter]=\"20\"></mat-spinner>\n </ng-container>\n <span>Upload</span>\n </button>\n </ng-container>\n</lib-modal>\n",
|
|
3037
|
+
template: "<lib-modal heading=\"Add new assets\">\n <ng-container content>\n <lib-upload-file\n *ngIf=\"!uploadAssetsService?.getFiles?.length\"\n (revalidate)=\"onValidate($event)\"\n ></lib-upload-file>\n <lib-file-list\n *ngIf=\"uploadAssetsService?.getFiles?.length\"\n (revalidate)=\"onValidate($event)\"\n ></lib-file-list>\n <div *ngFor=\"let message of errorMessages\" class=\"upload__error\" role=\"alert\">\n <mat-icon class=\"upload__error--icon\">error_outline</mat-icon>\n <span>{{ message }}</span>\n </div>\n </ng-container>\n <ng-container actions>\n <button mat-raised-button mat-dialog-close [disabled]=\"isLoading\">Cancel</button>\n <button\n class=\"upload__action\"\n [class.loading]=\"isLoading\"\n mat-raised-button\n color=\"primary\"\n (click)=\"uploadFiles()\"\n [disabled]=\"disabled || isLoading\"\n >\n <ng-container *ngIf=\"isLoading\">\n <mat-spinner [diameter]=\"20\"></mat-spinner>\n </ng-container>\n <span>Upload</span>\n </button>\n </ng-container>\n</lib-modal>\n",
|
|
2921
3038
|
providers: [UploadAssetsService],
|
|
2922
|
-
styles: [":host::ng-deep{display:block;width:1200px;max-width:100%;font-size:14px;line-height:16px;color:#979797;letter-spacing:.15px}:host::ng-deep .mat-dialog-title{position:relative;margin-bottom:0;padding-bottom:24px;color:#000}:host::ng-deep .mat-dialog-actions{justify-content:flex-end;padding:24px 0 0}:host::ng-deep .upload__action{min-width:100px}:host::ng-deep .upload__action.loading{padding:0 5px}:host::ng-deep .upload__action.loading .mat-button-wrapper{display:flex;width:100%;justify-content:center;align-items:center}:host::ng-deep .upload__action.loading .mat-spinner{margin-right:10px}"]
|
|
3039
|
+
styles: [":host::ng-deep{display:block;width:1200px;max-width:100%;font-size:14px;line-height:16px;color:#979797;letter-spacing:.15px}:host::ng-deep .mat-dialog-title{position:relative;margin-bottom:0;padding-bottom:24px;color:#000}:host::ng-deep .mat-dialog-actions{justify-content:flex-end;padding:24px 0 0}:host::ng-deep .upload__error{display:flex;align-items:center;width:-moz-fit-content;width:fit-content;max-width:100%;margin-top:8px;padding:4px 10px;border-radius:6px;background-color:#fdecea;color:#d32f2f;font-size:13px;line-height:18px;word-break:break-word}:host::ng-deep .upload__error--icon{flex-shrink:0;margin-right:6px;font-size:16px;width:16px;height:16px}:host::ng-deep .upload__action{min-width:100px}:host::ng-deep .upload__action.loading{padding:0 5px}:host::ng-deep .upload__action.loading .mat-button-wrapper{display:flex;width:100%;justify-content:center;align-items:center}:host::ng-deep .upload__action.loading .mat-spinner{margin-right:10px}"]
|
|
2923
3040
|
}] }
|
|
2924
3041
|
];
|
|
2925
3042
|
/** @nocollapse */
|
|
@@ -2934,6 +3051,18 @@ if (false) {
|
|
|
2934
3051
|
UploadDialogComponent.prototype.isLoading;
|
|
2935
3052
|
/** @type {?} */
|
|
2936
3053
|
UploadDialogComponent.prototype.disabled;
|
|
3054
|
+
/** @type {?} */
|
|
3055
|
+
UploadDialogComponent.prototype.errorMessages;
|
|
3056
|
+
/**
|
|
3057
|
+
* @type {?}
|
|
3058
|
+
* @private
|
|
3059
|
+
*/
|
|
3060
|
+
UploadDialogComponent.prototype.defaultErrorMessage;
|
|
3061
|
+
/**
|
|
3062
|
+
* @type {?}
|
|
3063
|
+
* @private
|
|
3064
|
+
*/
|
|
3065
|
+
UploadDialogComponent.prototype.isDestroyed;
|
|
2937
3066
|
/**
|
|
2938
3067
|
* @type {?}
|
|
2939
3068
|
* @private
|
|
@@ -3194,6 +3323,7 @@ class AssetListComponent {
|
|
|
3194
3323
|
this.hasAccessPermission = true;
|
|
3195
3324
|
this.hasArchivePermission = true;
|
|
3196
3325
|
this.backgroundProcessingNum = BackgroudProcessingStatus;
|
|
3326
|
+
this.processingCheckDelay = 5000;
|
|
3197
3327
|
this.unsubscribe$ = new Subject();
|
|
3198
3328
|
this.selectedAssets = [];
|
|
3199
3329
|
}
|
|
@@ -3209,15 +3339,7 @@ class AssetListComponent {
|
|
|
3209
3339
|
*/
|
|
3210
3340
|
ngOnChanges(changes) {
|
|
3211
3341
|
if (changes.assets) {
|
|
3212
|
-
|
|
3213
|
-
if (this.assets && this.assets.find((/**
|
|
3214
|
-
* @param {?} x
|
|
3215
|
-
* @return {?}
|
|
3216
|
-
*/
|
|
3217
|
-
x => x.BackgroudProcessingStatus === this.backgroundProcessingNum.InProcessing))) {
|
|
3218
|
-
this._resetUploadingAssets();
|
|
3219
|
-
}
|
|
3220
|
-
;
|
|
3342
|
+
this.checkProcessingAssets();
|
|
3221
3343
|
this.paginator.pageIndex = this.assetService.pageIndex;
|
|
3222
3344
|
this.paginator.pageSize = this.assetService.pageSize;
|
|
3223
3345
|
this.paginator.length = this.assetService.fileTotal;
|
|
@@ -3352,15 +3474,8 @@ class AssetListComponent {
|
|
|
3352
3474
|
* @param {?} res
|
|
3353
3475
|
* @return {?}
|
|
3354
3476
|
*/
|
|
3355
|
-
(res) =>
|
|
3356
|
-
/**
|
|
3357
|
-
const pagination = res && res.Meta || {};
|
|
3358
|
-
/** @type {?} */
|
|
3359
|
-
const assets = res && res.Data && res.Data.Children || [];
|
|
3360
|
-
/** @type {?} */
|
|
3361
|
-
const totalFile = res && res.Data && res.Data.TotalFile || 0;
|
|
3362
|
-
this.assetService.setAssetList(assets, pagination, totalFile);
|
|
3363
|
-
})).add((/**
|
|
3477
|
+
(res) => this.setAssetList(res)))
|
|
3478
|
+
.add((/**
|
|
3364
3479
|
* @return {?}
|
|
3365
3480
|
*/
|
|
3366
3481
|
() => {
|
|
@@ -3370,31 +3485,73 @@ class AssetListComponent {
|
|
|
3370
3485
|
});
|
|
3371
3486
|
}));
|
|
3372
3487
|
}
|
|
3488
|
+
/**
|
|
3489
|
+
* @private
|
|
3490
|
+
* @param {?} res
|
|
3491
|
+
* @return {?}
|
|
3492
|
+
*/
|
|
3493
|
+
setAssetList(res) {
|
|
3494
|
+
/** @type {?} */
|
|
3495
|
+
const pagination = res && res.Meta || {};
|
|
3496
|
+
/** @type {?} */
|
|
3497
|
+
const assets = res && res.Data && res.Data.Children || [];
|
|
3498
|
+
/** @type {?} */
|
|
3499
|
+
const totalFile = res && res.Data && res.Data.TotalFile || 0;
|
|
3500
|
+
this.assetService.setAssetList(assets, pagination, totalFile);
|
|
3501
|
+
}
|
|
3502
|
+
// Called on every new asset list: while some files are still processed in the background,
|
|
3503
|
+
// reload the list once after a delay. The reloaded list calls this again, until nothing is processing.
|
|
3373
3504
|
/**
|
|
3374
3505
|
* @private
|
|
3375
3506
|
* @return {?}
|
|
3376
3507
|
*/
|
|
3377
|
-
|
|
3508
|
+
checkProcessingAssets() {
|
|
3509
|
+
this.stopProcessingCheck();
|
|
3378
3510
|
/** @type {?} */
|
|
3379
|
-
const
|
|
3511
|
+
const hasProcessingAssets = this.assets && this.assets.some((/**
|
|
3512
|
+
* @param {?} asset
|
|
3380
3513
|
* @return {?}
|
|
3381
3514
|
*/
|
|
3382
|
-
() =>
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
* @param {?} x
|
|
3515
|
+
(asset) => asset.BackgroudProcessingStatus === this.backgroundProcessingNum.InProcessing));
|
|
3516
|
+
if (hasProcessingAssets) {
|
|
3517
|
+
this.processingCheckTimer = setTimeout((/**
|
|
3386
3518
|
* @return {?}
|
|
3387
3519
|
*/
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3520
|
+
() => this.reloadProcessingAssets()), this.processingCheckDelay);
|
|
3521
|
+
}
|
|
3522
|
+
}
|
|
3523
|
+
// Silent reload, without the global loading bar
|
|
3524
|
+
/**
|
|
3525
|
+
* @private
|
|
3526
|
+
* @return {?}
|
|
3527
|
+
*/
|
|
3528
|
+
reloadProcessingAssets() {
|
|
3529
|
+
if (!this.currentFolderId) {
|
|
3530
|
+
return;
|
|
3531
|
+
}
|
|
3532
|
+
this.processingCheckRequest = this.assetService
|
|
3533
|
+
.getChildrenAssets({ assetId: this.currentFolderId })
|
|
3534
|
+
.subscribe((/**
|
|
3535
|
+
* @param {?} res
|
|
3536
|
+
* @return {?}
|
|
3537
|
+
*/
|
|
3538
|
+
(res) => this.setAssetList(res)));
|
|
3539
|
+
}
|
|
3540
|
+
/**
|
|
3541
|
+
* @private
|
|
3542
|
+
* @return {?}
|
|
3543
|
+
*/
|
|
3544
|
+
stopProcessingCheck() {
|
|
3545
|
+
clearTimeout(this.processingCheckTimer);
|
|
3546
|
+
if (this.processingCheckRequest) {
|
|
3547
|
+
this.processingCheckRequest.unsubscribe();
|
|
3548
|
+
}
|
|
3393
3549
|
}
|
|
3394
3550
|
/**
|
|
3395
3551
|
* @return {?}
|
|
3396
3552
|
*/
|
|
3397
3553
|
ngOnDestroy() {
|
|
3554
|
+
this.stopProcessingCheck();
|
|
3398
3555
|
this.unsubscribe$.next();
|
|
3399
3556
|
this.unsubscribe$.complete();
|
|
3400
3557
|
}
|
|
@@ -3434,6 +3591,21 @@ if (false) {
|
|
|
3434
3591
|
AssetListComponent.prototype.assets;
|
|
3435
3592
|
/** @type {?} */
|
|
3436
3593
|
AssetListComponent.prototype.backgroundProcessingNum;
|
|
3594
|
+
/**
|
|
3595
|
+
* @type {?}
|
|
3596
|
+
* @private
|
|
3597
|
+
*/
|
|
3598
|
+
AssetListComponent.prototype.processingCheckDelay;
|
|
3599
|
+
/**
|
|
3600
|
+
* @type {?}
|
|
3601
|
+
* @private
|
|
3602
|
+
*/
|
|
3603
|
+
AssetListComponent.prototype.processingCheckTimer;
|
|
3604
|
+
/**
|
|
3605
|
+
* @type {?}
|
|
3606
|
+
* @private
|
|
3607
|
+
*/
|
|
3608
|
+
AssetListComponent.prototype.processingCheckRequest;
|
|
3437
3609
|
/**
|
|
3438
3610
|
* @type {?}
|
|
3439
3611
|
* @private
|