@huntsman-cancer-institute/user 16.0.0 → 17.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,418 +7,418 @@ import { HttpHeaders } from '@angular/common/http';
7
7
  import { of, throwError } from 'rxjs';
8
8
  import { map, catchError } from 'rxjs/operators';
9
9
 
10
- /**
11
- * An immutable representation of an HCI user entity.
12
- *
13
- * @since 1.0.0
14
- */
15
- class UserEntity {
16
- constructor(id, username, roles, firstname, lastname, href) {
17
- this.id = id;
18
- this.username = username;
19
- this.roles = roles;
20
- this.firstname = firstname;
21
- this.lastname = lastname;
22
- this.href = href;
23
- }
24
- /**
25
- * An accessor for the users system id.
26
- *
27
- * @returns {string} the system id
28
- * @constructor
29
- */
30
- get Id() {
31
- return this.id;
32
- }
33
- /**
34
- * An accessor for the users application identifier/username.
35
- *
36
- * @returns {string} the application id/username
37
- * @constructor
38
- */
39
- get Username() {
40
- return this.username;
41
- }
42
- /**
43
- * An accessor for the users assigned role authorization claims.
44
- *
45
- * @returns {@code RoleEntity[]} the role authorization claims
46
- * @constructor
47
- */
48
- get Roles() {
49
- return this.roles;
50
- }
51
- /**
52
- * An accessor for the users firstname.
53
- *
54
- * @return {string} the firstname
55
- * @constructor
56
- */
57
- get Firstname() {
58
- return this.firstname;
59
- }
60
- /**
61
- * A accessor for the users lastname.
62
- *
63
- * @return {string} the lastname
64
- * @constructor
65
- */
66
- get Lastname() {
67
- return this.lastname;
68
- }
69
- /**
70
- * A access for the users fully qualified href location on the system.
71
- *
72
- * @return {string} the href location
73
- * @constructor
74
- */
75
- get Href() {
76
- return this.href;
77
- }
10
+ /**
11
+ * An immutable representation of an HCI user entity.
12
+ *
13
+ * @since 1.0.0
14
+ */
15
+ class UserEntity {
16
+ constructor(id, username, roles, firstname, lastname, href) {
17
+ this.id = id;
18
+ this.username = username;
19
+ this.roles = roles;
20
+ this.firstname = firstname;
21
+ this.lastname = lastname;
22
+ this.href = href;
23
+ }
24
+ /**
25
+ * An accessor for the users system id.
26
+ *
27
+ * @returns {string} the system id
28
+ * @constructor
29
+ */
30
+ get Id() {
31
+ return this.id;
32
+ }
33
+ /**
34
+ * An accessor for the users application identifier/username.
35
+ *
36
+ * @returns {string} the application id/username
37
+ * @constructor
38
+ */
39
+ get Username() {
40
+ return this.username;
41
+ }
42
+ /**
43
+ * An accessor for the users assigned role authorization claims.
44
+ *
45
+ * @returns {@code RoleEntity[]} the role authorization claims
46
+ * @constructor
47
+ */
48
+ get Roles() {
49
+ return this.roles;
50
+ }
51
+ /**
52
+ * An accessor for the users firstname.
53
+ *
54
+ * @return {string} the firstname
55
+ * @constructor
56
+ */
57
+ get Firstname() {
58
+ return this.firstname;
59
+ }
60
+ /**
61
+ * A accessor for the users lastname.
62
+ *
63
+ * @return {string} the lastname
64
+ * @constructor
65
+ */
66
+ get Lastname() {
67
+ return this.lastname;
68
+ }
69
+ /**
70
+ * A access for the users fully qualified href location on the system.
71
+ *
72
+ * @return {string} the href location
73
+ * @constructor
74
+ */
75
+ get Href() {
76
+ return this.href;
77
+ }
78
78
  }
79
79
 
80
- /**
81
- * An immutable representation of an HCI role entity, which represents an authorization claim associated with an authenticated
82
- * subject.
83
- *
84
- * @since 1.0.0
85
- */
86
- class RoleEntity {
87
- constructor(roleName, permissions) {
88
- this.roleName = roleName;
89
- this.permissions = permissions;
90
- }
91
- /**
92
- * An accessor for the name of this role.
93
- *
94
- * @returns {string} the role name
95
- * @constructor
96
- */
97
- get RoleName() {
98
- return this.roleName;
99
- }
100
- /**
101
- * An accessor for a collection of {@link PermissionEntity} authorization claims that define this role. Permissions
102
- * provide a finer grained authorization claim description and are not required.
103
- *
104
- * @returns {PermissionEntity[]} a collection of permission entities
105
- * @constructor
106
- */
107
- get Permissions() {
108
- return this.permissions;
109
- }
80
+ /**
81
+ * An immutable representation of an HCI role entity, which represents an authorization claim associated with an authenticated
82
+ * subject.
83
+ *
84
+ * @since 1.0.0
85
+ */
86
+ class RoleEntity {
87
+ constructor(roleName, permissions) {
88
+ this.roleName = roleName;
89
+ this.permissions = permissions;
90
+ }
91
+ /**
92
+ * An accessor for the name of this role.
93
+ *
94
+ * @returns {string} the role name
95
+ * @constructor
96
+ */
97
+ get RoleName() {
98
+ return this.roleName;
99
+ }
100
+ /**
101
+ * An accessor for a collection of {@link PermissionEntity} authorization claims that define this role. Permissions
102
+ * provide a finer grained authorization claim description and are not required.
103
+ *
104
+ * @returns {PermissionEntity[]} a collection of permission entities
105
+ * @constructor
106
+ */
107
+ get Permissions() {
108
+ return this.permissions;
109
+ }
110
110
  }
111
111
 
112
- /*
113
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
114
- */
115
- /**
116
- * An immutable representation of an HCI permission entity, which represents a fine grained authorization claim that can
117
- * define a {@link RoleEntity}.
118
- *
119
- * @since 1.0.0
120
- */
121
- class PermissionEntity {
122
- constructor(domain, actions, instances) {
123
- this.domain = domain;
124
- this.actions = actions;
125
- this.instances = instances;
126
- }
127
- /**
128
- * An accessor for the domain this permission is defined for (i.e. user, study, specimen, etc...).
129
- *
130
- * @returns {string} the domain of this permission
131
- * @constructor
132
- */
133
- get Domain() {
134
- return this.domain;
135
- }
136
- /**
137
- * An accessor for the actions that this permission allows in the specified domain (i.e. create, read, activate, manage
138
- * etc...). If no actions are defined, this permission claims access to all actions of the specified domain.
139
- *
140
- * @returns {string[]} an array of actions for the specified domain
141
- * @constructor
142
- */
143
- get Actions() {
144
- return this.actions;
145
- }
146
- /**
147
- * An accessor for the instances that this permission is applicable to in the specified domain (i.e. joe, 1234, study-foo,
148
- * etc...). If no instances are defined, this permission claims applicability to all instances of the specified domain.
149
- * @returns {string[]}
150
- * @constructor
151
- */
152
- get Instances() {
153
- return this.instances;
154
- }
112
+ /*
113
+ * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
114
+ */
115
+ /**
116
+ * An immutable representation of an HCI permission entity, which represents a fine grained authorization claim that can
117
+ * define a {@link RoleEntity}.
118
+ *
119
+ * @since 1.0.0
120
+ */
121
+ class PermissionEntity {
122
+ constructor(domain, actions, instances) {
123
+ this.domain = domain;
124
+ this.actions = actions;
125
+ this.instances = instances;
126
+ }
127
+ /**
128
+ * An accessor for the domain this permission is defined for (i.e. user, study, specimen, etc...).
129
+ *
130
+ * @returns {string} the domain of this permission
131
+ * @constructor
132
+ */
133
+ get Domain() {
134
+ return this.domain;
135
+ }
136
+ /**
137
+ * An accessor for the actions that this permission allows in the specified domain (i.e. create, read, activate, manage
138
+ * etc...). If no actions are defined, this permission claims access to all actions of the specified domain.
139
+ *
140
+ * @returns {string[]} an array of actions for the specified domain
141
+ * @constructor
142
+ */
143
+ get Actions() {
144
+ return this.actions;
145
+ }
146
+ /**
147
+ * An accessor for the instances that this permission is applicable to in the specified domain (i.e. joe, 1234, study-foo,
148
+ * etc...). If no instances are defined, this permission claims applicability to all instances of the specified domain.
149
+ * @returns {string[]}
150
+ * @constructor
151
+ */
152
+ get Instances() {
153
+ return this.instances;
154
+ }
155
155
  }
156
156
 
157
- /*
158
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
159
- */
160
- let AUTHENTICATED_USER_ENDPOINT = new InjectionToken("authenticated_user_url");
161
- /**
162
- * @since 1.0.0
163
- */
164
- class UserService {
165
- /**
166
- * The generic error message used when a server error is thrown without a status.
167
- *
168
- * @type {string}
169
- */
170
- static { this.GENERIC_ERR_MSG = "Server error"; }
171
- constructor(_http, _authenticationUserEndpoint) {
172
- this._http = _http;
173
- this._authenticationUserEndpoint = _authenticationUserEndpoint;
174
- this._authenticatedUser = null;
175
- }
176
- /**
177
- * An accessor for an {@code Observable<UserEntity>} reflecting the currently authenticated user. If no subject is
178
- * available, the appropriate response status should be returned from the server to indicate that condition
179
- * (i.e. 404 - Not Found).
180
- *
181
- * @returns {Observable<UserEntity>} the currently authenticated user representation
182
- */
183
- getAuthenticatedUser() {
184
- if (isDevMode() && console && console.debug) {
185
- console.debug("getAuthenticatedUser");
186
- }
187
- if (!this._authenticatedUser) {
188
- if (isDevMode() && console && console.debug) {
189
- console.debug("_authenticationUserEndpoint: " + this._authenticationUserEndpoint);
190
- }
191
- return this._http.get(this._authenticationUserEndpoint, { observe: "response" }).pipe(map((resp) => {
192
- if (resp.status === 200) {
193
- this._authenticatedUser = this.buildUserEntity(resp.body);
194
- return this._authenticatedUser;
195
- }
196
- else {
197
- throw new Error("Get authenticated user failed. " + resp.status + ": " + resp.statusText);
198
- }
199
- }), catchError(this.handleError));
200
- }
201
- else {
202
- return of(this._authenticatedUser);
203
- }
204
- }
205
- handleError(error) {
206
- let errMsg = (error.message) ? error.message : UserService.GENERIC_ERR_MSG;
207
- return throwError(() => new Error(errMsg));
208
- }
209
- /**
210
- * TODO: Add in a deserializer into the entity.
211
- *
212
- * @param userJson
213
- * @returns {UserEntity}
214
- */
215
- buildUserEntity(userJson) {
216
- let roles = [];
217
- if (userJson.roles) {
218
- userJson.roles.map((role) => {
219
- let permissions;
220
- if (role.permissions) {
221
- /* TODO: JEH (10/27/16) - Revisit when we determine how permission are communicated to the client, if necessary */
222
- permissions = role.permissions.map((permission) => {
223
- return new PermissionEntity(permission.domain, permission.actions, permission.instances);
224
- });
225
- }
226
- roles.push(new RoleEntity(role.roleName, permissions));
227
- });
228
- }
229
- return new UserEntity(userJson.idUser, userJson.username, roles, userJson.firstname, userJson.lastname, userJson.href);
230
- }
231
- getPermissions(governorClass, governorId, governedClass) {
232
- let headers = new HttpHeaders()
233
- .set("SecurityGovernorClass", governorClass).set("SecurityGovernorId", String(governorId));
234
- return this._http.get("/core/api/user/permissions/" + governedClass, { headers: headers });
235
- }
236
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: UserService, deps: [{ token: i1.HttpClient }, { token: AUTHENTICATED_USER_ENDPOINT }], target: i0.ɵɵFactoryTarget.Injectable }); }
237
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: UserService }); }
238
- }
239
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: UserService, decorators: [{
240
- type: Injectable
241
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
242
- type: Inject,
243
- args: [AUTHENTICATED_USER_ENDPOINT]
244
- }] }]; } });
157
+ /*
158
+ * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
159
+ */
160
+ let AUTHENTICATED_USER_ENDPOINT = new InjectionToken("authenticated_user_url");
161
+ /**
162
+ * @since 1.0.0
163
+ */
164
+ class UserService {
165
+ /**
166
+ * The generic error message used when a server error is thrown without a status.
167
+ *
168
+ * @type {string}
169
+ */
170
+ static { this.GENERIC_ERR_MSG = "Server error"; }
171
+ constructor(_http, _authenticationUserEndpoint) {
172
+ this._http = _http;
173
+ this._authenticationUserEndpoint = _authenticationUserEndpoint;
174
+ this._authenticatedUser = null;
175
+ }
176
+ /**
177
+ * An accessor for an {@code Observable<UserEntity>} reflecting the currently authenticated user. If no subject is
178
+ * available, the appropriate response status should be returned from the server to indicate that condition
179
+ * (i.e. 404 - Not Found).
180
+ *
181
+ * @returns {Observable<UserEntity>} the currently authenticated user representation
182
+ */
183
+ getAuthenticatedUser() {
184
+ if (isDevMode() && console && console.debug) {
185
+ console.debug("getAuthenticatedUser");
186
+ }
187
+ if (!this._authenticatedUser) {
188
+ if (isDevMode() && console && console.debug) {
189
+ console.debug("_authenticationUserEndpoint: " + this._authenticationUserEndpoint);
190
+ }
191
+ return this._http.get(this._authenticationUserEndpoint, { observe: "response" }).pipe(map((resp) => {
192
+ if (resp.status === 200) {
193
+ this._authenticatedUser = this.buildUserEntity(resp.body);
194
+ return this._authenticatedUser;
195
+ }
196
+ else {
197
+ throw new Error("Get authenticated user failed. " + resp.status + ": " + resp.statusText);
198
+ }
199
+ }), catchError(this.handleError));
200
+ }
201
+ else {
202
+ return of(this._authenticatedUser);
203
+ }
204
+ }
205
+ handleError(error) {
206
+ let errMsg = (error.message) ? error.message : UserService.GENERIC_ERR_MSG;
207
+ return throwError(() => new Error(errMsg));
208
+ }
209
+ /**
210
+ * TODO: Add in a deserializer into the entity.
211
+ *
212
+ * @param userJson
213
+ * @returns {UserEntity}
214
+ */
215
+ buildUserEntity(userJson) {
216
+ let roles = [];
217
+ if (userJson.roles) {
218
+ userJson.roles.map((role) => {
219
+ let permissions;
220
+ if (role.permissions) {
221
+ /* TODO: JEH (10/27/16) - Revisit when we determine how permission are communicated to the client, if necessary */
222
+ permissions = role.permissions.map((permission) => {
223
+ return new PermissionEntity(permission.domain, permission.actions, permission.instances);
224
+ });
225
+ }
226
+ roles.push(new RoleEntity(role.roleName, permissions));
227
+ });
228
+ }
229
+ return new UserEntity(userJson.idUser, userJson.username, roles, userJson.firstname, userJson.lastname, userJson.href);
230
+ }
231
+ getPermissions(governorClass, governorId, governedClass) {
232
+ let headers = new HttpHeaders()
233
+ .set("SecurityGovernorClass", governorClass).set("SecurityGovernorId", String(governorId));
234
+ return this._http.get("/core/api/user/permissions/" + governedClass, { headers: headers });
235
+ }
236
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: UserService, deps: [{ token: i1.HttpClient }, { token: AUTHENTICATED_USER_ENDPOINT }], target: i0.ɵɵFactoryTarget.Injectable }); }
237
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: UserService }); }
238
+ }
239
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: UserService, decorators: [{
240
+ type: Injectable
241
+ }], ctorParameters: () => [{ type: i1.HttpClient }, { type: undefined, decorators: [{
242
+ type: Inject,
243
+ args: [AUTHENTICATED_USER_ENDPOINT]
244
+ }] }] });
245
245
 
246
- /*
247
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
248
- */
249
- /**
250
- * A structural directive for adding and removing elements of the client application based on a users <em>role</em>
251
- * authorization claims.
252
- *
253
- * This directive requires the {@link UserService} as a provider.
254
- *
255
- * @since 1.0.0
256
- */
257
- class RoleCheckDirective {
258
- constructor(_viewContainer, _templateRef, _usrSvc) {
259
- this._viewContainer = _viewContainer;
260
- this._templateRef = _templateRef;
261
- this._usrSvc = _usrSvc;
262
- this._lastCheck = null;
263
- }
264
- /**
265
- * Calculates the availability of a decorated element based on the authenticated users available roles.
266
- *
267
- * @param roleName for the role required to make the decorated element available
268
- */
269
- set hciHasRole(roleName) {
270
- if (isDevMode() && console && console.debug) {
271
- console.debug("hciHasRole");
272
- }
273
- this._usrSvc.getAuthenticatedUser().subscribe((authUser) => {
274
- let found;
275
- if (authUser && authUser.Roles) {
276
- found = authUser.Roles.some((role) => {
277
- return role.RoleName === roleName;
278
- });
279
- }
280
- else {
281
- found = false;
282
- }
283
- if (found && (this._lastCheck === null || !this._lastCheck)) {
284
- this._viewContainer.createEmbeddedView(this._templateRef);
285
- }
286
- else if (!found && (this._lastCheck === null || this._lastCheck)) {
287
- this._viewContainer.clear();
288
- }
289
- }, (error) => {
290
- // TODO: BHY (08/19/16) - Determine requirements around errors and then REMOVE CONSOLE LOGGING. Display to user,
291
- // log to external source, gobble?
292
- // Gobble up the error.
293
- });
294
- }
295
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RoleCheckDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: UserService }], target: i0.ɵɵFactoryTarget.Directive }); }
296
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: RoleCheckDirective, selector: "[hciHasRole]", inputs: { hciHasRole: "hciHasRole" }, providers: [UserService], ngImport: i0 }); }
297
- }
298
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RoleCheckDirective, decorators: [{
299
- type: Directive,
300
- args: [{
301
- selector: "[hciHasRole]",
302
- providers: [UserService]
303
- }]
304
- }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: UserService }]; }, propDecorators: { hciHasRole: [{
305
- type: Input
246
+ /*
247
+ * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
248
+ */
249
+ /**
250
+ * A structural directive for adding and removing elements of the client application based on a users <em>role</em>
251
+ * authorization claims.
252
+ *
253
+ * This directive requires the {@link UserService} as a provider.
254
+ *
255
+ * @since 1.0.0
256
+ */
257
+ class RoleCheckDirective {
258
+ constructor(_viewContainer, _templateRef, _usrSvc) {
259
+ this._viewContainer = _viewContainer;
260
+ this._templateRef = _templateRef;
261
+ this._usrSvc = _usrSvc;
262
+ this._lastCheck = null;
263
+ }
264
+ /**
265
+ * Calculates the availability of a decorated element based on the authenticated users available roles.
266
+ *
267
+ * @param roleName for the role required to make the decorated element available
268
+ */
269
+ set hciHasRole(roleName) {
270
+ if (isDevMode() && console && console.debug) {
271
+ console.debug("hciHasRole");
272
+ }
273
+ this._usrSvc.getAuthenticatedUser().subscribe((authUser) => {
274
+ let found;
275
+ if (authUser && authUser.Roles) {
276
+ found = authUser.Roles.some((role) => {
277
+ return role.RoleName === roleName;
278
+ });
279
+ }
280
+ else {
281
+ found = false;
282
+ }
283
+ if (found && (this._lastCheck === null || !this._lastCheck)) {
284
+ this._viewContainer.createEmbeddedView(this._templateRef);
285
+ }
286
+ else if (!found && (this._lastCheck === null || this._lastCheck)) {
287
+ this._viewContainer.clear();
288
+ }
289
+ }, (error) => {
290
+ // TODO: BHY (08/19/16) - Determine requirements around errors and then REMOVE CONSOLE LOGGING. Display to user,
291
+ // log to external source, gobble?
292
+ // Gobble up the error.
293
+ });
294
+ }
295
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: RoleCheckDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: UserService }], target: i0.ɵɵFactoryTarget.Directive }); }
296
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.2", type: RoleCheckDirective, selector: "[hciHasRole]", inputs: { hciHasRole: "hciHasRole" }, providers: [UserService], ngImport: i0 }); }
297
+ }
298
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: RoleCheckDirective, decorators: [{
299
+ type: Directive,
300
+ args: [{
301
+ selector: "[hciHasRole]",
302
+ providers: [UserService]
303
+ }]
304
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: UserService }], propDecorators: { hciHasRole: [{
305
+ type: Input
306
306
  }] } });
307
307
 
308
- /*
309
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
310
- */
311
- /**
312
- * An extension of the {@link RoleCheckDirective} the only evaluates the role if is it not null or undefined.
313
- *
314
- * This directive requires the {@link UserService} as a provider.
315
- *
316
- * @since 1.0.0
317
- */
318
- class RoleCheckUnlessNullDirective extends RoleCheckDirective {
319
- constructor(_viewContainer, _templateRef, _usrSvc) {
320
- super(_viewContainer, _templateRef, _usrSvc);
321
- this._context = new HciHasRoleUnlessNullContext();
322
- }
323
- set hciHasRoleUnlessNull(roleName) {
324
- if (!roleName) {
325
- // if the roleName is undefined or null then render
326
- if (this._context._condition !== true) {
327
- this._context._condition = true;
328
- this._updateView();
329
- }
330
- }
331
- else {
332
- // otherwise delegate the check to RoleCheckDirective
333
- this.hciHasRole = roleName;
334
- }
335
- }
336
- _updateView() {
337
- this._viewContainer.clear();
338
- if (this._context._condition) {
339
- this._viewContainer.createEmbeddedView(this._templateRef, this._context);
340
- }
341
- else {
342
- this._viewContainer.createEmbeddedView(this._templateRef, this._context);
343
- }
344
- }
345
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RoleCheckUnlessNullDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: UserService }], target: i0.ɵɵFactoryTarget.Directive }); }
346
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: RoleCheckUnlessNullDirective, selector: "[hciHasRoleUnlessNull]", inputs: { hciHasRoleUnlessNull: "hciHasRoleUnlessNull" }, usesInheritance: true, ngImport: i0 }); }
347
- }
348
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RoleCheckUnlessNullDirective, decorators: [{
349
- type: Directive,
350
- args: [{
351
- selector: "[hciHasRoleUnlessNull]"
352
- }]
353
- }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: UserService }]; }, propDecorators: { hciHasRoleUnlessNull: [{
354
- type: Input
355
- }] } });
356
- /**
357
- * I totally ripped off *ngIf source to get this to work correctly to prevent infinit loop rendering.
358
- */
359
- class HciHasRoleUnlessNullContext {
360
- constructor() {
361
- this._condition = false;
362
- }
308
+ /*
309
+ * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
310
+ */
311
+ /**
312
+ * An extension of the {@link RoleCheckDirective} the only evaluates the role if is it not null or undefined.
313
+ *
314
+ * This directive requires the {@link UserService} as a provider.
315
+ *
316
+ * @since 1.0.0
317
+ */
318
+ class RoleCheckUnlessNullDirective extends RoleCheckDirective {
319
+ constructor(_viewContainer, _templateRef, _usrSvc) {
320
+ super(_viewContainer, _templateRef, _usrSvc);
321
+ this._context = new HciHasRoleUnlessNullContext();
322
+ }
323
+ set hciHasRoleUnlessNull(roleName) {
324
+ if (!roleName) {
325
+ // if the roleName is undefined or null then render
326
+ if (this._context._condition !== true) {
327
+ this._context._condition = true;
328
+ this._updateView();
329
+ }
330
+ }
331
+ else {
332
+ // otherwise delegate the check to RoleCheckDirective
333
+ this.hciHasRole = roleName;
334
+ }
335
+ }
336
+ _updateView() {
337
+ this._viewContainer.clear();
338
+ if (this._context._condition) {
339
+ this._viewContainer.createEmbeddedView(this._templateRef, this._context);
340
+ }
341
+ else {
342
+ this._viewContainer.createEmbeddedView(this._templateRef, this._context);
343
+ }
344
+ }
345
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: RoleCheckUnlessNullDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: UserService }], target: i0.ɵɵFactoryTarget.Directive }); }
346
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.2", type: RoleCheckUnlessNullDirective, selector: "[hciHasRoleUnlessNull]", inputs: { hciHasRoleUnlessNull: "hciHasRoleUnlessNull" }, usesInheritance: true, ngImport: i0 }); }
347
+ }
348
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: RoleCheckUnlessNullDirective, decorators: [{
349
+ type: Directive,
350
+ args: [{
351
+ selector: "[hciHasRoleUnlessNull]"
352
+ }]
353
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: UserService }], propDecorators: { hciHasRoleUnlessNull: [{
354
+ type: Input
355
+ }] } });
356
+ /**
357
+ * I totally ripped off *ngIf source to get this to work correctly to prevent infinit loop rendering.
358
+ */
359
+ class HciHasRoleUnlessNullContext {
360
+ constructor() {
361
+ this._condition = false;
362
+ }
363
363
  }
364
364
 
365
- /*
366
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
367
- */
368
- /**
369
- * A feature module for user related services, directives, pipes, etc...
370
- *
371
- * @since 1.0.0
372
- */
373
- class UserModule {
374
- static forRoot() {
375
- return {
376
- providers: [
377
- UserService
378
- ],
379
- ngModule: UserModule
380
- };
381
- }
382
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: UserModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
383
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: UserModule, declarations: [RoleCheckDirective,
384
- RoleCheckUnlessNullDirective], imports: [CommonModule,
385
- ReactiveFormsModule,
386
- FormsModule], exports: [RoleCheckDirective,
387
- RoleCheckUnlessNullDirective] }); }
388
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: UserModule, imports: [CommonModule,
389
- ReactiveFormsModule,
390
- FormsModule] }); }
391
- }
392
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: UserModule, decorators: [{
393
- type: NgModule,
394
- args: [{
395
- imports: [
396
- CommonModule,
397
- ReactiveFormsModule,
398
- FormsModule
399
- ],
400
- declarations: [
401
- RoleCheckDirective,
402
- RoleCheckUnlessNullDirective
403
- ],
404
- exports: [
405
- RoleCheckDirective,
406
- RoleCheckUnlessNullDirective
407
- ]
408
- }]
365
+ /*
366
+ * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
367
+ */
368
+ /**
369
+ * A feature module for user related services, directives, pipes, etc...
370
+ *
371
+ * @since 1.0.0
372
+ */
373
+ class UserModule {
374
+ static forRoot() {
375
+ return {
376
+ providers: [
377
+ UserService
378
+ ],
379
+ ngModule: UserModule
380
+ };
381
+ }
382
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: UserModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
383
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.1.2", ngImport: i0, type: UserModule, declarations: [RoleCheckDirective,
384
+ RoleCheckUnlessNullDirective], imports: [CommonModule,
385
+ ReactiveFormsModule,
386
+ FormsModule], exports: [RoleCheckDirective,
387
+ RoleCheckUnlessNullDirective] }); }
388
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: UserModule, imports: [CommonModule,
389
+ ReactiveFormsModule,
390
+ FormsModule] }); }
391
+ }
392
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: UserModule, decorators: [{
393
+ type: NgModule,
394
+ args: [{
395
+ imports: [
396
+ CommonModule,
397
+ ReactiveFormsModule,
398
+ FormsModule
399
+ ],
400
+ declarations: [
401
+ RoleCheckDirective,
402
+ RoleCheckUnlessNullDirective
403
+ ],
404
+ exports: [
405
+ RoleCheckDirective,
406
+ RoleCheckUnlessNullDirective
407
+ ]
408
+ }]
409
409
  }] });
410
410
 
411
- /*
412
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
413
- */
414
- /**
415
- * A barrel file for the HCI ng2 user package.
416
- *
417
- * @since 1.0.0
411
+ /*
412
+ * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
413
+ */
414
+ /**
415
+ * A barrel file for the HCI ng2 user package.
416
+ *
417
+ * @since 1.0.0
418
418
  */
419
419
 
420
- /**
421
- * Generated bundle index. Do not edit.
420
+ /**
421
+ * Generated bundle index. Do not edit.
422
422
  */
423
423
 
424
424
  export { AUTHENTICATED_USER_ENDPOINT, PermissionEntity, RoleCheckDirective, RoleCheckUnlessNullDirective, RoleEntity, UserEntity, UserModule, UserService };