2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
39 import { Component, OnInit, Directive, Input, Output, EventEmitter, ViewChildren, QueryList, PipeTransform, ViewChild } from '@angular/core';
40 import { AdminService } from '../admin.service';
41 import {UserService} from '../../shared/services/user/user.service'
42 import { User } from 'src/app/shared/services/user/user';
43 import { of, Observable } from 'rxjs';
44 import { RoleFunction } from './role-function';
45 import { MatTableDataSource } from '@angular/material/table';
46 import { MatPaginator } from '@angular/material/paginator';
47 import { MatSort } from '@angular/material/sort';
48 import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
49 import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
50 import { NewRoleFunctionComponent } from './new-role-function/new-role-function.component';
51 import { Column, DataTableSettings, ColumnTypes } from 'portalsdk-tag-lib';
52 import { RoleFunctionsService } from './role-functions.service';
55 selector: 'app-role-functions',
56 templateUrl: './role-functions.component.html',
57 styleUrls: ['./role-functions.component.scss']
59 export class RoleFunctionsComponent implements OnInit {
61 tableData: Array<RoleFunction> = [];
64 function: RoleFunction;
65 isEditMode: boolean = false;
66 availableRoleFunctions: any;
69 isAppCentralized: any;
73 roleFunctionHeaders = ["name", "code", "type", "action", "edit", "delete"];
74 dataSource: MatTableDataSource<RoleFunction>;
76 constructor(public adminService: AdminService,
77 public userService: UserService,
78 private ngModal: NgbModal,
79 private roleFunctionService: RoleFunctionsService) { }
81 @ViewChild(MatPaginator, {}) paginator: MatPaginator;
82 @ViewChild(MatSort, {}) sort: MatSort;
85 public columns: any = [];
86 typeOptions: string[] = ['menu', 'url', 'other'];
89 this.showSpinner = false;
90 this.availableRoleFunctions = [];
91 this.getRoleFunctions();
92 let result = this.userService.getFunctionalMenuStaticDetailSession();
93 result.subscribe(user => {
95 this.isAppCentralized = this.user.isAppCentralized;
100 this.showSpinner = true;
102 this.response = this.adminService.getRoleFunctionList();
103 this.response.subscribe(data => {
105 this.result = JSON.parse(response.data);
106 this.availableRoleFunctions = this.result.availableRoleFunctions;
107 this.tableData = JSON.parse(this.result.availableRoleFunctions);
108 //console.log("Table data : ", this.tableData);
109 this.columns.push(new Column("name", "Name", ColumnTypes.TEXT, true, null));
110 this.columns.push(new Column("code", "Code", ColumnTypes.TEXT, true, null));
111 this.columns.push(new Column("type", "Type", ColumnTypes.RADIO, true, this.typeOptions));
112 this.columns.push(new Column("action", "Action", ColumnTypes.TEXT, true, null));
114 this.settings = new DataTableSettings()
115 this.settings.columns = this.columns;
116 this.settings.isPaginationEnabled = true;
117 this.settings.paginationsSize = "5";
118 this.settings.isReadOnly = false;
119 this.settings.isTableSearchEnabled = true;
120 this.settings.applicationService = this.roleFunctionService;
121 this.showSpinner = false;