tnx-shared 5.3.363 → 5.3.365
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/tnx-shared.umd.js +292 -255
- package/bundles/tnx-shared.umd.js.map +1 -1
- package/bundles/tnx-shared.umd.min.js +1 -1
- package/bundles/tnx-shared.umd.min.js.map +1 -1
- package/components/common-lib/common-lib.component.d.ts +14 -1
- package/components/common-lib/common-lib.component.d.ts.map +1 -1
- package/components/file-explorer/services/file-object.service.d.ts +1 -1
- package/components/file-explorer/services/file-object.service.d.ts.map +1 -1
- package/esm2015/components/common-lib/common-lib.component.js +45 -3
- package/esm2015/components/file-explorer/services/file-object.service.js +3 -3
- package/fesm2015/tnx-shared.js +266 -230
- package/fesm2015/tnx-shared.js.map +1 -1
- package/package.json +2 -2
- package/tnx-shared.metadata.json +1 -1
package/fesm2015/tnx-shared.js
CHANGED
|
@@ -26124,7 +26124,7 @@ class FileObjectService extends BaseService {
|
|
|
26124
26124
|
const arr = fileExtension.split('.');
|
|
26125
26125
|
fileExtension = arr[arr.length - 1];
|
|
26126
26126
|
}
|
|
26127
|
-
if ((/(pdf|doc|docx)$/i).test(fileExtension)) {
|
|
26127
|
+
if ((/(pdf|doc|docx|xlsx|xls)$/i).test(fileExtension)) {
|
|
26128
26128
|
return true;
|
|
26129
26129
|
}
|
|
26130
26130
|
}
|
|
@@ -34151,15 +34151,260 @@ UserPickerDialogComponent.propDecorators = {
|
|
|
34151
34151
|
control: [{ type: Input }]
|
|
34152
34152
|
};
|
|
34153
34153
|
|
|
34154
|
+
class GenericGuardChildService {
|
|
34155
|
+
constructor(_userService, _permissionService, _router, _injector, _notifierService) {
|
|
34156
|
+
this._userService = _userService;
|
|
34157
|
+
this._permissionService = _permissionService;
|
|
34158
|
+
this._router = _router;
|
|
34159
|
+
this._injector = _injector;
|
|
34160
|
+
this._notifierService = _notifierService;
|
|
34161
|
+
this.storage = sessionStorage;
|
|
34162
|
+
}
|
|
34163
|
+
canActivateChild(route, state) {
|
|
34164
|
+
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
34165
|
+
const _applicationContext = this._injector.get(ApplicationContextService);
|
|
34166
|
+
const root = _applicationContext.getRootContext();
|
|
34167
|
+
if (state.url == '/') {
|
|
34168
|
+
resolve(true);
|
|
34169
|
+
return;
|
|
34170
|
+
}
|
|
34171
|
+
if ((top.location.href.indexOf('/dashboard') > -1)
|
|
34172
|
+
|| (top.location.href.indexOf('/access-denied') > -1)) {
|
|
34173
|
+
resolve(true);
|
|
34174
|
+
return;
|
|
34175
|
+
}
|
|
34176
|
+
// todo: còn case sử dụng biến trong url
|
|
34177
|
+
const service = root.data.currentAppMetadata.code;
|
|
34178
|
+
const permission = `${root.data.currentAppMetadata.code}${state.url.split('#')[0].split('?')[0]}`.toUpperCase();
|
|
34179
|
+
const isAuthorized = yield this._permissionService.isAuthorized(service, permission);
|
|
34180
|
+
if (isAuthorized) {
|
|
34181
|
+
resolve(true);
|
|
34182
|
+
}
|
|
34183
|
+
else {
|
|
34184
|
+
const firstTimeLogin = localStorage.getItem('firstTimeLogin');
|
|
34185
|
+
if (firstTimeLogin && firstTimeLogin !== '' && firstTimeLogin == 'true') {
|
|
34186
|
+
localStorage.removeItem('firstTimeLogin');
|
|
34187
|
+
top.location.href = '/';
|
|
34188
|
+
}
|
|
34189
|
+
else {
|
|
34190
|
+
top.location.href = window['baseHref'] + '/access-denied';
|
|
34191
|
+
}
|
|
34192
|
+
resolve(false);
|
|
34193
|
+
}
|
|
34194
|
+
resolve(true);
|
|
34195
|
+
}));
|
|
34196
|
+
}
|
|
34197
|
+
}
|
|
34198
|
+
GenericGuardChildService.ɵprov = i0.ɵɵdefineInjectable({ factory: function GenericGuardChildService_Factory() { return new GenericGuardChildService(i0.ɵɵinject(UserService), i0.ɵɵinject(PermissionService), i0.ɵɵinject(i3$1.Router), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(NotifierService)); }, token: GenericGuardChildService, providedIn: "root" });
|
|
34199
|
+
GenericGuardChildService.decorators = [
|
|
34200
|
+
{ type: Injectable, args: [{
|
|
34201
|
+
providedIn: 'root'
|
|
34202
|
+
},] }
|
|
34203
|
+
];
|
|
34204
|
+
GenericGuardChildService.ctorParameters = () => [
|
|
34205
|
+
{ type: UserService },
|
|
34206
|
+
{ type: PermissionService },
|
|
34207
|
+
{ type: Router },
|
|
34208
|
+
{ type: Injector },
|
|
34209
|
+
{ type: NotifierService }
|
|
34210
|
+
];
|
|
34211
|
+
|
|
34212
|
+
class GenericGuardService {
|
|
34213
|
+
constructor(_permissionService, _injector) {
|
|
34214
|
+
this._permissionService = _permissionService;
|
|
34215
|
+
this._injector = _injector;
|
|
34216
|
+
this.storage = sessionStorage;
|
|
34217
|
+
}
|
|
34218
|
+
canActivate(route, state) {
|
|
34219
|
+
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
34220
|
+
const _applicationContext = this._injector.get(ApplicationContextService);
|
|
34221
|
+
const root = _applicationContext.getRootContext();
|
|
34222
|
+
if (state.url == '/') {
|
|
34223
|
+
resolve(true);
|
|
34224
|
+
return;
|
|
34225
|
+
}
|
|
34226
|
+
if ((top.location.href.indexOf('/dashboard') > -1)
|
|
34227
|
+
|| (top.location.href.indexOf('/access-denied') > -1)) {
|
|
34228
|
+
resolve(true);
|
|
34229
|
+
return;
|
|
34230
|
+
}
|
|
34231
|
+
// todo: còn case sử dụng biến trong url
|
|
34232
|
+
const service = root.data.currentAppMetadata.code;
|
|
34233
|
+
const permission = `${root.data.currentAppMetadata.code}${state.url.split('#')[0].split('?')[0]}`.toUpperCase();
|
|
34234
|
+
const isAuthorized = yield this._permissionService.isAuthorized(service, permission);
|
|
34235
|
+
if (isAuthorized) {
|
|
34236
|
+
resolve(true);
|
|
34237
|
+
}
|
|
34238
|
+
else {
|
|
34239
|
+
// this._notifierService.showWarning('Bạn không có quyền truy cập vào trang này', 'Cảnh báo');
|
|
34240
|
+
const firstTimeLogin = localStorage.getItem('firstTimeLogin');
|
|
34241
|
+
if (firstTimeLogin && firstTimeLogin !== '' && firstTimeLogin == 'true') {
|
|
34242
|
+
localStorage.removeItem('firstTimeLogin');
|
|
34243
|
+
top.location.href = '/';
|
|
34244
|
+
}
|
|
34245
|
+
else {
|
|
34246
|
+
top.location.href = '/access-denied';
|
|
34247
|
+
}
|
|
34248
|
+
resolve(false);
|
|
34249
|
+
}
|
|
34250
|
+
resolve(true);
|
|
34251
|
+
}));
|
|
34252
|
+
}
|
|
34253
|
+
}
|
|
34254
|
+
GenericGuardService.ɵprov = i0.ɵɵdefineInjectable({ factory: function GenericGuardService_Factory() { return new GenericGuardService(i0.ɵɵinject(PermissionService), i0.ɵɵinject(i0.INJECTOR)); }, token: GenericGuardService, providedIn: "root" });
|
|
34255
|
+
GenericGuardService.decorators = [
|
|
34256
|
+
{ type: Injectable, args: [{
|
|
34257
|
+
providedIn: 'root'
|
|
34258
|
+
},] }
|
|
34259
|
+
];
|
|
34260
|
+
GenericGuardService.ctorParameters = () => [
|
|
34261
|
+
{ type: PermissionService },
|
|
34262
|
+
{ type: Injector }
|
|
34263
|
+
];
|
|
34264
|
+
|
|
34265
|
+
class StorageService {
|
|
34266
|
+
constructor(_moduleConfigService) {
|
|
34267
|
+
this._moduleConfigService = _moduleConfigService;
|
|
34268
|
+
this.ignoreBuildInCacheKey = /(expires_at|id_token_expires_at|nonce|access_token_stored_at|id_token_stored_at|id_token|access_token|id_token_claims_obj|session_state|granted_scopes)/i;
|
|
34269
|
+
const st = this._moduleConfigService.getConfig().environment.storage;
|
|
34270
|
+
if (st === 'sessionStorage') {
|
|
34271
|
+
this.storage = sessionStorage;
|
|
34272
|
+
}
|
|
34273
|
+
else {
|
|
34274
|
+
this.storage = localStorage;
|
|
34275
|
+
}
|
|
34276
|
+
}
|
|
34277
|
+
setStorage(storage) {
|
|
34278
|
+
this.storage = storage;
|
|
34279
|
+
}
|
|
34280
|
+
getStorage() {
|
|
34281
|
+
return this.storage;
|
|
34282
|
+
}
|
|
34283
|
+
setItem(key, value) {
|
|
34284
|
+
if (!value) {
|
|
34285
|
+
this.storage.setItem(key, null);
|
|
34286
|
+
}
|
|
34287
|
+
if (value instanceof Object) {
|
|
34288
|
+
this.storage.setItem(key, JSON.stringify(value));
|
|
34289
|
+
}
|
|
34290
|
+
else {
|
|
34291
|
+
this.storage.setItem(key, value ? value.toString() : null);
|
|
34292
|
+
}
|
|
34293
|
+
}
|
|
34294
|
+
removeItem(key) {
|
|
34295
|
+
this.storage.removeItem(key);
|
|
34296
|
+
if (key.startsWith('v4_')) {
|
|
34297
|
+
this.storage.removeItem(key.replace('v4_', ''));
|
|
34298
|
+
}
|
|
34299
|
+
else {
|
|
34300
|
+
this.storage.removeItem('v4_' + key);
|
|
34301
|
+
}
|
|
34302
|
+
}
|
|
34303
|
+
removeByPattern(pattern) {
|
|
34304
|
+
this.getCacheKeysByPattern(pattern).forEach(item => {
|
|
34305
|
+
this.removeItem(item);
|
|
34306
|
+
if (item.startsWith('v4_')) {
|
|
34307
|
+
this.storage.removeItem(item.replace('v4_', ''));
|
|
34308
|
+
}
|
|
34309
|
+
else {
|
|
34310
|
+
this.storage.removeItem('v4_' + item);
|
|
34311
|
+
}
|
|
34312
|
+
});
|
|
34313
|
+
}
|
|
34314
|
+
getItem(key) {
|
|
34315
|
+
return this.storage.getItem(key);
|
|
34316
|
+
}
|
|
34317
|
+
getNumber(key, defaultValueIfNull = 0) {
|
|
34318
|
+
const rs = this.getItem(key);
|
|
34319
|
+
if (rs) {
|
|
34320
|
+
return +rs;
|
|
34321
|
+
}
|
|
34322
|
+
return defaultValueIfNull;
|
|
34323
|
+
}
|
|
34324
|
+
getBoolean(key, defaultValueIfNull = false) {
|
|
34325
|
+
const rs = this.getItem(key);
|
|
34326
|
+
if (rs) {
|
|
34327
|
+
return rs.toLowerCase() === 'true';
|
|
34328
|
+
}
|
|
34329
|
+
return defaultValueIfNull;
|
|
34330
|
+
}
|
|
34331
|
+
getObject(key) {
|
|
34332
|
+
const rs = this.getItem(key);
|
|
34333
|
+
if (rs) {
|
|
34334
|
+
return JSON.parse(rs);
|
|
34335
|
+
}
|
|
34336
|
+
return null;
|
|
34337
|
+
}
|
|
34338
|
+
getObjectAny(key) {
|
|
34339
|
+
const rs = this.getItem(key);
|
|
34340
|
+
if (rs) {
|
|
34341
|
+
return JSON.parse(rs);
|
|
34342
|
+
}
|
|
34343
|
+
return null;
|
|
34344
|
+
}
|
|
34345
|
+
getAllCachekeys() {
|
|
34346
|
+
return Object.keys(this.storage).filter(x => !x.match(this.ignoreBuildInCacheKey));
|
|
34347
|
+
}
|
|
34348
|
+
getCacheKeysByPattern(pattern) {
|
|
34349
|
+
return Object.keys(this.storage).filter(x => !x.match(this.ignoreBuildInCacheKey) && this.matchRuleShort(pattern, x));
|
|
34350
|
+
}
|
|
34351
|
+
matchRuleShort(str, rule) {
|
|
34352
|
+
const escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
|
|
34353
|
+
return new RegExp('^' + rule.split('*').map(escapeRegex).join('.*') + '$').test(str);
|
|
34354
|
+
}
|
|
34355
|
+
// Explanation code
|
|
34356
|
+
matchRuleExpl(str, rule) {
|
|
34357
|
+
// for this solution to work on any string, no matter what characters it has
|
|
34358
|
+
const escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
|
|
34359
|
+
// "." => Find a single character, except newline or line terminator
|
|
34360
|
+
// ".*" => Matches any string that contains zero or more characters
|
|
34361
|
+
rule = rule.split('*').map(escapeRegex).join('.*');
|
|
34362
|
+
// "^" => Matches any string with the following at the beginning of it
|
|
34363
|
+
// "$" => Matches any string with that in front at the end of it
|
|
34364
|
+
rule = '^' + rule + '$';
|
|
34365
|
+
// Create a regular expression object for matching string
|
|
34366
|
+
const regex = new RegExp(rule);
|
|
34367
|
+
// Returns true if it finds a match, otherwise it returns false
|
|
34368
|
+
return regex.test(str);
|
|
34369
|
+
}
|
|
34370
|
+
}
|
|
34371
|
+
StorageService.ɵprov = i0.ɵɵdefineInjectable({ factory: function StorageService_Factory() { return new StorageService(i0.ɵɵinject(ModuleConfigService)); }, token: StorageService, providedIn: "root" });
|
|
34372
|
+
StorageService.decorators = [
|
|
34373
|
+
{ type: Injectable, args: [{
|
|
34374
|
+
providedIn: 'root'
|
|
34375
|
+
},] }
|
|
34376
|
+
];
|
|
34377
|
+
StorageService.ctorParameters = () => [
|
|
34378
|
+
{ type: ModuleConfigService }
|
|
34379
|
+
];
|
|
34380
|
+
|
|
34154
34381
|
class CommonLibComponent {
|
|
34155
|
-
constructor(_componentContextService) {
|
|
34382
|
+
constructor(_componentContextService, _router, _activatedRoute, _applicationContext, _storageService, _moduleConfigService) {
|
|
34156
34383
|
this._componentContextService = _componentContextService;
|
|
34384
|
+
this._router = _router;
|
|
34385
|
+
this._activatedRoute = _activatedRoute;
|
|
34386
|
+
this._applicationContext = _applicationContext;
|
|
34387
|
+
this._storageService = _storageService;
|
|
34388
|
+
this._moduleConfigService = _moduleConfigService;
|
|
34157
34389
|
this.showRejectConfirm = true;
|
|
34390
|
+
this.appCode = '';
|
|
34391
|
+
this.environment = this._moduleConfigService.getConfig().environment;
|
|
34392
|
+
this.appCode = this._moduleConfigService.getConfig().appCode;
|
|
34158
34393
|
this._componentContextService.subscribe(ComCtxConstants.ROOT.SHOW_REJECT_CONFIRM, data => {
|
|
34159
34394
|
this.showRejectConfirm = data;
|
|
34160
34395
|
});
|
|
34396
|
+
this._applicationContext.addRootContext(this._componentContextService, _activatedRoute);
|
|
34397
|
+
this._componentContextService.data.personalize = this._storageService.getObjectAny('personalize');
|
|
34398
|
+
if (!this._componentContextService.data.personalize) {
|
|
34399
|
+
this._componentContextService.data.personalize = {};
|
|
34400
|
+
}
|
|
34161
34401
|
}
|
|
34162
34402
|
ngOnInit() {
|
|
34403
|
+
const root = this._applicationContext.getRootContext();
|
|
34404
|
+
this.rootData = root.data;
|
|
34405
|
+
root.data.currentAppMetadata = this.environment.appMetadata.appSwitcher.find(x => x.code.toLowerCase() == this.appCode.toLowerCase());
|
|
34406
|
+
root.data.appOrigin = this.environment.enableBaseHref ? `/${root.data.currentAppMetadata.code.toLowerCase()}/` : '/';
|
|
34407
|
+
this._router.config.forEach(route => this.addGuard(route));
|
|
34163
34408
|
}
|
|
34164
34409
|
focusTrap(event, direct) {
|
|
34165
34410
|
event.preventDefault();
|
|
@@ -34170,6 +34415,19 @@ class CommonLibComponent {
|
|
|
34170
34415
|
this.cancelButton.nativeElement.focus();
|
|
34171
34416
|
}
|
|
34172
34417
|
}
|
|
34418
|
+
addGuard(route) {
|
|
34419
|
+
if (route.path === '' || route.path === '/') {
|
|
34420
|
+
return;
|
|
34421
|
+
}
|
|
34422
|
+
else {
|
|
34423
|
+
if (route.loadChildren) {
|
|
34424
|
+
route.canActivateChild = route.canActivateChild ? route.canActivateChild : [GenericGuardChildService];
|
|
34425
|
+
}
|
|
34426
|
+
else {
|
|
34427
|
+
route.canActivate = route.canActivate ? route.canActivate : [GenericGuardService];
|
|
34428
|
+
}
|
|
34429
|
+
}
|
|
34430
|
+
}
|
|
34173
34431
|
}
|
|
34174
34432
|
CommonLibComponent.decorators = [
|
|
34175
34433
|
{ type: Component, args: [{
|
|
@@ -34180,7 +34438,12 @@ CommonLibComponent.decorators = [
|
|
|
34180
34438
|
},] }
|
|
34181
34439
|
];
|
|
34182
34440
|
CommonLibComponent.ctorParameters = () => [
|
|
34183
|
-
{ type: ComponentContextService }
|
|
34441
|
+
{ type: ComponentContextService },
|
|
34442
|
+
{ type: Router },
|
|
34443
|
+
{ type: ActivatedRoute },
|
|
34444
|
+
{ type: ApplicationContextService },
|
|
34445
|
+
{ type: StorageService },
|
|
34446
|
+
{ type: ModuleConfigService }
|
|
34184
34447
|
];
|
|
34185
34448
|
CommonLibComponent.propDecorators = {
|
|
34186
34449
|
okButton: [{ type: ViewChild, args: ['okButton',] }],
|
|
@@ -36138,59 +36401,6 @@ EformService.ctorParameters = () => [
|
|
|
36138
36401
|
{ type: ModuleConfigService }
|
|
36139
36402
|
];
|
|
36140
36403
|
|
|
36141
|
-
class GenericGuardService {
|
|
36142
|
-
constructor(_permissionService, _injector) {
|
|
36143
|
-
this._permissionService = _permissionService;
|
|
36144
|
-
this._injector = _injector;
|
|
36145
|
-
this.storage = sessionStorage;
|
|
36146
|
-
}
|
|
36147
|
-
canActivate(route, state) {
|
|
36148
|
-
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
36149
|
-
const _applicationContext = this._injector.get(ApplicationContextService);
|
|
36150
|
-
const root = _applicationContext.getRootContext();
|
|
36151
|
-
if (state.url == '/') {
|
|
36152
|
-
resolve(true);
|
|
36153
|
-
return;
|
|
36154
|
-
}
|
|
36155
|
-
if ((top.location.href.indexOf('/dashboard') > -1)
|
|
36156
|
-
|| (top.location.href.indexOf('/access-denied') > -1)) {
|
|
36157
|
-
resolve(true);
|
|
36158
|
-
return;
|
|
36159
|
-
}
|
|
36160
|
-
// todo: còn case sử dụng biến trong url
|
|
36161
|
-
const service = root.data.currentAppMetadata.code;
|
|
36162
|
-
const permission = `${root.data.currentAppMetadata.code}${state.url.split('#')[0].split('?')[0]}`.toUpperCase();
|
|
36163
|
-
const isAuthorized = yield this._permissionService.isAuthorized(service, permission);
|
|
36164
|
-
if (isAuthorized) {
|
|
36165
|
-
resolve(true);
|
|
36166
|
-
}
|
|
36167
|
-
else {
|
|
36168
|
-
// this._notifierService.showWarning('Bạn không có quyền truy cập vào trang này', 'Cảnh báo');
|
|
36169
|
-
const firstTimeLogin = localStorage.getItem('firstTimeLogin');
|
|
36170
|
-
if (firstTimeLogin && firstTimeLogin !== '' && firstTimeLogin == 'true') {
|
|
36171
|
-
localStorage.removeItem('firstTimeLogin');
|
|
36172
|
-
top.location.href = '/';
|
|
36173
|
-
}
|
|
36174
|
-
else {
|
|
36175
|
-
top.location.href = '/access-denied';
|
|
36176
|
-
}
|
|
36177
|
-
resolve(false);
|
|
36178
|
-
}
|
|
36179
|
-
resolve(true);
|
|
36180
|
-
}));
|
|
36181
|
-
}
|
|
36182
|
-
}
|
|
36183
|
-
GenericGuardService.ɵprov = i0.ɵɵdefineInjectable({ factory: function GenericGuardService_Factory() { return new GenericGuardService(i0.ɵɵinject(PermissionService), i0.ɵɵinject(i0.INJECTOR)); }, token: GenericGuardService, providedIn: "root" });
|
|
36184
|
-
GenericGuardService.decorators = [
|
|
36185
|
-
{ type: Injectable, args: [{
|
|
36186
|
-
providedIn: 'root'
|
|
36187
|
-
},] }
|
|
36188
|
-
];
|
|
36189
|
-
GenericGuardService.ctorParameters = () => [
|
|
36190
|
-
{ type: PermissionService },
|
|
36191
|
-
{ type: Injector }
|
|
36192
|
-
];
|
|
36193
|
-
|
|
36194
36404
|
class GlobalService {
|
|
36195
36405
|
constructor() {
|
|
36196
36406
|
this._state = true;
|
|
@@ -36811,122 +37021,6 @@ RandomDataService.decorators = [
|
|
|
36811
37021
|
];
|
|
36812
37022
|
RandomDataService.ctorParameters = () => [];
|
|
36813
37023
|
|
|
36814
|
-
class StorageService {
|
|
36815
|
-
constructor(_moduleConfigService) {
|
|
36816
|
-
this._moduleConfigService = _moduleConfigService;
|
|
36817
|
-
this.ignoreBuildInCacheKey = /(expires_at|id_token_expires_at|nonce|access_token_stored_at|id_token_stored_at|id_token|access_token|id_token_claims_obj|session_state|granted_scopes)/i;
|
|
36818
|
-
const st = this._moduleConfigService.getConfig().environment.storage;
|
|
36819
|
-
if (st === 'sessionStorage') {
|
|
36820
|
-
this.storage = sessionStorage;
|
|
36821
|
-
}
|
|
36822
|
-
else {
|
|
36823
|
-
this.storage = localStorage;
|
|
36824
|
-
}
|
|
36825
|
-
}
|
|
36826
|
-
setStorage(storage) {
|
|
36827
|
-
this.storage = storage;
|
|
36828
|
-
}
|
|
36829
|
-
getStorage() {
|
|
36830
|
-
return this.storage;
|
|
36831
|
-
}
|
|
36832
|
-
setItem(key, value) {
|
|
36833
|
-
if (!value) {
|
|
36834
|
-
this.storage.setItem(key, null);
|
|
36835
|
-
}
|
|
36836
|
-
if (value instanceof Object) {
|
|
36837
|
-
this.storage.setItem(key, JSON.stringify(value));
|
|
36838
|
-
}
|
|
36839
|
-
else {
|
|
36840
|
-
this.storage.setItem(key, value ? value.toString() : null);
|
|
36841
|
-
}
|
|
36842
|
-
}
|
|
36843
|
-
removeItem(key) {
|
|
36844
|
-
this.storage.removeItem(key);
|
|
36845
|
-
if (key.startsWith('v4_')) {
|
|
36846
|
-
this.storage.removeItem(key.replace('v4_', ''));
|
|
36847
|
-
}
|
|
36848
|
-
else {
|
|
36849
|
-
this.storage.removeItem('v4_' + key);
|
|
36850
|
-
}
|
|
36851
|
-
}
|
|
36852
|
-
removeByPattern(pattern) {
|
|
36853
|
-
this.getCacheKeysByPattern(pattern).forEach(item => {
|
|
36854
|
-
this.removeItem(item);
|
|
36855
|
-
if (item.startsWith('v4_')) {
|
|
36856
|
-
this.storage.removeItem(item.replace('v4_', ''));
|
|
36857
|
-
}
|
|
36858
|
-
else {
|
|
36859
|
-
this.storage.removeItem('v4_' + item);
|
|
36860
|
-
}
|
|
36861
|
-
});
|
|
36862
|
-
}
|
|
36863
|
-
getItem(key) {
|
|
36864
|
-
return this.storage.getItem(key);
|
|
36865
|
-
}
|
|
36866
|
-
getNumber(key, defaultValueIfNull = 0) {
|
|
36867
|
-
const rs = this.getItem(key);
|
|
36868
|
-
if (rs) {
|
|
36869
|
-
return +rs;
|
|
36870
|
-
}
|
|
36871
|
-
return defaultValueIfNull;
|
|
36872
|
-
}
|
|
36873
|
-
getBoolean(key, defaultValueIfNull = false) {
|
|
36874
|
-
const rs = this.getItem(key);
|
|
36875
|
-
if (rs) {
|
|
36876
|
-
return rs.toLowerCase() === 'true';
|
|
36877
|
-
}
|
|
36878
|
-
return defaultValueIfNull;
|
|
36879
|
-
}
|
|
36880
|
-
getObject(key) {
|
|
36881
|
-
const rs = this.getItem(key);
|
|
36882
|
-
if (rs) {
|
|
36883
|
-
return JSON.parse(rs);
|
|
36884
|
-
}
|
|
36885
|
-
return null;
|
|
36886
|
-
}
|
|
36887
|
-
getObjectAny(key) {
|
|
36888
|
-
const rs = this.getItem(key);
|
|
36889
|
-
if (rs) {
|
|
36890
|
-
return JSON.parse(rs);
|
|
36891
|
-
}
|
|
36892
|
-
return null;
|
|
36893
|
-
}
|
|
36894
|
-
getAllCachekeys() {
|
|
36895
|
-
return Object.keys(this.storage).filter(x => !x.match(this.ignoreBuildInCacheKey));
|
|
36896
|
-
}
|
|
36897
|
-
getCacheKeysByPattern(pattern) {
|
|
36898
|
-
return Object.keys(this.storage).filter(x => !x.match(this.ignoreBuildInCacheKey) && this.matchRuleShort(pattern, x));
|
|
36899
|
-
}
|
|
36900
|
-
matchRuleShort(str, rule) {
|
|
36901
|
-
const escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
|
|
36902
|
-
return new RegExp('^' + rule.split('*').map(escapeRegex).join('.*') + '$').test(str);
|
|
36903
|
-
}
|
|
36904
|
-
// Explanation code
|
|
36905
|
-
matchRuleExpl(str, rule) {
|
|
36906
|
-
// for this solution to work on any string, no matter what characters it has
|
|
36907
|
-
const escapeRegex = (str) => str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
|
|
36908
|
-
// "." => Find a single character, except newline or line terminator
|
|
36909
|
-
// ".*" => Matches any string that contains zero or more characters
|
|
36910
|
-
rule = rule.split('*').map(escapeRegex).join('.*');
|
|
36911
|
-
// "^" => Matches any string with the following at the beginning of it
|
|
36912
|
-
// "$" => Matches any string with that in front at the end of it
|
|
36913
|
-
rule = '^' + rule + '$';
|
|
36914
|
-
// Create a regular expression object for matching string
|
|
36915
|
-
const regex = new RegExp(rule);
|
|
36916
|
-
// Returns true if it finds a match, otherwise it returns false
|
|
36917
|
-
return regex.test(str);
|
|
36918
|
-
}
|
|
36919
|
-
}
|
|
36920
|
-
StorageService.ɵprov = i0.ɵɵdefineInjectable({ factory: function StorageService_Factory() { return new StorageService(i0.ɵɵinject(ModuleConfigService)); }, token: StorageService, providedIn: "root" });
|
|
36921
|
-
StorageService.decorators = [
|
|
36922
|
-
{ type: Injectable, args: [{
|
|
36923
|
-
providedIn: 'root'
|
|
36924
|
-
},] }
|
|
36925
|
-
];
|
|
36926
|
-
StorageService.ctorParameters = () => [
|
|
36927
|
-
{ type: ModuleConfigService }
|
|
36928
|
-
];
|
|
36929
|
-
|
|
36930
37024
|
class TemplateTextV4Service extends BaseService {
|
|
36931
37025
|
constructor(_moduleConfigService, _httpClient, _printService, _fileV4Service, _notifierService, _crudService, _commonService, injector) {
|
|
36932
37026
|
super(_httpClient, injector, `${_moduleConfigService.getConfig().environment.v4.apiDomain.templateEndpoint}/templateText`);
|
|
@@ -37907,64 +38001,6 @@ WorkflowService.ctorParameters = () => [
|
|
|
37907
38001
|
{ type: ModuleConfigService }
|
|
37908
38002
|
];
|
|
37909
38003
|
|
|
37910
|
-
class GenericGuardChildService {
|
|
37911
|
-
constructor(_userService, _permissionService, _router, _injector, _notifierService) {
|
|
37912
|
-
this._userService = _userService;
|
|
37913
|
-
this._permissionService = _permissionService;
|
|
37914
|
-
this._router = _router;
|
|
37915
|
-
this._injector = _injector;
|
|
37916
|
-
this._notifierService = _notifierService;
|
|
37917
|
-
this.storage = sessionStorage;
|
|
37918
|
-
}
|
|
37919
|
-
canActivateChild(route, state) {
|
|
37920
|
-
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
37921
|
-
const _applicationContext = this._injector.get(ApplicationContextService);
|
|
37922
|
-
const root = _applicationContext.getRootContext();
|
|
37923
|
-
if (state.url == '/') {
|
|
37924
|
-
resolve(true);
|
|
37925
|
-
return;
|
|
37926
|
-
}
|
|
37927
|
-
if ((top.location.href.indexOf('/dashboard') > -1)
|
|
37928
|
-
|| (top.location.href.indexOf('/access-denied') > -1)) {
|
|
37929
|
-
resolve(true);
|
|
37930
|
-
return;
|
|
37931
|
-
}
|
|
37932
|
-
// todo: còn case sử dụng biến trong url
|
|
37933
|
-
const service = root.data.currentAppMetadata.code;
|
|
37934
|
-
const permission = `${root.data.currentAppMetadata.code}${state.url.split('#')[0].split('?')[0]}`.toUpperCase();
|
|
37935
|
-
const isAuthorized = yield this._permissionService.isAuthorized(service, permission);
|
|
37936
|
-
if (isAuthorized) {
|
|
37937
|
-
resolve(true);
|
|
37938
|
-
}
|
|
37939
|
-
else {
|
|
37940
|
-
const firstTimeLogin = localStorage.getItem('firstTimeLogin');
|
|
37941
|
-
if (firstTimeLogin && firstTimeLogin !== '' && firstTimeLogin == 'true') {
|
|
37942
|
-
localStorage.removeItem('firstTimeLogin');
|
|
37943
|
-
top.location.href = '/';
|
|
37944
|
-
}
|
|
37945
|
-
else {
|
|
37946
|
-
top.location.href = window['baseHref'] + '/access-denied';
|
|
37947
|
-
}
|
|
37948
|
-
resolve(false);
|
|
37949
|
-
}
|
|
37950
|
-
resolve(true);
|
|
37951
|
-
}));
|
|
37952
|
-
}
|
|
37953
|
-
}
|
|
37954
|
-
GenericGuardChildService.ɵprov = i0.ɵɵdefineInjectable({ factory: function GenericGuardChildService_Factory() { return new GenericGuardChildService(i0.ɵɵinject(UserService), i0.ɵɵinject(PermissionService), i0.ɵɵinject(i3$1.Router), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(NotifierService)); }, token: GenericGuardChildService, providedIn: "root" });
|
|
37955
|
-
GenericGuardChildService.decorators = [
|
|
37956
|
-
{ type: Injectable, args: [{
|
|
37957
|
-
providedIn: 'root'
|
|
37958
|
-
},] }
|
|
37959
|
-
];
|
|
37960
|
-
GenericGuardChildService.ctorParameters = () => [
|
|
37961
|
-
{ type: UserService },
|
|
37962
|
-
{ type: PermissionService },
|
|
37963
|
-
{ type: Router },
|
|
37964
|
-
{ type: Injector },
|
|
37965
|
-
{ type: NotifierService }
|
|
37966
|
-
];
|
|
37967
|
-
|
|
37968
38004
|
class LatexService {
|
|
37969
38005
|
constructor(_commonService, _templateInstanceService, _fileObjectService) {
|
|
37970
38006
|
this._commonService = _commonService;
|