summaryrefslogtreecommitdiffstats
path: root/portal-FE-common/src/app/pages/role/role-functions
diff options
context:
space:
mode:
Diffstat (limited to 'portal-FE-common/src/app/pages/role/role-functions')
-rw-r--r--portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.html100
-rw-r--r--portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.scss40
-rw-r--r--portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.spec.ts62
-rw-r--r--portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.ts165
-rw-r--r--portal-FE-common/src/app/pages/role/role-functions/role-functions.component.html113
-rw-r--r--portal-FE-common/src/app/pages/role/role-functions/role-functions.component.scss47
-rw-r--r--portal-FE-common/src/app/pages/role/role-functions/role-functions.component.spec.ts62
-rw-r--r--portal-FE-common/src/app/pages/role/role-functions/role-functions.component.ts200
8 files changed, 789 insertions, 0 deletions
diff --git a/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.html b/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.html
new file mode 100644
index 00000000..be7dc2a1
--- /dev/null
+++ b/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.html
@@ -0,0 +1,100 @@
+<!--
+ ============LICENSE_START==========================================
+ ONAP Portal
+ ===================================================================
+ Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ ===================================================================
+
+ Unless otherwise specified, all software contained herein is licensed
+ under the Apache License, Version 2.0 (the "License");
+ you may not use this software except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Unless otherwise specified, all documentation contained herein is licensed
+ under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ you may not use this documentation except in compliance with the License.
+ You may obtain a copy of the License at
+
+ https://creativecommons.org/licenses/by/4.0/
+
+ Unless required by applicable law or agreed to in writing, documentation
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ============LICENSE_END============================================
+
+
+ -->
+
+<div class="container">
+ <div class="modal-header">
+ <h4 class="modal-title">{{title}}</h4>
+ <button type="button" class="close" aria-label="Close" (click)="activeModal.dismiss('Cross')">
+ <span aria-hidden="true">&times;</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <span class="onap-spinner" *ngIf="showSpinner"></span>
+ <form>
+ <fieldset class="form-group">
+ <div class="row">
+ <legend class="col-form-label col-sm-2 pt-0">Type</legend>
+ <div class="col-sm-10">
+ <div class="form-check">
+ <mat-radio-group aria-labelledby="type-radio-group-label" class="type-radio-group"
+ [(ngModel)]="selectedType" name="selectedType">
+ <mat-radio-button class="type-radio-button" [disabled]="editDisable" *ngFor="let type of typeOptions" [value]="type">
+ {{type}} &nbsp;
+ </mat-radio-button>
+ </mat-radio-group>
+ </div>
+ </div>
+ </div>
+ </fieldset>
+ <div *ngIf="selectedType === 'other'" class="form-group row">
+ <label for="inputOtherType" class="col-sm-2 col-form-label"></label>
+ <div class="col-sm-10">
+ <input type="text" class="form-control" [disabled]="editDisable" [(ngModel)]="otherTypeValue" name="type2" id="inputOtherType"
+ placeholder="Type">
+ </div>
+ </div>
+ <div class="form-group row">
+ <label for="inputInstance" class="col-sm-2 col-form-label">Instance</label>
+ <div class="col-sm-10">
+ <input type="text" class="form-control" [disabled]="editDisable" [(ngModel)]="roleFunction.code" name="code" id="inputInstance"
+ placeholder="Instance">
+ </div>
+ </div>
+ <div class="form-group row">
+ <label for="inputAction" class="col-sm-2 col-form-label">Action</label>
+ <div class="col-sm-10">
+ <input type="text" class="form-control" [disabled]="editDisable" [(ngModel)]="roleFunction.action" name="action" id="inputAction"
+ placeholder="Action">
+ </div>
+ </div>
+ <div class="form-group row">
+ <label for="inputName" class="col-sm-2 col-form-label">Name</label>
+ <div class="col-sm-10">
+ <input type="text" class="form-control" [(ngModel)]="roleFunction.name" name="name" id="inputName"
+ placeholder="Name">
+ </div>
+ </div>
+ </form>
+ </div>
+ <div class="modal-footer">
+ <button type="submit" class="btn btn-primary"
+ [disabled]="(selectedType === 'other' && otherTypeValue.length === 0 ) || (roleFunction.code.length === 0 || roleFunction.action.length === 0 || roleFunction.name.length === 0)"
+ (click)="saveRoleFunction()">Save</button> &nbsp;
+ <button type="button" class="btn btn-primary" (click)="activeModal.close('Close')">Cancel</button>
+ </div>
+</div> \ No newline at end of file
diff --git a/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.scss b/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.scss
new file mode 100644
index 00000000..fff036cd
--- /dev/null
+++ b/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.scss
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+.onap-spinner{
+ z-index: 9999;
+} \ No newline at end of file
diff --git a/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.spec.ts b/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.spec.ts
new file mode 100644
index 00000000..2c5ef631
--- /dev/null
+++ b/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.spec.ts
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { RoleFunctionModalComponent } from './role-function-modal.component';
+
+describe('RoleFunctionModalComponent', () => {
+ let component: RoleFunctionModalComponent;
+ let fixture: ComponentFixture<RoleFunctionModalComponent>;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ RoleFunctionModalComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(RoleFunctionModalComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.ts b/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.ts
new file mode 100644
index 00000000..d54cd02c
--- /dev/null
+++ b/portal-FE-common/src/app/pages/role/role-functions/role-function-modal/role-function-modal.component.ts
@@ -0,0 +1,165 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
+import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
+import { RoleFunction, Role } from 'src/app/shared/model';
+import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
+import { environment } from 'src/environments/environment';
+import { HttpClient } from '@angular/common/http';
+import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
+
+@Component({
+ selector: 'app-role-function-modal',
+ templateUrl: './role-function-modal.component.html',
+ styleUrls: ['./role-function-modal.component.scss']
+})
+export class RoleFunctionModalComponent implements OnInit {
+
+ @Input() title: string;
+ @Input() appId: any;
+ @Input() dialogState: number;
+ @Input() currentRoleFunctions: any;
+ @Input() editRoleFunction: RoleFunction;
+ @Output() passBackRoleFunctionPopup: EventEmitter<any> = new EventEmitter();
+ roleFunction: RoleFunction;
+ otherTypeValue: string;
+ typeOptions: string[] = ['menu', 'url', 'other'];
+ api = environment.api;
+ isEditing: any;
+ editDisable: boolean;
+ showSpinner: boolean;
+ selectedType: string;
+ createOrUpdate: string;
+ constructor(public activeModal: NgbActiveModal, public ngbModal: NgbModal, public http: HttpClient) { }
+
+ ngOnInit() {
+ this.createOrUpdate = 'create';
+ this.selectedType = 'menu';
+ this.roleFunction = new RoleFunction(this.selectedType, '', '*', '');
+ this.otherTypeValue = '';
+ if (this.editRoleFunction) {
+ this.createOrUpdate = 'update';
+ this.editDisable = true;
+ this.selectedType = this.editRoleFunction.type;
+ if (this.editRoleFunction.type !== 'menu' && this.editRoleFunction.type !== 'url') {
+ this.selectedType = 'other';
+ this.otherTypeValue = this.editRoleFunction.type;
+ }
+ this.roleFunction = new RoleFunction(this.editRoleFunction.type, this.editRoleFunction.code, this.editRoleFunction.action, this.editRoleFunction.name);
+ }
+ }
+
+ saveRoleFunction() {
+ if (/[^a-zA-Z0-9\-\.\_]/.test(this.roleFunction.type) && this.selectedType === 'other') {
+ this.openConfirmationModal('Confirmation', 'Type can only contain alphanumeric characters, dots(.) and underscores(_)');
+ return;
+ } else {
+ this.roleFunction.type = this.selectedType;
+ }
+ if (this.roleFunction.action !== '*' && /[^a-zA-Z0-9\-\.\_]/.test(this.roleFunction.action)) {
+ this.openConfirmationModal('Confirmation', 'Action can only contain alphanumeric characters, hyphens(-), dots(.) and underscores(_) and single asterisk character(*)');
+ return;
+ }
+ if (/[^a-zA-Z0-9\-\:\_\./*]/.test(this.roleFunction.code)) {
+ this.openConfirmationModal('Confirmation', 'Instance can only contain alphanumeric characters, hyphens(-), dots(.), colons(:), forwardSlash(/) , asterisk(*) and underscores(_)');
+ return;
+ }
+ const modalInfoRef = this.ngbModal.open(InformationModalComponent);
+ modalInfoRef.componentInstance.title = 'Confirmation';
+ modalInfoRef.componentInstance.message = 'You are about to ' + this.createOrUpdate + ' the role function ' + this.roleFunction.name + '. Do you want to continue?';
+ modalInfoRef.result.then((_res) => {
+ if (_res === 'Ok') {
+ this.showSpinner = true;
+ var uuu = this.api.saveRoleFunction.replace(':appId', this.appId);
+ var postData = this.roleFunction;
+ var exists = false, x;
+ for (x in this.currentRoleFunctions) {
+ if (this.currentRoleFunctions[x].type == this.roleFunction.type
+ && this.currentRoleFunctions[x].code == this.roleFunction.code
+ && this.currentRoleFunctions[x].action == this.roleFunction.action
+ && this.currentRoleFunctions[x].name == this.roleFunction.name) {
+ this.openConfirmationModal('Confirmation', "Role Function already exist.");
+ exists = true;
+ this.showSpinner = false;
+ break;
+ }
+ if (!this.editDisable) {
+ if (this.currentRoleFunctions[x].type == this.roleFunction.type
+ && this.currentRoleFunctions[x].code == this.roleFunction.code
+ && this.currentRoleFunctions[x].action == this.roleFunction.action
+ ) {
+ this.openConfirmationModal('Confirmation', "Please make sure code, type and action is unique. Please create a role function with a different code or type or action to proceed.");
+ exists = true;
+ this.showSpinner = false;
+ break;
+ }
+ }
+ }
+ if (this.selectedType === 'other')
+ this.roleFunction.type = this.otherTypeValue;
+ if (!exists && this.roleFunction.name.trim() != '' && this.roleFunction.code.trim() != '') {
+ this.http.post(uuu, JSON.stringify(postData)).toPromise().then((res: any) => {
+ if (res.status == 'OK') {
+ this.showSpinner = false;
+ if (this.editRoleFunction) {
+ this.editRoleFunction.name = this.roleFunction.name;
+ this.passBackRoleFunctionPopup.emit(this.editRoleFunction);
+ } else{
+ this.passBackRoleFunctionPopup.emit(this.roleFunction);
+ }
+ this.openConfirmationModal('Success', res.message);
+ } else {
+ this.showSpinner = false;
+ this.openConfirmationModal('Error', res.message);
+ }
+ });
+
+ }
+ }
+ }, (_dismiss) => {
+
+ })
+ }
+
+
+ openConfirmationModal(_title: string, _message: string) {
+ const modalInfoRef = this.ngbModal.open(ConfirmationModalComponent);
+ modalInfoRef.componentInstance.title = _title;
+ modalInfoRef.componentInstance.message = _message;
+ }
+}
diff --git a/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.html b/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.html
new file mode 100644
index 00000000..046d0a07
--- /dev/null
+++ b/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.html
@@ -0,0 +1,113 @@
+<!--
+ ============LICENSE_START==========================================
+ ONAP Portal
+ ===================================================================
+ Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ ===================================================================
+
+ Unless otherwise specified, all software contained herein is licensed
+ under the Apache License, Version 2.0 (the "License");
+ you may not use this software except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Unless otherwise specified, all documentation contained herein is licensed
+ under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ you may not use this documentation except in compliance with the License.
+ You may obtain a copy of the License at
+
+ https://creativecommons.org/licenses/by/4.0/
+
+ Unless required by applicable law or agreed to in writing, documentation
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ============LICENSE_END============================================
+
+
+ -->
+
+<div class="container">
+ <div class="onap-main-view-title">
+ <h1 class="heading-page">Role Functions</h1>
+ </div>
+ <mat-form-field>
+ <mat-label> Select Application </mat-label>
+ <mat-select [disabled]='centralizedApps.length === 0' [(ngModel)]="selectedCentralizedApp">
+ <mat-option *ngFor="let app of centralizedApps" [value]="app.appId"
+ (click)="getRoleFunctions(selectedCentralizedApp)">
+ {{app.appName}}</mat-option>
+ </mat-select>
+ </mat-form-field>
+ &nbsp;
+ <button type="button" class="btn btn-primary" [disabled]='centralizedApps.length === 0'
+ (click)="syncRolesFromExternalAuthSystem()"><i class="icon ion-md-sync"></i>
+ Sync Role Functions </button>
+ <button type="button" class="btn btn-primary" [disabled]='centralizedApps.length === 0'
+ (click)="addRoleFunctionModalPopup()"><i class="icon ion-md-add-circle-outline"></i>
+ Create </button>
+ <span class="onap-spinner" *ngIf="showSpinner"></span>
+ <table mat-table [dataSource]="roleFunctionsDataSource" matSort>
+ <!-- Type Column -->
+ <ng-container matColumnDef="type">
+ <th id="col1" mat-header-cell *matHeaderCellDef mat-sort-header> Type </th>
+ <td id="rowheader_t1_{{i}}-type" mat-cell *matCellDef="let element; let i = index;"> {{element.type}}
+ </td>
+ </ng-container>
+
+ <!-- Instance Column -->
+ <ng-container matColumnDef="instance">
+ <th id="col2" mat-header-cell *matHeaderCellDef mat-sort-header> Instance </th>
+ <td id="rowheader_t1_{{i}}-instance" mat-cell *matCellDef="let element; let i=index;"> {{element.code}}
+ </td>
+ </ng-container>
+
+ <!-- Action Column -->
+ <ng-container matColumnDef="action">
+ <th id="col3" mat-header-cell *matHeaderCellDef mat-sort-header> Action </th>
+ <td id="rowheader_t1_{{i}}-action" mat-cell *matCellDef="let element; let i=index;"> {{element.action}}
+ </td>
+ </ng-container>
+
+ <!-- Name Column -->
+ <ng-container matColumnDef="name">
+ <th id="col3" mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
+ <td id="rowheader_t1_{{i}}-name" mat-cell *matCellDef="let element; let i=index;"> {{element.name}}
+ </td>
+ </ng-container>
+
+ <!-- Edit Column -->
+ <ng-container matColumnDef="edit">
+ <th id="col3" mat-header-cell *matHeaderCellDef mat-sort-header> Edit </th>
+ <td id="rowheader_t1_{{i}}-userId" mat-cell *matCellDef="let element; let i=index;">
+ <span class="icon-trash" id="{{i}}-button-edit" (click)="editRoleFunctionModalPopup(element)">
+ <i class="icon ion-md-create"></i>
+ </span>
+ </td>
+ </ng-container>
+
+ <!-- Delete Column -->
+ <ng-container matColumnDef="delete">
+ <th id="col4" mat-header-cell *matHeaderCellDef> Delete </th>
+ <td id="rowheader_t1_{{i}}-delete" mat-cell *matCellDef="let element; let i=index;">
+ <span class="icon-trash" id="{{i}}-button-portal-admin-remove" (click)="removeRoleFunction(element)">
+ <i class="icon ion-md-trash"></i>
+ </span>
+ </td>
+ </ng-container>
+
+ <tr [hidden]="availableRoleFunctions.length === 0" mat-header-row *matHeaderRowDef="displayedColumns"></tr>
+ <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
+ </table>
+ <mat-paginator [hidden]="availableRoleFunctions.length === 0" [pageSizeOptions]="[10, 20]" showFirstLastButtons>
+ </mat-paginator>
+</div> \ No newline at end of file
diff --git a/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.scss b/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.scss
new file mode 100644
index 00000000..944e9c8c
--- /dev/null
+++ b/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.scss
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+@import "../../pages.component";
+
+.icon-trash{
+ cursor: pointer;
+ font-size: 20px;
+}
+
+.onap-spinner{
+ z-index: 9999;
+} \ No newline at end of file
diff --git a/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.spec.ts b/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.spec.ts
new file mode 100644
index 00000000..ccefb8d2
--- /dev/null
+++ b/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.spec.ts
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { RoleFunctionsComponent } from './role-functions.component';
+
+describe('RoleFunctionsComponent', () => {
+ let component: RoleFunctionsComponent;
+ let fixture: ComponentFixture<RoleFunctionsComponent>;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ RoleFunctionsComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(RoleFunctionsComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.ts b/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.ts
new file mode 100644
index 00000000..1b68526d
--- /dev/null
+++ b/portal-FE-common/src/app/pages/role/role-functions/role-functions.component.ts
@@ -0,0 +1,200 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ *
+ */
+import { Component, OnInit, ViewChild } from '@angular/core';
+import { RoleService, ApplicationsService } from 'src/app/shared/services';
+import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material';
+import { RoleFunctionModalComponent } from './role-function-modal/role-function-modal.component';
+import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
+import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
+import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
+import { HttpClient } from '@angular/common/http';
+import { environment } from 'src/environments/environment';
+
+@Component({
+ selector: 'app-role-functions',
+ templateUrl: './role-functions.component.html',
+ styleUrls: ['./role-functions.component.scss']
+})
+export class RoleFunctionsComponent implements OnInit {
+ api = environment.api
+ centralizedApps: any;
+ selectedCentralizedApp: any;
+ availableRoleFunctions: any;
+ displayedColumns: string[] = ['type', 'instance', 'action', 'name', 'edit', 'delete'];
+ roleFunctionsDataSource = new MatTableDataSource(this.availableRoleFunctions);
+ @ViewChild(MatSort) sort: MatSort;
+ @ViewChild(MatPaginator) paginator: MatPaginator;
+ showSpinner: boolean;
+
+ constructor(public ngbModal: NgbModal,private roleService: RoleService, private applicationsService: ApplicationsService, public http: HttpClient) {}
+
+ ngOnInit() {
+ this.availableRoleFunctions = [];
+ this.centralizedApps = [];
+ this.getCentralizedApps(sessionStorage.userId);
+ }
+
+ syncRolesFromExternalAuthSystem() {
+ this.applicationsService.syncRolesEcompFromExtAuthSystem(this.selectedCentralizedApp).toPromise().then((res: any) => {
+ if (res.status == 'OK') {
+ const modalInfoRef = this.ngbModal.open(InformationModalComponent);
+ modalInfoRef.componentInstance.title = 'Success';
+ modalInfoRef.componentInstance.message = 'Sync role functions completed successfully!';
+ modalInfoRef.result.then((_res) => {
+ if (_res === 'Ok')
+ this.getRoleFunctions(this.selectedCentralizedApp);
+ }, (result) => {
+
+ })
+ } else {
+ this.openConfirmationModal('Error', 'Sync failed ' + res.message);
+ }
+ }).catch(err => {
+ this.openConfirmationModal('Error', 'Sync failed' + err);
+ });
+ };
+
+
+ // getCentalizedApps
+ getCentralizedApps(userId) {
+ this.roleService.getCentralizedApps(userId).toPromise().then((res: any) => {
+ if (res.length > 0) {
+ this.centralizedApps = res;
+ this.selectedCentralizedApp = this.centralizedApps[0].appId;
+ this.getRoleFunctions(this.centralizedApps[0].appId);
+ }
+ }).catch(err => {
+ // $log.error('RoleListCtrl::centralizedApps retrieval error: ', err);
+ }).finally(() => {
+ // this.isLoadingTable = false;
+ });
+ }
+
+ getRoleFunctions(id) {
+ this.showSpinner = true;
+ this.roleService.getRoleFunctionList(id).subscribe((data: any) => {
+ this.showSpinner = false;
+ var j = data;
+ var roleFunctions = JSON.parse(j.data);
+ this.availableRoleFunctions = roleFunctions.availableRoleFunctions;
+ this.roleFunctionsDataSource = new MatTableDataSource(this.availableRoleFunctions);
+ this.roleFunctionsDataSource.sort = this.sort;
+ this.roleFunctionsDataSource.paginator = this.paginator;
+ }, (error) => {
+ this.showSpinner = false;
+ this.openConfirmationModal('Error', 'Failed to get role functions. Please try again!' + error.message);
+ })
+ };
+
+ addRoleFunctionModalPopup(){
+ const modalInfoRef = this.ngbModal.open(RoleFunctionModalComponent);
+ modalInfoRef.componentInstance.title = 'Add Role Function';
+ modalInfoRef.componentInstance.appId = this.selectedCentralizedApp;
+ modalInfoRef.componentInstance.currentRoleFunctions = this.availableRoleFunctions;
+ modalInfoRef.componentInstance.passBackRoleFunctionPopup.subscribe((_result: any) => {
+ if(_result){
+ modalInfoRef.close();
+ this.availableRoleFunctions.push(_result);
+ this.roleFunctionsDataSource = new MatTableDataSource(this.availableRoleFunctions);
+ this.roleFunctionsDataSource.sort = this.sort;
+ this.roleFunctionsDataSource.paginator = this.paginator;
+ }
+ }, (_reason: any) => {
+ return;
+ });
+
+ }
+
+ editRoleFunctionModalPopup(_element){
+ const modalInfoRef = this.ngbModal.open(RoleFunctionModalComponent);
+ modalInfoRef.componentInstance.title = 'Edit Role Function';
+ modalInfoRef.componentInstance.appId = this.selectedCentralizedApp;
+ modalInfoRef.componentInstance.editRoleFunction = _element;
+ modalInfoRef.componentInstance.currentRoleFunctions = this.availableRoleFunctions;
+ modalInfoRef.componentInstance.passBackRoleFunctionPopup.subscribe((_result: any) => {
+ if(_result){
+ modalInfoRef.close();
+ this.availableRoleFunctions.splice(this.availableRoleFunctions.indexOf(_element), 1);
+ this.availableRoleFunctions.push(_result);
+ this.roleFunctionsDataSource = new MatTableDataSource(this.availableRoleFunctions);
+ this.roleFunctionsDataSource.sort = this.sort;
+ this.roleFunctionsDataSource.paginator = this.paginator;
+ }
+ }, (_reason: any) => {
+ return;
+ });
+ }
+
+ removeRoleFunction(_element: any){
+ const ngbInfoModal = this.ngbModal.open(InformationModalComponent);
+ ngbInfoModal.componentInstance.title = 'Confirmation';
+ ngbInfoModal.componentInstance.message = 'You are about to delete the role function ' + _element.name + '. Do you want to continue?';
+ ngbInfoModal.result.then(_res =>{
+ if(_res === 'Ok'){
+ this.showSpinner = true;
+ var uuu = this.api.removeRoleFunction.replace(':appId', this.selectedCentralizedApp);
+ var postData = _element;
+ this.http.post(uuu, postData).subscribe((response: any) => {
+ this.showSpinner = false;
+ if(response.status == 'OK'){
+ this.openConfirmationModal('Success', response.message);
+ this.availableRoleFunctions.splice(this.availableRoleFunctions.indexOf(_element), 1);
+ this.roleFunctionsDataSource = new MatTableDataSource(this.availableRoleFunctions);
+ this.roleFunctionsDataSource.sort = this.sort;
+ this.roleFunctionsDataSource.paginator = this.paginator;
+ } else{
+ this.showSpinner = false;
+ this.openConfirmationModal('Error', "Error while deleting: " + response.message);
+ }
+ }, (err) => {
+ this.showSpinner = false;
+ this.openConfirmationModal('Error', err.message);
+ });
+ }
+ }, (_reason: any) => {
+ return;
+ });
+ }
+
+ openConfirmationModal(_title: string, _message: string) {
+ const modalInfoRef = this.ngbModal.open(ConfirmationModalComponent);
+ modalInfoRef.componentInstance.title = _title;
+ modalInfoRef.componentInstance.message = _message;
+ }
+
+}