@sumaris-net/ngx-components 1.11.8 → 1.11.11
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/sumaris-net.ngx-components.umd.js +53 -65
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/esm2015/src/app/core/form/entity-editor.class.js +18 -16
- package/esm2015/src/app/shared/upload-file/testing/upload-file.testing.js +7 -17
- package/esm2015/src/app/shared/upload-file/upload-file-popover.component.js +2 -2
- package/esm2015/src/app/shared/upload-file/upload-file.component.js +10 -10
- package/esm2015/src/app/shared/upload-file/upload-file.model.js +1 -1
- package/fesm2015/sumaris-net.ngx-components.js +32 -40
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/form/entity-editor.class.d.ts +4 -3
- package/src/app/shared/upload-file/testing/upload-file.testing.d.ts +3 -1
- package/src/app/shared/upload-file/upload-file.model.d.ts +1 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -18002,8 +18002,8 @@
|
|
|
18002
18002
|
UploadFileComponent.prototype.deleteFile = function (index) {
|
|
18003
18003
|
return __awaiter(this, void 0, void 0, function () {
|
|
18004
18004
|
var file, deleted, err_1;
|
|
18005
|
-
return __generator(this, function (
|
|
18006
|
-
switch (
|
|
18005
|
+
return __generator(this, function (_b) {
|
|
18006
|
+
switch (_b.label) {
|
|
18007
18007
|
case 0:
|
|
18008
18008
|
file = this.files[index];
|
|
18009
18009
|
if (!(file.progress === 1 && this.deleteFn)) return [3 /*break*/, 6];
|
|
@@ -18011,18 +18011,18 @@
|
|
|
18011
18011
|
console.warn("[upload-file] This file already deleting");
|
|
18012
18012
|
return [2 /*return*/];
|
|
18013
18013
|
}
|
|
18014
|
-
|
|
18014
|
+
_b.label = 1;
|
|
18015
18015
|
case 1:
|
|
18016
|
-
|
|
18016
|
+
_b.trys.push([1, 3, 4, 5]);
|
|
18017
18017
|
file.deleting = true;
|
|
18018
18018
|
return [4 /*yield*/, this.deleteFn(file)];
|
|
18019
18019
|
case 2:
|
|
18020
|
-
deleted =
|
|
18020
|
+
deleted = _b.sent();
|
|
18021
18021
|
if (!deleted)
|
|
18022
18022
|
return [2 /*return*/];
|
|
18023
18023
|
return [3 /*break*/, 5];
|
|
18024
18024
|
case 3:
|
|
18025
|
-
err_1 =
|
|
18025
|
+
err_1 = _b.sent();
|
|
18026
18026
|
console.error(err_1 && err_1.message || err_1);
|
|
18027
18027
|
return [2 /*return*/];
|
|
18028
18028
|
case 4:
|
|
@@ -18039,7 +18039,7 @@
|
|
|
18039
18039
|
console.warn("[upload-file] Cannot remove this file while uploading");
|
|
18040
18040
|
return [2 /*return*/];
|
|
18041
18041
|
}
|
|
18042
|
-
|
|
18042
|
+
_b.label = 7;
|
|
18043
18043
|
case 7:
|
|
18044
18044
|
this.files.splice(index, 1);
|
|
18045
18045
|
this.cd.markForCheck();
|
|
@@ -18054,7 +18054,7 @@
|
|
|
18054
18054
|
* @param files (Files List)
|
|
18055
18055
|
*/
|
|
18056
18056
|
UploadFileComponent.prototype.prepareFilesList = function (files) {
|
|
18057
|
-
var
|
|
18057
|
+
var _b;
|
|
18058
18058
|
var items;
|
|
18059
18059
|
if (files instanceof FileList) {
|
|
18060
18060
|
items = [];
|
|
@@ -18066,7 +18066,7 @@
|
|
|
18066
18066
|
else {
|
|
18067
18067
|
items = files;
|
|
18068
18068
|
}
|
|
18069
|
-
(
|
|
18069
|
+
(_b = this.files).push.apply(_b, __spread(items));
|
|
18070
18070
|
this.fileDropEl.nativeElement.value = '';
|
|
18071
18071
|
// Start upload
|
|
18072
18072
|
if (this.instantUpload) {
|
|
@@ -18080,7 +18080,7 @@
|
|
|
18080
18080
|
return __awaiter(this, void 0, void 0, function () {
|
|
18081
18081
|
var $processingFileCountChange, $changes, jobs;
|
|
18082
18082
|
var _this = this;
|
|
18083
|
-
return __generator(this, function (
|
|
18083
|
+
return __generator(this, function (_b) {
|
|
18084
18084
|
if (!files) {
|
|
18085
18085
|
console.info('[upload-file] Uploading all files...');
|
|
18086
18086
|
files = this.files;
|
|
@@ -18117,20 +18117,20 @@
|
|
|
18117
18117
|
// Start uploading
|
|
18118
18118
|
operators.switchMap(function (file) { return _this.uploadFn(file)
|
|
18119
18119
|
.pipe(operators.map(function (event) {
|
|
18120
|
-
var _a, _b, _c;
|
|
18121
18120
|
// Progress event
|
|
18122
18121
|
if ((event === null || event === void 0 ? void 0 : event.type) === i2$1.HttpEventType.UploadProgress || event.type === i2$1.HttpEventType.User) {
|
|
18123
|
-
|
|
18124
|
-
|
|
18125
|
-
|
|
18122
|
+
if (isNotNil(event.loaded) && event.loaded >= 0) {
|
|
18123
|
+
file.progress = Math.min(1, event.loaded / (event.total || 1));
|
|
18124
|
+
}
|
|
18125
|
+
else {
|
|
18126
|
+
file.progress = -1; // Indeterminate progression
|
|
18127
|
+
}
|
|
18126
18128
|
}
|
|
18127
18129
|
// Response event
|
|
18128
18130
|
else if (event instanceof i2$1.HttpResponse || event instanceof FileResponse) {
|
|
18129
|
-
file.body = event.body;
|
|
18130
18131
|
file.progress = 1;
|
|
18131
|
-
|
|
18132
|
-
console.debug("[upload-file] " + file.name + ": " +
|
|
18133
|
-
+ (((_b = file.body) === null || _b === void 0 ? void 0 : _b.finalName) ? " (finalName: " + ((_c = file.body) === null || _c === void 0 ? void 0 : _c.finalName) + ")" : ''));
|
|
18132
|
+
file.response = event;
|
|
18133
|
+
console.debug("[upload-file] " + file.name + ": " + (event.statusText || 'OK'), file.response);
|
|
18134
18134
|
}
|
|
18135
18135
|
// Other events
|
|
18136
18136
|
else {
|
|
@@ -18162,7 +18162,7 @@
|
|
|
18162
18162
|
UploadFileComponent.decorators = [
|
|
18163
18163
|
{ type: i0.Component, args: [{
|
|
18164
18164
|
selector: 'app-upload-file',
|
|
18165
|
-
template: "<div *ngIf=\"!uniqueFile || files.length === 0\"\n class=\"container\"\n appDragAndDrop (fileDropped)=\"onFileDropped($event)\">\n <input\n type=\"file\"\n #fileDropRef\n id=\"fileDropRef\"\n multiple\n [accept]=\"fileExtension\"\n (change)=\"fileBrowseHandler($any($event.target).files)\"\n />\n <mat-icon style=\"font-size: xx-large\" color=\"accent\">file_upload</mat-icon>\n <ion-label\n [innerHTML]=\"\n 'FILE.UPLOAD.DRAG_AND_DROP' | translate: { extension: !fileExtension ? '' : ' (' + fileExtension + ')' }\n \"\n ></ion-label>\n <ion-button>{{ 'FILE.UPLOAD.BROWSE' | translate }}</ion-button>\n</div>\n<div class=\"files-list\">\n <div *ngFor=\"let file of files; index as i\"\n class=\"single-file\"\n [class.deleting]=\"file.deleting\">\n <mat-icon>description</mat-icon>\n <div class=\"info\">\n <h4 class=\"name\">\n {{ file.name }}\n </h4>\n <p class=\"size\">\n {{ file.size | fileSize }}\n </p>\n <ion-progress-bar *ngIf=\"!file.error\"\n [value]=\"file.progress||0\"\n [type]=\"file.deleting ? 'indeterminate' : 'determinate'\"></ion-progress-bar>\n <ion-label *ngIf=\"file.error\" color=\"danger\" [innerHTML]=\"file.error | translate\"></ion-label>\n </div>\n <!-- remote from list (before importation) -->\n <button *ngIf=\"!(file.progress) || file.error\" mat-icon-button (click)=\"deleteFile(i)\">\n <mat-icon>clear</mat-icon>\n </button>\n <!-- delete file (remotely - after importation) -->\n <button *ngIf=\"file.progress === 1 && !!deleteFn && !file.deleting\" mat-icon-button (click)=\"deleteFile(i)\">\n <mat-icon>clear</mat-icon>\n </button>\n </div>\n</div>\n",
|
|
18165
|
+
template: "<div *ngIf=\"!uniqueFile || files.length === 0\"\n class=\"container\"\n appDragAndDrop (fileDropped)=\"onFileDropped($event)\">\n <input\n type=\"file\"\n #fileDropRef\n id=\"fileDropRef\"\n multiple\n [accept]=\"fileExtension\"\n (change)=\"fileBrowseHandler($any($event.target).files)\"\n />\n <mat-icon style=\"font-size: xx-large\" color=\"accent\">file_upload</mat-icon>\n <ion-label\n [innerHTML]=\"\n 'FILE.UPLOAD.DRAG_AND_DROP' | translate: { extension: !fileExtension ? '' : ' (' + fileExtension + ')' }\n \"\n ></ion-label>\n <ion-button>{{ 'FILE.UPLOAD.BROWSE' | translate }}</ion-button>\n</div>\n<div class=\"files-list\">\n <div *ngFor=\"let file of files; index as i\"\n class=\"single-file\"\n [class.deleting]=\"file.deleting\">\n <mat-icon>description</mat-icon>\n <div class=\"info\">\n <h4 class=\"name\">\n {{ file.name }}\n </h4>\n <p class=\"size\">\n {{ file.size | fileSize }}\n </p>\n <ion-progress-bar *ngIf=\"!file.error\"\n [value]=\"file.progress||0\"\n [type]=\"(file.deleting || file.progress === -1) ? 'indeterminate' : 'determinate'\"></ion-progress-bar>\n <ion-label *ngIf=\"file.error\" color=\"danger\" [innerHTML]=\"file.error | translate\"></ion-label>\n </div>\n <!-- remote from list (before importation) -->\n <button *ngIf=\"!(file.progress) || file.error\" mat-icon-button (click)=\"deleteFile(i)\">\n <mat-icon>clear</mat-icon>\n </button>\n <!-- delete file (remotely - after importation) -->\n <button *ngIf=\"file.progress === 1 && !!deleteFn && !file.deleting\" mat-icon-button (click)=\"deleteFile(i)\">\n <mat-icon>clear</mat-icon>\n </button>\n </div>\n</div>\n",
|
|
18166
18166
|
styles: [".container{width:calc(100% - 3rem);min-height:200px;padding:2rem;text-align:center;border:1px dashed #979797;position:relative;margin:1.5rem}.container input{opacity:0;position:absolute;z-index:2;width:100%;height:100%;top:0;left:0;cursor:pointer}.container ion-label{display:block;font-size:20px;font-weight:600;color:#38424c}.container label{display:inline-block;color:#fff;width:183px;height:44px;border-radius:21.5px;background-color:#db202f;padding:8px 16px}.fileover{-webkit-animation:shake 1s;animation:shake 1s;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite}.files-list{max-height:300px;overflow:auto}.files-list .single-file{display:flex;flex-grow:1;padding:.5rem;justify-content:space-between;align-items:center;border:1px dashed #979797;margin-bottom:1rem}.files-list .single-file.deleting .name{color:grey!important;font-style:italic!important}.files-list .single-file .name{font-size:14px;font-weight:500;color:#353f4a;margin:0}.files-list .single-file .size{font-size:12px;font-weight:500;color:#a4a4a4;margin:0 0 .25rem}.files-list .single-file .info{width:100%}@-webkit-keyframes shake{0%{transform:translate(1px,1px) rotate(0deg)}10%{transform:translate(-1px,-2px) rotate(-1deg)}20%{transform:translate(-3px) rotate(1deg)}30%{transform:translate(3px,2px) rotate(0deg)}40%{transform:translate(1px,-1px) rotate(1deg)}50%{transform:translate(-1px,2px) rotate(-1deg)}60%{transform:translate(-3px,1px) rotate(0deg)}70%{transform:translate(3px,1px) rotate(-1deg)}80%{transform:translate(-1px,-1px) rotate(1deg)}90%{transform:translate(1px,2px) rotate(0deg)}to{transform:translate(1px,-2px) rotate(-1deg)}}@keyframes shake{0%{transform:translate(1px,1px) rotate(0deg)}10%{transform:translate(-1px,-2px) rotate(-1deg)}20%{transform:translate(-3px) rotate(1deg)}30%{transform:translate(3px,2px) rotate(0deg)}40%{transform:translate(1px,-1px) rotate(1deg)}50%{transform:translate(-1px,2px) rotate(-1deg)}60%{transform:translate(-3px,1px) rotate(0deg)}70%{transform:translate(3px,1px) rotate(-1deg)}80%{transform:translate(-1px,-1px) rotate(1deg)}90%{transform:translate(1px,2px) rotate(0deg)}to{transform:translate(1px,-2px) rotate(-1deg)}}"]
|
|
18167
18167
|
},] }
|
|
18168
18168
|
];
|
|
@@ -18250,10 +18250,10 @@
|
|
|
18250
18250
|
errors.forEach(function (error) { return console.error(error); });
|
|
18251
18251
|
throw { message: 'FILE.UPLOAD.ERROR' };
|
|
18252
18252
|
}
|
|
18253
|
-
// return
|
|
18253
|
+
// return files
|
|
18254
18254
|
return [4 /*yield*/, this.popoverController.dismiss(files)];
|
|
18255
18255
|
case 5:
|
|
18256
|
-
// return
|
|
18256
|
+
// return files
|
|
18257
18257
|
_a.sent();
|
|
18258
18258
|
return [3 /*break*/, 7];
|
|
18259
18259
|
case 6:
|
|
@@ -27425,13 +27425,16 @@
|
|
|
27425
27425
|
});
|
|
27426
27426
|
});
|
|
27427
27427
|
};
|
|
27428
|
+
AppEntityEditor.prototype.canUserWrite = function (data, opts) {
|
|
27429
|
+
return this.dataService.canUserWrite(data, opts);
|
|
27430
|
+
};
|
|
27428
27431
|
AppEntityEditor.prototype.startListenRemoteChanges = function () {
|
|
27429
27432
|
var _this = this;
|
|
27430
27433
|
// Skip if disable, or already listening
|
|
27431
27434
|
if (this._listenChangesSubscription || !this._enableListenChanges || this.isNewData)
|
|
27432
27435
|
return;
|
|
27433
27436
|
// Listen for changes on server
|
|
27434
|
-
this._listenChangesSubscription = this.
|
|
27437
|
+
this._listenChangesSubscription = this.listenChanges(this.data.id, { interval: this._listenIntervalInSeconds })
|
|
27435
27438
|
.pipe(operators.filter(isNotNil))
|
|
27436
27439
|
.subscribe(function (data) {
|
|
27437
27440
|
if (data.updateDate && data.updateDate.isAfter(_this.data.updateDate)) {
|
|
@@ -27784,6 +27787,19 @@
|
|
|
27784
27787
|
});
|
|
27785
27788
|
});
|
|
27786
27789
|
};
|
|
27790
|
+
AppEntityEditor.prototype.unload = function () {
|
|
27791
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
27792
|
+
return __generator(this, function (_c) {
|
|
27793
|
+
this.stopListenRemoteChanges();
|
|
27794
|
+
this.form.reset();
|
|
27795
|
+
this.registerForms();
|
|
27796
|
+
this._dirty = false;
|
|
27797
|
+
this.data = null;
|
|
27798
|
+
this.saving = false;
|
|
27799
|
+
return [2 /*return*/];
|
|
27800
|
+
});
|
|
27801
|
+
});
|
|
27802
|
+
};
|
|
27787
27803
|
AppEntityEditor.prototype.goBack = function (event) {
|
|
27788
27804
|
var _a;
|
|
27789
27805
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -27833,10 +27849,6 @@
|
|
|
27833
27849
|
if (!opts || opts.emitEvent !== false)
|
|
27834
27850
|
this.markForCheck();
|
|
27835
27851
|
};
|
|
27836
|
-
/* -- public abstract methods (to override) -- */
|
|
27837
|
-
AppEntityEditor.prototype.canUserWrite = function (data, opts) {
|
|
27838
|
-
return this.dataService.canUserWrite(data, opts);
|
|
27839
|
-
};
|
|
27840
27852
|
/* -- protected methods -- */
|
|
27841
27853
|
/**
|
|
27842
27854
|
* Return undefined to keep same tab
|
|
@@ -27846,19 +27858,6 @@
|
|
|
27846
27858
|
var nextTabIndex = this.selectedTabIndex + 1;
|
|
27847
27859
|
return nextTabIndex < this.tabCount ? nextTabIndex : undefined;
|
|
27848
27860
|
};
|
|
27849
|
-
AppEntityEditor.prototype.unload = function () {
|
|
27850
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
27851
|
-
return __generator(this, function (_c) {
|
|
27852
|
-
this.stopListenRemoteChanges();
|
|
27853
|
-
this.form.reset();
|
|
27854
|
-
this.registerForms();
|
|
27855
|
-
this._dirty = false;
|
|
27856
|
-
this.data = null;
|
|
27857
|
-
this.saving = false;
|
|
27858
|
-
return [2 /*return*/];
|
|
27859
|
-
});
|
|
27860
|
-
});
|
|
27861
|
-
};
|
|
27862
27861
|
AppEntityEditor.prototype.onBeforeEntityLoad = function () {
|
|
27863
27862
|
return __awaiter(this, void 0, void 0, function () {
|
|
27864
27863
|
return __generator(this, function (_c) {
|
|
@@ -27982,6 +27981,9 @@
|
|
|
27982
27981
|
}
|
|
27983
27982
|
return parentUrl;
|
|
27984
27983
|
};
|
|
27984
|
+
AppEntityEditor.prototype.listenChanges = function (id, opts) {
|
|
27985
|
+
return this.dataService.listenChanges(this.data.id, opts);
|
|
27986
|
+
};
|
|
27985
27987
|
AppEntityEditor.prototype.markForCheck = function () {
|
|
27986
27988
|
this.cd.markForCheck();
|
|
27987
27989
|
};
|
|
@@ -29981,30 +29983,15 @@
|
|
|
29981
29983
|
}
|
|
29982
29984
|
UploadFileTestingPage.prototype.showPopover = function (event, opts) {
|
|
29983
29985
|
return __awaiter(this, void 0, void 0, function () {
|
|
29984
|
-
var
|
|
29986
|
+
var data, filenames;
|
|
29985
29987
|
var _this = this;
|
|
29986
|
-
return __generator(this, function (
|
|
29987
|
-
switch (
|
|
29988
|
-
case 0: return [4 /*yield*/, this.popoverController.
|
|
29989
|
-
component: UploadFilePopover,
|
|
29990
|
-
componentProps: Object.assign({ title: 'modalTitle', uploadFn: function (file) { return _this.uploadFile(file); }, deleteFn: function (file) { return _this.deleteFile(file); } }, opts),
|
|
29991
|
-
backdropDismiss: false,
|
|
29992
|
-
keyboardClose: false,
|
|
29993
|
-
event: event,
|
|
29994
|
-
translucent: true,
|
|
29995
|
-
cssClass: 'popover-large',
|
|
29996
|
-
})];
|
|
29988
|
+
return __generator(this, function (_c) {
|
|
29989
|
+
switch (_c.label) {
|
|
29990
|
+
case 0: return [4 /*yield*/, FilesUtils.showUploadPopover(this.popoverController, event, Object.assign({ uploadFn: function (file) { return _this.uploadFile(file); }, deleteFn: function (file) { return _this.deleteFile(file); } }, opts))];
|
|
29997
29991
|
case 1:
|
|
29998
|
-
|
|
29999
|
-
|
|
30000
|
-
|
|
30001
|
-
_a.sent();
|
|
30002
|
-
return [4 /*yield*/, modal.onDidDismiss()];
|
|
30003
|
-
case 3:
|
|
30004
|
-
data = (_a.sent()).data;
|
|
30005
|
-
if (data) {
|
|
30006
|
-
console.info('Popover result: ', data);
|
|
30007
|
-
}
|
|
29992
|
+
data = (_c.sent()).data;
|
|
29993
|
+
filenames = (data || []).map(function (file) { var _a, _b; return (_b = (_a = file.response) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.finalName; });
|
|
29994
|
+
console.info('Popover result: ', filenames);
|
|
30008
29995
|
return [2 /*return*/];
|
|
30009
29996
|
}
|
|
30010
29997
|
});
|
|
@@ -30023,7 +30010,8 @@
|
|
|
30023
30010
|
loaded += loadStep;
|
|
30024
30011
|
// Return progression
|
|
30025
30012
|
if (loaded < file.size) {
|
|
30026
|
-
return {
|
|
30013
|
+
//return {type: HttpEventType.UploadProgress, total: file.size, loaded };
|
|
30014
|
+
return { type: i2$1.HttpEventType.UploadProgress, loaded: -1 };
|
|
30027
30015
|
}
|
|
30028
30016
|
// Stop the timer
|
|
30029
30017
|
setTimeout(function () { return $stop.next(); }, 100);
|
|
@@ -30033,13 +30021,13 @@
|
|
|
30033
30021
|
};
|
|
30034
30022
|
UploadFileTestingPage.prototype.deleteFile = function (file) {
|
|
30035
30023
|
return __awaiter(this, void 0, void 0, function () {
|
|
30036
|
-
return __generator(this, function (
|
|
30037
|
-
switch (
|
|
30024
|
+
return __generator(this, function (_c) {
|
|
30025
|
+
switch (_c.label) {
|
|
30038
30026
|
case 0:
|
|
30039
30027
|
console.info('[testing] Simulate remote deletion... (waiting 2s)');
|
|
30040
30028
|
return [4 /*yield*/, sleep(2000)];
|
|
30041
30029
|
case 1:
|
|
30042
|
-
|
|
30030
|
+
_c.sent();
|
|
30043
30031
|
return [2 /*return*/, true];
|
|
30044
30032
|
}
|
|
30045
30033
|
});
|