src/app/user/user.component.ts
| encapsulation | ViewEncapsulation.None |
| host | { |
| selector | app-user |
| styleUrls | ./user.component.scss |
| templateUrl | ./user.component.html |
Properties |
|
Methods |
|
constructor(helperService: HelperService, sasService: SasService, route: ActivatedRoute, location: Location, router: Router)
|
||||||||||||||||||
|
Defined in src/app/user/user.component.ts:41
|
||||||||||||||||||
|
Parameters :
|
| Public getRoleURI | ||||||
getRoleURI(role: any)
|
||||||
|
Defined in src/app/user/user.component.ts:285
|
||||||
|
Parameters :
Returns :
any
|
| ngOnInit |
ngOnInit()
|
|
Defined in src/app/user/user.component.ts:58
|
|
Returns :
void
|
| Public userListOnFilter |
userListOnFilter()
|
|
Defined in src/app/user/user.component.ts:190
|
|
Returns :
void
|
| Public userOnClick | ||||||
userOnClick(user: any)
|
||||||
|
Defined in src/app/user/user.component.ts:195
|
||||||
|
Parameters :
Returns :
void
|
| Public isViya |
Type : boolean
|
Default value : false
|
|
Defined in src/app/user/user.component.ts:38
|
| Public loading |
Type : boolean
|
Default value : false
|
|
Defined in src/app/user/user.component.ts:23
|
| Public paramName |
Type : string
|
Default value : ''
|
|
Defined in src/app/user/user.component.ts:36
|
| Public paramPresent |
Type : boolean
|
Default value : false
|
|
Defined in src/app/user/user.component.ts:35
|
| Public route |
Type : ActivatedRoute
|
|
Defined in src/app/user/user.component.ts:46
|
| Public router |
Type : Router
|
|
Defined in src/app/user/user.component.ts:48
|
| Public sasjsConfig |
Type : SASjsConfig
|
Default value : new SASjsConfig()
|
|
Defined in src/app/user/user.component.ts:37
|
| Public serverType |
Type : string
|
Default value : ''
|
|
Defined in src/app/user/user.component.ts:39
|
| ServerType |
Type : unknown
|
Default value : ServerType
|
|
Defined in src/app/user/user.component.ts:41
|
| Public userData |
Type : Array<any> | undefined
|
|
Defined in src/app/user/user.component.ts:25
|
| Public userEmails |
Type : Array<any> | undefined
|
|
Defined in src/app/user/user.component.ts:27
|
| Public userEmailsCount |
Type : number | undefined
|
|
Defined in src/app/user/user.component.ts:28
|
| Public userGroups |
Type : Array<any> | undefined
|
|
Defined in src/app/user/user.component.ts:29
|
| Public userGroupsCount |
Type : number | undefined
|
|
Defined in src/app/user/user.component.ts:30
|
| Public userInfo |
Type : any | undefined
|
|
Defined in src/app/user/user.component.ts:26
|
| Public userLogins |
Type : Array<any> | undefined
|
|
Defined in src/app/user/user.component.ts:33
|
| Public userLoginsCount |
Type : number | undefined
|
|
Defined in src/app/user/user.component.ts:34
|
| Public userRoles |
Type : Array<any> | undefined
|
|
Defined in src/app/user/user.component.ts:31
|
| Public userRolesCount |
Type : number | undefined
|
|
Defined in src/app/user/user.component.ts:32
|
| Public users |
Type : Array<any> | undefined
|
|
Defined in src/app/user/user.component.ts:22
|
| Public userSearch |
Type : string
|
Default value : ''
|
|
Defined in src/app/user/user.component.ts:24
|
import { Component, OnInit, ViewEncapsulation } from '@angular/core'
import { globals } from '../_globals'
import { HelperService } from '../services/helper.service'
import { Router, ActivatedRoute } from '@angular/router'
import { Location } from '@angular/common'
import { SasService } from '../services/sas.service'
import { SASjsConfig } from '@sasjs/adapter'
import { ServerType } from '@sasjs/utils/types/serverType'
import { RequestWrapperResponse } from '../models/request-wrapper/RequestWrapperResponse'
@Component({
selector: 'app-user',
templateUrl: './user.component.html',
styleUrls: ['./user.component.scss'],
host: {
class: 'content-container'
},
encapsulation: ViewEncapsulation.None,
standalone: false
})
export class UserComponent implements OnInit {
public users: Array<any> | undefined
public loading: boolean = false
public userSearch: string = ''
public userData: Array<any> | undefined
public userInfo: any | undefined
public userEmails: Array<any> | undefined
public userEmailsCount: number | undefined
public userGroups: Array<any> | undefined
public userGroupsCount: number | undefined
public userRoles: Array<any> | undefined
public userRolesCount: number | undefined
public userLogins: Array<any> | undefined
public userLoginsCount: number | undefined
public paramPresent: boolean = false
public paramName: string = ''
public sasjsConfig: SASjsConfig = new SASjsConfig()
public isViya: boolean = false
public serverType: string = ''
ServerType = ServerType
constructor(
private helperService: HelperService,
private sasService: SasService,
public route: ActivatedRoute,
private location: Location,
public router: Router
) {
this.serverType = this.sasService.getServerType()
this.sasjsConfig = this.sasService.getSasjsConfig()
if (this.sasjsConfig.serverType === 'SASVIYA') {
this.isViya = true
}
}
ngOnInit() {
globals.viewer.currentSelection = 'view/usernav/users'
if (this.route.snapshot.params['uri'] !== undefined) {
this.paramPresent = true
this.paramName = this.route.snapshot.params['uri']
}
if (globals.usernav.userList && !this.paramPresent) {
this.users = globals.usernav.userList
this.userSearch = globals.usernav.userSearch
} else {
if (globals.usernav.userList === undefined) {
this.loading = true
if (this.isViya) {
fetch(this.sasjsConfig.serverUrl + '/identities/users?limit=2000', {
headers: {
Accept: 'application/json'
}
})
.then((res: any) => {
return res.text()
})
.then((res: any) => {
let jsonRes = JSON.parse(res)
let users = jsonRes.items.map((user: any) => {
return {
NAME: user.name,
URI: user.id,
PROVIDER: user.providerId
}
})
this.loading = false
this.users = users
globals.usernav.userList = users
})
} else {
this.sasService
.request('usernav/usermembers', null)
.then((res: RequestWrapperResponse) => {
this.loading = false
this.users = res.adapterResponse.users
globals.usernav.userList = res.adapterResponse.users
})
}
} else {
this.users = globals.usernav.userList
this.userSearch = globals.usernav.userSearch
}
if (this.paramPresent) {
this.loading = true
if (this.isViya) {
let uri = this.route.snapshot.params['uri']
fetch(
this.sasjsConfig.serverUrl +
'/identities/users/' +
uri +
'/memberships?limit=2000',
{
headers: {
Accept: 'application/json'
}
}
)
.then((res: any) => {
return res.text()
})
.then((res: any) => {
let jsonRes = JSON.parse(res)
this.userData = jsonRes
this.loading = false
let groups = jsonRes.items.map((group: any) => {
return {
GROUPNAME: group.name,
URI: group.id
}
})
this.userGroups = groups
this.userGroupsCount = groups.length
if (this.users) {
this.userInfo = this.users.find((userAr) => userAr.URI === uri)
}
})
} else {
const uri = this.route.snapshot.params['uri']
let data = { iwant: [{ uri }] }
this.sasService
.request('usernav/usergroupsbymember', data)
.then((res: RequestWrapperResponse) => {
this.loading = false
switch (this.serverType) {
case ServerType.Sas9: {
this.userInfo = res.adapterResponse.info[0]
this.userEmails = res.adapterResponse.emails
this.userEmailsCount = res.adapterResponse.emails.length
this.userRoles = res.adapterResponse.roles
this.userRolesCount = res.adapterResponse.roles.length
this.userLogins = res.adapterResponse.logins
this.userLoginsCount = res.adapterResponse.logins.length
break
}
case ServerType.Sasjs: {
if (this.users) {
this.userInfo = this.users.find(
(userAr) => userAr.URI === uri
)
} else {
const group = res.adapterResponse.groups[0]
this.userInfo = {
URI: group.ID,
NAME: group.NAME,
DISPLAYNAME: group.NAME
}
}
break
}
}
this.userData = res.adapterResponse
this.userGroups = res.adapterResponse.groups
this.userGroupsCount = res.adapterResponse.groups.length
})
}
}
}
}
public userListOnFilter() {
this.helperService.libraryOnFilter(this.users, this.userSearch, 'NAME')
globals.usernav.userSearch = this.userSearch
}
public userOnClick(user: any) {
this.loading = true
let url = this.router.url
if (this.paramPresent) {
this.location.replaceState(
url.slice(0, url.lastIndexOf('/')) + '/' + encodeURI(user.URI)
)
} else {
this.location.replaceState(url + '/' + encodeURI(user.URI))
}
if (this.isViya) {
fetch(
this.sasjsConfig.serverUrl +
'/identities/users/' +
user.URI +
'/memberships?limit=2000',
{
headers: {
Accept: 'application/json'
}
}
)
.then((res: any) => {
return res.text()
})
.then((res: any) => {
let jsonRes = JSON.parse(res)
this.userData = jsonRes
this.loading = false
let groups = jsonRes.items.map((group: any) => {
return {
GROUPNAME: group.name,
URI: group.id
}
})
this.userGroups = groups
this.userGroupsCount = groups.length
if (this.users) {
this.userInfo = this.users.find((userAr) => userAr.URI === user.URI)
}
})
} else {
let data = { iwant: [{ uri: user.URI }] }
this.sasService
.request('usernav/usergroupsbymember', data)
.then((res: RequestWrapperResponse) => {
this.loading = false
switch (this.serverType) {
case ServerType.Sas9: {
this.userInfo = res.adapterResponse.info[0]
this.userEmails = res.adapterResponse.emails
this.userEmailsCount = res.adapterResponse.emails.length
this.userRoles = res.adapterResponse.roles
this.userRolesCount = res.adapterResponse.roles.length
this.userLogins = res.adapterResponse.logins
this.userLoginsCount = res.adapterResponse.logins.length
break
}
case ServerType.Sasjs: {
if (this.users) {
this.userInfo = this.users.find(
(userAr) => userAr.URI === user.URI
)
} else {
const group = res.adapterResponse.groups[0]
this.userInfo = {
URI: group.ID,
NAME: group.NAME,
DISPLAYNAME: group.NAME
}
}
break
}
}
this.userData = res.adapterResponse
this.userGroups = res.adapterResponse.groups
this.userGroupsCount = res.adapterResponse.groups.length
})
}
}
public getRoleURI(role: any) {
return role.split('OMSOBJ:IdentityGroup')[1].slice(1)
}
}
<app-sidebar class="sidebar-height">
<clr-tree>
@if (users) {
<clr-tree-node class="search-node">
<div class="tree-search-wrapper">
<input
appStealFocus
clrInput
#searchLibTreeInput
placeholder="Filter by Users"
name="input"
[(ngModel)]="userSearch"
(keyup)="userListOnFilter()"
autocomplete="off"
/>
@if (searchLibTreeInput.value.length < 1) {
<clr-icon shape="search"></clr-icon>
}
@if (searchLibTreeInput.value.length > 0) {
<clr-icon
(click)="userSearch = ''; userListOnFilter()"
shape="times"
></clr-icon>
}
</div>
</clr-tree-node>
}
@for (user of users; track user) {
@if (!user['hidden']) {
<clr-tree-node
(click)="userOnClick(user)"
[class.active]="userInfo?.URI === user.URI"
>
<p class="m-0 cursor-pointer list-padding">
<clr-icon shape="user"></clr-icon>
{{ user.NAME }}
</p>
</clr-tree-node>
}
}
</clr-tree>
</app-sidebar>
<div class="content-area">
@if (loading) {
<div class="loadingSpinner">
<span class="spinner"> Loading... </span>
</div>
}
@if (userData && !loading) {
<div>
@if (serverType !== ServerType.SasViya) {
<div class="clr-row">
<div class="clr-col-8">
<table class="table user-info">
<tbody>
<tr>
<td class="left">
<p class="user-info-text">
<b>{{ userInfo.NAME }}</b>
</p>
</td>
</tr>
<tr>
<td class="left">
<p class="user-info-text">
<b>{{ userInfo.DISPLAYNAME }}</b>
</p>
</td>
</tr>
@if (serverType === ServerType.Sas9) {
<tr>
<td class="left">
Metadata Created: <b>{{ userInfo.METADATACREATED }}</b>
</td>
</tr>
<tr>
<td class="left">
Metadata Updated: <b>{{ userInfo.METADATAUPDATED }}</b>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
@if (serverType === ServerType.SasViya && userInfo) {
<div class="clr-row">
<div class="clr-col-8">
<table class="table user-info">
<tbody>
<tr>
<td class="left">
<p class="user-info-text">
<b>{{ userInfo.NAME }}</b>
</p>
</td>
</tr>
<tr>
<td class="left">
User ID: <b>{{ userInfo.URI }}</b>
</td>
</tr>
<tr>
<td class="left">
User provider ID: <b>{{ userInfo.PROVIDER }}</b>
</td>
</tr>
</tbody>
</table>
</div>
</div>
}
<div class="clr-row">
<div class="clr-col-8">
<div class="card user-data">
@if (serverType === ServerType.Sas9) {
<div>
<h3>EMAILS ({{ userEmailsCount || '0' }})</h3>
@if (userEmailsCount == 0) {
<h5>No Emails Present</h5>
}
<div class="table-container">
@if (userEmailsCount != 0) {
<table class="table user-table">
<thead>
<tr>
<td class="width-50"><b>EMAIL</b></td>
<td class=""><b>TYPE</b></td>
</tr>
</thead>
<tbody>
@for (email of userEmails; track email) {
<tr>
<td class="">{{ email.EMAIL }}</td>
<td class="">{{ email.TYPE }}</td>
</tr>
}
</tbody>
</table>
}
</div>
</div>
}
@if (serverType === ServerType.Sas9) {
<hr />
}
<div>
<h3>GROUPS ({{ userGroupsCount || '0' }})</h3>
@if (userGroupsCount == 0) {
<h5>No Groups Present</h5>
}
<div class="table-container">
@if (userGroupsCount != 0) {
<table class="table user-table">
<tbody>
@for (group of userGroups; track group) {
<tr>
@if (serverType === ServerType.SasViya) {
<td
[routerLink]="'/view/usernav/groups/' + group.URI"
routerLinkActive="active"
class=""
>
{{ group.GROUPNAME }}
</td>
}
@if (serverType !== ServerType.SasViya) {
<td
[routerLink]="
'/view/usernav/groups/' +
(group.GROUPURI || group.URI)
"
routerLinkActive="active"
class=""
>
{{ group.GROUPNAME }}
</td>
}
</tr>
}
</tbody>
</table>
}
</div>
</div>
@if (serverType === ServerType.Sas9) {
<hr />
}
@if (serverType === ServerType.Sas9) {
<div>
<h3>ROLES ({{ userRolesCount || '0' }})</h3>
@if (userRolesCount == 0) {
<h5>No Roles Present</h5>
}
<div class="table-container">
@if (userRolesCount != 0) {
<table class="table user-table">
<tbody>
@for (role of userRoles; track role) {
<tr>
<td
[routerLink]="
'/view/usernav/roles/' +
getRoleURI(role.ROLEURI)
"
>
{{ role.ROLENAME }}
</td>
</tr>
}
</tbody>
</table>
}
</div>
</div>
}
@if (serverType === ServerType.Sas9) {
<hr />
}
@if (serverType === ServerType.Sas9) {
<div>
<h3>LOGINS ({{ userLoginsCount || '0' }})</h3>
@if (userLoginsCount == 0) {
<h5>No Logins Present</h5>
}
<div class="table-container">
@if (userLoginsCount != 0) {
<table class="table user-table">
<thead>
<tr>
<td class="width-50"><b>DOMAIN</b></td>
<td><b>USER ID</b></td>
</tr>
</thead>
<tbody>
@for (login of userLogins; track login) {
<tr>
<td class="">{{ login.DOMAIN }}</td>
<td class="">{{ login.USERID }}</td>
</tr>
}
</tbody>
</table>
}
</div>
</div>
}
<br />
</div>
</div>
</div>
</div>
}
</div>
./user.component.scss