@stemy/ngx-utils 12.0.5 → 12.1.1
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/stemy-ngx-utils.umd.js +73 -35
- package/bundles/stemy-ngx-utils.umd.js.map +1 -1
- package/esm2015/ngx-utils/common-types.js +1 -1
- package/esm2015/ngx-utils/directives/async-method.base.js +54 -0
- package/esm2015/ngx-utils/directives/async-method.directive.js +8 -46
- package/esm2015/ngx-utils/services/base-http.service.js +4 -5
- package/esm2015/ngx-utils/services/config.service.js +23 -12
- package/esm2015/public_api.js +2 -1
- package/fesm2015/stemy-ngx-utils.js +51 -28
- package/fesm2015/stemy-ngx-utils.js.map +1 -1
- package/ngx-utils/common-types.d.ts +1 -1
- package/ngx-utils/directives/async-method.base.d.ts +16 -0
- package/ngx-utils/directives/async-method.directive.d.ts +4 -13
- package/package.json +3 -2
- package/public_api.d.ts +1 -0
- package/stemy-ngx-utils.metadata.json +1 -1
|
@@ -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.
|
|
@@ -3033,8 +3033,7 @@
|
|
|
3033
3033
|
}
|
|
3034
3034
|
return;
|
|
3035
3035
|
}
|
|
3036
|
-
|
|
3037
|
-
resolve(_this.parseResponse(response, url, options));
|
|
3036
|
+
resolve(_this.parseResponse(event, url, options));
|
|
3038
3037
|
var headers = options.headers;
|
|
3039
3038
|
var authKey = "Authorization";
|
|
3040
3039
|
// If we use token auth
|
|
@@ -3085,7 +3084,7 @@
|
|
|
3085
3084
|
// Set base options
|
|
3086
3085
|
options = options ? Object.assign({}, options) : {};
|
|
3087
3086
|
options.method = method;
|
|
3088
|
-
options.observe = "body";
|
|
3087
|
+
options.observe = options.observe || "body";
|
|
3089
3088
|
options.originalHeaders = options.originalHeaders || options.headers || {};
|
|
3090
3089
|
options.withCredentials = ObjectUtils.isBoolean(options.withCredentials) ? options.withCredentials : this.withCredentials;
|
|
3091
3090
|
options.body = body || {};
|
|
@@ -3274,16 +3273,38 @@
|
|
|
3274
3273
|
ConfigService.prototype.initService = function () {
|
|
3275
3274
|
};
|
|
3276
3275
|
ConfigService.prototype.loadJson = function () {
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
return
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3276
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3277
|
+
var configUrl, config5, e_1, config, e_2;
|
|
3278
|
+
return __generator(this, function (_b) {
|
|
3279
|
+
switch (_b.label) {
|
|
3280
|
+
case 0:
|
|
3281
|
+
if (this.universal.isServer) {
|
|
3282
|
+
return [2 /*return*/, Promise.resolve(this.loadedConfig)];
|
|
3283
|
+
}
|
|
3284
|
+
configUrl = this.configUrl;
|
|
3285
|
+
_b.label = 1;
|
|
3286
|
+
case 1:
|
|
3287
|
+
_b.trys.push([1, 3, , 8]);
|
|
3288
|
+
return [4 /*yield*/, this.http.get(core.isDevMode() ? configUrl + "5" : configUrl, { responseType: "text" }).toPromise()];
|
|
3289
|
+
case 2:
|
|
3290
|
+
config5 = _b.sent();
|
|
3291
|
+
return [2 /*return*/, json5.parse(config5)];
|
|
3292
|
+
case 3:
|
|
3293
|
+
e_1 = _b.sent();
|
|
3294
|
+
_b.label = 4;
|
|
3295
|
+
case 4:
|
|
3296
|
+
_b.trys.push([4, 6, , 7]);
|
|
3297
|
+
return [4 /*yield*/, this.http.get(configUrl).toPromise()];
|
|
3298
|
+
case 5:
|
|
3299
|
+
config = _b.sent();
|
|
3300
|
+
console.log("Can't parse json5 config: " + e_1);
|
|
3301
|
+
return [2 /*return*/, config];
|
|
3302
|
+
case 6:
|
|
3303
|
+
e_2 = _b.sent();
|
|
3304
|
+
throw new Error("Config file not found at: " + configUrl);
|
|
3305
|
+
case 7: return [3 /*break*/, 8];
|
|
3306
|
+
case 8: return [2 /*return*/];
|
|
3307
|
+
}
|
|
3287
3308
|
});
|
|
3288
3309
|
});
|
|
3289
3310
|
};
|
|
@@ -4805,39 +4826,42 @@
|
|
|
4805
4826
|
},] }
|
|
4806
4827
|
];
|
|
4807
4828
|
|
|
4808
|
-
var
|
|
4809
|
-
function
|
|
4829
|
+
var AsyncMethodBase = /** @class */ (function () {
|
|
4830
|
+
function AsyncMethodBase(toaster) {
|
|
4810
4831
|
this.toaster = toaster;
|
|
4811
4832
|
this.onSuccess = new core.EventEmitter();
|
|
4812
4833
|
this.onError = new core.EventEmitter();
|
|
4813
4834
|
}
|
|
4814
|
-
Object.defineProperty(
|
|
4835
|
+
Object.defineProperty(AsyncMethodBase.prototype, "isDisabled", {
|
|
4815
4836
|
get: function () {
|
|
4816
4837
|
return this.disabled;
|
|
4817
4838
|
},
|
|
4818
4839
|
enumerable: false,
|
|
4819
4840
|
configurable: true
|
|
4820
4841
|
});
|
|
4821
|
-
Object.defineProperty(
|
|
4842
|
+
Object.defineProperty(AsyncMethodBase.prototype, "isLoading", {
|
|
4822
4843
|
get: function () {
|
|
4823
4844
|
return this.loading;
|
|
4824
4845
|
},
|
|
4825
4846
|
enumerable: false,
|
|
4826
4847
|
configurable: true
|
|
4827
4848
|
});
|
|
4828
|
-
|
|
4849
|
+
AsyncMethodBase.prototype.click = function () {
|
|
4829
4850
|
if (this.disabled)
|
|
4830
4851
|
return;
|
|
4831
4852
|
this.callMethod();
|
|
4832
4853
|
};
|
|
4833
|
-
|
|
4854
|
+
AsyncMethodBase.prototype.callMethod = function () {
|
|
4834
4855
|
var _this = this;
|
|
4835
4856
|
if (this.loading)
|
|
4836
4857
|
return true;
|
|
4837
|
-
var result = !this.method ? null : this.method(this.context);
|
|
4838
|
-
if (!(result instanceof Promise))
|
|
4839
|
-
return false;
|
|
4840
4858
|
this.loading = true;
|
|
4859
|
+
var method = this.getMethod();
|
|
4860
|
+
var result = !method ? null : method(this.context);
|
|
4861
|
+
if (!(result instanceof Promise)) {
|
|
4862
|
+
this.loading = false;
|
|
4863
|
+
return false;
|
|
4864
|
+
}
|
|
4841
4865
|
result.then(function (result) {
|
|
4842
4866
|
_this.loading = false;
|
|
4843
4867
|
if (result) {
|
|
@@ -4853,8 +4877,28 @@
|
|
|
4853
4877
|
});
|
|
4854
4878
|
return true;
|
|
4855
4879
|
};
|
|
4856
|
-
return
|
|
4880
|
+
return AsyncMethodBase;
|
|
4857
4881
|
}());
|
|
4882
|
+
AsyncMethodBase.propDecorators = {
|
|
4883
|
+
disabled: [{ type: core.Input }],
|
|
4884
|
+
context: [{ type: core.Input }],
|
|
4885
|
+
onSuccess: [{ type: core.Output }],
|
|
4886
|
+
onError: [{ type: core.Output }],
|
|
4887
|
+
isDisabled: [{ type: core.HostBinding, args: ["class.disabled",] }],
|
|
4888
|
+
isLoading: [{ type: core.HostBinding, args: ["class.loading",] }],
|
|
4889
|
+
click: [{ type: core.HostListener, args: ["click",] }]
|
|
4890
|
+
};
|
|
4891
|
+
|
|
4892
|
+
var AsyncMethodDirective = /** @class */ (function (_super) {
|
|
4893
|
+
__extends(AsyncMethodDirective, _super);
|
|
4894
|
+
function AsyncMethodDirective(toaster) {
|
|
4895
|
+
return _super.call(this, toaster) || this;
|
|
4896
|
+
}
|
|
4897
|
+
AsyncMethodDirective.prototype.getMethod = function () {
|
|
4898
|
+
return this.method;
|
|
4899
|
+
};
|
|
4900
|
+
return AsyncMethodDirective;
|
|
4901
|
+
}(AsyncMethodBase));
|
|
4858
4902
|
AsyncMethodDirective.decorators = [
|
|
4859
4903
|
{ type: core.Directive, args: [{
|
|
4860
4904
|
selector: "[async-method]",
|
|
@@ -4865,14 +4909,7 @@
|
|
|
4865
4909
|
{ type: undefined, decorators: [{ type: core.Inject, args: [TOASTER_SERVICE,] }] }
|
|
4866
4910
|
]; };
|
|
4867
4911
|
AsyncMethodDirective.propDecorators = {
|
|
4868
|
-
method: [{ type: core.Input, args: ["async-method",] }]
|
|
4869
|
-
disabled: [{ type: core.Input }],
|
|
4870
|
-
context: [{ type: core.Input }],
|
|
4871
|
-
onSuccess: [{ type: core.Output }],
|
|
4872
|
-
onError: [{ type: core.Output }],
|
|
4873
|
-
isDisabled: [{ type: core.HostBinding, args: ["class.disabled",] }],
|
|
4874
|
-
isLoading: [{ type: core.HostBinding, args: ["class.loading",] }],
|
|
4875
|
-
click: [{ type: core.HostListener, args: ["click",] }]
|
|
4912
|
+
method: [{ type: core.Input, args: ["async-method",] }]
|
|
4876
4913
|
};
|
|
4877
4914
|
|
|
4878
4915
|
var defaultClass = "default-image";
|
|
@@ -5975,6 +6012,7 @@
|
|
|
5975
6012
|
exports.AjaxRequestHandler = AjaxRequestHandler;
|
|
5976
6013
|
exports.ApiService = ApiService;
|
|
5977
6014
|
exports.ArrayUtils = ArrayUtils;
|
|
6015
|
+
exports.AsyncMethodBase = AsyncMethodBase;
|
|
5978
6016
|
exports.AsyncMethodDirective = AsyncMethodDirective;
|
|
5979
6017
|
exports.AuthGuard = AuthGuard;
|
|
5980
6018
|
exports.BASE_CONFIG = BASE_CONFIG;
|