@sumaris-net/ngx-components 1.11.1 → 1.11.4

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.
@@ -18114,22 +18114,30 @@
18114
18114
  return rxjs.of(file);
18115
18115
  })
18116
18116
  .map(function (file$) { return file$.pipe(operators.tap(function (file) { return console.debug("[upload-file] " + file.name + ": uploading..."); }), operators.switchMap(function (file) { return _this.uploadFn(file).pipe(operators.map(function (event) {
18117
- if (event.type === i2$1.HttpEventType.UploadProgress) {
18118
- var total = event.total || file.size;
18119
- file.progress = Math.min(1, event.loaded / total);
18117
+ // Progress event
18118
+ if ((event === null || event === void 0 ? void 0 : event.type) === i2$1.HttpEventType.UploadProgress || event.type === i2$1.HttpEventType.User) {
18119
+ var total = event.total || 1;
18120
+ var loaded = event.loaded || 0;
18121
+ file.progress = Math.min(1, loaded / total);
18120
18122
  }
18123
+ // Response event
18121
18124
  else if (event instanceof i2$1.HttpResponse || event instanceof FileResponse) {
18122
- var content = event.body;
18123
- file.finalName = content === null || content === void 0 ? void 0 : content.finalName;
18125
+ var body = event.body;
18126
+ file.finalName = body === null || body === void 0 ? void 0 : body.finalName;
18124
18127
  file.progress = 1;
18125
- var message = content.message || event.statusText || 'succeed';
18126
- console.info("[upload-file] " + file.name + ": " + message + " (finalName: " + file.finalName + ")");
18128
+ var message = (body === null || body === void 0 ? void 0 : body.message) || event.statusText || 'OK';
18129
+ console.debug("[upload-file] " + file.name + ": " + message
18130
+ + (file.finalName ? " (finalName: " + file.finalName + ")" : ''));
18131
+ }
18132
+ else {
18133
+ // Other events
18134
+ console.warn('[upload-file] Unknown event, returned by uploadFn\'s observable:', event);
18127
18135
  }
18128
18136
  return file;
18129
18137
  }), operators.catchError(function (err) {
18130
18138
  var _a;
18131
18139
  console.error(err);
18132
- file.error = ((_a = err.error) === null || _a === void 0 ? void 0 : _a.message) || 'FILE.UPLOAD.ERROR';
18140
+ file.error = err && (err.message || ((_a = err.error) === null || _a === void 0 ? void 0 : _a.message)) || 'FILE.UPLOAD.ERROR';
18133
18141
  return rxjs.of(file);
18134
18142
  }), operators.tap(function () {
18135
18143
  $changes.next();