summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.ts')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.ts103
1 files changed, 103 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.ts
new file mode 100644
index 00000000..c9893bf2
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.component.ts
@@ -0,0 +1,103 @@
+import { Component, OnInit, Directive, Input, Output, EventEmitter, ViewChildren, QueryList, PipeTransform, ViewChild } from '@angular/core';
+import { AdminService } from '../admin.service';
+import {UserService} from '../../../shared/services/user/user.service'
+import { User } from 'src/app/shared/services/user/user';
+import { of, Observable } from 'rxjs';
+import { RoleFunction } from './role-function';
+import { MatTableDataSource } from '@angular/material/table';
+import { MatPaginator } from '@angular/material/paginator';
+import { MatSort } from '@angular/material/sort';
+import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
+import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
+
+@Component({
+ selector: 'app-role-functions',
+ templateUrl: './role-functions.component.html',
+ styleUrls: ['./role-functions.component.scss']
+})
+export class RoleFunctionsComponent implements OnInit {
+
+ tableData: Array<RoleFunction> = [];
+ response: any;
+ result: any;
+ function:RoleFunction;
+
+ isAppCentralized:any;
+ user: User;
+ closeResult: string;
+
+ roleFunctionHeaders = ["name","code","type","action","edit","delete"];
+ dataSource: MatTableDataSource<RoleFunction>;
+
+ constructor(public adminService: AdminService, public userService: UserService,private ngModal: NgbModal) { }
+
+ @ViewChild(MatPaginator, {}) paginator: MatPaginator;
+ @ViewChild(MatSort, {}) sort: MatSort;
+
+ ngOnInit() {
+ this.getRoleFunctions();
+ let result = this.userService.getFunctionalMenuStaticDetailSession();
+ let user;
+ result.subscribe(user => {
+ this.user = user;
+ this.isAppCentralized = this.user.isAppCentralized;
+ });
+ }
+
+ getRoleFunctions(){
+
+ let response;
+ this.response = this.adminService.getRoleFunctionList();
+ this.response.subscribe(data => {
+ response = data;
+ this.result = JSON.parse(response.data);
+ this.tableData = JSON.parse(this.result.availableRoleFunctions);
+ this.dataSource = new MatTableDataSource(this.tableData);
+ this.dataSource.paginator = this.paginator;
+ this.dataSource.sort = this.sort;
+
+ });
+
+ }
+
+ applyFilter(filterValue: string) {
+ this.dataSource.filter = filterValue.trim().toLowerCase();
+
+ if (this.dataSource.paginator) {
+ this.dataSource.paginator.firstPage();
+ }
+ }
+
+
+ delRoleFunction(item: any) {
+ const modalRef = this.ngModal.open(InformationModalComponent);
+ modalRef.componentInstance.title = 'Confirmation';
+ let response;
+ modalRef.componentInstance.message = `Are you sure you want to delete ${item.name} ?`;
+ modalRef.result.then((result) => {
+ if (result === 'Ok') {
+ this.adminService.deleteRoleFunction(item).subscribe(data => {
+ response = data;
+ if(response ='SUCCESS')
+ {
+ this.getRoleFunctions();
+ }
+ })
+ }
+ }, (reason) => {
+ this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
+ });
+ }
+
+ private getDismissReason(reason: any): string {
+ if (reason === ModalDismissReasons.ESC) {
+ return 'by pressing ESC';
+ } else if (reason === ModalDismissReasons.BACKDROP_CLICK) {
+ return 'by clicking on a backdrop';
+ } else {
+ return `with: ${reason}`;
+ }
+
+ }
+
+}