src/app/role/role.component.ts
| encapsulation | ViewEncapsulation.None |
| host | { |
| selector | app-role |
| styleUrls | ./role.component.scss |
| templateUrl | ./role.component.html |
Properties |
|
Methods |
|
constructor(sasService: SasService, helperService: HelperService, router: Router, location: Location, route: ActivatedRoute)
|
||||||||||||||||||
|
Defined in src/app/role/role.component.ts:31
|
||||||||||||||||||
|
Parameters :
|
| Public findRole | |||||||||
findRole(list: Array
|
|||||||||
|
Defined in src/app/role/role.component.ts:151
|
|||||||||
|
Parameters :
Returns :
any
|
| ngOnInit |
ngOnInit()
|
|
Defined in src/app/role/role.component.ts:41
|
|
Returns :
void
|
| Public roleListOnFilter |
roleListOnFilter()
|
|
Defined in src/app/role/role.component.ts:120
|
|
Returns :
void
|
| Public roleOnClick | ||||||
roleOnClick(role: any)
|
||||||
|
Defined in src/app/role/role.component.ts:125
|
||||||
|
Parameters :
Returns :
void
|
| Public loading |
Type : boolean
|
Default value : false
|
|
Defined in src/app/role/role.component.ts:31
|
| Public paramPresent |
Type : boolean
|
Default value : false
|
|
Defined in src/app/role/role.component.ts:29
|
| Public paramURI |
Type : string
|
Default value : ''
|
|
Defined in src/app/role/role.component.ts:30
|
| Public roleDesc |
Type : string
|
Default value : ''
|
|
Defined in src/app/role/role.component.ts:24
|
| Public roleGroups |
Type : Array<any> | undefined
|
|
Defined in src/app/role/role.component.ts:27
|
| Public roleGroupsCount |
Type : number | undefined
|
|
Defined in src/app/role/role.component.ts:28
|
| Public roleMembers |
Type : Array<any> | undefined
|
|
Defined in src/app/role/role.component.ts:25
|
| Public roleMembersCount |
Type : number | undefined
|
|
Defined in src/app/role/role.component.ts:26
|
| Public roleName |
Type : string
|
Default value : ''
|
|
Defined in src/app/role/role.component.ts:23
|
| Public roles |
Type : Array<any> | undefined
|
|
Defined in src/app/role/role.component.ts:20
|
| Public roleSearch |
Type : string
|
Default value : ''
|
|
Defined in src/app/role/role.component.ts:21
|
| Public roleUri |
Type : string
|
Default value : ''
|
|
Defined in src/app/role/role.component.ts:22
|
import { Component, OnInit, ViewEncapsulation } from '@angular/core'
import { globals } from '../_globals'
import { HelperService } from '../services/helper.service'
import { Location } from '@angular/common'
import { Router, ActivatedRoute } from '@angular/router'
import { SasService } from '../services/sas.service'
import { RequestWrapperResponse } from '../models/request-wrapper/RequestWrapperResponse'
@Component({
selector: 'app-role',
templateUrl: './role.component.html',
styleUrls: ['./role.component.scss'],
host: {
class: 'content-container'
},
encapsulation: ViewEncapsulation.None,
standalone: false
})
export class RoleComponent implements OnInit {
public roles: Array<any> | undefined
public roleSearch: string = ''
public roleUri: string = ''
public roleName: string = ''
public roleDesc: string = ''
public roleMembers: Array<any> | undefined
public roleMembersCount: number | undefined
public roleGroups: Array<any> | undefined
public roleGroupsCount: number | undefined
public paramPresent: boolean = false
public paramURI: string = ''
public loading: boolean = false
constructor(
private sasService: SasService,
private helperService: HelperService,
private router: Router,
private location: Location,
private route: ActivatedRoute
) {}
ngOnInit() {
globals.viewer.currentSelection = 'view/usernav/roles'
if (this.route.snapshot.params['uri'] !== undefined) {
this.paramPresent = true
this.paramURI = this.route.snapshot.params['uri']
}
if (globals.usernav.roleList && !this.paramPresent) {
this.roles = globals.usernav.roleList
this.roleSearch = globals.usernav.roleSearch
} else {
if (globals.usernav.roleList === undefined) {
this.loading = true
this.sasService
.request('usernav/userroles', null)
.then((res: RequestWrapperResponse) => {
this.loading = false
this.roles = res.adapterResponse.roles
globals.usernav.roleList = res.adapterResponse.roles
if (this.paramPresent) {
if (this.roles !== undefined) {
let validRole = this.findRole(this.roles, this.paramURI)
if (validRole !== false) {
this.loading = true
let data = { iwant: [{ roleid: this.paramURI }] }
this.sasService
.request('usernav/usermembersbyrole', data)
.then((res: RequestWrapperResponse) => {
this.loading = false
this.roleMembers = res.adapterResponse.sasmembers
this.roleMembersCount =
res.adapterResponse.sasmembers.length
this.roleGroups = res.adapterResponse.sasgroups
this.roleGroupsCount =
res.adapterResponse.sasgroups.length
this.roleUri = validRole.ROLEURI
this.roleName = validRole.ROLENAME
this.roleDesc = validRole.ROLEDESC
})
}
}
}
})
} else {
this.roles = globals.usernav.roleList
this.roleSearch = globals.usernav.roleSearch
this.sasService
.request('usernav/userroles', null)
.then((res: RequestWrapperResponse) => {
this.roles = res.adapterResponse.roles
globals.usernav.roleList = res.adapterResponse.roles
if (this.paramPresent) {
if (this.roles !== undefined) {
let validRole = this.findRole(this.roles, this.paramURI)
if (validRole !== false) {
this.loading = true
let data = { iwant: [{ roleid: this.paramURI }] }
this.sasService
.request('usernav/usermembersbyrole', data)
.then((res: RequestWrapperResponse) => {
this.loading = false
this.roleMembers = res.adapterResponse.sasmembers
this.roleMembersCount =
res.adapterResponse.sasmembers.length
this.roleGroups = res.adapterResponse.sasgroups
this.roleGroupsCount =
res.adapterResponse.sasgroups.length
this.roleUri = validRole.ROLEURI
this.roleName = validRole.ROLENAME
this.roleDesc = validRole.ROLEDESC
})
}
}
}
})
}
}
}
public roleListOnFilter() {
this.helperService.libraryOnFilter(this.roles, this.roleSearch, 'ROLENAME')
globals.usernav.roleSearch = this.roleSearch
}
public roleOnClick(role: any) {
this.loading = true
let url = this.router.url
if (this.paramPresent) {
this.location.replaceState(
url.slice(0, url.lastIndexOf('/')) + '/' + encodeURI(role.ROLEURI)
)
} else {
this.location.replaceState(url + '/' + encodeURI(role.ROLEURI))
}
let data = { iwant: [{ roleid: role.ROLEURI }] }
this.sasService
.request('usernav/usermembersbyrole', data)
.then((res: RequestWrapperResponse) => {
this.loading = false
this.roleMembers = res.adapterResponse.sasmembers
this.roleMembersCount = res.adapterResponse.sasmembers.length
this.roleGroups = res.adapterResponse.sasgroups
this.roleGroupsCount = res.adapterResponse.sasgroups.length
this.roleUri = role.ROLEURI
this.roleName = role.ROLENAME
this.roleDesc = role.ROLEDESC
})
}
public findRole(list: Array<any>, role: any): any {
let result = false
list.forEach((element) => {
if (element.ROLEURI === role) {
result = element
}
})
return result
}
}
<app-sidebar class="sidebar-height">
<clr-tree>
@if (roles) {
<clr-tree-node class="search-node">
<div class="tree-search-wrapper">
<input
appStealFocus
clrInput
#searchLibTreeInput
placeholder="Filter by Roles"
name="input"
[(ngModel)]="roleSearch"
(keyup)="roleListOnFilter()"
autocomplete="off"
/>
@if (searchLibTreeInput.value.length < 1) {
<clr-icon shape="search"></clr-icon>
}
@if (searchLibTreeInput.value.length > 0) {
<clr-icon
(click)="roleSearch = ''; roleListOnFilter()"
shape="times"
></clr-icon>
}
</div>
</clr-tree-node>
}
@for (role of roles; track role) {
@if (!role['hidden']) {
<clr-tree-node
(click)="roleOnClick(role)"
[class.active]="role.ROLEURI === roleUri"
>
<p class="m-0 cursor-pointer list-padding">
<clr-icon shape="blocks-group"></clr-icon>
{{ role.ROLENAME }}
</p>
</clr-tree-node>
}
}
</clr-tree>
</app-sidebar>
<div class="content-area">
@if (loading) {
<div class="loadingSpinner">
<span class="spinner"> Loading... </span>
</div>
}
@if (roleMembers && !loading) {
<div>
<div class="clr-row">
<div class="clr-col-8">
<table class="table role-info">
<tbody>
<tr>
<td class="left">
<p class="role-info-text">
<b>{{ roleName }}</b>
</p>
</td>
</tr>
<tr>
<td class="left">
<i>{{ roleDesc }}</i>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="clr-row">
<div class="clr-col-8">
<div class="card role-data">
<div>
<h3>MEMBERS ({{ roleMembersCount }})</h3>
@if (roleMembersCount == 0) {
<h5>No Members Present</h5>
}
<div class="table-container">
@if (roleMembersCount != 0) {
<table class="table member-table">
<thead>
<tr>
<td class="width-25"><b>NAME</b></td>
<td class="width-25"><b>EMAIL</b></td>
<td class="width-25"><b>CREATED</b></td>
<td class=""><b>UPDATED</b></td>
</tr>
</thead>
<tbody>
@for (member of roleMembers; track member) {
<tr
[routerLink]="'/view/usernav/users/' + member.URIMEM"
>
<td class="">{{ member.MEMBERNAME }}</td>
<td class="">{{ member.EMAIL }}</td>
<td class="">{{ member.MEMBERCREATED }}</td>
<td class="">{{ member.MEMBERUPDATED }}</td>
</tr>
}
</tbody>
</table>
}
</div>
</div>
<hr />
<div>
<h3>Groups ({{ roleGroupsCount }})</h3>
@if (roleGroupsCount == 0) {
<h5>No Groups Present !</h5>
}
<div class="table-container">
@if (roleGroupsCount != 0) {
<table class="table member-table">
<thead>
<tr>
<td class="width-25"><b>NAME</b></td>
<td class="width-25"><b>EMAIL</b></td>
<td class="width-25"><b>CREATED</b></td>
<td class=""><b>UPDATED</b></td>
</tr>
</thead>
<tbody>
@for (group of roleGroups; track group) {
<tr
[routerLink]="'/view/usernav/groups/' + group.URIMEM"
>
<td class="">{{ group.MEMBERNAME }}</td>
<td class="">{{ group.EMAIL }}</td>
<td class="">{{ group.MEMBERCREATED }}</td>
<td class="">{{ group.MEMBERUPDATED }}</td>
</tr>
}
</tbody>
</table>
}
</div>
</div>
<br />
</div>
</div>
</div>
</div>
}
</div>
./role.component.scss
@import '../../colors.scss';
::ng-deep body[cds-theme="dark"] {
.role {
background-color: $headerBackground;
border-color: $headerBackground;
}
.role-data {
background-color: $headerBackground;
border-color: $headerBackground;
}
.member-table tbody{
tr:hover{
background-color: #29404b;
}
}
}
::ng-deep body[cds-theme="light"] {
.role-info{
background-color: #f9f9f9;
border-color: #a7a7a7;
box-shadow: 0px 2px 5px #dad7d7;
}
.role-data {
background-color: #f9f9f9;
border-color: #a7a7a7;
box-shadow: 0px 2px 5px #dad7d7;
}
.member-table tbody{
tr:hover{
background-color: #e6e6e6;
}
}
}
.sidebar-height{
height: 100%;
}
.role-info-text{
display: inline;
font-size: 20px;
}
.role-info{
border: 1px solid;
border-radius: 3px;
}
.role-info td{
text-align: center;
}
.role-data{
border: 1px solid;
border-radius: 3px;
}
.role-data{
min-height: unset;
h3, h5{
text-align: center;
}
}
.member-table{
width: 100%;
}
.member-table tbody{
tr:hover{
cursor: pointer;
}
}
.table-container{
overflow-y: scroll;
max-height: 700px;
}
@media screen and (max-width: 768px){
.role-data{
min-height: unset !important;
}
}