tnx-shared 5.3.254 → 5.3.256

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.
@@ -2007,6 +2007,7 @@
2007
2007
  _this.placeholder = '';
2008
2008
  _this.hiddenToolbar = false;
2009
2009
  _this.hiddenMenubar = false;
2010
+ _this.isFullPage = false;
2010
2011
  for (var key in init) {
2011
2012
  _this[key] = init[key];
2012
2013
  }
@@ -12115,19 +12116,21 @@
12115
12116
  new ColumnSchemaBase({
12116
12117
  field: 'code',
12117
12118
  width: '150px',
12118
- includeSelect: isInUserList
12119
+ includeSelect: isInUserList,
12120
+ isPinned: true
12119
12121
  }),
12120
12122
  new ColumnSchemaBase({
12121
12123
  field: 'fullNameNew',
12122
12124
  width: '200px',
12123
12125
  includeSelect: isInUserList,
12124
- visible: isInUserList
12126
+ visible: isInUserList,
12127
+ isPinned: true
12125
12128
  }),
12126
12129
  new ColumnSchemaBase({
12127
12130
  field: 'dob',
12128
12131
  dataType: 'date',
12129
12132
  width: '110px',
12130
- includeSelect: isInUserList
12133
+ includeSelect: isInUserList,
12131
12134
  }),
12132
12135
  new ColumnSchemaBase({
12133
12136
  field: 'email',
@@ -19339,827 +19342,346 @@
19339
19342
  onDataBinded: [{ type: i0.Output }]
19340
19343
  };
19341
19344
 
19342
- var SearchInfo = /** @class */ (function () {
19343
- function SearchInfo(init) {
19344
- this.fieldSearchText = [];
19345
- this.tooltipSearchText = '';
19346
- this.fieldDropdown = {};
19347
- for (var key in init) {
19348
- this[key] = init[key];
19349
- }
19345
+ var CauHinhWorkflowService = /** @class */ (function (_super) {
19346
+ __extends(CauHinhWorkflowService, _super);
19347
+ function CauHinhWorkflowService(http, injector, _moduleConfigService) {
19348
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/CauHinhWorkflow") || this;
19349
+ _this._moduleConfigService = _moduleConfigService;
19350
+ _this.serviceCode = 'congviec';
19351
+ _this.entityName = 'CauHinhWorkflow';
19352
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
19353
+ return _this;
19350
19354
  }
19351
- return SearchInfo;
19352
- }());
19355
+ return CauHinhWorkflowService;
19356
+ }(BaseService));
19357
+ CauHinhWorkflowService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function CauHinhWorkflowService_Factory() { return new CauHinhWorkflowService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: CauHinhWorkflowService, providedIn: "root" });
19358
+ CauHinhWorkflowService.decorators = [
19359
+ { type: i0.Injectable, args: [{
19360
+ providedIn: 'root'
19361
+ },] }
19362
+ ];
19363
+ CauHinhWorkflowService.ctorParameters = function () { return [
19364
+ { type: i1$1.HttpClient },
19365
+ { type: i0.Injector },
19366
+ { type: ModuleConfigService }
19367
+ ]; };
19353
19368
 
19354
- var EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
19355
- var EXCEL_EXTENSION = '.xlsx';
19356
- var ExportService = /** @class */ (function () {
19357
- function ExportService(_http, _injector, _commonService, _moduleConfigService) {
19358
- this._http = _http;
19359
- this._injector = _injector;
19360
- this._commonService = _commonService;
19361
- this._moduleConfig = _moduleConfigService.getConfig();
19362
- this.environment = this._moduleConfig.environment;
19363
- this.serviceUri = this._moduleConfig.environment.apiDomain.templateEndpoint + "/Export";
19369
+ var StateMachinesService = /** @class */ (function (_super) {
19370
+ __extends(StateMachinesService, _super);
19371
+ function StateMachinesService(http, injector, _moduleConfigService) {
19372
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/StateMachines") || this;
19373
+ _this._moduleConfigService = _moduleConfigService;
19374
+ _this.entityName = 'StateMachines';
19375
+ _this.serviceCode = 'workflow';
19376
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint;
19377
+ return _this;
19364
19378
  }
19365
- ExportService.prototype.objectToExcel = function (data, fileName, numOfHeaderRow) {
19366
- var _this = this;
19367
- return this._http
19368
- .post(this.serviceUri + "/ObjectToExcel?numOfHeaderRow=" + numOfHeaderRow, data, { responseType: 'blob' })
19369
- .pipe(operators.catchError(function (err) { return _this._commonService.handleError(err, _this._injector); }))
19370
- .subscribe(function (res) {
19371
- _this.saveAsExcelFile(res, fileName);
19372
- });
19379
+ StateMachinesService.prototype.changeState = function (itemWorkflowHistory) {
19380
+ return this.defaultPost(this.serviceUri + "/ChangeState", itemWorkflowHistory);
19373
19381
  };
19374
- ExportService.prototype.saveAsExcelFile = function (buffer, fileName) {
19375
- var data = new Blob([buffer], {
19376
- type: EXCEL_TYPE
19377
- });
19378
- FileSaver__default["default"].saveAs(data, fileName + '_' + new Date().getTime() + EXCEL_EXTENSION);
19382
+ StateMachinesService.prototype.rollback = function (rowData) {
19383
+ return this.defaultPost(this.serviceUri + "/Rollback/" + rowData.__workflowCode + "/" + rowData.id, {});
19379
19384
  };
19380
- ExportService.prototype.saveSpreadSheet = function (buffer, fileName) {
19381
- var data = new Blob([buffer], {
19382
- type: EXCEL_TYPE
19383
- });
19384
- FileSaver__default["default"].saveAs(data, new Date().getTime() + '_' + fileName);
19385
+ StateMachinesService.prototype.getUserInProcessForm = function (workflowCode, stateCode, actionCode, itemId) {
19386
+ return this.defaultPost(this.serviceUri + "/GetUserInProcessForm/" + workflowCode + "/" + stateCode + "/" + actionCode + "/" + itemId, {});
19385
19387
  };
19386
- return ExportService;
19387
- }());
19388
- ExportService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ExportService_Factory() { return new ExportService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(CommonService), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: ExportService, providedIn: "root" });
19389
- ExportService.decorators = [
19388
+ return StateMachinesService;
19389
+ }(BaseService));
19390
+ StateMachinesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function StateMachinesService_Factory() { return new StateMachinesService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: StateMachinesService, providedIn: "root" });
19391
+ StateMachinesService.decorators = [
19390
19392
  { type: i0.Injectable, args: [{
19391
19393
  providedIn: 'root'
19392
19394
  },] }
19393
19395
  ];
19394
- ExportService.ctorParameters = function () { return [
19396
+ StateMachinesService.ctorParameters = function () { return [
19395
19397
  { type: i1$1.HttpClient },
19396
19398
  { type: i0.Injector },
19397
- { type: CommonService },
19398
19399
  { type: ModuleConfigService }
19399
19400
  ]; };
19400
19401
 
19401
- var PhanQuyenModel = /** @class */ (function () {
19402
- function PhanQuyenModel(init) {
19403
- this.addRoleIds = [];
19404
- this.removeRoleIds = [];
19405
- this.addPermissionIds = [];
19406
- this.removePermissionIds = [];
19407
- for (var key in init) {
19408
- this[key] = init[key];
19409
- }
19410
- }
19411
- return PhanQuyenModel;
19412
- }());
19413
- var PermissionService = /** @class */ (function (_super) {
19414
- __extends(PermissionService, _super);
19415
- function PermissionService(http, injector, _moduleConfigService, _userService, _oauthService, _appContext) {
19416
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/permission") || this;
19402
+ var DmLoaiCongViecService = /** @class */ (function (_super) {
19403
+ __extends(DmLoaiCongViecService, _super);
19404
+ function DmLoaiCongViecService(http, injector, _moduleConfigService) {
19405
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/DM_LoaiCongViec") || this;
19417
19406
  _this._moduleConfigService = _moduleConfigService;
19418
- _this._userService = _userService;
19419
- _this._oauthService = _oauthService;
19420
- _this._appContext = _appContext;
19421
- _this.storage = sessionStorage;
19422
- _this.ignoreAdmin = false;
19423
- _this.delayCheckPermissions = [];
19424
- _this.appCode = null;
19425
- _this._config = _this._moduleConfigService.getConfig();
19426
- _this.endPoint = _this._config.environment.apiDomain.authorizationEndpoint;
19427
- _this.ignoreAdmin = _this._config.environment.isIgnoreAdmin;
19428
- _this.appCode = _this._config.appCode;
19407
+ _this.serviceCode = 'congviec';
19408
+ _this.entityName = 'DM_LoaiCongViec';
19409
+ _this.dicLoaiCongViec = {};
19410
+ _this.keyIdLoaiCongViecRoot = 'root';
19411
+ _this.getWorkflowSettingByIdLoaiCongViec = function (idLoaiCongViec) { return __awaiter(_this, void 0, void 0, function () {
19412
+ var result, idLoaiCongViecs, i;
19413
+ return __generator(this, function (_a) {
19414
+ switch (_a.label) {
19415
+ case 0:
19416
+ if (!!this.dicWorkflowByLoaiCongViec) return [3 /*break*/, 2];
19417
+ return [4 /*yield*/, this.getDatasourceWorkflowCongViec()];
19418
+ case 1:
19419
+ _a.sent();
19420
+ _a.label = 2;
19421
+ case 2:
19422
+ if (!idLoaiCongViec) {
19423
+ return [2 /*return*/, this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot]];
19424
+ }
19425
+ result = this.dicWorkflowByLoaiCongViec[idLoaiCongViec];
19426
+ if (result)
19427
+ return [2 /*return*/, result];
19428
+ return [4 /*yield*/, this.getIdLoaiCongViecs(idLoaiCongViec)];
19429
+ case 3:
19430
+ idLoaiCongViecs = _a.sent();
19431
+ if (!Array.isArray(idLoaiCongViecs))
19432
+ return [2 /*return*/, null];
19433
+ if (idLoaiCongViecs.length > 1) {
19434
+ for (i = idLoaiCongViecs.length - 2; i >= 0; i--) {
19435
+ result = this.dicWorkflowByLoaiCongViec[idLoaiCongViecs[i]];
19436
+ if (result)
19437
+ return [2 /*return*/, result];
19438
+ }
19439
+ }
19440
+ if (!result) {
19441
+ result = this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot];
19442
+ }
19443
+ return [2 /*return*/, result];
19444
+ }
19445
+ });
19446
+ }); };
19447
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
19429
19448
  return _this;
19430
19449
  }
19431
- PermissionService.prototype.clearPermissionCacheAll = function () {
19432
- var _a, _b, _c;
19433
- var lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(function (app) { return app.code; })) !== null && _c !== void 0 ? _c : [];
19434
- var lstApiEndpoint = [];
19435
- var apiDomain = this._config.environment.apiDomain;
19436
- for (var domainName in apiDomain) {
19437
- if (domainName.startsWith('-') || domainName.startsWith('1') || domainName == 'gateway')
19438
- continue;
19439
- var realDomainName = domainName.split('Endpoint') ? domainName.split('Endpoint')[0] : domainName;
19440
- lstApiEndpoint.push(realDomainName.toUpperCase());
19441
- }
19442
- return this.clearPermissionCache(__spreadArray(__spreadArray([], __read(lstAppCodes)), __read(lstApiEndpoint)));
19443
- };
19444
- PermissionService.prototype.clearPermissionCache = function (lstModule) {
19445
- var url = this.serviceUri + "/ClearPermissionCache";
19446
- return this.defaultPost(url, lstModule);
19447
- };
19448
- PermissionService.prototype.getCurrentUserPermission = function () {
19449
- var url = this.serviceUri + "/GetCurrentUserPermission";
19450
- return this.defaultGet(url);
19451
- };
19452
- PermissionService.prototype.getAllBasePermission = function (userId) {
19453
- var _a, _b, _c;
19450
+ DmLoaiCongViecService.prototype.getDatasourceWorkflowCongViec = function () {
19454
19451
  return __awaiter(this, void 0, void 0, function () {
19455
- var url, user, res, lstAppCodes, promiseArr, lstAppCodes_1, lstAppCodes_1_1, code, lstAppCodes_2, lstAppCodes_2_1, service, permissions, serviceCode, key_1, key, storageItem;
19456
- var e_1, _d, e_2, _e;
19457
- return __generator(this, function (_f) {
19458
- switch (_f.label) {
19452
+ var cauHinhWorkflowService, cauHinhWorkflows, notifierService, workflowCodes, stateMachinesService, workflows;
19453
+ var _this = this;
19454
+ return __generator(this, function (_a) {
19455
+ switch (_a.label) {
19459
19456
  case 0:
19460
- url = this.serviceUri + "/GetAllBasePermission";
19461
- // return sớm vì đây là trường hợp lấy permission theo Id của User
19462
- // ko set local storage vì sẽ làm hỏng quyền của người dùng hiện tại
19463
- if (userId && userId != '' && userId != this._commonService.guidEmpty()) {
19464
- return [2 /*return*/, this.defaultGet(url + ("?userId=" + userId))];
19465
- }
19466
- if (i0.isDevMode()) {
19467
- return [2 /*return*/];
19468
- }
19469
- user = this._userService.getCurrentUser();
19470
- if (user
19471
- && (user.issuperuser && user.issuperuser.toLowerCase() == 'true')
19472
- || (user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin)) {
19473
- return [2 /*return*/];
19457
+ if (!this.dicWorkflowByLoaiCongViec) {
19458
+ this.dicWorkflowByLoaiCongViec = {};
19474
19459
  }
19475
- return [4 /*yield*/, this.defaultGet(url)];
19460
+ cauHinhWorkflowService = this._injector.get(CauHinhWorkflowService);
19461
+ return [4 /*yield*/, cauHinhWorkflowService.getAll([], 'idLoaiCongViec,workflowCodes,workflowCode')];
19476
19462
  case 1:
19477
- res = _f.sent();
19478
- lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(function (app) { return app.code; })) !== null && _c !== void 0 ? _c : [];
19479
- if (!(!res || !res.success || res.data == null)) return [3 /*break*/, 3];
19480
- promiseArr = [];
19481
- try {
19482
- for (lstAppCodes_1 = __values(lstAppCodes), lstAppCodes_1_1 = lstAppCodes_1.next(); !lstAppCodes_1_1.done; lstAppCodes_1_1 = lstAppCodes_1.next()) {
19483
- code = lstAppCodes_1_1.value;
19484
- promiseArr.push(this.getServicePermission(code, true));
19485
- }
19463
+ cauHinhWorkflows = (_a.sent()).data;
19464
+ notifierService = this._injector.get(NotifierService);
19465
+ if (cauHinhWorkflows == null) {
19466
+ notifierService.showWarning('Dịch vụ workflow không phản hồi');
19467
+ return [2 /*return*/, []];
19486
19468
  }
19487
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
19488
- finally {
19489
- try {
19490
- if (lstAppCodes_1_1 && !lstAppCodes_1_1.done && (_d = lstAppCodes_1.return)) _d.call(lstAppCodes_1);
19469
+ workflowCodes = [];
19470
+ cauHinhWorkflows.forEach(function (itemWorkflowSetting) {
19471
+ if (itemWorkflowSetting.workflowCodes && !Array.isArray(itemWorkflowSetting.workflowCodes)) {
19472
+ itemWorkflowSetting.workflowCodes = itemWorkflowSetting.workflowCodes.split(',');
19491
19473
  }
19492
- finally { if (e_1) throw e_1.error; }
19493
- }
19494
- return [4 /*yield*/, Promise.all(promiseArr)];
19474
+ else {
19475
+ itemWorkflowSetting.workflowCodes = [];
19476
+ }
19477
+ itemWorkflowSetting.workflowCodes.forEach(function (workflowCode) {
19478
+ if (workflowCodes.indexOf(workflowCode) == -1) {
19479
+ workflowCodes.push(workflowCode);
19480
+ }
19481
+ });
19482
+ });
19483
+ stateMachinesService = this._injector.get(StateMachinesService);
19484
+ return [4 /*yield*/, stateMachinesService.getDataDropdownByFilter([
19485
+ this.newFilter('code', exports.Operator.in, workflowCodes)
19486
+ ], new DropdownOptions({
19487
+ valueField: 'code',
19488
+ displayField: 'title',
19489
+ fieldPlus: 'data'
19490
+ }))];
19495
19491
  case 2:
19496
- _f.sent();
19497
- return [2 /*return*/];
19498
- case 3:
19499
- try {
19500
- // Set local storage cho permission của người dùng
19501
- for (lstAppCodes_2 = __values(lstAppCodes), lstAppCodes_2_1 = lstAppCodes_2.next(); !lstAppCodes_2_1.done; lstAppCodes_2_1 = lstAppCodes_2.next()) {
19502
- service = lstAppCodes_2_1.value;
19503
- permissions = [];
19504
- serviceCode = service.toUpperCase();
19505
- for (key_1 in res.data) {
19506
- if (key_1.toUpperCase() != serviceCode) {
19507
- continue;
19492
+ workflows = (_a.sent());
19493
+ workflows.forEach(function (item) {
19494
+ item.data = JSON.parse(item.data);
19495
+ var stateMachineData = item.data;
19496
+ stateMachineData.actions = {};
19497
+ stateMachineData.machines.forEach(function (machine) {
19498
+ stateMachineData.actions[machine.code] = [];
19499
+ stateMachineData.connections.forEach(function (conn) {
19500
+ if (conn.source == machine.id) {
19501
+ stateMachineData.actions[machine.code].push(conn);
19508
19502
  }
19509
- permissions = res.data[key_1];
19510
- break;
19511
- }
19512
- key = "AUTHORIZATION." + serviceCode;
19513
- storageItem = this.storage.getItem(key);
19514
- if (storageItem != null) {
19515
- this.storage.removeItem(key);
19516
- }
19517
- this.storage.setItem(key, JSON.stringify(permissions));
19503
+ });
19504
+ });
19505
+ });
19506
+ cauHinhWorkflows.forEach(function (itemWorkflowSetting) {
19507
+ itemWorkflowSetting.workflows = workflows.filter(function (q) { return itemWorkflowSetting.workflowCodes.indexOf(q.code) > -1; });
19508
+ if (!itemWorkflowSetting.idLoaiCongViec) {
19509
+ _this.dicWorkflowByLoaiCongViec[_this.keyIdLoaiCongViecRoot] = itemWorkflowSetting;
19518
19510
  }
19519
- }
19520
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
19521
- finally {
19522
- try {
19523
- if (lstAppCodes_2_1 && !lstAppCodes_2_1.done && (_e = lstAppCodes_2.return)) _e.call(lstAppCodes_2);
19511
+ else {
19512
+ _this.dicWorkflowByLoaiCongViec[itemWorkflowSetting.idLoaiCongViec] = itemWorkflowSetting;
19524
19513
  }
19525
- finally { if (e_2) throw e_2.error; }
19526
- }
19527
- return [2 /*return*/];
19514
+ });
19515
+ return [2 /*return*/, workflows];
19528
19516
  }
19529
19517
  });
19530
19518
  });
19531
19519
  };
19532
- /**
19533
- * Truyền vào danh sách permision cần check
19534
- * @param lstPermissionCode những perrmision code cần check => nên dùng trong trường hợp check các button trong code
19535
- * @returns trả ra các perrmisionCode có quyền
19536
- */
19537
- PermissionService.prototype.getPermissionAuthorized = function (lstPermissionCode) {
19538
- var _this = this;
19539
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
19540
- var user, result, lstPermissionCode_1, lstPermissionCode_1_1, item, e_3_1;
19541
- var e_3, _d;
19542
- return __generator(this, function (_e) {
19543
- switch (_e.label) {
19544
- case 0: return [4 /*yield*/, this._userService.getCurrentUser()];
19545
- case 1:
19546
- user = (_e.sent());
19547
- if (user && user.issuperuser.toLowerCase() == 'true') {
19548
- resolve(lstPermissionCode);
19549
- return [2 /*return*/];
19550
- }
19551
- if (user && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin) {
19552
- resolve(lstPermissionCode);
19553
- return [2 /*return*/];
19554
- }
19555
- result = [];
19556
- _e.label = 2;
19557
- case 2:
19558
- _e.trys.push([2, 7, 8, 9]);
19559
- lstPermissionCode_1 = __values(lstPermissionCode), lstPermissionCode_1_1 = lstPermissionCode_1.next();
19560
- _e.label = 3;
19561
- case 3:
19562
- if (!!lstPermissionCode_1_1.done) return [3 /*break*/, 6];
19563
- item = lstPermissionCode_1_1.value;
19564
- return [4 /*yield*/, this.isAuthorizedPermission(item)];
19565
- case 4:
19566
- if (_e.sent()) {
19567
- result.push(item);
19568
- }
19569
- _e.label = 5;
19570
- case 5:
19571
- lstPermissionCode_1_1 = lstPermissionCode_1.next();
19572
- return [3 /*break*/, 3];
19573
- case 6: return [3 /*break*/, 9];
19574
- case 7:
19575
- e_3_1 = _e.sent();
19576
- e_3 = { error: e_3_1 };
19577
- return [3 /*break*/, 9];
19578
- case 8:
19579
- try {
19580
- if (lstPermissionCode_1_1 && !lstPermissionCode_1_1.done && (_d = lstPermissionCode_1.return)) _d.call(lstPermissionCode_1);
19581
- }
19582
- finally { if (e_3) throw e_3.error; }
19583
- return [7 /*endfinally*/];
19584
- case 9:
19585
- resolve(result);
19586
- return [2 /*return*/];
19587
- }
19588
- });
19589
- }); });
19590
- };
19591
- PermissionService.prototype.isAuthorizedPermission = function (permission) {
19520
+ DmLoaiCongViecService.prototype.getIdLoaiCongViecs = function (idLoaiCongViec) {
19592
19521
  return __awaiter(this, void 0, void 0, function () {
19593
- var retryCount;
19594
- return __generator(this, function (_d) {
19595
- switch (_d.label) {
19522
+ var notifierService, itemLoaiCongViec, idLoaiCongViecs;
19523
+ return __generator(this, function (_a) {
19524
+ switch (_a.label) {
19596
19525
  case 0:
19597
- retryCount = 0;
19598
- _d.label = 1;
19526
+ notifierService = this._injector.get(NotifierService);
19527
+ return [4 /*yield*/, this.getItemLoaiCongViec(idLoaiCongViec)];
19599
19528
  case 1:
19600
- if (!!this._oauthService.hasValidAccessToken()) return [3 /*break*/, 3];
19601
- return [4 /*yield*/, this._commonService.delay(100)];
19602
- case 2:
19603
- _d.sent();
19604
- retryCount++;
19605
- if (retryCount > 50) {
19606
- return [3 /*break*/, 3];
19529
+ itemLoaiCongViec = _a.sent();
19530
+ if (itemLoaiCongViec == null) {
19531
+ notifierService.showWarning('Loại công việc không tồn tại');
19532
+ return [2 /*return*/, null];
19607
19533
  }
19608
- return [3 /*break*/, 1];
19609
- case 3: return [4 /*yield*/, this.checkPermission(this.appCode, permission)];
19610
- case 4: return [2 /*return*/, _d.sent()];
19534
+ idLoaiCongViecs = itemLoaiCongViec.idDuongDan.split(';').filter(function (q) { return !!q; });
19535
+ return [2 /*return*/, idLoaiCongViecs];
19611
19536
  }
19612
19537
  });
19613
19538
  });
19614
19539
  };
19615
- PermissionService.prototype.isAuthorized = function (service, permission, checForMenu) {
19616
- if (checForMenu === void 0) { checForMenu = false; }
19540
+ DmLoaiCongViecService.prototype.getItemLoaiCongViec = function (idLoaiCongViec) {
19617
19541
  return __awaiter(this, void 0, void 0, function () {
19618
- var retryCount;
19619
- return __generator(this, function (_d) {
19620
- switch (_d.label) {
19542
+ var _a, _b;
19543
+ return __generator(this, function (_c) {
19544
+ switch (_c.label) {
19621
19545
  case 0:
19622
- this.root = this._appContext.getRootContext();
19623
- retryCount = 0;
19624
- _d.label = 1;
19546
+ if (!!this.dicLoaiCongViec[idLoaiCongViec]) return [3 /*break*/, 2];
19547
+ _a = this.dicLoaiCongViec;
19548
+ _b = idLoaiCongViec;
19549
+ return [4 /*yield*/, this.getDetail(idLoaiCongViec)];
19625
19550
  case 1:
19626
- if (!!this._oauthService.hasValidAccessToken()) return [3 /*break*/, 3];
19627
- return [4 /*yield*/, this._commonService.delay(100)];
19628
- case 2:
19629
- _d.sent();
19630
- retryCount++;
19631
- if (retryCount > 50) {
19632
- return [3 /*break*/, 3];
19633
- }
19634
- return [3 /*break*/, 1];
19635
- case 3: return [4 /*yield*/, this.checkPermission(service, permission, checForMenu)];
19636
- case 4: return [2 /*return*/, _d.sent()];
19551
+ _a[_b] = (_c.sent()).data;
19552
+ _c.label = 2;
19553
+ case 2: return [2 /*return*/, this.dicLoaiCongViec[idLoaiCongViec]];
19637
19554
  }
19638
19555
  });
19639
19556
  });
19640
19557
  };
19641
- PermissionService.prototype.checkPermission = function (service, permissionToCheck, checkForMenu) {
19642
- if (checkForMenu === void 0) { checkForMenu = false; }
19558
+ return DmLoaiCongViecService;
19559
+ }(BaseService));
19560
+ DmLoaiCongViecService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function DmLoaiCongViecService_Factory() { return new DmLoaiCongViecService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: DmLoaiCongViecService, providedIn: "root" });
19561
+ DmLoaiCongViecService.decorators = [
19562
+ { type: i0.Injectable, args: [{
19563
+ providedIn: 'root'
19564
+ },] }
19565
+ ];
19566
+ DmLoaiCongViecService.ctorParameters = function () { return [
19567
+ { type: i1$1.HttpClient },
19568
+ { type: i0.Injector },
19569
+ { type: ModuleConfigService }
19570
+ ]; };
19571
+
19572
+ var CongViecService = /** @class */ (function (_super) {
19573
+ __extends(CongViecService, _super);
19574
+ function CongViecService(http, injector, _moduleConfigService, _dmLoaiCongViecService) {
19575
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/CongViec_Chinh") || this;
19576
+ _this._dmLoaiCongViecService = _dmLoaiCongViecService;
19577
+ _this.serviceCode = 'congviec';
19578
+ _this.entityName = 'CongViec_Chinh';
19579
+ _this.objectName = 'công việc';
19580
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
19581
+ _this._moduleConfig = _moduleConfigService.getConfig();
19582
+ return _this;
19583
+ }
19584
+ CongViecService.prototype.adjustSettingWorkflowForCrudList = function (setting) {
19585
+ this.useWorkflow = true;
19586
+ setting.isWorkflowTree = true;
19587
+ setting.baseService = this;
19588
+ setting.displayField = function (item) { return item.ten; };
19589
+ setting.baseService.useWorkflow = true;
19590
+ setting.workflowConfigAdvance = {
19591
+ getWorkflowSetting: this.getWorkflowConfig.bind(this)
19592
+ };
19593
+ };
19594
+ CongViecService.prototype.getWorkflowConfig = function (rowData) {
19643
19595
  return __awaiter(this, void 0, void 0, function () {
19644
- var user, valueIsDevMode, userPermissions, _a_1;
19645
- return __generator(this, function (_d) {
19646
- switch (_d.label) {
19647
- case 0:
19648
- _d.trys.push([0, 2, , 3]);
19649
- user = this._userService.getCurrentUser();
19650
- valueIsDevMode = true;
19651
- if (i0.isDevMode() && valueIsDevMode) {
19652
- return [2 /*return*/, true];
19653
- }
19654
- if (user && user.issuperuser && user.issuperuser.toLowerCase() == 'true' && valueIsDevMode) {
19655
- return [2 /*return*/, true];
19656
- }
19657
- if (user && user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin && valueIsDevMode) {
19658
- return [2 /*return*/, true];
19659
- }
19660
- return [4 /*yield*/, this.getServicePermission(service)];
19661
- case 1:
19662
- userPermissions = _d.sent();
19663
- if (userPermissions && userPermissions.length > 0) {
19664
- return [2 /*return*/, checkForMenu
19665
- ? userPermissions.includes(permissionToCheck)
19666
- : this._checkPermission(userPermissions, permissionToCheck)];
19667
- }
19668
- else {
19669
- // console.log(`Không có quyền với phân hệ [${service}]`);
19670
- return [2 /*return*/, false];
19671
- }
19672
- return [3 /*break*/, 3];
19673
- case 2:
19674
- _a_1 = _d.sent();
19675
- return [2 /*return*/, false];
19676
- case 3: return [2 /*return*/];
19596
+ return __generator(this, function (_a) {
19597
+ switch (_a.label) {
19598
+ case 0: return [4 /*yield*/, this._dmLoaiCongViecService.getWorkflowSettingByIdLoaiCongViec(rowData.idLoaiCongViec)];
19599
+ case 1: return [2 /*return*/, _a.sent()];
19677
19600
  }
19678
19601
  });
19679
19602
  });
19680
19603
  };
19681
- PermissionService.prototype._checkPermission = function (userPermissions, permissionToCheck) {
19682
- var e_4, _d;
19683
- var isAuthorized = false;
19684
- try {
19685
- // check permission của người dùng
19686
- // duyệt qua từng permission của người dùng
19687
- for (var userPermissions_1 = __values(userPermissions), userPermissions_1_1 = userPermissions_1.next(); !userPermissions_1_1.done; userPermissions_1_1 = userPermissions_1.next()) {
19688
- var userPermission = userPermissions_1_1.value;
19689
- // biến để break khỏi vòng khi người dùng được authorized
19690
- var breakOuterLoop = false;
19691
- // pointer permission của người dùng
19692
- var userPermissionPointer = 0;
19693
- // pointer permission đang check
19694
- var permissionToCheckPointer = 0;
19695
- // mark co the check query param
19696
- var aboutToCheckQueryParam = false;
19697
- // check từng char của 2 mảng
19698
- for (; permissionToCheckPointer < permissionToCheck.length;) {
19699
- // nếu char là ký tự bắt đầu template => tịnh tiến pointer của 2 mảng
19700
- var needRecheck = false;
19701
- if (userPermission[userPermissionPointer] == '{') {
19702
- // cho đến khi tìm được ký tự '/' tiếp theo thì dừng lại
19703
- for (; userPermissionPointer < userPermission.length; userPermissionPointer++) {
19704
- if (userPermissionPointer == userPermission.length - 1) {
19705
- break;
19706
- }
19707
- if (userPermission[userPermissionPointer] != '}') {
19708
- continue;
19709
- }
19710
- if (userPermission[userPermissionPointer] === '?') {
19711
- aboutToCheckQueryParam = true;
19712
- }
19713
- ++userPermissionPointer; // tiến tiến đến ký tự sau kết thúc template
19714
- // check trường hợp trường hợp chuỗi template có dạng "{template}acsekjf"
19715
- // => cần check các ký tự sau template và trước ký tự '/'
19716
- if (userPermission[userPermissionPointer] != '/' && (aboutToCheckQueryParam && userPermission[userPermissionPointer] != '&')) {
19717
- needRecheck = true;
19718
- for (; userPermissionPointer < userPermission.length; userPermissionPointer++) {
19719
- if (userPermissionPointer == userPermission.length - 1) {
19720
- break;
19721
- }
19722
- if (userPermission[userPermissionPointer] != '/') {
19723
- continue;
19724
- }
19725
- break;
19726
- }
19727
- }
19728
- break;
19729
- }
19730
- for (; permissionToCheckPointer < permissionToCheck.length; permissionToCheckPointer++) {
19731
- if (permissionToCheckPointer == permissionToCheck.length - 1) {
19732
- break;
19733
- }
19734
- if (permissionToCheck[permissionToCheckPointer] == '/' || (aboutToCheckQueryParam && permissionToCheck[permissionToCheckPointer] == '&')) {
19735
- break;
19736
- }
19737
- }
19738
- }
19739
- var breakInnerLoop = false;
19740
- if (needRecheck) {
19741
- // check lại cho trường hợp chuỗi template có dạng "{template}acslekfj"
19742
- // duyệt ngược lại cho đến khi gặp ký tự kết thúc template
19743
- var tempUserPointer = userPermissionPointer;
19744
- var tempToCheckPointer = permissionToCheckPointer;
19745
- while (userPermission[tempUserPointer] != '}') {
19746
- // ký tự khác nhau => break khỏi vòng kiểm tra trong
19747
- if (userPermission[tempUserPointer].toLowerCase() != permissionToCheck[tempToCheckPointer].toLowerCase()) {
19748
- breakInnerLoop = true;
19749
- break;
19750
- }
19751
- tempUserPointer--;
19752
- tempToCheckPointer--;
19753
- }
19754
- }
19755
- if (breakInnerLoop) {
19756
- break;
19757
- }
19758
- var userChar = userPermission[userPermissionPointer].toLowerCase();
19759
- var toCheckChar = permissionToCheck[permissionToCheckPointer].toLowerCase();
19760
- // nếu userPermission đang ở index cuối
19761
- if (userPermissionPointer == userPermission.length - 1) {
19762
- // check char cuối của 2 mảng (trừ khi là ký tự kết thúc template)
19763
- // và cũng phải là char cuối của mảng permission cần check
19764
- // => người dùng authorized và break khỏi vòng lặp ngoài cùng
19765
- if ((userChar == '}' || userChar == toCheckChar)
19766
- && permissionToCheckPointer == permissionToCheck.length - 1) {
19767
- breakOuterLoop = true;
19768
- isAuthorized = true;
19769
- }
19770
- break;
19771
- }
19772
- // check char có giống nhau không, không giống thì break khỏi vòng check
19773
- if (userChar != toCheckChar) {
19774
- break;
19775
- }
19776
- // nếu char giống nhau thì tiếp tục vòng lăp
19777
- permissionToCheckPointer++;
19778
- userPermissionPointer++;
19779
- }
19780
- if (breakOuterLoop) {
19781
- break;
19782
- }
19783
- }
19784
- }
19785
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
19786
- finally {
19787
- try {
19788
- if (userPermissions_1_1 && !userPermissions_1_1.done && (_d = userPermissions_1.return)) _d.call(userPermissions_1);
19789
- }
19790
- finally { if (e_4) throw e_4.error; }
19791
- }
19792
- return isAuthorized;
19604
+ CongViecService.prototype.countByMenuState = function (data) {
19605
+ return this.defaultPost(this.serviceUri + "/CountByMenuState", data);
19793
19606
  };
19794
- PermissionService.prototype._checkPermissionOld = function (userPermissions, permissionToCheck) {
19795
- var e_5, _d;
19796
- var isAuthorized = false;
19797
- // check quyền theo cách cũ nếu trường họp là phân quyền module
19798
- if (permissionToCheck.includes('MODULE')) {
19799
- return userPermissions.includes(permissionToCheck);
19800
- }
19801
- try {
19802
- for (var userPermissions_2 = __values(userPermissions), userPermissions_2_1 = userPermissions_2.next(); !userPermissions_2_1.done; userPermissions_2_1 = userPermissions_2.next()) {
19803
- var userPermission = userPermissions_2_1.value;
19804
- // Cắt chuỗi permission thành mảng để xem mỗi fragement có khớp nhau không
19805
- var userPermissionFragments = userPermission.split('/');
19806
- var permissionFragments = permissionToCheck.split('/');
19807
- // Mảng khác độ dài thì thoát sớm
19808
- if (userPermissionFragments.length != permissionFragments.length) {
19809
- continue;
19810
- }
19811
- // biến flag ra hiệu người dùng authorized và out vòng
19812
- var breakLoop = false;
19813
- // nếu tất cả phần tử khớp nhau => permission này trùng và người dùng được authorized
19814
- for (var index = 0; index < permissionFragments.length; index++) {
19815
- var userFragement = userPermissionFragments[index];
19816
- var permissionFragment = permissionFragments[index];
19817
- // skip qua các phần tử có ký tự bắt đầu là '{'
19818
- if (userFragement[0] == '{') {
19819
- if (index == permissionFragments.length - 1) {
19820
- isAuthorized = true;
19821
- breakLoop = true;
19822
- }
19823
- continue;
19824
- }
19825
- if (userFragement.toLowerCase() != permissionFragment.toLowerCase()) {
19826
- break;
19827
- }
19828
- if (index == permissionFragments.length - 1) {
19829
- isAuthorized = true;
19830
- breakLoop = true;
19831
- }
19832
- }
19833
- if (breakLoop) {
19834
- break;
19835
- }
19836
- }
19837
- }
19838
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
19839
- finally {
19840
- try {
19841
- if (userPermissions_2_1 && !userPermissions_2_1.done && (_d = userPermissions_2.return)) _d.call(userPermissions_2);
19842
- }
19843
- finally { if (e_5) throw e_5.error; }
19844
- }
19845
- return isAuthorized;
19607
+ CongViecService.prototype.getDicIdByMenuState = function (data, tuNgay, denNgay) {
19608
+ return this.defaultPost(this.serviceUri + "/GetDicIdByMenuState", {
19609
+ lstTrangThai: data,
19610
+ tuNgay: tuNgay,
19611
+ denNgay: denNgay
19612
+ });
19846
19613
  };
19847
- PermissionService.prototype.isAuthorizedByPermissions = function (permissions, operator, ignoreAdmin) {
19848
- var _this = this;
19849
- if (operator === void 0) { operator = 'OR'; }
19850
- if (ignoreAdmin === void 0) { ignoreAdmin = false; }
19851
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
19852
- var user, isAuthorized;
19853
- var _this = this;
19854
- return __generator(this, function (_d) {
19855
- switch (_d.label) {
19856
- case 0: return [4 /*yield*/, this._userService.getCurrentUser()];
19857
- case 1:
19858
- user = (_d.sent());
19859
- if (user && user.issuperuser.toLowerCase() == 'true') {
19860
- resolve(true);
19861
- return [2 /*return*/];
19862
- }
19863
- if (user && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin) {
19864
- resolve(true);
19865
- return [2 /*return*/];
19866
- }
19867
- isAuthorized = true;
19868
- if (operator.toUpperCase() == 'OR') {
19869
- isAuthorized = false;
19870
- }
19871
- permissions.forEach(function (item) {
19872
- _this.getServicePermission(item.service).then(function (permissionResult) {
19873
- if (operator.toUpperCase() == 'OR') {
19874
- if (permissionResult.includes(item.permission)) {
19875
- isAuthorized = true;
19876
- return;
19877
- }
19878
- }
19879
- else {
19880
- if (!permissionResult.includes(item.permission)) {
19881
- isAuthorized = false;
19882
- return;
19883
- }
19884
- }
19885
- }, function (error) {
19886
- reject(false);
19887
- });
19888
- });
19889
- resolve(isAuthorized);
19890
- return [2 /*return*/];
19891
- }
19892
- });
19893
- }); });
19614
+ CongViecService.prototype.updateBulkIdCha = function (model) {
19615
+ var url = this.serviceUri + "/UpdateBulkIdCha";
19616
+ return this.defaultPost(url, model);
19894
19617
  };
19895
- PermissionService.prototype.getServicePermission = function (service, overrideLocalStorage) {
19896
- if (overrideLocalStorage === void 0) { overrideLocalStorage = false; }
19897
- return __awaiter(this, void 0, void 0, function () {
19898
- var key, storageItem, result, url, response;
19899
- return __generator(this, function (_d) {
19900
- switch (_d.label) {
19901
- case 0:
19902
- key = "AUTHORIZATION." + service.toUpperCase();
19903
- if (!overrideLocalStorage) {
19904
- storageItem = this.storage.getItem(key);
19905
- if (storageItem && storageItem !== 'null') {
19906
- result = JSON.parse(storageItem);
19907
- return [2 /*return*/, result];
19908
- }
19909
- }
19910
- url = this.serviceUri + "/GetPermissionsByService?service=" + service;
19911
- return [4 /*yield*/, this.defaultGet(url)];
19912
- case 1:
19913
- response = _d.sent();
19914
- if (!response || !response.success) {
19915
- return [2 /*return*/, []];
19916
- }
19917
- if (overrideLocalStorage) {
19918
- this.storage.removeItem(key);
19919
- }
19920
- this.storage.setItem(key, JSON.stringify(response.data));
19921
- return [2 /*return*/, response.data];
19922
- }
19923
- });
19924
- });
19618
+ CongViecService.prototype.deleteBulkCongViecCon = function (ids) {
19619
+ var url = this.serviceUri + "/DeleteBulkCongViecCon";
19620
+ return this.defaultPost(url, ids);
19925
19621
  };
19926
- PermissionService.prototype.getPermissionIdsByModule = function (moduleCode, userId) {
19927
- var url = this.serviceUri + "/GetPermissionIdsByModule/" + moduleCode + "/" + userId;
19928
- return this.defaultGet(url);
19622
+ CongViecService.prototype.getDataDashboardCaNhan = function (inputData) {
19623
+ var url = this.serviceUri + "/GetDataDashboardCaNhan";
19624
+ return this.defaultPost(url, inputData);
19929
19625
  };
19930
- PermissionService.prototype.phanQuyenNguoiDung = function (model) {
19931
- var url = this.serviceUri + "/PhanQuyenNguoiDung";
19932
- return this.defaultPost(url, model);
19626
+ CongViecService.prototype.getDataDashboardByDonVi = function (inputData) {
19627
+ var url = this.serviceUri + "/GetDataDashboardByDonVi";
19628
+ return this.defaultPost(url, inputData);
19933
19629
  };
19934
- return PermissionService;
19630
+ CongViecService.prototype.getListTasksDashboard = function (dataFilter) {
19631
+ var url = this.serviceUri + "/getListTasksDashboard";
19632
+ return this.defaultPost(url, dataFilter);
19633
+ };
19634
+ return CongViecService;
19935
19635
  }(BaseService));
19936
- PermissionService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PermissionService_Factory() { return new PermissionService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService), i0__namespace.ɵɵinject(UserService), i0__namespace.ɵɵinject(i4__namespace.OAuthService), i0__namespace.ɵɵinject(ApplicationContextService)); }, token: PermissionService, providedIn: "root" });
19937
- PermissionService.decorators = [
19636
+ CongViecService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function CongViecService_Factory() { return new CongViecService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService), i0__namespace.ɵɵinject(DmLoaiCongViecService)); }, token: CongViecService, providedIn: "root" });
19637
+ CongViecService.decorators = [
19938
19638
  { type: i0.Injectable, args: [{
19939
19639
  providedIn: 'root'
19940
19640
  },] }
19941
19641
  ];
19942
- PermissionService.ctorParameters = function () { return [
19642
+ CongViecService.ctorParameters = function () { return [
19943
19643
  { type: i1$1.HttpClient },
19944
19644
  { type: i0.Injector },
19945
19645
  { type: ModuleConfigService },
19946
- { type: UserService },
19947
- { type: i4.OAuthService },
19948
- { type: ApplicationContextService }
19646
+ { type: DmLoaiCongViecService }
19949
19647
  ]; };
19950
19648
 
19951
- var sort_by;
19952
- (function () {
19953
- var defaultCompareFunc = function (a, b) {
19954
- if (a == b)
19955
- return 0;
19956
- return a < b ? -1 : 1;
19957
- };
19958
- var getCompareFunc = function (primer, reverse) {
19959
- var defaultCompare = defaultCompareFunc;
19960
- var compare = defaultCompareFunc;
19961
- if (primer) {
19962
- compare = function (a, b) {
19963
- return defaultCompare(primer(a), primer(b));
19964
- };
19965
- }
19966
- if (reverse) {
19967
- return function (a, b) {
19968
- return -1 * compare(a, b);
19969
- };
19970
- }
19971
- return compare;
19972
- };
19973
- sort_by = function () {
19974
- var args = [];
19975
- for (var _i = 0; _i < arguments.length; _i++) {
19976
- args[_i] = arguments[_i];
19977
- }
19978
- var fields = [], n_fields = args.length;
19979
- var field, name, cmp;
19980
- // preprocess sorting options
19981
- for (var i = 0; i < n_fields; i++) {
19982
- field = args[i];
19983
- if (typeof field === 'string') {
19984
- name = field;
19985
- cmp = defaultCompareFunc;
19986
- }
19987
- else {
19988
- name = field.name;
19989
- cmp = getCompareFunc(field.primer, field.reverse);
19990
- }
19991
- fields.push({
19992
- name: name,
19993
- cmp: cmp
19994
- });
19649
+ var SearchInfo = /** @class */ (function () {
19650
+ function SearchInfo(init) {
19651
+ this.fieldSearchText = [];
19652
+ this.tooltipSearchText = '';
19653
+ this.fieldDropdown = {};
19654
+ for (var key in init) {
19655
+ this[key] = init[key];
19995
19656
  }
19996
- // final comparison function
19997
- return function (A, B) {
19998
- var name, result;
19999
- for (var i = 0; i < n_fields; i++) {
20000
- result = 0;
20001
- field = fields[i];
20002
- name = field.name;
20003
- result = field.cmp(A[name], B[name]);
20004
- if (result !== 0)
20005
- break;
20006
- }
20007
- return result;
20008
- };
20009
- };
19657
+ }
19658
+ return SearchInfo;
20010
19659
  }());
20011
- // multipleSort('idTinhThanh', 'idQuanHuyen')
20012
- // multipleSort({name: 'idTinhThanh', reverse: true}, 'idQuanHuyen')
20013
- // multipleSort({name: 'soThuTu', primer: parseInt}, 'idQuanHuyen') // parseInt là function
20014
- var multipleSort = sort_by;
20015
19660
 
20016
- var moduleMap = {};
20017
- function loadRemoteEntry(remoteEntry) {
20018
- return new Promise(function (resolve, reject) {
20019
- if (moduleMap[remoteEntry]) {
20020
- resolve();
20021
- return;
20022
- }
20023
- var script = document.createElement('script');
20024
- script.src = remoteEntry;
20025
- script.onerror = reject;
20026
- script.onload = function () {
20027
- moduleMap[remoteEntry] = true;
20028
- resolve(); // window is the global namespace
20029
- };
20030
- document.body.append(script);
20031
- });
20032
- }
20033
- function lookupExposedModule(remoteName, exposedModule) {
20034
- return __awaiter(this, void 0, void 0, function () {
20035
- var container, factory, Module;
20036
- return __generator(this, function (_a) {
20037
- switch (_a.label) {
20038
- case 0:
20039
- // Initializes the share scope. This fills it with known provided modules from this build and all remotes
20040
- return [4 /*yield*/, __webpack_init_sharing__('default')];
20041
- case 1:
20042
- // Initializes the share scope. This fills it with known provided modules from this build and all remotes
20043
- _a.sent();
20044
- container = window[remoteName];
20045
- // Initialize the container, it may provide shared modules
20046
- return [4 /*yield*/, container.init(__webpack_share_scopes__.default)];
20047
- case 2:
20048
- // Initialize the container, it may provide shared modules
20049
- _a.sent();
20050
- return [4 /*yield*/, container.get(exposedModule)];
20051
- case 3:
20052
- factory = _a.sent();
20053
- Module = factory();
20054
- return [2 /*return*/, Module];
20055
- }
20056
- });
20057
- });
20058
- }
20059
- function loadRemoteModule(options) {
20060
- return __awaiter(this, void 0, void 0, function () {
20061
- return __generator(this, function (_a) {
20062
- switch (_a.label) {
20063
- case 0: return [4 /*yield*/, loadRemoteEntry(options.remoteEntry)];
20064
- case 1:
20065
- _a.sent();
20066
- return [4 /*yield*/, lookupExposedModule(options.remoteName, options.exposedModule)];
20067
- case 2: return [2 /*return*/, _a.sent()];
20068
- }
20069
- });
20070
- });
20071
- }
20072
- function loadRemotePageModule(remoteName, module, environment) {
20073
- return __awaiter(this, void 0, void 0, function () {
20074
- var remoteEntry, options;
20075
- return __generator(this, function (_a) {
20076
- switch (_a.label) {
20077
- case 0:
20078
- remoteEntry = environment.clientDomain.appDomain + "/" + remoteName + "/remoteEntry.js";
20079
- if (!environment.production) {
20080
- remoteEntry = environment.clientDomain[remoteName] + "/remoteEntry.js";
20081
- }
20082
- options = {
20083
- remoteName: remoteName,
20084
- remoteEntry: remoteEntry,
20085
- exposedModule: module,
20086
- };
20087
- return [4 /*yield*/, loadRemoteModule(options)];
20088
- case 1: return [2 /*return*/, _a.sent()];
20089
- }
20090
- });
20091
- });
20092
- }
20093
-
20094
- var FederationService = /** @class */ (function () {
20095
- function FederationService(resolver, _moduleConfigService) {
20096
- this.resolver = resolver;
20097
- this._moduleConfigService = _moduleConfigService;
20098
- this.environment = _moduleConfigService.getConfig().environment;
19661
+ var BasePermissionService = /** @class */ (function (_super) {
19662
+ __extends(BasePermissionService, _super);
19663
+ function BasePermissionService(http, injector, _moduleConfigService) {
19664
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/BasePermission") || this;
19665
+ _this._moduleConfigService = _moduleConfigService;
19666
+ _this.entityName = 'BasePermission';
19667
+ _this.serviceCode = 'Authorization';
19668
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint;
19669
+ return _this;
20099
19670
  }
20100
- FederationService.prototype.loadRemoteComponent = function (remoteName, componentName, viewContainerRef) {
20101
- return __awaiter(this, void 0, void 0, function () {
20102
- var remoteEntry, options, component, componentFactory, viewContainer, compRef;
20103
- return __generator(this, function (_a) {
20104
- switch (_a.label) {
20105
- case 0:
20106
- remoteEntry = this.environment.clientDomain.appDomain + "/" + remoteName + "/remoteEntry.js";
20107
- if (!this.environment.production) {
20108
- remoteEntry = this.environment.clientDomain[remoteName] + "/remoteEntry.js";
20109
- }
20110
- options = {
20111
- remoteName: remoteName,
20112
- remoteEntry: remoteEntry,
20113
- exposedModule: componentName,
20114
- };
20115
- return [4 /*yield*/, loadRemoteModule(options)];
20116
- case 1:
20117
- component = _a.sent();
20118
- componentFactory = this.resolver.resolveComponentFactory(component[componentName]);
20119
- viewContainer = viewContainerRef.viewContainerRef;
20120
- viewContainer.clear();
20121
- compRef = viewContainer.createComponent(componentFactory);
20122
- return [2 /*return*/, compRef];
20123
- }
20124
- });
20125
- });
20126
- };
20127
- FederationService.prototype.loadRemoteNewComponent = function (remoteName, componentName, viewContainerRef) {
20128
- return __awaiter(this, void 0, void 0, function () {
20129
- var remoteEntry, options, component, componentFactory, compRef;
20130
- return __generator(this, function (_a) {
20131
- switch (_a.label) {
20132
- case 0:
20133
- remoteEntry = this.environment.clientDomain.appDomain + "/" + remoteName + "/remoteEntry.js";
20134
- if (!this.environment.production) {
20135
- remoteEntry = this.environment.clientDomain[remoteName] + "/remoteEntry.js";
20136
- }
20137
- options = {
20138
- remoteName: remoteName,
20139
- remoteEntry: remoteEntry,
20140
- exposedModule: componentName,
20141
- };
20142
- return [4 /*yield*/, loadRemoteModule(options)];
20143
- case 1:
20144
- component = _a.sent();
20145
- componentFactory = this.resolver.resolveComponentFactory(component[componentName]);
20146
- viewContainerRef.clear();
20147
- compRef = viewContainerRef.createComponent(componentFactory);
20148
- return [2 /*return*/, compRef];
20149
- }
20150
- });
20151
- });
19671
+ BasePermissionService.prototype.getPermissionByCode = function (code) {
19672
+ return this.defaultGet(this.serviceUri + "/GetPermissionByCode?code=" + code);
20152
19673
  };
20153
- return FederationService;
20154
- }());
20155
- FederationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function FederationService_Factory() { return new FederationService(i0__namespace.ɵɵinject(i0__namespace.ComponentFactoryResolver), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: FederationService, providedIn: "root" });
20156
- FederationService.decorators = [
19674
+ return BasePermissionService;
19675
+ }(BaseService));
19676
+ BasePermissionService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function BasePermissionService_Factory() { return new BasePermissionService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: BasePermissionService, providedIn: "root" });
19677
+ BasePermissionService.decorators = [
20157
19678
  { type: i0.Injectable, args: [{
20158
19679
  providedIn: 'root'
20159
19680
  },] }
20160
19681
  ];
20161
- FederationService.ctorParameters = function () { return [
20162
- { type: i0.ComponentFactoryResolver },
19682
+ BasePermissionService.ctorParameters = function () { return [
19683
+ { type: i1$1.HttpClient },
19684
+ { type: i0.Injector },
20163
19685
  { type: ModuleConfigService }
20164
19686
  ]; };
20165
19687
 
@@ -21160,361 +20682,862 @@
21160
20682
  { type: CrudService }
21161
20683
  ]; };
21162
20684
 
21163
- var StateMachinesService = /** @class */ (function (_super) {
21164
- __extends(StateMachinesService, _super);
21165
- function StateMachinesService(http, injector, _moduleConfigService) {
21166
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/StateMachines") || this;
21167
- _this._moduleConfigService = _moduleConfigService;
21168
- _this.entityName = 'StateMachines';
21169
- _this.serviceCode = 'workflow';
21170
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint;
20685
+ var EntityWorkflowHistoryService = /** @class */ (function (_super) {
20686
+ __extends(EntityWorkflowHistoryService, _super);
20687
+ function EntityWorkflowHistoryService(http, injector, _moduleConfigService) {
20688
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/EntityWorkflowHistory") || this;
20689
+ _this.entityName = 'EntityWorkflowHistory';
20690
+ _this.serviceManagers = {};
20691
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint;
20692
+ _this._moduleConfig = _moduleConfigService.getConfig();
21171
20693
  return _this;
21172
20694
  }
21173
- StateMachinesService.prototype.changeState = function (itemWorkflowHistory) {
21174
- return this.defaultPost(this.serviceUri + "/ChangeState", itemWorkflowHistory);
20695
+ EntityWorkflowHistoryService.prototype.registerService = function (entityName, service) {
20696
+ this.serviceManagers[entityName] = service;
21175
20697
  };
21176
- StateMachinesService.prototype.rollback = function (rowData) {
21177
- return this.defaultPost(this.serviceUri + "/Rollback/" + rowData.__workflowCode + "/" + rowData.id, {});
20698
+ EntityWorkflowHistoryService.prototype.getEndpointByService = function (service) {
20699
+ return service.endPoint + "/" + this._moduleConfig.environment.apiVersion;
21178
20700
  };
21179
- StateMachinesService.prototype.getUserInProcessForm = function (workflowCode, stateCode, actionCode, itemId) {
21180
- return this.defaultPost(this.serviceUri + "/GetUserInProcessForm/" + workflowCode + "/" + stateCode + "/" + actionCode + "/" + itemId, {});
20701
+ EntityWorkflowHistoryService.prototype.setCurrentServiceUri = function (tableName) {
20702
+ var service = this.serviceManagers[tableName];
20703
+ if (service == undefined) {
20704
+ (this._injector.get(NotifierService)).showWarning('Bạn chưa đăng ký base service cho entity workflow history');
20705
+ }
20706
+ this.serviceUri = this.getEndpointByService(service) + "/EntityWorkflowHistory";
21181
20707
  };
21182
- return StateMachinesService;
20708
+ EntityWorkflowHistoryService.prototype.getLastHistory = function (tableName, filters) {
20709
+ if (filters === void 0) { filters = []; }
20710
+ var service = this.serviceManagers[tableName];
20711
+ if (service == undefined) {
20712
+ (this._injector.get(NotifierService)).showWarning('Bạn chưa đăng ký base service cho entity workflow history');
20713
+ }
20714
+ var url = this.getEndpointByService(service) + "/EntityWorkflowHistory/GetLastByFilter";
20715
+ var gridInfo = {
20716
+ pageInfo: {
20717
+ page: 1,
20718
+ pageSize: 1
20719
+ },
20720
+ filters: filters,
20721
+ sorts: [
20722
+ new Sort({ field: 'created', dir: 1 })
20723
+ ]
20724
+ };
20725
+ return this.defaultPost(url, gridInfo);
20726
+ };
20727
+ return EntityWorkflowHistoryService;
21183
20728
  }(BaseService));
21184
- StateMachinesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function StateMachinesService_Factory() { return new StateMachinesService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: StateMachinesService, providedIn: "root" });
21185
- StateMachinesService.decorators = [
20729
+ EntityWorkflowHistoryService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function EntityWorkflowHistoryService_Factory() { return new EntityWorkflowHistoryService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: EntityWorkflowHistoryService, providedIn: "root" });
20730
+ EntityWorkflowHistoryService.decorators = [
21186
20731
  { type: i0.Injectable, args: [{
21187
20732
  providedIn: 'root'
21188
20733
  },] }
21189
20734
  ];
21190
- StateMachinesService.ctorParameters = function () { return [
20735
+ EntityWorkflowHistoryService.ctorParameters = function () { return [
21191
20736
  { type: i1$1.HttpClient },
21192
20737
  { type: i0.Injector },
21193
20738
  { type: ModuleConfigService }
21194
20739
  ]; };
21195
20740
 
21196
- var CauHinhWorkflowService = /** @class */ (function (_super) {
21197
- __extends(CauHinhWorkflowService, _super);
21198
- function CauHinhWorkflowService(http, injector, _moduleConfigService) {
21199
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/CauHinhWorkflow") || this;
21200
- _this._moduleConfigService = _moduleConfigService;
21201
- _this.serviceCode = 'congviec';
21202
- _this.entityName = 'CauHinhWorkflow';
21203
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
21204
- return _this;
20741
+ var EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
20742
+ var EXCEL_EXTENSION = '.xlsx';
20743
+ var ExportService = /** @class */ (function () {
20744
+ function ExportService(_http, _injector, _commonService, _moduleConfigService) {
20745
+ this._http = _http;
20746
+ this._injector = _injector;
20747
+ this._commonService = _commonService;
20748
+ this._moduleConfig = _moduleConfigService.getConfig();
20749
+ this.environment = this._moduleConfig.environment;
20750
+ this.serviceUri = this._moduleConfig.environment.apiDomain.templateEndpoint + "/Export";
21205
20751
  }
21206
- return CauHinhWorkflowService;
21207
- }(BaseService));
21208
- CauHinhWorkflowService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function CauHinhWorkflowService_Factory() { return new CauHinhWorkflowService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: CauHinhWorkflowService, providedIn: "root" });
21209
- CauHinhWorkflowService.decorators = [
20752
+ ExportService.prototype.objectToExcel = function (data, fileName, numOfHeaderRow) {
20753
+ var _this = this;
20754
+ return this._http
20755
+ .post(this.serviceUri + "/ObjectToExcel?numOfHeaderRow=" + numOfHeaderRow, data, { responseType: 'blob' })
20756
+ .pipe(operators.catchError(function (err) { return _this._commonService.handleError(err, _this._injector); }))
20757
+ .subscribe(function (res) {
20758
+ _this.saveAsExcelFile(res, fileName);
20759
+ });
20760
+ };
20761
+ ExportService.prototype.saveAsExcelFile = function (buffer, fileName) {
20762
+ var data = new Blob([buffer], {
20763
+ type: EXCEL_TYPE
20764
+ });
20765
+ FileSaver__default["default"].saveAs(data, fileName + '_' + new Date().getTime() + EXCEL_EXTENSION);
20766
+ };
20767
+ ExportService.prototype.saveSpreadSheet = function (buffer, fileName) {
20768
+ var data = new Blob([buffer], {
20769
+ type: EXCEL_TYPE
20770
+ });
20771
+ FileSaver__default["default"].saveAs(data, new Date().getTime() + '_' + fileName);
20772
+ };
20773
+ return ExportService;
20774
+ }());
20775
+ ExportService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ExportService_Factory() { return new ExportService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(CommonService), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: ExportService, providedIn: "root" });
20776
+ ExportService.decorators = [
21210
20777
  { type: i0.Injectable, args: [{
21211
20778
  providedIn: 'root'
21212
20779
  },] }
21213
20780
  ];
21214
- CauHinhWorkflowService.ctorParameters = function () { return [
20781
+ ExportService.ctorParameters = function () { return [
21215
20782
  { type: i1$1.HttpClient },
21216
20783
  { type: i0.Injector },
20784
+ { type: CommonService },
21217
20785
  { type: ModuleConfigService }
21218
20786
  ]; };
21219
20787
 
21220
- var DmLoaiCongViecService = /** @class */ (function (_super) {
21221
- __extends(DmLoaiCongViecService, _super);
21222
- function DmLoaiCongViecService(http, injector, _moduleConfigService) {
21223
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/DM_LoaiCongViec") || this;
21224
- _this._moduleConfigService = _moduleConfigService;
21225
- _this.serviceCode = 'congviec';
21226
- _this.entityName = 'DM_LoaiCongViec';
21227
- _this.dicLoaiCongViec = {};
21228
- _this.keyIdLoaiCongViecRoot = 'root';
21229
- _this.getWorkflowSettingByIdLoaiCongViec = function (idLoaiCongViec) { return __awaiter(_this, void 0, void 0, function () {
21230
- var result, idLoaiCongViecs, i;
20788
+ var moduleMap = {};
20789
+ function loadRemoteEntry(remoteEntry) {
20790
+ return new Promise(function (resolve, reject) {
20791
+ if (moduleMap[remoteEntry]) {
20792
+ resolve();
20793
+ return;
20794
+ }
20795
+ var script = document.createElement('script');
20796
+ script.src = remoteEntry;
20797
+ script.onerror = reject;
20798
+ script.onload = function () {
20799
+ moduleMap[remoteEntry] = true;
20800
+ resolve(); // window is the global namespace
20801
+ };
20802
+ document.body.append(script);
20803
+ });
20804
+ }
20805
+ function lookupExposedModule(remoteName, exposedModule) {
20806
+ return __awaiter(this, void 0, void 0, function () {
20807
+ var container, factory, Module;
20808
+ return __generator(this, function (_a) {
20809
+ switch (_a.label) {
20810
+ case 0:
20811
+ // Initializes the share scope. This fills it with known provided modules from this build and all remotes
20812
+ return [4 /*yield*/, __webpack_init_sharing__('default')];
20813
+ case 1:
20814
+ // Initializes the share scope. This fills it with known provided modules from this build and all remotes
20815
+ _a.sent();
20816
+ container = window[remoteName];
20817
+ // Initialize the container, it may provide shared modules
20818
+ return [4 /*yield*/, container.init(__webpack_share_scopes__.default)];
20819
+ case 2:
20820
+ // Initialize the container, it may provide shared modules
20821
+ _a.sent();
20822
+ return [4 /*yield*/, container.get(exposedModule)];
20823
+ case 3:
20824
+ factory = _a.sent();
20825
+ Module = factory();
20826
+ return [2 /*return*/, Module];
20827
+ }
20828
+ });
20829
+ });
20830
+ }
20831
+ function loadRemoteModule(options) {
20832
+ return __awaiter(this, void 0, void 0, function () {
20833
+ return __generator(this, function (_a) {
20834
+ switch (_a.label) {
20835
+ case 0: return [4 /*yield*/, loadRemoteEntry(options.remoteEntry)];
20836
+ case 1:
20837
+ _a.sent();
20838
+ return [4 /*yield*/, lookupExposedModule(options.remoteName, options.exposedModule)];
20839
+ case 2: return [2 /*return*/, _a.sent()];
20840
+ }
20841
+ });
20842
+ });
20843
+ }
20844
+ function loadRemotePageModule(remoteName, module, environment) {
20845
+ return __awaiter(this, void 0, void 0, function () {
20846
+ var remoteEntry, options;
20847
+ return __generator(this, function (_a) {
20848
+ switch (_a.label) {
20849
+ case 0:
20850
+ remoteEntry = environment.clientDomain.appDomain + "/" + remoteName + "/remoteEntry.js";
20851
+ if (!environment.production) {
20852
+ remoteEntry = environment.clientDomain[remoteName] + "/remoteEntry.js";
20853
+ }
20854
+ options = {
20855
+ remoteName: remoteName,
20856
+ remoteEntry: remoteEntry,
20857
+ exposedModule: module,
20858
+ };
20859
+ return [4 /*yield*/, loadRemoteModule(options)];
20860
+ case 1: return [2 /*return*/, _a.sent()];
20861
+ }
20862
+ });
20863
+ });
20864
+ }
20865
+
20866
+ var FederationService = /** @class */ (function () {
20867
+ function FederationService(resolver, _moduleConfigService) {
20868
+ this.resolver = resolver;
20869
+ this._moduleConfigService = _moduleConfigService;
20870
+ this.environment = _moduleConfigService.getConfig().environment;
20871
+ }
20872
+ FederationService.prototype.loadRemoteComponent = function (remoteName, componentName, viewContainerRef) {
20873
+ return __awaiter(this, void 0, void 0, function () {
20874
+ var remoteEntry, options, component, componentFactory, viewContainer, compRef;
21231
20875
  return __generator(this, function (_a) {
21232
20876
  switch (_a.label) {
21233
20877
  case 0:
21234
- if (!!this.dicWorkflowByLoaiCongViec) return [3 /*break*/, 2];
21235
- return [4 /*yield*/, this.getDatasourceWorkflowCongViec()];
20878
+ remoteEntry = this.environment.clientDomain.appDomain + "/" + remoteName + "/remoteEntry.js";
20879
+ if (!this.environment.production) {
20880
+ remoteEntry = this.environment.clientDomain[remoteName] + "/remoteEntry.js";
20881
+ }
20882
+ options = {
20883
+ remoteName: remoteName,
20884
+ remoteEntry: remoteEntry,
20885
+ exposedModule: componentName,
20886
+ };
20887
+ return [4 /*yield*/, loadRemoteModule(options)];
21236
20888
  case 1:
21237
- _a.sent();
21238
- _a.label = 2;
20889
+ component = _a.sent();
20890
+ componentFactory = this.resolver.resolveComponentFactory(component[componentName]);
20891
+ viewContainer = viewContainerRef.viewContainerRef;
20892
+ viewContainer.clear();
20893
+ compRef = viewContainer.createComponent(componentFactory);
20894
+ return [2 /*return*/, compRef];
20895
+ }
20896
+ });
20897
+ });
20898
+ };
20899
+ FederationService.prototype.loadRemoteNewComponent = function (remoteName, componentName, viewContainerRef) {
20900
+ return __awaiter(this, void 0, void 0, function () {
20901
+ var remoteEntry, options, component, componentFactory, compRef;
20902
+ return __generator(this, function (_a) {
20903
+ switch (_a.label) {
20904
+ case 0:
20905
+ remoteEntry = this.environment.clientDomain.appDomain + "/" + remoteName + "/remoteEntry.js";
20906
+ if (!this.environment.production) {
20907
+ remoteEntry = this.environment.clientDomain[remoteName] + "/remoteEntry.js";
20908
+ }
20909
+ options = {
20910
+ remoteName: remoteName,
20911
+ remoteEntry: remoteEntry,
20912
+ exposedModule: componentName,
20913
+ };
20914
+ return [4 /*yield*/, loadRemoteModule(options)];
20915
+ case 1:
20916
+ component = _a.sent();
20917
+ componentFactory = this.resolver.resolveComponentFactory(component[componentName]);
20918
+ viewContainerRef.clear();
20919
+ compRef = viewContainerRef.createComponent(componentFactory);
20920
+ return [2 /*return*/, compRef];
20921
+ }
20922
+ });
20923
+ });
20924
+ };
20925
+ return FederationService;
20926
+ }());
20927
+ FederationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function FederationService_Factory() { return new FederationService(i0__namespace.ɵɵinject(i0__namespace.ComponentFactoryResolver), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: FederationService, providedIn: "root" });
20928
+ FederationService.decorators = [
20929
+ { type: i0.Injectable, args: [{
20930
+ providedIn: 'root'
20931
+ },] }
20932
+ ];
20933
+ FederationService.ctorParameters = function () { return [
20934
+ { type: i0.ComponentFactoryResolver },
20935
+ { type: ModuleConfigService }
20936
+ ]; };
20937
+
20938
+ var PhanQuyenModel = /** @class */ (function () {
20939
+ function PhanQuyenModel(init) {
20940
+ this.addRoleIds = [];
20941
+ this.removeRoleIds = [];
20942
+ this.addPermissionIds = [];
20943
+ this.removePermissionIds = [];
20944
+ for (var key in init) {
20945
+ this[key] = init[key];
20946
+ }
20947
+ }
20948
+ return PhanQuyenModel;
20949
+ }());
20950
+ var PermissionService = /** @class */ (function (_super) {
20951
+ __extends(PermissionService, _super);
20952
+ function PermissionService(http, injector, _moduleConfigService, _userService, _oauthService, _appContext) {
20953
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/permission") || this;
20954
+ _this._moduleConfigService = _moduleConfigService;
20955
+ _this._userService = _userService;
20956
+ _this._oauthService = _oauthService;
20957
+ _this._appContext = _appContext;
20958
+ _this.storage = sessionStorage;
20959
+ _this.ignoreAdmin = false;
20960
+ _this.delayCheckPermissions = [];
20961
+ _this.appCode = null;
20962
+ _this._config = _this._moduleConfigService.getConfig();
20963
+ _this.endPoint = _this._config.environment.apiDomain.authorizationEndpoint;
20964
+ _this.ignoreAdmin = _this._config.environment.isIgnoreAdmin;
20965
+ _this.appCode = _this._config.appCode;
20966
+ return _this;
20967
+ }
20968
+ PermissionService.prototype.clearPermissionCacheAll = function () {
20969
+ var _a, _b, _c;
20970
+ var lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(function (app) { return app.code; })) !== null && _c !== void 0 ? _c : [];
20971
+ var lstApiEndpoint = [];
20972
+ var apiDomain = this._config.environment.apiDomain;
20973
+ for (var domainName in apiDomain) {
20974
+ if (domainName.startsWith('-') || domainName.startsWith('1') || domainName == 'gateway')
20975
+ continue;
20976
+ var realDomainName = domainName.split('Endpoint') ? domainName.split('Endpoint')[0] : domainName;
20977
+ lstApiEndpoint.push(realDomainName.toUpperCase());
20978
+ }
20979
+ return this.clearPermissionCache(__spreadArray(__spreadArray([], __read(lstAppCodes)), __read(lstApiEndpoint)));
20980
+ };
20981
+ PermissionService.prototype.clearPermissionCache = function (lstModule) {
20982
+ var url = this.serviceUri + "/ClearPermissionCache";
20983
+ return this.defaultPost(url, lstModule);
20984
+ };
20985
+ PermissionService.prototype.getCurrentUserPermission = function () {
20986
+ var url = this.serviceUri + "/GetCurrentUserPermission";
20987
+ return this.defaultGet(url);
20988
+ };
20989
+ PermissionService.prototype.getAllBasePermission = function (userId) {
20990
+ var _a, _b, _c;
20991
+ return __awaiter(this, void 0, void 0, function () {
20992
+ var url, user, res, lstAppCodes, promiseArr, lstAppCodes_1, lstAppCodes_1_1, code, lstAppCodes_2, lstAppCodes_2_1, service, permissions, serviceCode, key_1, key, storageItem;
20993
+ var e_1, _d, e_2, _e;
20994
+ return __generator(this, function (_f) {
20995
+ switch (_f.label) {
20996
+ case 0:
20997
+ url = this.serviceUri + "/GetAllBasePermission";
20998
+ // return sớm vì đây là trường hợp lấy permission theo Id của User
20999
+ // ko set local storage vì sẽ làm hỏng quyền của người dùng hiện tại
21000
+ if (userId && userId != '' && userId != this._commonService.guidEmpty()) {
21001
+ return [2 /*return*/, this.defaultGet(url + ("?userId=" + userId))];
21002
+ }
21003
+ if (i0.isDevMode()) {
21004
+ return [2 /*return*/];
21005
+ }
21006
+ user = this._userService.getCurrentUser();
21007
+ if (user
21008
+ && (user.issuperuser && user.issuperuser.toLowerCase() == 'true')
21009
+ || (user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin)) {
21010
+ return [2 /*return*/];
21011
+ }
21012
+ return [4 /*yield*/, this.defaultGet(url)];
21013
+ case 1:
21014
+ res = _f.sent();
21015
+ lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(function (app) { return app.code; })) !== null && _c !== void 0 ? _c : [];
21016
+ if (!(!res || !res.success || res.data == null)) return [3 /*break*/, 3];
21017
+ promiseArr = [];
21018
+ try {
21019
+ for (lstAppCodes_1 = __values(lstAppCodes), lstAppCodes_1_1 = lstAppCodes_1.next(); !lstAppCodes_1_1.done; lstAppCodes_1_1 = lstAppCodes_1.next()) {
21020
+ code = lstAppCodes_1_1.value;
21021
+ promiseArr.push(this.getServicePermission(code, true));
21022
+ }
21023
+ }
21024
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
21025
+ finally {
21026
+ try {
21027
+ if (lstAppCodes_1_1 && !lstAppCodes_1_1.done && (_d = lstAppCodes_1.return)) _d.call(lstAppCodes_1);
21028
+ }
21029
+ finally { if (e_1) throw e_1.error; }
21030
+ }
21031
+ return [4 /*yield*/, Promise.all(promiseArr)];
21239
21032
  case 2:
21240
- if (!idLoaiCongViec) {
21241
- return [2 /*return*/, this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot]];
21033
+ _f.sent();
21034
+ return [2 /*return*/];
21035
+ case 3:
21036
+ try {
21037
+ // Set local storage cho permission của người dùng
21038
+ for (lstAppCodes_2 = __values(lstAppCodes), lstAppCodes_2_1 = lstAppCodes_2.next(); !lstAppCodes_2_1.done; lstAppCodes_2_1 = lstAppCodes_2.next()) {
21039
+ service = lstAppCodes_2_1.value;
21040
+ permissions = [];
21041
+ serviceCode = service.toUpperCase();
21042
+ for (key_1 in res.data) {
21043
+ if (key_1.toUpperCase() != serviceCode) {
21044
+ continue;
21045
+ }
21046
+ permissions = res.data[key_1];
21047
+ break;
21048
+ }
21049
+ key = "AUTHORIZATION." + serviceCode;
21050
+ storageItem = this.storage.getItem(key);
21051
+ if (storageItem != null) {
21052
+ this.storage.removeItem(key);
21053
+ }
21054
+ this.storage.setItem(key, JSON.stringify(permissions));
21055
+ }
21242
21056
  }
21243
- result = this.dicWorkflowByLoaiCongViec[idLoaiCongViec];
21244
- if (result)
21245
- return [2 /*return*/, result];
21246
- return [4 /*yield*/, this.getIdLoaiCongViecs(idLoaiCongViec)];
21057
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
21058
+ finally {
21059
+ try {
21060
+ if (lstAppCodes_2_1 && !lstAppCodes_2_1.done && (_e = lstAppCodes_2.return)) _e.call(lstAppCodes_2);
21061
+ }
21062
+ finally { if (e_2) throw e_2.error; }
21063
+ }
21064
+ return [2 /*return*/];
21065
+ }
21066
+ });
21067
+ });
21068
+ };
21069
+ /**
21070
+ * Truyền vào danh sách permision cần check
21071
+ * @param lstPermissionCode những perrmision code cần check => nên dùng trong trường hợp check các button trong code
21072
+ * @returns trả ra các perrmisionCode có quyền
21073
+ */
21074
+ PermissionService.prototype.getPermissionAuthorized = function (lstPermissionCode) {
21075
+ var _this = this;
21076
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
21077
+ var user, result, lstPermissionCode_1, lstPermissionCode_1_1, item, e_3_1;
21078
+ var e_3, _d;
21079
+ return __generator(this, function (_e) {
21080
+ switch (_e.label) {
21081
+ case 0: return [4 /*yield*/, this._userService.getCurrentUser()];
21082
+ case 1:
21083
+ user = (_e.sent());
21084
+ if (user && user.issuperuser.toLowerCase() == 'true') {
21085
+ resolve(lstPermissionCode);
21086
+ return [2 /*return*/];
21087
+ }
21088
+ if (user && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin) {
21089
+ resolve(lstPermissionCode);
21090
+ return [2 /*return*/];
21091
+ }
21092
+ result = [];
21093
+ _e.label = 2;
21094
+ case 2:
21095
+ _e.trys.push([2, 7, 8, 9]);
21096
+ lstPermissionCode_1 = __values(lstPermissionCode), lstPermissionCode_1_1 = lstPermissionCode_1.next();
21097
+ _e.label = 3;
21247
21098
  case 3:
21248
- idLoaiCongViecs = _a.sent();
21249
- if (!Array.isArray(idLoaiCongViecs))
21250
- return [2 /*return*/, null];
21251
- if (idLoaiCongViecs.length > 1) {
21252
- for (i = idLoaiCongViecs.length - 2; i >= 0; i--) {
21253
- result = this.dicWorkflowByLoaiCongViec[idLoaiCongViecs[i]];
21254
- if (result)
21255
- return [2 /*return*/, result];
21099
+ if (!!lstPermissionCode_1_1.done) return [3 /*break*/, 6];
21100
+ item = lstPermissionCode_1_1.value;
21101
+ return [4 /*yield*/, this.isAuthorizedPermission(item)];
21102
+ case 4:
21103
+ if (_e.sent()) {
21104
+ result.push(item);
21105
+ }
21106
+ _e.label = 5;
21107
+ case 5:
21108
+ lstPermissionCode_1_1 = lstPermissionCode_1.next();
21109
+ return [3 /*break*/, 3];
21110
+ case 6: return [3 /*break*/, 9];
21111
+ case 7:
21112
+ e_3_1 = _e.sent();
21113
+ e_3 = { error: e_3_1 };
21114
+ return [3 /*break*/, 9];
21115
+ case 8:
21116
+ try {
21117
+ if (lstPermissionCode_1_1 && !lstPermissionCode_1_1.done && (_d = lstPermissionCode_1.return)) _d.call(lstPermissionCode_1);
21118
+ }
21119
+ finally { if (e_3) throw e_3.error; }
21120
+ return [7 /*endfinally*/];
21121
+ case 9:
21122
+ resolve(result);
21123
+ return [2 /*return*/];
21124
+ }
21125
+ });
21126
+ }); });
21127
+ };
21128
+ PermissionService.prototype.isAuthorizedPermission = function (permission) {
21129
+ return __awaiter(this, void 0, void 0, function () {
21130
+ var retryCount;
21131
+ return __generator(this, function (_d) {
21132
+ switch (_d.label) {
21133
+ case 0:
21134
+ retryCount = 0;
21135
+ _d.label = 1;
21136
+ case 1:
21137
+ if (!!this._oauthService.hasValidAccessToken()) return [3 /*break*/, 3];
21138
+ return [4 /*yield*/, this._commonService.delay(100)];
21139
+ case 2:
21140
+ _d.sent();
21141
+ retryCount++;
21142
+ if (retryCount > 50) {
21143
+ return [3 /*break*/, 3];
21144
+ }
21145
+ return [3 /*break*/, 1];
21146
+ case 3: return [4 /*yield*/, this.checkPermission(this.appCode, permission)];
21147
+ case 4: return [2 /*return*/, _d.sent()];
21148
+ }
21149
+ });
21150
+ });
21151
+ };
21152
+ PermissionService.prototype.isAuthorized = function (service, permission, checForMenu) {
21153
+ if (checForMenu === void 0) { checForMenu = false; }
21154
+ return __awaiter(this, void 0, void 0, function () {
21155
+ var retryCount;
21156
+ return __generator(this, function (_d) {
21157
+ switch (_d.label) {
21158
+ case 0:
21159
+ this.root = this._appContext.getRootContext();
21160
+ retryCount = 0;
21161
+ _d.label = 1;
21162
+ case 1:
21163
+ if (!!this._oauthService.hasValidAccessToken()) return [3 /*break*/, 3];
21164
+ return [4 /*yield*/, this._commonService.delay(100)];
21165
+ case 2:
21166
+ _d.sent();
21167
+ retryCount++;
21168
+ if (retryCount > 50) {
21169
+ return [3 /*break*/, 3];
21170
+ }
21171
+ return [3 /*break*/, 1];
21172
+ case 3: return [4 /*yield*/, this.checkPermission(service, permission, checForMenu)];
21173
+ case 4: return [2 /*return*/, _d.sent()];
21174
+ }
21175
+ });
21176
+ });
21177
+ };
21178
+ PermissionService.prototype.checkPermission = function (service, permissionToCheck, checkForMenu) {
21179
+ if (checkForMenu === void 0) { checkForMenu = false; }
21180
+ return __awaiter(this, void 0, void 0, function () {
21181
+ var user, valueIsDevMode, userPermissions, _a_1;
21182
+ return __generator(this, function (_d) {
21183
+ switch (_d.label) {
21184
+ case 0:
21185
+ _d.trys.push([0, 2, , 3]);
21186
+ user = this._userService.getCurrentUser();
21187
+ valueIsDevMode = true;
21188
+ if (i0.isDevMode() && valueIsDevMode) {
21189
+ return [2 /*return*/, true];
21190
+ }
21191
+ if (user && user.issuperuser && user.issuperuser.toLowerCase() == 'true' && valueIsDevMode) {
21192
+ return [2 /*return*/, true];
21193
+ }
21194
+ if (user && user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin && valueIsDevMode) {
21195
+ return [2 /*return*/, true];
21196
+ }
21197
+ return [4 /*yield*/, this.getServicePermission(service)];
21198
+ case 1:
21199
+ userPermissions = _d.sent();
21200
+ if (userPermissions && userPermissions.length > 0) {
21201
+ return [2 /*return*/, checkForMenu
21202
+ ? userPermissions.includes(permissionToCheck)
21203
+ : this._checkPermission(userPermissions, permissionToCheck)];
21204
+ }
21205
+ else {
21206
+ // console.log(`Không có quyền với phân hệ [${service}]`);
21207
+ return [2 /*return*/, false];
21208
+ }
21209
+ return [3 /*break*/, 3];
21210
+ case 2:
21211
+ _a_1 = _d.sent();
21212
+ return [2 /*return*/, false];
21213
+ case 3: return [2 /*return*/];
21214
+ }
21215
+ });
21216
+ });
21217
+ };
21218
+ PermissionService.prototype._checkPermission = function (userPermissions, permissionToCheck) {
21219
+ var e_4, _d;
21220
+ var isAuthorized = false;
21221
+ try {
21222
+ // check permission của người dùng
21223
+ // duyệt qua từng permission của người dùng
21224
+ for (var userPermissions_1 = __values(userPermissions), userPermissions_1_1 = userPermissions_1.next(); !userPermissions_1_1.done; userPermissions_1_1 = userPermissions_1.next()) {
21225
+ var userPermission = userPermissions_1_1.value;
21226
+ // biến để break khỏi vòng khi người dùng được authorized
21227
+ var breakOuterLoop = false;
21228
+ // pointer permission của người dùng
21229
+ var userPermissionPointer = 0;
21230
+ // pointer permission đang check
21231
+ var permissionToCheckPointer = 0;
21232
+ // mark co the check query param
21233
+ var aboutToCheckQueryParam = false;
21234
+ // check từng char của 2 mảng
21235
+ for (; permissionToCheckPointer < permissionToCheck.length;) {
21236
+ // nếu char là ký tự bắt đầu template => tịnh tiến pointer của 2 mảng
21237
+ var needRecheck = false;
21238
+ if (userPermission[userPermissionPointer] == '{') {
21239
+ // cho đến khi tìm được ký tự '/' tiếp theo thì dừng lại
21240
+ for (; userPermissionPointer < userPermission.length; userPermissionPointer++) {
21241
+ if (userPermissionPointer == userPermission.length - 1) {
21242
+ break;
21243
+ }
21244
+ if (userPermission[userPermissionPointer] != '}') {
21245
+ continue;
21256
21246
  }
21247
+ if (userPermission[userPermissionPointer] === '?') {
21248
+ aboutToCheckQueryParam = true;
21249
+ }
21250
+ ++userPermissionPointer; // tiến tiến đến ký tự sau kết thúc template
21251
+ // check trường hợp trường hợp chuỗi template có dạng "{template}acsekjf"
21252
+ // => cần check các ký tự sau template và trước ký tự '/'
21253
+ if (userPermission[userPermissionPointer] != '/' && (aboutToCheckQueryParam && userPermission[userPermissionPointer] != '&')) {
21254
+ needRecheck = true;
21255
+ for (; userPermissionPointer < userPermission.length; userPermissionPointer++) {
21256
+ if (userPermissionPointer == userPermission.length - 1) {
21257
+ break;
21258
+ }
21259
+ if (userPermission[userPermissionPointer] != '/') {
21260
+ continue;
21261
+ }
21262
+ break;
21263
+ }
21264
+ }
21265
+ break;
21257
21266
  }
21258
- if (!result) {
21259
- result = this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot];
21267
+ for (; permissionToCheckPointer < permissionToCheck.length; permissionToCheckPointer++) {
21268
+ if (permissionToCheckPointer == permissionToCheck.length - 1) {
21269
+ break;
21270
+ }
21271
+ if (permissionToCheck[permissionToCheckPointer] == '/' || (aboutToCheckQueryParam && permissionToCheck[permissionToCheckPointer] == '&')) {
21272
+ break;
21273
+ }
21274
+ }
21275
+ }
21276
+ var breakInnerLoop = false;
21277
+ if (needRecheck) {
21278
+ // check lại cho trường hợp chuỗi template có dạng "{template}acslekfj"
21279
+ // duyệt ngược lại cho đến khi gặp ký tự kết thúc template
21280
+ var tempUserPointer = userPermissionPointer;
21281
+ var tempToCheckPointer = permissionToCheckPointer;
21282
+ while (userPermission[tempUserPointer] != '}') {
21283
+ // ký tự khác nhau => break khỏi vòng kiểm tra trong
21284
+ if (userPermission[tempUserPointer].toLowerCase() != permissionToCheck[tempToCheckPointer].toLowerCase()) {
21285
+ breakInnerLoop = true;
21286
+ break;
21287
+ }
21288
+ tempUserPointer--;
21289
+ tempToCheckPointer--;
21290
+ }
21291
+ }
21292
+ if (breakInnerLoop) {
21293
+ break;
21294
+ }
21295
+ var userChar = userPermission[userPermissionPointer].toLowerCase();
21296
+ var toCheckChar = permissionToCheck[permissionToCheckPointer].toLowerCase();
21297
+ // nếu userPermission đang ở index cuối
21298
+ if (userPermissionPointer == userPermission.length - 1) {
21299
+ // check char cuối của 2 mảng (trừ khi là ký tự kết thúc template)
21300
+ // và cũng phải là char cuối của mảng permission cần check
21301
+ // => người dùng authorized và break khỏi vòng lặp ngoài cùng
21302
+ if ((userChar == '}' || userChar == toCheckChar)
21303
+ && permissionToCheckPointer == permissionToCheck.length - 1) {
21304
+ breakOuterLoop = true;
21305
+ isAuthorized = true;
21306
+ }
21307
+ break;
21308
+ }
21309
+ // check char có giống nhau không, không giống thì break khỏi vòng check
21310
+ if (userChar != toCheckChar) {
21311
+ break;
21312
+ }
21313
+ // nếu char giống nhau thì tiếp tục vòng lăp
21314
+ permissionToCheckPointer++;
21315
+ userPermissionPointer++;
21316
+ }
21317
+ if (breakOuterLoop) {
21318
+ break;
21319
+ }
21320
+ }
21321
+ }
21322
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
21323
+ finally {
21324
+ try {
21325
+ if (userPermissions_1_1 && !userPermissions_1_1.done && (_d = userPermissions_1.return)) _d.call(userPermissions_1);
21326
+ }
21327
+ finally { if (e_4) throw e_4.error; }
21328
+ }
21329
+ return isAuthorized;
21330
+ };
21331
+ PermissionService.prototype._checkPermissionOld = function (userPermissions, permissionToCheck) {
21332
+ var e_5, _d;
21333
+ var isAuthorized = false;
21334
+ // check quyền theo cách cũ nếu trường họp là phân quyền module
21335
+ if (permissionToCheck.includes('MODULE')) {
21336
+ return userPermissions.includes(permissionToCheck);
21337
+ }
21338
+ try {
21339
+ for (var userPermissions_2 = __values(userPermissions), userPermissions_2_1 = userPermissions_2.next(); !userPermissions_2_1.done; userPermissions_2_1 = userPermissions_2.next()) {
21340
+ var userPermission = userPermissions_2_1.value;
21341
+ // Cắt chuỗi permission thành mảng để xem mỗi fragement có khớp nhau không
21342
+ var userPermissionFragments = userPermission.split('/');
21343
+ var permissionFragments = permissionToCheck.split('/');
21344
+ // Mảng khác độ dài thì thoát sớm
21345
+ if (userPermissionFragments.length != permissionFragments.length) {
21346
+ continue;
21347
+ }
21348
+ // biến flag ra hiệu người dùng authorized và out vòng
21349
+ var breakLoop = false;
21350
+ // nếu tất cả phần tử khớp nhau => permission này trùng và người dùng được authorized
21351
+ for (var index = 0; index < permissionFragments.length; index++) {
21352
+ var userFragement = userPermissionFragments[index];
21353
+ var permissionFragment = permissionFragments[index];
21354
+ // skip qua các phần tử có ký tự bắt đầu là '{'
21355
+ if (userFragement[0] == '{') {
21356
+ if (index == permissionFragments.length - 1) {
21357
+ isAuthorized = true;
21358
+ breakLoop = true;
21260
21359
  }
21261
- return [2 /*return*/, result];
21360
+ continue;
21361
+ }
21362
+ if (userFragement.toLowerCase() != permissionFragment.toLowerCase()) {
21363
+ break;
21364
+ }
21365
+ if (index == permissionFragments.length - 1) {
21366
+ isAuthorized = true;
21367
+ breakLoop = true;
21368
+ }
21262
21369
  }
21263
- });
21264
- }); };
21265
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
21266
- return _this;
21267
- }
21268
- DmLoaiCongViecService.prototype.getDatasourceWorkflowCongViec = function () {
21269
- return __awaiter(this, void 0, void 0, function () {
21270
- var cauHinhWorkflowService, cauHinhWorkflows, notifierService, workflowCodes, stateMachinesService, workflows;
21370
+ if (breakLoop) {
21371
+ break;
21372
+ }
21373
+ }
21374
+ }
21375
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
21376
+ finally {
21377
+ try {
21378
+ if (userPermissions_2_1 && !userPermissions_2_1.done && (_d = userPermissions_2.return)) _d.call(userPermissions_2);
21379
+ }
21380
+ finally { if (e_5) throw e_5.error; }
21381
+ }
21382
+ return isAuthorized;
21383
+ };
21384
+ PermissionService.prototype.isAuthorizedByPermissions = function (permissions, operator, ignoreAdmin) {
21385
+ var _this = this;
21386
+ if (operator === void 0) { operator = 'OR'; }
21387
+ if (ignoreAdmin === void 0) { ignoreAdmin = false; }
21388
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
21389
+ var user, isAuthorized;
21271
21390
  var _this = this;
21272
- return __generator(this, function (_a) {
21273
- switch (_a.label) {
21274
- case 0:
21275
- if (!this.dicWorkflowByLoaiCongViec) {
21276
- this.dicWorkflowByLoaiCongViec = {};
21277
- }
21278
- cauHinhWorkflowService = this._injector.get(CauHinhWorkflowService);
21279
- return [4 /*yield*/, cauHinhWorkflowService.getAll([], 'idLoaiCongViec,workflowCodes,workflowCode')];
21391
+ return __generator(this, function (_d) {
21392
+ switch (_d.label) {
21393
+ case 0: return [4 /*yield*/, this._userService.getCurrentUser()];
21280
21394
  case 1:
21281
- cauHinhWorkflows = (_a.sent()).data;
21282
- notifierService = this._injector.get(NotifierService);
21283
- if (cauHinhWorkflows == null) {
21284
- notifierService.showWarning('Dịch vụ workflow không phản hồi');
21285
- return [2 /*return*/, []];
21395
+ user = (_d.sent());
21396
+ if (user && user.issuperuser.toLowerCase() == 'true') {
21397
+ resolve(true);
21398
+ return [2 /*return*/];
21286
21399
  }
21287
- workflowCodes = [];
21288
- cauHinhWorkflows.forEach(function (itemWorkflowSetting) {
21289
- if (itemWorkflowSetting.workflowCodes && !Array.isArray(itemWorkflowSetting.workflowCodes)) {
21290
- itemWorkflowSetting.workflowCodes = itemWorkflowSetting.workflowCodes.split(',');
21291
- }
21292
- else {
21293
- itemWorkflowSetting.workflowCodes = [];
21294
- }
21295
- itemWorkflowSetting.workflowCodes.forEach(function (workflowCode) {
21296
- if (workflowCodes.indexOf(workflowCode) == -1) {
21297
- workflowCodes.push(workflowCode);
21400
+ if (user && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin) {
21401
+ resolve(true);
21402
+ return [2 /*return*/];
21403
+ }
21404
+ isAuthorized = true;
21405
+ if (operator.toUpperCase() == 'OR') {
21406
+ isAuthorized = false;
21407
+ }
21408
+ permissions.forEach(function (item) {
21409
+ _this.getServicePermission(item.service).then(function (permissionResult) {
21410
+ if (operator.toUpperCase() == 'OR') {
21411
+ if (permissionResult.includes(item.permission)) {
21412
+ isAuthorized = true;
21413
+ return;
21414
+ }
21298
21415
  }
21299
- });
21300
- });
21301
- stateMachinesService = this._injector.get(StateMachinesService);
21302
- return [4 /*yield*/, stateMachinesService.getDataDropdownByFilter([
21303
- this.newFilter('code', exports.Operator.in, workflowCodes)
21304
- ], new DropdownOptions({
21305
- valueField: 'code',
21306
- displayField: 'title',
21307
- fieldPlus: 'data'
21308
- }))];
21309
- case 2:
21310
- workflows = (_a.sent());
21311
- workflows.forEach(function (item) {
21312
- item.data = JSON.parse(item.data);
21313
- var stateMachineData = item.data;
21314
- stateMachineData.actions = {};
21315
- stateMachineData.machines.forEach(function (machine) {
21316
- stateMachineData.actions[machine.code] = [];
21317
- stateMachineData.connections.forEach(function (conn) {
21318
- if (conn.source == machine.id) {
21319
- stateMachineData.actions[machine.code].push(conn);
21416
+ else {
21417
+ if (!permissionResult.includes(item.permission)) {
21418
+ isAuthorized = false;
21419
+ return;
21320
21420
  }
21321
- });
21421
+ }
21422
+ }, function (error) {
21423
+ reject(false);
21322
21424
  });
21323
21425
  });
21324
- cauHinhWorkflows.forEach(function (itemWorkflowSetting) {
21325
- itemWorkflowSetting.workflows = workflows.filter(function (q) { return itemWorkflowSetting.workflowCodes.indexOf(q.code) > -1; });
21326
- if (!itemWorkflowSetting.idLoaiCongViec) {
21327
- _this.dicWorkflowByLoaiCongViec[_this.keyIdLoaiCongViecRoot] = itemWorkflowSetting;
21328
- }
21329
- else {
21330
- _this.dicWorkflowByLoaiCongViec[itemWorkflowSetting.idLoaiCongViec] = itemWorkflowSetting;
21331
- }
21332
- });
21333
- return [2 /*return*/, workflows];
21426
+ resolve(isAuthorized);
21427
+ return [2 /*return*/];
21334
21428
  }
21335
21429
  });
21336
- });
21430
+ }); });
21337
21431
  };
21338
- DmLoaiCongViecService.prototype.getIdLoaiCongViecs = function (idLoaiCongViec) {
21432
+ PermissionService.prototype.getServicePermission = function (service, overrideLocalStorage) {
21433
+ if (overrideLocalStorage === void 0) { overrideLocalStorage = false; }
21339
21434
  return __awaiter(this, void 0, void 0, function () {
21340
- var notifierService, itemLoaiCongViec, idLoaiCongViecs;
21341
- return __generator(this, function (_a) {
21342
- switch (_a.label) {
21435
+ var key, storageItem, result, url, response;
21436
+ return __generator(this, function (_d) {
21437
+ switch (_d.label) {
21343
21438
  case 0:
21344
- notifierService = this._injector.get(NotifierService);
21345
- return [4 /*yield*/, this.getItemLoaiCongViec(idLoaiCongViec)];
21346
- case 1:
21347
- itemLoaiCongViec = _a.sent();
21348
- if (itemLoaiCongViec == null) {
21349
- notifierService.showWarning('Loại công việc không tồn tại');
21350
- return [2 /*return*/, null];
21439
+ key = "AUTHORIZATION." + service.toUpperCase();
21440
+ if (!overrideLocalStorage) {
21441
+ storageItem = this.storage.getItem(key);
21442
+ if (storageItem && storageItem !== 'null') {
21443
+ result = JSON.parse(storageItem);
21444
+ return [2 /*return*/, result];
21445
+ }
21351
21446
  }
21352
- idLoaiCongViecs = itemLoaiCongViec.idDuongDan.split(';').filter(function (q) { return !!q; });
21353
- return [2 /*return*/, idLoaiCongViecs];
21354
- }
21355
- });
21356
- });
21357
- };
21358
- DmLoaiCongViecService.prototype.getItemLoaiCongViec = function (idLoaiCongViec) {
21359
- return __awaiter(this, void 0, void 0, function () {
21360
- var _a, _b;
21361
- return __generator(this, function (_c) {
21362
- switch (_c.label) {
21363
- case 0:
21364
- if (!!this.dicLoaiCongViec[idLoaiCongViec]) return [3 /*break*/, 2];
21365
- _a = this.dicLoaiCongViec;
21366
- _b = idLoaiCongViec;
21367
- return [4 /*yield*/, this.getDetail(idLoaiCongViec)];
21447
+ url = this.serviceUri + "/GetPermissionsByService?service=" + service;
21448
+ return [4 /*yield*/, this.defaultGet(url)];
21368
21449
  case 1:
21369
- _a[_b] = (_c.sent()).data;
21370
- _c.label = 2;
21371
- case 2: return [2 /*return*/, this.dicLoaiCongViec[idLoaiCongViec]];
21372
- }
21373
- });
21374
- });
21375
- };
21376
- return DmLoaiCongViecService;
21377
- }(BaseService));
21378
- DmLoaiCongViecService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function DmLoaiCongViecService_Factory() { return new DmLoaiCongViecService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: DmLoaiCongViecService, providedIn: "root" });
21379
- DmLoaiCongViecService.decorators = [
21380
- { type: i0.Injectable, args: [{
21381
- providedIn: 'root'
21382
- },] }
21383
- ];
21384
- DmLoaiCongViecService.ctorParameters = function () { return [
21385
- { type: i1$1.HttpClient },
21386
- { type: i0.Injector },
21387
- { type: ModuleConfigService }
21388
- ]; };
21389
-
21390
- var CongViecService = /** @class */ (function (_super) {
21391
- __extends(CongViecService, _super);
21392
- function CongViecService(http, injector, _moduleConfigService, _dmLoaiCongViecService) {
21393
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/CongViec_Chinh") || this;
21394
- _this._dmLoaiCongViecService = _dmLoaiCongViecService;
21395
- _this.serviceCode = 'congviec';
21396
- _this.entityName = 'CongViec_Chinh';
21397
- _this.objectName = 'công việc';
21398
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
21399
- _this._moduleConfig = _moduleConfigService.getConfig();
21400
- return _this;
21401
- }
21402
- CongViecService.prototype.adjustSettingWorkflowForCrudList = function (setting) {
21403
- this.useWorkflow = true;
21404
- setting.isWorkflowTree = true;
21405
- setting.baseService = this;
21406
- setting.displayField = function (item) { return item.ten; };
21407
- setting.baseService.useWorkflow = true;
21408
- setting.workflowConfigAdvance = {
21409
- getWorkflowSetting: this.getWorkflowConfig.bind(this)
21410
- };
21411
- };
21412
- CongViecService.prototype.getWorkflowConfig = function (rowData) {
21413
- return __awaiter(this, void 0, void 0, function () {
21414
- return __generator(this, function (_a) {
21415
- switch (_a.label) {
21416
- case 0: return [4 /*yield*/, this._dmLoaiCongViecService.getWorkflowSettingByIdLoaiCongViec(rowData.idLoaiCongViec)];
21417
- case 1: return [2 /*return*/, _a.sent()];
21450
+ response = _d.sent();
21451
+ if (!response || !response.success) {
21452
+ return [2 /*return*/, []];
21453
+ }
21454
+ if (overrideLocalStorage) {
21455
+ this.storage.removeItem(key);
21456
+ }
21457
+ this.storage.setItem(key, JSON.stringify(response.data));
21458
+ return [2 /*return*/, response.data];
21418
21459
  }
21419
21460
  });
21420
21461
  });
21421
21462
  };
21422
- CongViecService.prototype.countByMenuState = function (data) {
21423
- return this.defaultPost(this.serviceUri + "/CountByMenuState", data);
21424
- };
21425
- CongViecService.prototype.getDicIdByMenuState = function (data, tuNgay, denNgay) {
21426
- return this.defaultPost(this.serviceUri + "/GetDicIdByMenuState", {
21427
- lstTrangThai: data,
21428
- tuNgay: tuNgay,
21429
- denNgay: denNgay
21430
- });
21463
+ PermissionService.prototype.getPermissionIdsByModule = function (moduleCode, userId) {
21464
+ var url = this.serviceUri + "/GetPermissionIdsByModule/" + moduleCode + "/" + userId;
21465
+ return this.defaultGet(url);
21431
21466
  };
21432
- CongViecService.prototype.updateBulkIdCha = function (model) {
21433
- var url = this.serviceUri + "/UpdateBulkIdCha";
21467
+ PermissionService.prototype.phanQuyenNguoiDung = function (model) {
21468
+ var url = this.serviceUri + "/PhanQuyenNguoiDung";
21434
21469
  return this.defaultPost(url, model);
21435
21470
  };
21436
- CongViecService.prototype.deleteBulkCongViecCon = function (ids) {
21437
- var url = this.serviceUri + "/DeleteBulkCongViecCon";
21438
- return this.defaultPost(url, ids);
21439
- };
21440
- CongViecService.prototype.getDataDashboardCaNhan = function (inputData) {
21441
- var url = this.serviceUri + "/GetDataDashboardCaNhan";
21442
- return this.defaultPost(url, inputData);
21443
- };
21444
- CongViecService.prototype.getDataDashboardByDonVi = function (inputData) {
21445
- var url = this.serviceUri + "/GetDataDashboardByDonVi";
21446
- return this.defaultPost(url, inputData);
21447
- };
21448
- CongViecService.prototype.getListTasksDashboard = function (dataFilter) {
21449
- var url = this.serviceUri + "/getListTasksDashboard";
21450
- return this.defaultPost(url, dataFilter);
21451
- };
21452
- return CongViecService;
21471
+ return PermissionService;
21453
21472
  }(BaseService));
21454
- CongViecService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function CongViecService_Factory() { return new CongViecService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService), i0__namespace.ɵɵinject(DmLoaiCongViecService)); }, token: CongViecService, providedIn: "root" });
21455
- CongViecService.decorators = [
21473
+ PermissionService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PermissionService_Factory() { return new PermissionService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService), i0__namespace.ɵɵinject(UserService), i0__namespace.ɵɵinject(i4__namespace.OAuthService), i0__namespace.ɵɵinject(ApplicationContextService)); }, token: PermissionService, providedIn: "root" });
21474
+ PermissionService.decorators = [
21456
21475
  { type: i0.Injectable, args: [{
21457
21476
  providedIn: 'root'
21458
21477
  },] }
21459
21478
  ];
21460
- CongViecService.ctorParameters = function () { return [
21479
+ PermissionService.ctorParameters = function () { return [
21461
21480
  { type: i1$1.HttpClient },
21462
21481
  { type: i0.Injector },
21463
21482
  { type: ModuleConfigService },
21464
- { type: DmLoaiCongViecService }
21483
+ { type: UserService },
21484
+ { type: i4.OAuthService },
21485
+ { type: ApplicationContextService }
21465
21486
  ]; };
21466
21487
 
21467
- var EntityWorkflowHistoryService = /** @class */ (function (_super) {
21468
- __extends(EntityWorkflowHistoryService, _super);
21469
- function EntityWorkflowHistoryService(http, injector, _moduleConfigService) {
21470
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/EntityWorkflowHistory") || this;
21471
- _this.entityName = 'EntityWorkflowHistory';
21488
+ var WorkflowHistoryService = /** @class */ (function (_super) {
21489
+ __extends(WorkflowHistoryService, _super);
21490
+ function WorkflowHistoryService(http, injector, _moduleConfigService) {
21491
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/WorkflowHistory") || this;
21472
21492
  _this.serviceManagers = {};
21473
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint;
21493
+ _this.entityName = 'WorkflowHistory';
21494
+ _this.serviceCode = 'workflow';
21495
+ _this.apiDomain = _moduleConfigService.getConfig().environment.apiDomain;
21496
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint;
21474
21497
  _this._moduleConfig = _moduleConfigService.getConfig();
21498
+ _this.apiVersion = _moduleConfigService.getConfig().environment.apiVersion;
21475
21499
  return _this;
21476
21500
  }
21477
- EntityWorkflowHistoryService.prototype.registerService = function (entityName, service) {
21478
- this.serviceManagers[entityName] = service;
21501
+ WorkflowHistoryService.prototype.registerService = function (settingKey, service) {
21502
+ this.serviceManagers[settingKey] = service;
21479
21503
  };
21480
- EntityWorkflowHistoryService.prototype.getEndpointByService = function (service) {
21504
+ WorkflowHistoryService.prototype.getEndpointByService = function (service) {
21481
21505
  return service.endPoint + "/" + this._moduleConfig.environment.apiVersion;
21482
21506
  };
21483
- EntityWorkflowHistoryService.prototype.setCurrentServiceUri = function (tableName) {
21484
- var service = this.serviceManagers[tableName];
21485
- if (service == undefined) {
21486
- (this._injector.get(NotifierService)).showWarning('Bạn chưa đăng ký base service cho entity workflow history');
21487
- }
21488
- this.serviceUri = this.getEndpointByService(service) + "/EntityWorkflowHistory";
21507
+ WorkflowHistoryService.prototype.changeEndpoint = function (baseService) {
21508
+ this.serviceUri = this.getEndpointByService(baseService) + "/WorkflowHistory";
21509
+ return this;
21489
21510
  };
21490
- EntityWorkflowHistoryService.prototype.getLastHistory = function (tableName, filters) {
21491
- if (filters === void 0) { filters = []; }
21492
- var service = this.serviceManagers[tableName];
21493
- if (service == undefined) {
21494
- (this._injector.get(NotifierService)).showWarning('Bạn chưa đăng ký base service cho entity workflow history');
21511
+ WorkflowHistoryService.prototype.getLastByItemId = function (itemId) {
21512
+ // return this.getDetailByFilter(
21513
+ // [
21514
+ // this.newFilter('itemId', Operator.equal, itemId)
21515
+ // ],
21516
+ // [{ field: 'time', dir: -1 }]
21517
+ // );
21518
+ return this.defaultPost(this.serviceUri + "/GetLastByItemIdInMainThread/" + itemId, {});
21519
+ };
21520
+ WorkflowHistoryService.prototype.choYKien = function (model) {
21521
+ return this.defaultPost(this.serviceUri + "/ChoYKien", model);
21522
+ };
21523
+ WorkflowHistoryService.prototype.getAllObjectRelated = function (serviceCode, entity, entityKey, fullApiUrl) {
21524
+ if (fullApiUrl === void 0) { fullApiUrl = null; }
21525
+ var apiUrl = fullApiUrl || this.apiDomain[serviceCode + "Endpoint"];
21526
+ if (!apiUrl) {
21527
+ throw new Error("Kh\u00F4ng t\u00ECm th\u1EA5y api endpoint \u1EE9ng v\u1EDBi service " + serviceCode);
21495
21528
  }
21496
- var url = this.getEndpointByService(service) + "/EntityWorkflowHistory/GetLastByFilter";
21497
- var gridInfo = {
21498
- pageInfo: {
21499
- page: 1,
21500
- pageSize: 1
21501
- },
21502
- filters: filters,
21503
- sorts: [
21504
- new Sort({ field: 'created', dir: 1 })
21505
- ]
21506
- };
21507
- return this.defaultPost(url, gridInfo);
21529
+ apiUrl = apiUrl + "/" + this.apiVersion + "/WorkflowHistory/GetAllObjectRelated/" + entity + "/" + entityKey;
21530
+ return this.defaultGet(apiUrl);
21508
21531
  };
21509
- return EntityWorkflowHistoryService;
21532
+ return WorkflowHistoryService;
21510
21533
  }(BaseService));
21511
- EntityWorkflowHistoryService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function EntityWorkflowHistoryService_Factory() { return new EntityWorkflowHistoryService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: EntityWorkflowHistoryService, providedIn: "root" });
21512
- EntityWorkflowHistoryService.decorators = [
21534
+ WorkflowHistoryService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function WorkflowHistoryService_Factory() { return new WorkflowHistoryService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: WorkflowHistoryService, providedIn: "root" });
21535
+ WorkflowHistoryService.decorators = [
21513
21536
  { type: i0.Injectable, args: [{
21514
21537
  providedIn: 'root'
21515
21538
  },] }
21516
21539
  ];
21517
- EntityWorkflowHistoryService.ctorParameters = function () { return [
21540
+ WorkflowHistoryService.ctorParameters = function () { return [
21518
21541
  { type: i1$1.HttpClient },
21519
21542
  { type: i0.Injector },
21520
21543
  { type: ModuleConfigService }
@@ -21688,90 +21711,70 @@
21688
21711
  { type: ModuleConfigService }
21689
21712
  ]; };
21690
21713
 
21691
- var WorkflowHistoryService = /** @class */ (function (_super) {
21692
- __extends(WorkflowHistoryService, _super);
21693
- function WorkflowHistoryService(http, injector, _moduleConfigService) {
21694
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/WorkflowHistory") || this;
21695
- _this.serviceManagers = {};
21696
- _this.entityName = 'WorkflowHistory';
21697
- _this.serviceCode = 'workflow';
21698
- _this.apiDomain = _moduleConfigService.getConfig().environment.apiDomain;
21699
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint;
21700
- _this._moduleConfig = _moduleConfigService.getConfig();
21701
- _this.apiVersion = _moduleConfigService.getConfig().environment.apiVersion;
21702
- return _this;
21703
- }
21704
- WorkflowHistoryService.prototype.registerService = function (settingKey, service) {
21705
- this.serviceManagers[settingKey] = service;
21706
- };
21707
- WorkflowHistoryService.prototype.getEndpointByService = function (service) {
21708
- return service.endPoint + "/" + this._moduleConfig.environment.apiVersion;
21709
- };
21710
- WorkflowHistoryService.prototype.changeEndpoint = function (baseService) {
21711
- this.serviceUri = this.getEndpointByService(baseService) + "/WorkflowHistory";
21712
- return this;
21713
- };
21714
- WorkflowHistoryService.prototype.getLastByItemId = function (itemId) {
21715
- // return this.getDetailByFilter(
21716
- // [
21717
- // this.newFilter('itemId', Operator.equal, itemId)
21718
- // ],
21719
- // [{ field: 'time', dir: -1 }]
21720
- // );
21721
- return this.defaultPost(this.serviceUri + "/GetLastByItemIdInMainThread/" + itemId, {});
21722
- };
21723
- WorkflowHistoryService.prototype.choYKien = function (model) {
21724
- return this.defaultPost(this.serviceUri + "/ChoYKien", model);
21714
+ var sort_by;
21715
+ (function () {
21716
+ var defaultCompareFunc = function (a, b) {
21717
+ if (a == b)
21718
+ return 0;
21719
+ return a < b ? -1 : 1;
21725
21720
  };
21726
- WorkflowHistoryService.prototype.getAllObjectRelated = function (serviceCode, entity, entityKey, fullApiUrl) {
21727
- if (fullApiUrl === void 0) { fullApiUrl = null; }
21728
- var apiUrl = fullApiUrl || this.apiDomain[serviceCode + "Endpoint"];
21729
- if (!apiUrl) {
21730
- throw new Error("Kh\u00F4ng t\u00ECm th\u1EA5y api endpoint \u1EE9ng v\u1EDBi service " + serviceCode);
21721
+ var getCompareFunc = function (primer, reverse) {
21722
+ var defaultCompare = defaultCompareFunc;
21723
+ var compare = defaultCompareFunc;
21724
+ if (primer) {
21725
+ compare = function (a, b) {
21726
+ return defaultCompare(primer(a), primer(b));
21727
+ };
21731
21728
  }
21732
- apiUrl = apiUrl + "/" + this.apiVersion + "/WorkflowHistory/GetAllObjectRelated/" + entity + "/" + entityKey;
21733
- return this.defaultGet(apiUrl);
21729
+ if (reverse) {
21730
+ return function (a, b) {
21731
+ return -1 * compare(a, b);
21732
+ };
21733
+ }
21734
+ return compare;
21734
21735
  };
21735
- return WorkflowHistoryService;
21736
- }(BaseService));
21737
- WorkflowHistoryService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function WorkflowHistoryService_Factory() { return new WorkflowHistoryService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: WorkflowHistoryService, providedIn: "root" });
21738
- WorkflowHistoryService.decorators = [
21739
- { type: i0.Injectable, args: [{
21740
- providedIn: 'root'
21741
- },] }
21742
- ];
21743
- WorkflowHistoryService.ctorParameters = function () { return [
21744
- { type: i1$1.HttpClient },
21745
- { type: i0.Injector },
21746
- { type: ModuleConfigService }
21747
- ]; };
21748
-
21749
- var BasePermissionService = /** @class */ (function (_super) {
21750
- __extends(BasePermissionService, _super);
21751
- function BasePermissionService(http, injector, _moduleConfigService) {
21752
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/BasePermission") || this;
21753
- _this._moduleConfigService = _moduleConfigService;
21754
- _this.entityName = 'BasePermission';
21755
- _this.serviceCode = 'Authorization';
21756
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint;
21757
- return _this;
21758
- }
21759
- BasePermissionService.prototype.getPermissionByCode = function (code) {
21760
- return this.defaultGet(this.serviceUri + "/GetPermissionByCode?code=" + code);
21736
+ sort_by = function () {
21737
+ var args = [];
21738
+ for (var _i = 0; _i < arguments.length; _i++) {
21739
+ args[_i] = arguments[_i];
21740
+ }
21741
+ var fields = [], n_fields = args.length;
21742
+ var field, name, cmp;
21743
+ // preprocess sorting options
21744
+ for (var i = 0; i < n_fields; i++) {
21745
+ field = args[i];
21746
+ if (typeof field === 'string') {
21747
+ name = field;
21748
+ cmp = defaultCompareFunc;
21749
+ }
21750
+ else {
21751
+ name = field.name;
21752
+ cmp = getCompareFunc(field.primer, field.reverse);
21753
+ }
21754
+ fields.push({
21755
+ name: name,
21756
+ cmp: cmp
21757
+ });
21758
+ }
21759
+ // final comparison function
21760
+ return function (A, B) {
21761
+ var name, result;
21762
+ for (var i = 0; i < n_fields; i++) {
21763
+ result = 0;
21764
+ field = fields[i];
21765
+ name = field.name;
21766
+ result = field.cmp(A[name], B[name]);
21767
+ if (result !== 0)
21768
+ break;
21769
+ }
21770
+ return result;
21771
+ };
21761
21772
  };
21762
- return BasePermissionService;
21763
- }(BaseService));
21764
- BasePermissionService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function BasePermissionService_Factory() { return new BasePermissionService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: BasePermissionService, providedIn: "root" });
21765
- BasePermissionService.decorators = [
21766
- { type: i0.Injectable, args: [{
21767
- providedIn: 'root'
21768
- },] }
21769
- ];
21770
- BasePermissionService.ctorParameters = function () { return [
21771
- { type: i1$1.HttpClient },
21772
- { type: i0.Injector },
21773
- { type: ModuleConfigService }
21774
- ]; };
21773
+ }());
21774
+ // multipleSort('idTinhThanh', 'idQuanHuyen')
21775
+ // multipleSort({name: 'idTinhThanh', reverse: true}, 'idQuanHuyen')
21776
+ // multipleSort({name: 'soThuTu', primer: parseInt}, 'idQuanHuyen') // parseInt là function
21777
+ var multipleSort = sort_by;
21775
21778
 
21776
21779
  var ListComponentBase = /** @class */ (function (_super) {
21777
21780
  __extends(ListComponentBase, _super);
@@ -23185,15 +23188,15 @@
23185
23188
  var result = newArr.reduce(function (x, y) { return y.colSpan + x; }, 0);
23186
23189
  return result > a ? result : a;
23187
23190
  }, 0);
23188
- var startIndex = this.setting.hiddenCheckbox ? 0 : 1;
23189
23191
  var endIndex = maxColSize - (this.setting.hiddenFunctionColumn ? 1 : 2);
23190
23192
  for (var ind = 0; ind < lstRow.length; ind++) {
23191
23193
  var arrTh = __spreadArray([], __read(allTh[ind]));
23194
+ var startIndex = arrTh[0].className.includes('chkbox') ? 1 : 0;
23192
23195
  if (startIndex > endIndex) {
23193
23196
  return null;
23194
23197
  }
23195
23198
  result[ind] = (_a = result[ind]) !== null && _a !== void 0 ? _a : [];
23196
- var colIndex = 0;
23199
+ var colIndex = result[ind].length;
23197
23200
  var numOfColSpan = arrTh.reduce(function (x, y) { return x + y.colSpan - 1; }, 0);
23198
23201
  for (var i = startIndex; i <= endIndex - numOfColSpan; i++) {
23199
23202
  if (arrTh[i]) {
@@ -23358,6 +23361,7 @@
23358
23361
  };
23359
23362
  ListComponentBase.prototype.getValueCheckboxFormat = function (data) {
23360
23363
  var checkBox = data.querySelector('p-checkbox');
23364
+ var input = data.querySelector('input');
23361
23365
  if (checkBox) {
23362
23366
  var value = data.querySelector('span.pi-check');
23363
23367
  if (value) {
@@ -23367,6 +23371,9 @@
23367
23371
  return 'Không';
23368
23372
  }
23369
23373
  }
23374
+ if (input) {
23375
+ return input.value;
23376
+ }
23370
23377
  return '';
23371
23378
  };
23372
23379
  ListComponentBase.prototype.view = function (rowData) {
@@ -53116,34 +53123,37 @@
53116
53123
  },
53117
53124
  mobile: {
53118
53125
  theme: 'silver',
53119
- plugins: ['fullpage advlist autolink lists link image charmap print preview anchor textcolor searchreplace visualblocks code fullscreen insertdatetime media table media code lists colorpicker imagetools tabfocus textcolor'],
53126
+ plugins: ['advlist autolink lists link image charmap print preview anchor textcolor searchreplace visualblocks code fullscreen insertdatetime media table media code lists colorpicker imagetools tabfocus textcolor'],
53120
53127
  }
53121
53128
  };
53122
53129
  if (mode == 'full') {
53123
53130
  config.plugins = [
53124
- 'fullpage advlist autolink lists link image charmap print preview anchor textcolor searchreplace visualblocks code fullscreen insertdatetime media table media code lists colorpicker imagetools tabfocus editFileNew addNews'
53131
+ 'advlist autolink lists link image charmap print preview anchor textcolor searchreplace visualblocks code fullscreen insertdatetime media table media code lists colorpicker imagetools tabfocus editFileNew addNews'
53125
53132
  ];
53126
53133
  config.toolbar = 'formatselect | bold italic Strikethrough forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table link editFileNew addNews | print removeformat undo redo | fullscreen ';
53127
53134
  config.mobile.toolbar = 'bold italic Strikethrough forecolor backcolor | bullist numlist | fullscreen';
53128
- return config;
53135
+ // return config;
53129
53136
  }
53130
53137
  else if (mode == 'medium') {
53131
- config.plugins = ['fullpage advlist autolink lists link image charmap print preview anchor textcolor searchreplace visualblocks code fullscreen insertdatetime media table media code lists colorpicker imagetools tabfocus textcolor'];
53138
+ config.plugins = ['advlist autolink lists link image charmap print preview anchor textcolor searchreplace visualblocks code fullscreen insertdatetime media table media code lists colorpicker imagetools tabfocus textcolor'];
53132
53139
  config.toolbar = 'formatselect | bold italic Strikethrough forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table link | print removeformat undo redo | fullscreen';
53133
53140
  config.mobile.toolbar = 'bold italic Strikethrough forecolor backcolor | bullist numlist | fullscreen';
53134
- return config;
53141
+ // return config;
53135
53142
  }
53136
53143
  else if (mode == 'simple') {
53137
- config.plugins = ['fullpage advlist autolink lists link image charmap print preview anchor textcolor searchreplace visualblocks code fullscreen insertdatetime media table media code lists colorpicker imagetools tabfocus textcolor'];
53144
+ config.plugins = ['advlist autolink lists link image charmap print preview anchor textcolor searchreplace visualblocks code fullscreen insertdatetime media table media code lists colorpicker imagetools tabfocus textcolor'];
53138
53145
  config.toolbar = 'bold italic Strikethrough forecolor backcolor | bullist numlist | fullscreen';
53139
53146
  config.mobile.toolbar = 'fullscreen | bold italic Strikethrough forecolor backcolor | bullist numlist';
53140
- return config;
53147
+ // return config;
53141
53148
  }
53142
53149
  else {
53143
- config.plugins = ['fullpage advlist autolink lists link image charmap print preview anchor textcolor searchreplace visualblocks code fullscreen insertdatetime media table media code lists colorpicker imagetools tabfocus textcolor'];
53150
+ config.plugins = ['advlist autolink lists link image charmap print preview anchor textcolor searchreplace visualblocks code fullscreen insertdatetime media table media code lists colorpicker imagetools tabfocus textcolor'];
53144
53151
  // config.toolbar = 'formatselect | bold italic Strikethrough forecolor backcolor| alignleft aligncenter alignright alignjustify | bullist numlist';
53145
53152
  config.toolbar = 'bold italic Strikethrough forecolor backcolor | bullist numlist | fullscreen';
53146
53153
  }
53154
+ if ($this.control.isFullPage && !config.some(function (x) { return x == 'fullpage'; })) {
53155
+ config.plugins.push(' fullpage');
53156
+ }
53147
53157
  config.paste_data_images = true;
53148
53158
  return config;
53149
53159
  };