@csmart/ngc-smart-core 0.7.87 → 0.7.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/csmart-ngc-smart-core.umd.js +94 -48
- package/bundles/csmart-ngc-smart-core.umd.js.map +1 -1
- package/bundles/csmart-ngc-smart-core.umd.min.js +1 -1
- package/bundles/csmart-ngc-smart-core.umd.min.js.map +1 -1
- package/csmart-ngc-smart-core.metadata.json +1 -1
- package/esm2015/lib/smart-auth/smart-access-control.directive.js +5 -6
- package/esm2015/lib/smart-auth/smart-auth.service.js +65 -29
- package/esm2015/lib/smart-auth/smart-authorization-guard.service.js +4 -4
- package/esm2015/lib/smart-offender-header/smart-offender-header.component.js +2 -3
- package/esm2015/lib/smart-storage/xdm.service.js +6 -2
- package/esm5/lib/smart-auth/smart-access-control.directive.js +5 -6
- package/esm5/lib/smart-auth/smart-auth.service.js +77 -35
- package/esm5/lib/smart-auth/smart-authorization-guard.service.js +4 -4
- package/esm5/lib/smart-offender-header/smart-offender-header.component.js +2 -3
- package/esm5/lib/smart-storage/xdm.service.js +8 -2
- package/fesm2015/csmart-ngc-smart-core.js +77 -39
- package/fesm2015/csmart-ngc-smart-core.js.map +1 -1
- package/fesm5/csmart-ngc-smart-core.js +92 -46
- package/fesm5/csmart-ngc-smart-core.js.map +1 -1
- package/lib/smart-auth/smart-auth.service.d.ts +1 -1
- package/lib/smart-storage/xdm.service.d.ts +1 -1
- package/package.json +1 -1
|
@@ -6,8 +6,8 @@ import { __spread, __awaiter, __generator } from 'tslib';
|
|
|
6
6
|
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
|
7
7
|
import { MsalService } from '@azure/msal-angular';
|
|
8
8
|
import { Router, ActivatedRoute } from '@angular/router';
|
|
9
|
-
import { Subject, of, from,
|
|
10
|
-
import { InjectionToken, Injectable, Inject, isDevMode,
|
|
9
|
+
import { Subject, of, from, throwError, EMPTY, concat } from 'rxjs';
|
|
10
|
+
import { InjectionToken, Injectable, Inject, isDevMode, Directive, Input, ElementRef, Component, ViewChild, ViewEncapsulation, NgModule, NgZone, defineInjectable, inject } from '@angular/core';
|
|
11
11
|
import { map, switchMap, take, catchError, mergeMap, retryWhen, delay } from 'rxjs/operators';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -160,6 +160,7 @@ var XdmService = /** @class */ (function () {
|
|
|
160
160
|
* Offender
|
|
161
161
|
* ************************************
|
|
162
162
|
* @param {?} selectedOffender
|
|
163
|
+
* @param {?=} redirectFunction
|
|
163
164
|
* @return {?}
|
|
164
165
|
*/
|
|
165
166
|
XdmService.prototype.setSelectedOffender = /**
|
|
@@ -167,10 +168,12 @@ var XdmService = /** @class */ (function () {
|
|
|
167
168
|
* Offender
|
|
168
169
|
* ************************************
|
|
169
170
|
* @param {?} selectedOffender
|
|
171
|
+
* @param {?=} redirectFunction
|
|
170
172
|
* @return {?}
|
|
171
173
|
*/
|
|
172
|
-
function (selectedOffender) {
|
|
174
|
+
function (selectedOffender, redirectFunction) {
|
|
173
175
|
var _this = this;
|
|
176
|
+
if (redirectFunction === void 0) { redirectFunction = null; }
|
|
174
177
|
this.connection.promise.then((/**
|
|
175
178
|
* @param {?} child
|
|
176
179
|
* @return {?}
|
|
@@ -178,6 +181,9 @@ var XdmService = /** @class */ (function () {
|
|
|
178
181
|
function (child) {
|
|
179
182
|
child.setSelectedOffender(selectedOffender);
|
|
180
183
|
_this.offenderSubject.next(selectedOffender);
|
|
184
|
+
if (redirectFunction) {
|
|
185
|
+
redirectFunction();
|
|
186
|
+
}
|
|
181
187
|
}));
|
|
182
188
|
};
|
|
183
189
|
/**
|
|
@@ -561,8 +567,7 @@ var SmartOffenderHeaderComponent = /** @class */ (function () {
|
|
|
561
567
|
// : false,
|
|
562
568
|
// } as SelectedOffender;
|
|
563
569
|
this.selectedOffender = offender;
|
|
564
|
-
this.xdmService.setSelectedOffender(this.selectedOffender);
|
|
565
|
-
this.reloadCurrentRoute();
|
|
570
|
+
this.xdmService.setSelectedOffender(this.selectedOffender, this.reloadCurrentRoute);
|
|
566
571
|
}
|
|
567
572
|
};
|
|
568
573
|
/**
|
|
@@ -1759,10 +1764,10 @@ var SmartAuthService = /** @class */ (function () {
|
|
|
1759
1764
|
* @return {?}
|
|
1760
1765
|
*/
|
|
1761
1766
|
function (p) {
|
|
1762
|
-
return (p.appModuleId === accessControlConfig.appModuleId
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1767
|
+
return (p.appModuleId === accessControlConfig.appModuleId &&
|
|
1768
|
+
p.resource === resource &&
|
|
1769
|
+
(!roleId || p.roleId === roleId) &&
|
|
1770
|
+
p.assignmentStaffRelationId === assignmentStaffRelationId);
|
|
1766
1771
|
}));
|
|
1767
1772
|
if (permission) {
|
|
1768
1773
|
if (accessType === 'read') {
|
|
@@ -1807,35 +1812,38 @@ var SmartAuthService = /** @class */ (function () {
|
|
|
1807
1812
|
*/
|
|
1808
1813
|
function (loginStaff, feature, appModuleId) {
|
|
1809
1814
|
if (appModuleId === void 0) { appModuleId = null; }
|
|
1810
|
-
if (!this.isAuthEnable(loginStaff.roles, appModuleId)) {
|
|
1811
|
-
|
|
1812
|
-
}
|
|
1815
|
+
// if (!this.isAuthEnable(loginStaff.roles, appModuleId)) {
|
|
1816
|
+
// return true;
|
|
1817
|
+
// }
|
|
1813
1818
|
return this.hasAppFeaturePermission(loginStaff.permissions, feature, appModuleId);
|
|
1814
1819
|
};
|
|
1820
|
+
// public isAuthEnable(roles: Role[], appModuleId: string) {
|
|
1821
|
+
// if (roles && roles.length > 0) {
|
|
1822
|
+
// return roles.map(r => r.roleId).findIndex(this.isExternalRole) > -1 || appModuleId === 'RR';
|
|
1823
|
+
// }
|
|
1824
|
+
// return false;
|
|
1825
|
+
// }
|
|
1826
|
+
// public isAuthEnable(roles: Role[], appModuleId: string) {
|
|
1827
|
+
// if (roles && roles.length > 0) {
|
|
1828
|
+
// return roles.map(r => r.roleId).findIndex(this.isExternalRole) > -1 || appModuleId === 'RR';
|
|
1829
|
+
// }
|
|
1830
|
+
// return false;
|
|
1831
|
+
// }
|
|
1815
1832
|
/**
|
|
1816
1833
|
* @param {?} roles
|
|
1817
|
-
* @param {?} appModuleId
|
|
1818
|
-
* @return {?}
|
|
1819
|
-
*/
|
|
1820
|
-
SmartAuthService.prototype.isAuthEnable = /**
|
|
1821
|
-
* @param {?} roles
|
|
1822
|
-
* @param {?} appModuleId
|
|
1823
1834
|
* @return {?}
|
|
1824
1835
|
*/
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1836
|
+
SmartAuthService.prototype.hasIntakeRole =
|
|
1837
|
+
// public isAuthEnable(roles: Role[], appModuleId: string) {
|
|
1838
|
+
// if (roles && roles.length > 0) {
|
|
1839
|
+
// return roles.map(r => r.roleId).findIndex(this.isExternalRole) > -1 || appModuleId === 'RR';
|
|
1840
|
+
// }
|
|
1841
|
+
// return false;
|
|
1842
|
+
// }
|
|
1831
1843
|
/**
|
|
1832
1844
|
* @param {?} roles
|
|
1833
1845
|
* @return {?}
|
|
1834
1846
|
*/
|
|
1835
|
-
SmartAuthService.prototype.hasIntakeRole = /**
|
|
1836
|
-
* @param {?} roles
|
|
1837
|
-
* @return {?}
|
|
1838
|
-
*/
|
|
1839
1847
|
function (roles) {
|
|
1840
1848
|
if (roles && roles.length > 0) {
|
|
1841
1849
|
return roles.findIndex(this.isIntakeRole) > -1;
|
|
@@ -1859,36 +1867,34 @@ var SmartAuthService = /** @class */ (function () {
|
|
|
1859
1867
|
function (permissions, feature, appModuleId) {
|
|
1860
1868
|
if (permissions && permissions.length > 0) {
|
|
1861
1869
|
if (appModuleId) {
|
|
1862
|
-
return permissions.findIndex((/**
|
|
1870
|
+
return (permissions.findIndex((/**
|
|
1863
1871
|
* @param {?} p
|
|
1864
1872
|
* @return {?}
|
|
1865
1873
|
*/
|
|
1866
|
-
function (p) {
|
|
1867
|
-
return p.resource === feature && p.appModuleId === appModuleId;
|
|
1868
|
-
})) > -1;
|
|
1874
|
+
function (p) { return p.resource === feature && p.appModuleId === appModuleId; })) > -1);
|
|
1869
1875
|
}
|
|
1870
1876
|
else {
|
|
1871
|
-
return
|
|
1877
|
+
return permissions.findIndex((/**
|
|
1872
1878
|
* @param {?} p
|
|
1873
1879
|
* @return {?}
|
|
1874
1880
|
*/
|
|
1875
|
-
function (p) { return p.resource === feature; })) > -1
|
|
1881
|
+
function (p) { return p.resource === feature; })) > -1;
|
|
1876
1882
|
}
|
|
1877
1883
|
}
|
|
1878
1884
|
return false;
|
|
1879
1885
|
};
|
|
1880
1886
|
/**
|
|
1881
1887
|
* @private
|
|
1882
|
-
* @param {?}
|
|
1888
|
+
* @param {?} roleId
|
|
1883
1889
|
* @return {?}
|
|
1884
1890
|
*/
|
|
1885
1891
|
SmartAuthService.prototype.isExternalRole = /**
|
|
1886
1892
|
* @private
|
|
1887
|
-
* @param {?}
|
|
1893
|
+
* @param {?} roleId
|
|
1888
1894
|
* @return {?}
|
|
1889
1895
|
*/
|
|
1890
|
-
function (
|
|
1891
|
-
switch (
|
|
1896
|
+
function (roleId) {
|
|
1897
|
+
switch (roleId) {
|
|
1892
1898
|
case 'EUDTL':
|
|
1893
1899
|
case 'EUDUSM':
|
|
1894
1900
|
case 'EUJDG':
|
|
@@ -2045,6 +2051,47 @@ var SmartAuthService = /** @class */ (function () {
|
|
|
2045
2051
|
return null;
|
|
2046
2052
|
})));
|
|
2047
2053
|
};
|
|
2054
|
+
/**
|
|
2055
|
+
* @private
|
|
2056
|
+
* @param {?} appModuleId
|
|
2057
|
+
* @param {?} resource
|
|
2058
|
+
* @return {?}
|
|
2059
|
+
*/
|
|
2060
|
+
SmartAuthService.prototype.getRolePermissions = /**
|
|
2061
|
+
* @private
|
|
2062
|
+
* @param {?} appModuleId
|
|
2063
|
+
* @param {?} resource
|
|
2064
|
+
* @return {?}
|
|
2065
|
+
*/
|
|
2066
|
+
function (appModuleId, resource) {
|
|
2067
|
+
/** @type {?} */
|
|
2068
|
+
var queryString = "\n query findvRolePermissionPivots{\n findvRolePermissionPivots(input: {where: {appModuleId: " + appModuleId + ", resource: " + resource + "}}){\n totalCount\n message\n }\n }";
|
|
2069
|
+
return this.http
|
|
2070
|
+
.post(this.smartDataServiceUrl, { query: queryString })
|
|
2071
|
+
.pipe(take(1), map((/**
|
|
2072
|
+
* @param {?} result
|
|
2073
|
+
* @return {?}
|
|
2074
|
+
*/
|
|
2075
|
+
function (result) {
|
|
2076
|
+
if (isDevMode) {
|
|
2077
|
+
console.log('##### findvRolePermissionPivots() from service ', result);
|
|
2078
|
+
}
|
|
2079
|
+
if (result.data.findvRolePermissionPivots.totalCount > 0) {
|
|
2080
|
+
return true;
|
|
2081
|
+
}
|
|
2082
|
+
else {
|
|
2083
|
+
return false;
|
|
2084
|
+
// return throwError('No access right.');
|
|
2085
|
+
}
|
|
2086
|
+
})), catchError((/**
|
|
2087
|
+
* @param {?} error
|
|
2088
|
+
* @return {?}
|
|
2089
|
+
*/
|
|
2090
|
+
function (error) {
|
|
2091
|
+
console.log('error ' + error);
|
|
2092
|
+
return throwError(error);
|
|
2093
|
+
})));
|
|
2094
|
+
};
|
|
2048
2095
|
SmartAuthService.decorators = [
|
|
2049
2096
|
{ type: Injectable, args: [{
|
|
2050
2097
|
providedIn: 'root',
|
|
@@ -2095,11 +2142,10 @@ var SmartAccessControlDirective = /** @class */ (function () {
|
|
|
2095
2142
|
!this.accessControlConfig.route.data.selectedOffender) {
|
|
2096
2143
|
return;
|
|
2097
2144
|
}
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
}
|
|
2145
|
+
// const loginStaff = this.accessControlConfig.route.data.loginStaff;
|
|
2146
|
+
// if (!this.auth.isAuthEnable(loginStaff.roles, this.accessControlConfig.appModuleId)) {
|
|
2147
|
+
// return;
|
|
2148
|
+
// }
|
|
2103
2149
|
this.elementRef.nativeElement.style.display = this.auth.checkPermission(this.accessControlConfig)
|
|
2104
2150
|
? 'block'
|
|
2105
2151
|
: 'none';
|
|
@@ -2147,9 +2193,9 @@ var SmartAuthorizationGuard = /** @class */ (function () {
|
|
|
2147
2193
|
if (!loginStaff || !route || !route.routeConfig) {
|
|
2148
2194
|
return of(false);
|
|
2149
2195
|
}
|
|
2150
|
-
if (!
|
|
2151
|
-
|
|
2152
|
-
}
|
|
2196
|
+
// if (!this.authnService.isAuthEnable(loginStaff.roles, null)) {
|
|
2197
|
+
// return of(true);
|
|
2198
|
+
// }
|
|
2153
2199
|
/** @type {?} */
|
|
2154
2200
|
var resource = route.routeConfig.path
|
|
2155
2201
|
? route.routeConfig.path.split('/')[0]
|