@stemy/ngx-utils 12.0.4 → 12.1.0

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('reflect-metadata'), require('moment'), require('rxjs/operators'), require('rxjs'), require('invokable'), require('@angular/router'), require('@angular/common'), require('ngx-device-detector'), require('@angular/common/http'), require('@angular/platform-browser'), require('resize-detector'), require('@angular/forms')) :
3
- typeof define === 'function' && define.amd ? define('@stemy/ngx-utils', ['exports', '@angular/core', 'reflect-metadata', 'moment', 'rxjs/operators', 'rxjs', 'invokable', '@angular/router', '@angular/common', 'ngx-device-detector', '@angular/common/http', '@angular/platform-browser', 'resize-detector', '@angular/forms'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.stemy = global.stemy || {}, global.stemy["ngx-utils"] = {}), global.ng.core, null, global.moment, global.rxjs.operators, global.rxjs, global.invokable, global.ng.router, global.ng.common, global["ngx-device-detector"], global.ng.common.http, global.ng.platformBrowser, global["resize-detector"], global.ng.forms));
5
- })(this, (function (exports, core, reflectMetadata, moment, operators, rxjs, invokable, router, common, ngxDeviceDetector, http, platformBrowser, resizeDetector, forms) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('reflect-metadata'), require('moment'), require('rxjs/operators'), require('rxjs'), require('invokable'), require('@angular/router'), require('@angular/common'), require('ngx-device-detector'), require('@angular/common/http'), require('json5'), require('@angular/platform-browser'), require('resize-detector'), require('@angular/forms')) :
3
+ typeof define === 'function' && define.amd ? define('@stemy/ngx-utils', ['exports', '@angular/core', 'reflect-metadata', 'moment', 'rxjs/operators', 'rxjs', 'invokable', '@angular/router', '@angular/common', 'ngx-device-detector', '@angular/common/http', 'json5', '@angular/platform-browser', 'resize-detector', '@angular/forms'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.stemy = global.stemy || {}, global.stemy["ngx-utils"] = {}), global.ng.core, null, global.moment, global.rxjs.operators, global.rxjs, global.invokable, global.ng.router, global.ng.common, global["ngx-device-detector"], global.ng.common.http, global.json5, global.ng.platformBrowser, global["resize-detector"], global.ng.forms));
5
+ })(this, (function (exports, core, reflectMetadata, moment, operators, rxjs, invokable, router, common, ngxDeviceDetector, http, json5, platformBrowser, resizeDetector, forms) { 'use strict';
6
6
 
7
7
  /*! *****************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -3274,16 +3274,38 @@
3274
3274
  ConfigService.prototype.initService = function () {
3275
3275
  };
3276
3276
  ConfigService.prototype.loadJson = function () {
3277
- var _this = this;
3278
- if (this.universal.isServer) {
3279
- return Promise.resolve(this.loadedConfig);
3280
- }
3281
- var configUrl = this.configUrl;
3282
- return new Promise(function (resolve, reject) {
3283
- _this.http.get(configUrl).toPromise().then(function (response) {
3284
- resolve(response);
3285
- }, function () {
3286
- reject("Config file not found at: " + configUrl);
3277
+ return __awaiter(this, void 0, void 0, function () {
3278
+ var configUrl, config5, e_1, config, e_2;
3279
+ return __generator(this, function (_b) {
3280
+ switch (_b.label) {
3281
+ case 0:
3282
+ if (this.universal.isServer) {
3283
+ return [2 /*return*/, Promise.resolve(this.loadedConfig)];
3284
+ }
3285
+ configUrl = this.configUrl;
3286
+ _b.label = 1;
3287
+ case 1:
3288
+ _b.trys.push([1, 3, , 8]);
3289
+ return [4 /*yield*/, this.http.get(core.isDevMode() ? configUrl + "5" : configUrl, { responseType: "text" }).toPromise()];
3290
+ case 2:
3291
+ config5 = _b.sent();
3292
+ return [2 /*return*/, json5.parse(config5)];
3293
+ case 3:
3294
+ e_1 = _b.sent();
3295
+ _b.label = 4;
3296
+ case 4:
3297
+ _b.trys.push([4, 6, , 7]);
3298
+ return [4 /*yield*/, this.http.get(configUrl).toPromise()];
3299
+ case 5:
3300
+ config = _b.sent();
3301
+ console.log("Can't parse json5 config: " + e_1);
3302
+ return [2 /*return*/, config];
3303
+ case 6:
3304
+ e_2 = _b.sent();
3305
+ throw new Error("Config file not found at: " + configUrl);
3306
+ case 7: return [3 /*break*/, 8];
3307
+ case 8: return [2 /*return*/];
3308
+ }
3287
3309
  });
3288
3310
  });
3289
3311
  };
@@ -4805,37 +4827,43 @@
4805
4827
  },] }
4806
4828
  ];
4807
4829
 
4808
- var AsyncMethodDirective = /** @class */ (function () {
4809
- function AsyncMethodDirective(toaster) {
4830
+ var AsyncMethodBase = /** @class */ (function () {
4831
+ function AsyncMethodBase(toaster) {
4810
4832
  this.toaster = toaster;
4811
4833
  this.onSuccess = new core.EventEmitter();
4812
4834
  this.onError = new core.EventEmitter();
4813
4835
  }
4814
- Object.defineProperty(AsyncMethodDirective.prototype, "isDisabled", {
4836
+ Object.defineProperty(AsyncMethodBase.prototype, "isDisabled", {
4815
4837
  get: function () {
4816
4838
  return this.disabled;
4817
4839
  },
4818
4840
  enumerable: false,
4819
4841
  configurable: true
4820
4842
  });
4821
- Object.defineProperty(AsyncMethodDirective.prototype, "isLoading", {
4843
+ Object.defineProperty(AsyncMethodBase.prototype, "isLoading", {
4822
4844
  get: function () {
4823
4845
  return this.loading;
4824
4846
  },
4825
4847
  enumerable: false,
4826
4848
  configurable: true
4827
4849
  });
4828
- AsyncMethodDirective.prototype.click = function () {
4850
+ AsyncMethodBase.prototype.click = function () {
4829
4851
  if (this.disabled)
4830
4852
  return;
4831
4853
  this.callMethod();
4832
4854
  };
4833
- AsyncMethodDirective.prototype.callMethod = function () {
4855
+ AsyncMethodBase.prototype.callMethod = function () {
4834
4856
  var _this = this;
4835
4857
  if (this.loading)
4836
- return;
4858
+ return true;
4837
4859
  this.loading = true;
4838
- this.method(this.context).then(function (result) {
4860
+ var method = this.getMethod();
4861
+ var result = !method ? null : method(this.context);
4862
+ if (!(result instanceof Promise)) {
4863
+ this.loading = false;
4864
+ return false;
4865
+ }
4866
+ result.then(function (result) {
4839
4867
  _this.loading = false;
4840
4868
  if (result) {
4841
4869
  _this.onSuccess.emit(result);
@@ -4848,9 +4876,30 @@
4848
4876
  _this.onError.emit(reason);
4849
4877
  _this.toaster.error(reason.message, reason.context);
4850
4878
  });
4879
+ return true;
4851
4880
  };
4852
- return AsyncMethodDirective;
4881
+ return AsyncMethodBase;
4853
4882
  }());
4883
+ AsyncMethodBase.propDecorators = {
4884
+ disabled: [{ type: core.Input }],
4885
+ context: [{ type: core.Input }],
4886
+ onSuccess: [{ type: core.Output }],
4887
+ onError: [{ type: core.Output }],
4888
+ isDisabled: [{ type: core.HostBinding, args: ["class.disabled",] }],
4889
+ isLoading: [{ type: core.HostBinding, args: ["class.loading",] }],
4890
+ click: [{ type: core.HostListener, args: ["click",] }]
4891
+ };
4892
+
4893
+ var AsyncMethodDirective = /** @class */ (function (_super) {
4894
+ __extends(AsyncMethodDirective, _super);
4895
+ function AsyncMethodDirective(toaster) {
4896
+ return _super.call(this, toaster) || this;
4897
+ }
4898
+ AsyncMethodDirective.prototype.getMethod = function () {
4899
+ return this.method;
4900
+ };
4901
+ return AsyncMethodDirective;
4902
+ }(AsyncMethodBase));
4854
4903
  AsyncMethodDirective.decorators = [
4855
4904
  { type: core.Directive, args: [{
4856
4905
  selector: "[async-method]",
@@ -4861,14 +4910,7 @@
4861
4910
  { type: undefined, decorators: [{ type: core.Inject, args: [TOASTER_SERVICE,] }] }
4862
4911
  ]; };
4863
4912
  AsyncMethodDirective.propDecorators = {
4864
- method: [{ type: core.Input, args: ["async-method",] }],
4865
- disabled: [{ type: core.Input }],
4866
- context: [{ type: core.Input }],
4867
- onSuccess: [{ type: core.Output }],
4868
- onError: [{ type: core.Output }],
4869
- isDisabled: [{ type: core.HostBinding, args: ["class.disabled",] }],
4870
- isLoading: [{ type: core.HostBinding, args: ["class.loading",] }],
4871
- click: [{ type: core.HostListener, args: ["click",] }]
4913
+ method: [{ type: core.Input, args: ["async-method",] }]
4872
4914
  };
4873
4915
 
4874
4916
  var defaultClass = "default-image";
@@ -5971,6 +6013,7 @@
5971
6013
  exports.AjaxRequestHandler = AjaxRequestHandler;
5972
6014
  exports.ApiService = ApiService;
5973
6015
  exports.ArrayUtils = ArrayUtils;
6016
+ exports.AsyncMethodBase = AsyncMethodBase;
5974
6017
  exports.AsyncMethodDirective = AsyncMethodDirective;
5975
6018
  exports.AuthGuard = AuthGuard;
5976
6019
  exports.BASE_CONFIG = BASE_CONFIG;