@sumaris-net/ngx-components 1.15.11 → 1.15.14

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.
@@ -4587,6 +4587,21 @@
4587
4587
  },] },
4588
4588
  { type: i0.Injectable, args: [{ providedIn: 'root' },] }
4589
4589
  ];
4590
+ var FormGetGroupPipe = /** @class */ (function () {
4591
+ function FormGetGroupPipe() {
4592
+ }
4593
+ FormGetGroupPipe.prototype.transform = function (form, path) {
4594
+ return form.get(path);
4595
+ };
4596
+ return FormGetGroupPipe;
4597
+ }());
4598
+ FormGetGroupPipe.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function FormGetGroupPipe_Factory() { return new FormGetGroupPipe(); }, token: FormGetGroupPipe, providedIn: "root" });
4599
+ FormGetGroupPipe.decorators = [
4600
+ { type: i0.Pipe, args: [{
4601
+ name: 'formGetGroup'
4602
+ },] },
4603
+ { type: i0.Injectable, args: [{ providedIn: 'root' },] }
4604
+ ];
4590
4605
 
4591
4606
  var SharedPipesModule = /** @class */ (function () {
4592
4607
  function SharedPipesModule() {
@@ -4636,7 +4651,8 @@
4636
4651
  FormErrorTranslatePipe,
4637
4652
  FormGetPipe,
4638
4653
  FormGetControlPipe,
4639
- FormGetArrayPipe
4654
+ FormGetArrayPipe,
4655
+ FormGetGroupPipe
4640
4656
  ],
4641
4657
  exports: [
4642
4658
  PropertyGetPipe,
@@ -4674,7 +4690,8 @@
4674
4690
  FormErrorTranslatePipe,
4675
4691
  FormGetPipe,
4676
4692
  FormGetControlPipe,
4677
- FormGetArrayPipe
4693
+ FormGetArrayPipe,
4694
+ FormGetGroupPipe
4678
4695
  ]
4679
4696
  },] }
4680
4697
  ];
@@ -11297,18 +11314,14 @@
11297
11314
  var HttpUtils = /** @class */ (function () {
11298
11315
  function HttpUtils() {
11299
11316
  }
11300
- HttpUtils.getResource = function (http, uri, opts) {
11317
+ HttpUtils.getText = function (http, uri, opts) {
11301
11318
  return __awaiter(this, void 0, void 0, function () {
11302
11319
  var err_1;
11303
11320
  return __generator(this, function (_a) {
11304
11321
  switch (_a.label) {
11305
11322
  case 0:
11306
11323
  // Add headers
11307
- opts = Object.assign({}, opts
11308
- //headers: new HttpHeaders(),
11309
- //.append('X-App-Name', environment.name)
11310
- //.append('X-App-Version', environment.version),
11311
- );
11324
+ opts = opts || { responseType: 'text' };
11312
11325
  // Force no cache
11313
11326
  if (opts.nocache === true) {
11314
11327
  opts.headers = (opts.headers instanceof i2$1.HttpHeaders ? opts.headers : new i2$1.HttpHeaders(opts.headers));
@@ -11319,10 +11332,8 @@
11319
11332
  _a.label = 1;
11320
11333
  case 1:
11321
11334
  _a.trys.push([1, 3, , 4]);
11322
- return [4 /*yield*/, http.get(uri, opts).toPromise()];
11323
- case 2:
11324
- // Using web http client
11325
- return [2 /*return*/, (_a.sent())];
11335
+ return [4 /*yield*/, http.get(uri, Object.assign(Object.assign({}, opts), { responseType: 'text' })).toPromise()];
11336
+ case 2: return [2 /*return*/, (_a.sent())];
11326
11337
  case 3:
11327
11338
  err_1 = _a.sent();
11328
11339
  if (err_1 && err_1.message) {
@@ -11337,6 +11348,40 @@
11337
11348
  });
11338
11349
  });
11339
11350
  };
11351
+ HttpUtils.getJson = function (http, uri, opts) {
11352
+ return __awaiter(this, void 0, void 0, function () {
11353
+ var err_2;
11354
+ return __generator(this, function (_a) {
11355
+ switch (_a.label) {
11356
+ case 0:
11357
+ // Add headers
11358
+ opts = opts || {};
11359
+ // Force no cache
11360
+ if (opts.nocache === true) {
11361
+ opts.headers = (opts.headers instanceof i2$1.HttpHeaders ? opts.headers : new i2$1.HttpHeaders(opts.headers));
11362
+ opts.headers
11363
+ .append('Cache-Control', 'no-cache')
11364
+ .append('Pragma', 'no-cache');
11365
+ }
11366
+ _a.label = 1;
11367
+ case 1:
11368
+ _a.trys.push([1, 3, , 4]);
11369
+ return [4 /*yield*/, http.get(uri, Object.assign(Object.assign({}, opts), { responseType: 'json' })).toPromise()];
11370
+ case 2: return [2 /*return*/, (_a.sent())];
11371
+ case 3:
11372
+ err_2 = _a.sent();
11373
+ if (err_2 && err_2.message) {
11374
+ console.error("[network] Error on get request " + uri + ": " + err_2.message, err_2);
11375
+ }
11376
+ else {
11377
+ console.error("[network] Error on get request " + uri + ": " + (err_2 && err_2.statusText) + " - " + JSON.stringify(err_2));
11378
+ }
11379
+ throw { code: err_2.status, message: 'ERROR.UNKNOWN_NETWORK_ERROR' };
11380
+ case 4: return [2 /*return*/];
11381
+ }
11382
+ });
11383
+ });
11384
+ };
11340
11385
  return HttpUtils;
11341
11386
  }());
11342
11387
 
@@ -11357,7 +11402,7 @@
11357
11402
  if (peerUrl.endsWith('/')) {
11358
11403
  peerUrl = peerUrl.substr(0, peerUrl.length - 1);
11359
11404
  }
11360
- return [2 /*return*/, HttpUtils.getResource(http, peerUrl + '/api/node/info', opts)];
11405
+ return [2 /*return*/, HttpUtils.getJson(http, peerUrl + '/api/node/info', opts)];
11361
11406
  });
11362
11407
  });
11363
11408
  }
@@ -12622,7 +12667,7 @@
12622
12667
  if (opts === null || opts === void 0 ? void 0 : opts.nocache) {
12623
12668
  path += '?t=' + Date.now();
12624
12669
  }
12625
- return [4 /*yield*/, this.get(path, opts)];
12670
+ return [4 /*yield*/, this.getText(path, opts)];
12626
12671
  case 1:
12627
12672
  appVersion = _b.sent();
12628
12673
  if (isNotNilOrBlank(appVersion))
@@ -12889,31 +12934,43 @@
12889
12934
  });
12890
12935
  this._timerSubscription.add(function () { return console.debug('[network] Refresh timer stopped'); });
12891
12936
  };
12937
+ NetworkService.prototype.getText = function (path, opts) {
12938
+ return __awaiter(this, void 0, void 0, function () {
12939
+ var uri;
12940
+ return __generator(this, function (_b) {
12941
+ uri = this.getUri(path);
12942
+ return [2 /*return*/, HttpUtils.getText(this.http, uri, opts)];
12943
+ });
12944
+ });
12945
+ };
12892
12946
  NetworkService.prototype.get = function (path, opts) {
12893
12947
  return __awaiter(this, void 0, void 0, function () {
12894
- var uri, peerUrl;
12948
+ var uri;
12895
12949
  return __generator(this, function (_b) {
12896
- uri = path;
12897
- // If path is not an URI: prepend with peer URL
12898
- if (!uri.startsWith('http://') && !uri.startsWith('https://')) {
12899
- peerUrl = (this.peer && this.peer.url);
12900
- // Remove trailing slash
12901
- if (peerUrl.endsWith('/')) {
12902
- peerUrl = peerUrl.substr(0, peerUrl.length - 1);
12903
- }
12904
- // Add first path
12905
- if (!path.startsWith('/')) {
12906
- path = '/' + path;
12907
- }
12908
- // Create the URI: concat peer URL and path
12909
- uri = peerUrl + path;
12910
- }
12911
- // Execute the request
12912
- return [2 /*return*/, HttpUtils.getResource(this.http, uri, opts)];
12950
+ uri = this.getUri(path);
12951
+ return [2 /*return*/, HttpUtils.getJson(this.http, uri, opts)];
12913
12952
  });
12914
12953
  });
12915
12954
  };
12916
12955
  /* -- Protected methods -- */
12956
+ NetworkService.prototype.getUri = function (path) {
12957
+ var uri = path;
12958
+ // If path is not an URI: prepend with peer URL
12959
+ if (!uri.startsWith('http://') && !uri.startsWith('https://')) {
12960
+ var peerUrl = (this.peer && this.peer.url);
12961
+ // Remove trailing slash
12962
+ if (peerUrl.endsWith('/')) {
12963
+ peerUrl = peerUrl.substr(0, peerUrl.length - 1);
12964
+ }
12965
+ // Add first path
12966
+ if (!path.startsWith('/')) {
12967
+ path = '/' + path;
12968
+ }
12969
+ // Create the URI: concat peer URL and path
12970
+ uri = peerUrl + path;
12971
+ }
12972
+ return uri;
12973
+ };
12917
12974
  NetworkService.prototype.onDeviceConnectionChanged = function (connectionType) {
12918
12975
  connectionType = (connectionType || 'unknown').toLowerCase();
12919
12976
  if (connectionType.startsWith('cell'))
@@ -18409,11 +18466,11 @@
18409
18466
  return FileResponse;
18410
18467
  }());
18411
18468
  function isProgressEvent(event) {
18412
- return event.type === i2$1.HttpEventType.UploadProgress
18413
- || event.type === i2$1.HttpEventType.DownloadProgress;
18469
+ return event && (event.type === i2$1.HttpEventType.UploadProgress
18470
+ || event.type === i2$1.HttpEventType.DownloadProgress);
18414
18471
  }
18415
18472
  function isResponseEvent(event) {
18416
- return event.type === i2$1.HttpEventType.Response;
18473
+ return event && event.type === i2$1.HttpEventType.Response;
18417
18474
  }
18418
18475
 
18419
18476
  var UploadFileComponent = /** @class */ (function () {
@@ -18556,7 +18613,7 @@
18556
18613
  });
18557
18614
  jobs = files
18558
18615
  .map(function (f) { return f; })
18559
- .filter(function (file) { return isNil(file.progress) && !file.error; }) // Skip if already started or in error
18616
+ .filter(function (file) { return file && isNil(file.progress) && !file.error; }) // Skip if already started or in error
18560
18617
  .map(function (file, i) {
18561
18618
  // Wait if need
18562
18619
  if (isNotNil(_this.maxParallelUpload)) {
@@ -18574,12 +18631,12 @@
18574
18631
  file.progress = 0;
18575
18632
  return rxjs.of(file);
18576
18633
  })
18577
- .map(function (file$) { return file$.pipe(
18634
+ .map(function (file$) { return file$.pipe(operators.filter(isNotNil),
18578
18635
  // Log
18579
18636
  operators.tap(function (file) { return console.debug("[upload-file] " + file.name + ": uploading..."); }),
18580
18637
  // Start uploading
18581
18638
  operators.switchMap(function (file) { return _this.uploadFn(file)
18582
- .pipe(operators.map(function (event) {
18639
+ .pipe(operators.filter(isNotNil), operators.map(function (event) {
18583
18640
  // Progress event
18584
18641
  if (isProgressEvent(event)) {
18585
18642
  if (isNotNil(event.loaded) && event.loaded >= 0) {
@@ -18589,10 +18646,6 @@
18589
18646
  file.progress = -1; // Indeterminate progression
18590
18647
  }
18591
18648
  }
18592
- // User event
18593
- else if (event.type === i2$1.HttpEventType.User) {
18594
- file.progress = -1; // Indeterminate progression
18595
- }
18596
18649
  // Response event
18597
18650
  else if (isResponseEvent(event)) {
18598
18651
  file.progress = 1;
@@ -31350,6 +31403,7 @@
31350
31403
  exports.FormFieldValuesHolder = FormFieldValuesHolder;
31351
31404
  exports.FormGetArrayPipe = FormGetArrayPipe;
31352
31405
  exports.FormGetControlPipe = FormGetControlPipe;
31406
+ exports.FormGetGroupPipe = FormGetGroupPipe;
31353
31407
  exports.FormGetPipe = FormGetPipe;
31354
31408
  exports.Fragments = Fragments;
31355
31409
  exports.GraphqlService = GraphqlService;