@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
|
@@ -1448,6 +1448,7 @@ var UploadAssetsService = /** @class */ (function () {
|
|
|
1448
1448
|
this._api = _api;
|
|
1449
1449
|
this.files = [];
|
|
1450
1450
|
this.fileNames = [];
|
|
1451
|
+
this.uploadErrors = new Map();
|
|
1451
1452
|
this.supportedSize = 10 * 1024 * 1024; // 10MB
|
|
1452
1453
|
// 10MB
|
|
1453
1454
|
this.documentExtension = ['.pdf', '.csv'];
|
|
@@ -1550,9 +1551,25 @@ var UploadAssetsService = /** @class */ (function () {
|
|
|
1550
1551
|
* @return {?}
|
|
1551
1552
|
*/
|
|
1552
1553
|
function (index) {
|
|
1554
|
+
this.uploadErrors.delete(this.files[index]);
|
|
1553
1555
|
this.files.splice(index, 1);
|
|
1554
1556
|
this.fileNames.splice(index, 1);
|
|
1555
1557
|
};
|
|
1558
|
+
/**
|
|
1559
|
+
* @param {?} index
|
|
1560
|
+
* @return {?}
|
|
1561
|
+
*/
|
|
1562
|
+
UploadAssetsService.prototype.getUploadName = /**
|
|
1563
|
+
* @param {?} index
|
|
1564
|
+
* @return {?}
|
|
1565
|
+
*/
|
|
1566
|
+
function (index) {
|
|
1567
|
+
/** @type {?} */
|
|
1568
|
+
var nameSplit = this.files[index].name.split('.');
|
|
1569
|
+
/** @type {?} */
|
|
1570
|
+
var ext = "." + nameSplit.splice(nameSplit.length - 1, 1)[0];
|
|
1571
|
+
return "" + this.fileNames[index].name + ext;
|
|
1572
|
+
};
|
|
1556
1573
|
/**
|
|
1557
1574
|
* @param {?} parentAssetId
|
|
1558
1575
|
* @return {?}
|
|
@@ -1564,21 +1581,11 @@ var UploadAssetsService = /** @class */ (function () {
|
|
|
1564
1581
|
function (parentAssetId) {
|
|
1565
1582
|
var files = this.files;
|
|
1566
1583
|
/** @type {?} */
|
|
1567
|
-
var fileNames = this.fileNames.map((/**
|
|
1568
|
-
* @param {?} file
|
|
1569
|
-
* @return {?}
|
|
1570
|
-
*/
|
|
1571
|
-
function (file) { return file.name; }));
|
|
1572
|
-
/** @type {?} */
|
|
1573
1584
|
var formData = new FormData();
|
|
1574
1585
|
formData.append('parentAssetId', parentAssetId);
|
|
1575
1586
|
formData.append('companyId', '732DA8D2-04EC-4BE0-A168-63EE0DCF50D8');
|
|
1576
1587
|
for (var i = 0; i < files.length; i++) {
|
|
1577
|
-
|
|
1578
|
-
var nameSplit = files[i].name.split('.');
|
|
1579
|
-
/** @type {?} */
|
|
1580
|
-
var ext = "." + nameSplit.splice(nameSplit.length - 1, 1)[0];
|
|
1581
|
-
formData.append('files', files[i], "" + fileNames[i] + ext);
|
|
1588
|
+
formData.append('files', files[i], this.getUploadName(i));
|
|
1582
1589
|
}
|
|
1583
1590
|
return this._api.post(this.baseUrl + "/File/Upload", formData);
|
|
1584
1591
|
};
|
|
@@ -1602,6 +1609,8 @@ if (false) {
|
|
|
1602
1609
|
/** @type {?} */
|
|
1603
1610
|
UploadAssetsService.prototype.fileNames;
|
|
1604
1611
|
/** @type {?} */
|
|
1612
|
+
UploadAssetsService.prototype.uploadErrors;
|
|
1613
|
+
/** @type {?} */
|
|
1605
1614
|
UploadAssetsService.prototype.supportedSize;
|
|
1606
1615
|
/** @type {?} */
|
|
1607
1616
|
UploadAssetsService.prototype.documentExtension;
|
|
@@ -2407,6 +2416,16 @@ var FileItemComponent = /** @class */ (function () {
|
|
|
2407
2416
|
function () {
|
|
2408
2417
|
this.initDataFile();
|
|
2409
2418
|
};
|
|
2419
|
+
Object.defineProperty(FileItemComponent.prototype, "uploadErrors", {
|
|
2420
|
+
get: /**
|
|
2421
|
+
* @return {?}
|
|
2422
|
+
*/
|
|
2423
|
+
function () {
|
|
2424
|
+
return this.uploadAssetService.uploadErrors.get(this.file);
|
|
2425
|
+
},
|
|
2426
|
+
enumerable: true,
|
|
2427
|
+
configurable: true
|
|
2428
|
+
});
|
|
2410
2429
|
/**
|
|
2411
2430
|
* @private
|
|
2412
2431
|
* @return {?}
|
|
@@ -2529,8 +2548,8 @@ var FileItemComponent = /** @class */ (function () {
|
|
|
2529
2548
|
FileItemComponent.decorators = [
|
|
2530
2549
|
{ type: Component, args: [{
|
|
2531
2550
|
selector: 'lib-file-item',
|
|
2532
|
-
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
|
|
2533
|
-
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:#
|
|
2551
|
+
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",
|
|
2552
|
+
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{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}"]
|
|
2534
2553
|
}] }
|
|
2535
2554
|
];
|
|
2536
2555
|
/** @nocollapse */
|
|
@@ -3251,6 +3270,9 @@ var UploadDialogComponent = /** @class */ (function () {
|
|
|
3251
3270
|
this.uploadAssetsService = uploadAssetsService;
|
|
3252
3271
|
this.isLoading = false;
|
|
3253
3272
|
this.disabled = true;
|
|
3273
|
+
this.errorMessages = [];
|
|
3274
|
+
this.defaultErrorMessage = 'Something went wrong while uploading. Please try again.';
|
|
3275
|
+
this.isDestroyed = false;
|
|
3254
3276
|
this.destroy$ = new Subject();
|
|
3255
3277
|
if (this.data.fileType) {
|
|
3256
3278
|
this.uploadAssetsService.supportedTypes =
|
|
@@ -3278,6 +3300,7 @@ var UploadDialogComponent = /** @class */ (function () {
|
|
|
3278
3300
|
*/
|
|
3279
3301
|
function (error) {
|
|
3280
3302
|
_this.disabled = error;
|
|
3303
|
+
_this.clearErrors();
|
|
3281
3304
|
_this.changeDetectorRef.detectChanges();
|
|
3282
3305
|
}));
|
|
3283
3306
|
};
|
|
@@ -3291,6 +3314,7 @@ var UploadDialogComponent = /** @class */ (function () {
|
|
|
3291
3314
|
*/
|
|
3292
3315
|
function (hasError) {
|
|
3293
3316
|
this.disabled = hasError;
|
|
3317
|
+
this.clearErrors();
|
|
3294
3318
|
};
|
|
3295
3319
|
/**
|
|
3296
3320
|
* @return {?}
|
|
@@ -3301,6 +3325,8 @@ var UploadDialogComponent = /** @class */ (function () {
|
|
|
3301
3325
|
function () {
|
|
3302
3326
|
var _this = this;
|
|
3303
3327
|
this.isLoading = true;
|
|
3328
|
+
this.clearErrors();
|
|
3329
|
+
this.dialogRef.disableClose = true;
|
|
3304
3330
|
this.uploadAssetsService
|
|
3305
3331
|
.uploadMultipleAssets(this.data.currentAssetId)
|
|
3306
3332
|
.pipe(takeUntil(this.destroy$))
|
|
@@ -3312,8 +3338,129 @@ var UploadDialogComponent = /** @class */ (function () {
|
|
|
3312
3338
|
if (res) {
|
|
3313
3339
|
_this.closeDialog(true);
|
|
3314
3340
|
}
|
|
3341
|
+
}), (/**
|
|
3342
|
+
* @param {?} err
|
|
3343
|
+
* @return {?}
|
|
3344
|
+
*/
|
|
3345
|
+
function (err) {
|
|
3346
|
+
_this.setUploadErrors(_this.getErrorMessages(err));
|
|
3347
|
+
_this.stopLoading();
|
|
3348
|
+
}), (
|
|
3349
|
+
// the request can complete without a truthy response (or be swallowed by an interceptor)
|
|
3350
|
+
// the request can complete without a truthy response (or be swallowed by an interceptor)
|
|
3351
|
+
/**
|
|
3352
|
+
* @return {?}
|
|
3353
|
+
*/
|
|
3354
|
+
function () { return _this.stopLoading(); }));
|
|
3355
|
+
};
|
|
3356
|
+
/**
|
|
3357
|
+
* @private
|
|
3358
|
+
* @return {?}
|
|
3359
|
+
*/
|
|
3360
|
+
UploadDialogComponent.prototype.stopLoading = /**
|
|
3361
|
+
* @private
|
|
3362
|
+
* @return {?}
|
|
3363
|
+
*/
|
|
3364
|
+
function () {
|
|
3365
|
+
// takeUntil also completes the upload when the dialog is destroyed, its view can't be checked anymore
|
|
3366
|
+
if (this.isDestroyed) {
|
|
3367
|
+
return;
|
|
3368
|
+
}
|
|
3369
|
+
this.isLoading = false;
|
|
3370
|
+
this.dialogRef.disableClose = false;
|
|
3371
|
+
this.changeDetectorRef.detectChanges();
|
|
3372
|
+
};
|
|
3373
|
+
/**
|
|
3374
|
+
* @private
|
|
3375
|
+
* @return {?}
|
|
3376
|
+
*/
|
|
3377
|
+
UploadDialogComponent.prototype.clearErrors = /**
|
|
3378
|
+
* @private
|
|
3379
|
+
* @return {?}
|
|
3380
|
+
*/
|
|
3381
|
+
function () {
|
|
3382
|
+
this.errorMessages = [];
|
|
3383
|
+
this.uploadAssetsService.uploadErrors.clear();
|
|
3384
|
+
};
|
|
3385
|
+
// show each message on the file it mentions, the rest stay under the list
|
|
3386
|
+
// show each message on the file it mentions, the rest stay under the list
|
|
3387
|
+
/**
|
|
3388
|
+
* @private
|
|
3389
|
+
* @param {?} messages
|
|
3390
|
+
* @return {?}
|
|
3391
|
+
*/
|
|
3392
|
+
UploadDialogComponent.prototype.setUploadErrors =
|
|
3393
|
+
// show each message on the file it mentions, the rest stay under the list
|
|
3394
|
+
/**
|
|
3395
|
+
* @private
|
|
3396
|
+
* @param {?} messages
|
|
3397
|
+
* @return {?}
|
|
3398
|
+
*/
|
|
3399
|
+
function (messages) {
|
|
3400
|
+
var _this = this;
|
|
3401
|
+
var _a = this.uploadAssetsService, files = _a.getFiles, uploadErrors = _a.uploadErrors;
|
|
3402
|
+
/** @type {?} */
|
|
3403
|
+
var uploadNames = files.map((/**
|
|
3404
|
+
* @param {?} file
|
|
3405
|
+
* @param {?} index
|
|
3406
|
+
* @return {?}
|
|
3407
|
+
*/
|
|
3408
|
+
function (file, index) { return _this.uploadAssetsService.getUploadName(index); }));
|
|
3409
|
+
this.errorMessages = messages.filter((/**
|
|
3410
|
+
* @param {?} message
|
|
3411
|
+
* @return {?}
|
|
3412
|
+
*/
|
|
3413
|
+
function (message) {
|
|
3414
|
+
/** @type {?} */
|
|
3415
|
+
var index = uploadNames.findIndex((/**
|
|
3416
|
+
* @param {?} name
|
|
3417
|
+
* @return {?}
|
|
3418
|
+
*/
|
|
3419
|
+
function (name) { return message.indexOf(name) > -1; }));
|
|
3420
|
+
if (index < 0 && files.length === 1) {
|
|
3421
|
+
index = 0;
|
|
3422
|
+
}
|
|
3423
|
+
if (index < 0) {
|
|
3424
|
+
return true;
|
|
3425
|
+
}
|
|
3426
|
+
uploadErrors.set(files[index], __spread((uploadErrors.get(files[index]) || []), [message]));
|
|
3427
|
+
return false;
|
|
3315
3428
|
}));
|
|
3316
3429
|
};
|
|
3430
|
+
/**
|
|
3431
|
+
* @private
|
|
3432
|
+
* @param {?} err
|
|
3433
|
+
* @return {?}
|
|
3434
|
+
*/
|
|
3435
|
+
UploadDialogComponent.prototype.getErrorMessages = /**
|
|
3436
|
+
* @private
|
|
3437
|
+
* @param {?} err
|
|
3438
|
+
* @return {?}
|
|
3439
|
+
*/
|
|
3440
|
+
function (err) {
|
|
3441
|
+
// HttpErrorResponse keeps the API body in `error`, an interceptor may already unwrap it
|
|
3442
|
+
/** @type {?} */
|
|
3443
|
+
var body = err && err.error && typeof err.error === 'object' ? err.error : err || {};
|
|
3444
|
+
/** @type {?} */
|
|
3445
|
+
var messages = (body.Messages || [])
|
|
3446
|
+
.map((/**
|
|
3447
|
+
* @param {?} message
|
|
3448
|
+
* @return {?}
|
|
3449
|
+
*/
|
|
3450
|
+
function (message) { return (typeof message === 'string' ? message : message && message.Text); }))
|
|
3451
|
+
.filter(Boolean);
|
|
3452
|
+
if (!messages.length && body.ResponseMessage) {
|
|
3453
|
+
messages.push(body.ResponseMessage);
|
|
3454
|
+
}
|
|
3455
|
+
return messages.length
|
|
3456
|
+
? messages.filter((/**
|
|
3457
|
+
* @param {?} message
|
|
3458
|
+
* @param {?} index
|
|
3459
|
+
* @return {?}
|
|
3460
|
+
*/
|
|
3461
|
+
function (message, index) { return messages.indexOf(message) === index; }))
|
|
3462
|
+
: [this.defaultErrorMessage];
|
|
3463
|
+
};
|
|
3317
3464
|
/**
|
|
3318
3465
|
* @param {?=} res
|
|
3319
3466
|
* @return {?}
|
|
@@ -3332,15 +3479,16 @@ var UploadDialogComponent = /** @class */ (function () {
|
|
|
3332
3479
|
* @return {?}
|
|
3333
3480
|
*/
|
|
3334
3481
|
function () {
|
|
3482
|
+
this.isDestroyed = true;
|
|
3335
3483
|
this.destroy$.next(true);
|
|
3336
3484
|
this.destroy$.complete();
|
|
3337
3485
|
};
|
|
3338
3486
|
UploadDialogComponent.decorators = [
|
|
3339
3487
|
{ type: Component, args: [{
|
|
3340
3488
|
selector: 'lib-upload-dialog',
|
|
3341
|
-
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",
|
|
3489
|
+
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",
|
|
3342
3490
|
providers: [UploadAssetsService],
|
|
3343
|
-
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}"]
|
|
3491
|
+
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}"]
|
|
3344
3492
|
}] }
|
|
3345
3493
|
];
|
|
3346
3494
|
/** @nocollapse */
|
|
@@ -3357,6 +3505,18 @@ if (false) {
|
|
|
3357
3505
|
UploadDialogComponent.prototype.isLoading;
|
|
3358
3506
|
/** @type {?} */
|
|
3359
3507
|
UploadDialogComponent.prototype.disabled;
|
|
3508
|
+
/** @type {?} */
|
|
3509
|
+
UploadDialogComponent.prototype.errorMessages;
|
|
3510
|
+
/**
|
|
3511
|
+
* @type {?}
|
|
3512
|
+
* @private
|
|
3513
|
+
*/
|
|
3514
|
+
UploadDialogComponent.prototype.defaultErrorMessage;
|
|
3515
|
+
/**
|
|
3516
|
+
* @type {?}
|
|
3517
|
+
* @private
|
|
3518
|
+
*/
|
|
3519
|
+
UploadDialogComponent.prototype.isDestroyed;
|
|
3360
3520
|
/**
|
|
3361
3521
|
* @type {?}
|
|
3362
3522
|
* @private
|
|
@@ -3643,6 +3803,7 @@ var AssetListComponent = /** @class */ (function () {
|
|
|
3643
3803
|
this.hasAccessPermission = true;
|
|
3644
3804
|
this.hasArchivePermission = true;
|
|
3645
3805
|
this.backgroundProcessingNum = BackgroudProcessingStatus;
|
|
3806
|
+
this.processingCheckDelay = 5000;
|
|
3646
3807
|
this.unsubscribe$ = new Subject();
|
|
3647
3808
|
this.selectedAssets = [];
|
|
3648
3809
|
}
|
|
@@ -3664,17 +3825,8 @@ var AssetListComponent = /** @class */ (function () {
|
|
|
3664
3825
|
* @return {?}
|
|
3665
3826
|
*/
|
|
3666
3827
|
function (changes) {
|
|
3667
|
-
var _this = this;
|
|
3668
3828
|
if (changes.assets) {
|
|
3669
|
-
|
|
3670
|
-
if (this.assets && this.assets.find((/**
|
|
3671
|
-
* @param {?} x
|
|
3672
|
-
* @return {?}
|
|
3673
|
-
*/
|
|
3674
|
-
function (x) { return x.BackgroudProcessingStatus === _this.backgroundProcessingNum.InProcessing; }))) {
|
|
3675
|
-
this._resetUploadingAssets();
|
|
3676
|
-
}
|
|
3677
|
-
;
|
|
3829
|
+
this.checkProcessingAssets();
|
|
3678
3830
|
this.paginator.pageIndex = this.assetService.pageIndex;
|
|
3679
3831
|
this.paginator.pageSize = this.assetService.pageSize;
|
|
3680
3832
|
this.paginator.length = this.assetService.fileTotal;
|
|
@@ -3827,15 +3979,8 @@ var AssetListComponent = /** @class */ (function () {
|
|
|
3827
3979
|
* @param {?} res
|
|
3828
3980
|
* @return {?}
|
|
3829
3981
|
*/
|
|
3830
|
-
function (res) {
|
|
3831
|
-
/**
|
|
3832
|
-
var pagination = res && res.Meta || {};
|
|
3833
|
-
/** @type {?} */
|
|
3834
|
-
var assets = res && res.Data && res.Data.Children || [];
|
|
3835
|
-
/** @type {?} */
|
|
3836
|
-
var totalFile = res && res.Data && res.Data.TotalFile || 0;
|
|
3837
|
-
_this.assetService.setAssetList(assets, pagination, totalFile);
|
|
3838
|
-
})).add((/**
|
|
3982
|
+
function (res) { return _this.setAssetList(res); }))
|
|
3983
|
+
.add((/**
|
|
3839
3984
|
* @return {?}
|
|
3840
3985
|
*/
|
|
3841
3986
|
function () {
|
|
@@ -3847,29 +3992,92 @@ var AssetListComponent = /** @class */ (function () {
|
|
|
3847
3992
|
};
|
|
3848
3993
|
/**
|
|
3849
3994
|
* @private
|
|
3995
|
+
* @param {?} res
|
|
3850
3996
|
* @return {?}
|
|
3851
3997
|
*/
|
|
3852
|
-
AssetListComponent.prototype.
|
|
3998
|
+
AssetListComponent.prototype.setAssetList = /**
|
|
3999
|
+
* @private
|
|
4000
|
+
* @param {?} res
|
|
4001
|
+
* @return {?}
|
|
4002
|
+
*/
|
|
4003
|
+
function (res) {
|
|
4004
|
+
/** @type {?} */
|
|
4005
|
+
var pagination = res && res.Meta || {};
|
|
4006
|
+
/** @type {?} */
|
|
4007
|
+
var assets = res && res.Data && res.Data.Children || [];
|
|
4008
|
+
/** @type {?} */
|
|
4009
|
+
var totalFile = res && res.Data && res.Data.TotalFile || 0;
|
|
4010
|
+
this.assetService.setAssetList(assets, pagination, totalFile);
|
|
4011
|
+
};
|
|
4012
|
+
// Called on every new asset list: while some files are still processed in the background,
|
|
4013
|
+
// reload the list once after a delay. The reloaded list calls this again, until nothing is processing.
|
|
4014
|
+
// Called on every new asset list: while some files are still processed in the background,
|
|
4015
|
+
// reload the list once after a delay. The reloaded list calls this again, until nothing is processing.
|
|
4016
|
+
/**
|
|
4017
|
+
* @private
|
|
4018
|
+
* @return {?}
|
|
4019
|
+
*/
|
|
4020
|
+
AssetListComponent.prototype.checkProcessingAssets =
|
|
4021
|
+
// Called on every new asset list: while some files are still processed in the background,
|
|
4022
|
+
// reload the list once after a delay. The reloaded list calls this again, until nothing is processing.
|
|
4023
|
+
/**
|
|
3853
4024
|
* @private
|
|
3854
4025
|
* @return {?}
|
|
3855
4026
|
*/
|
|
3856
4027
|
function () {
|
|
3857
4028
|
var _this = this;
|
|
4029
|
+
this.stopProcessingCheck();
|
|
3858
4030
|
/** @type {?} */
|
|
3859
|
-
var
|
|
4031
|
+
var hasProcessingAssets = this.assets && this.assets.some((/**
|
|
4032
|
+
* @param {?} asset
|
|
3860
4033
|
* @return {?}
|
|
3861
4034
|
*/
|
|
3862
|
-
function () {
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
* @param {?} x
|
|
4035
|
+
function (asset) { return asset.BackgroudProcessingStatus === _this.backgroundProcessingNum.InProcessing; }));
|
|
4036
|
+
if (hasProcessingAssets) {
|
|
4037
|
+
this.processingCheckTimer = setTimeout((/**
|
|
3866
4038
|
* @return {?}
|
|
3867
4039
|
*/
|
|
3868
|
-
function (
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
4040
|
+
function () { return _this.reloadProcessingAssets(); }), this.processingCheckDelay);
|
|
4041
|
+
}
|
|
4042
|
+
};
|
|
4043
|
+
// Silent reload, without the global loading bar
|
|
4044
|
+
// Silent reload, without the global loading bar
|
|
4045
|
+
/**
|
|
4046
|
+
* @private
|
|
4047
|
+
* @return {?}
|
|
4048
|
+
*/
|
|
4049
|
+
AssetListComponent.prototype.reloadProcessingAssets =
|
|
4050
|
+
// Silent reload, without the global loading bar
|
|
4051
|
+
/**
|
|
4052
|
+
* @private
|
|
4053
|
+
* @return {?}
|
|
4054
|
+
*/
|
|
4055
|
+
function () {
|
|
4056
|
+
var _this = this;
|
|
4057
|
+
if (!this.currentFolderId) {
|
|
4058
|
+
return;
|
|
4059
|
+
}
|
|
4060
|
+
this.processingCheckRequest = this.assetService
|
|
4061
|
+
.getChildrenAssets({ assetId: this.currentFolderId })
|
|
4062
|
+
.subscribe((/**
|
|
4063
|
+
* @param {?} res
|
|
4064
|
+
* @return {?}
|
|
4065
|
+
*/
|
|
4066
|
+
function (res) { return _this.setAssetList(res); }));
|
|
4067
|
+
};
|
|
4068
|
+
/**
|
|
4069
|
+
* @private
|
|
4070
|
+
* @return {?}
|
|
4071
|
+
*/
|
|
4072
|
+
AssetListComponent.prototype.stopProcessingCheck = /**
|
|
4073
|
+
* @private
|
|
4074
|
+
* @return {?}
|
|
4075
|
+
*/
|
|
4076
|
+
function () {
|
|
4077
|
+
clearTimeout(this.processingCheckTimer);
|
|
4078
|
+
if (this.processingCheckRequest) {
|
|
4079
|
+
this.processingCheckRequest.unsubscribe();
|
|
4080
|
+
}
|
|
3873
4081
|
};
|
|
3874
4082
|
/**
|
|
3875
4083
|
* @return {?}
|
|
@@ -3878,6 +4086,7 @@ var AssetListComponent = /** @class */ (function () {
|
|
|
3878
4086
|
* @return {?}
|
|
3879
4087
|
*/
|
|
3880
4088
|
function () {
|
|
4089
|
+
this.stopProcessingCheck();
|
|
3881
4090
|
this.unsubscribe$.next();
|
|
3882
4091
|
this.unsubscribe$.complete();
|
|
3883
4092
|
};
|
|
@@ -3918,6 +4127,21 @@ if (false) {
|
|
|
3918
4127
|
AssetListComponent.prototype.assets;
|
|
3919
4128
|
/** @type {?} */
|
|
3920
4129
|
AssetListComponent.prototype.backgroundProcessingNum;
|
|
4130
|
+
/**
|
|
4131
|
+
* @type {?}
|
|
4132
|
+
* @private
|
|
4133
|
+
*/
|
|
4134
|
+
AssetListComponent.prototype.processingCheckDelay;
|
|
4135
|
+
/**
|
|
4136
|
+
* @type {?}
|
|
4137
|
+
* @private
|
|
4138
|
+
*/
|
|
4139
|
+
AssetListComponent.prototype.processingCheckTimer;
|
|
4140
|
+
/**
|
|
4141
|
+
* @type {?}
|
|
4142
|
+
* @private
|
|
4143
|
+
*/
|
|
4144
|
+
AssetListComponent.prototype.processingCheckRequest;
|
|
3921
4145
|
/**
|
|
3922
4146
|
* @type {?}
|
|
3923
4147
|
* @private
|