summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.html101
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.scss40
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.spec.ts69
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.ts174
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-function.ts52
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.html48
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.scss63
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.spec.ts99
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.ts126
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.service.ts57
10 files changed, 829 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.html
new file mode 100644
index 00000000..888deca8
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.html
@@ -0,0 +1,101 @@
+<!--
+ ============LICENSE_START==========================================
+ ONAP Portal- SDK
+ ===================================================================
+ 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="ecomp-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">
+ {{selectedType}}
+ <mat-radio-group aria-labelledby="example-radio-group-label" class="example-radio-group"
+ [(ngModel)]="selectedType" name="type">
+ <mat-radio-button class="example-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="button" 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/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.scss b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.scss
new file mode 100644
index 00000000..56cb1aa3
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.scss
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal - SDK
+ * ===================================================================
+ * 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============================================
+ *
+ *
+ */
+ .ecomp-spinner{
+ z-index: 9999;
+} \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.spec.ts
new file mode 100644
index 00000000..ecc0947d
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.spec.ts
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * 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 { NewRoleFunctionComponent } from './new-role-function.component';
+import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
+import { FormsModule } from '@angular/forms';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
+
+describe('NewRoleFunctionComponent', () => {
+ let component: NewRoleFunctionComponent;
+ let fixture: ComponentFixture<NewRoleFunctionComponent>;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ schemas:[CUSTOM_ELEMENTS_SCHEMA],
+ declarations: [ NewRoleFunctionComponent ],
+ imports:[FormsModule,HttpClientTestingModule],
+ providers:[NgbActiveModal]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(NewRoleFunctionComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ // it('should create', () => {
+ // expect(component).toBeTruthy();
+ // });
+});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.ts
new file mode 100644
index 00000000..d0be5145
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/new-role-function/new-role-function.component.ts
@@ -0,0 +1,174 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * 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 { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
+import { RoleFunction } from '../role-function';
+import { HttpClient } from '@angular/common/http';
+import { AdminService } from '../../admin.service';
+import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
+
+@Component({
+ selector: 'app-new-role-function',
+ templateUrl: './new-role-function.component.html',
+ styleUrls: ['./new-role-function.component.scss']
+})
+export class NewRoleFunctionComponent 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 = '';
+ isEditing: any;
+ editDisable: boolean;
+ showSpinner: boolean;
+ selectedType: string;
+ createOrUpdate: string;
+ constructor(public adminService: AdminService, 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;
+ if (this.editRoleFunction.type !== 'menu' && this.editRoleFunction.type !== 'url') {
+ this.selectedType = 'other';
+ this.otherTypeValue = this.editRoleFunction.type;
+ }else{
+ this.selectedType = 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.openConfirmationModal('Confirmation', 'Type can only contain alphanumeric characters, dots(.) and underscores(_)');
+ return;
+ }
+ 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 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;
+ }else{
+ this.roleFunction.type = this.selectedType;
+ }
+
+ if (!exists && this.roleFunction.name.trim() != '' && this.roleFunction.code.trim() != '') {
+ var postData = this.roleFunction;
+ //console.log("saveRoleFunction post data :: ",postData);
+ this.adminService.saveRoleFunction(JSON.stringify(postData))
+ .subscribe(_data => {
+ this.showSpinner = false;
+ //console.log("saveRoleFunction response",_data);
+ if (this.editRoleFunction) {
+ this.editRoleFunction.name = this.roleFunction.name;
+ this.passBackRoleFunctionPopup.emit(this.editRoleFunction);
+ } else{
+ this.passBackRoleFunctionPopup.emit(this.roleFunction);
+ }
+ if (this.editRoleFunction) {
+ this.openConfirmationModal('Success', "Role function updated successfully.");
+ }else{
+ this.openConfirmationModal('Success', "Role function created successfully.");
+ }
+ }, error =>{
+ //console.log(error);
+ this.showSpinner = false;
+ this.openConfirmationModal('Error', error.message);
+ });
+ }
+ }
+ }, (_dismiss) => {
+
+ })
+ }
+
+
+ openConfirmationModal(_title: string, _message: string) {
+ const modalInfoRef = this.ngbModal.open(ConfirmationModalComponent);
+ modalInfoRef.componentInstance.title = _title;
+ modalInfoRef.componentInstance.message = _message;
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-function.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-function.ts
new file mode 100644
index 00000000..9a00995b
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-function.ts
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * 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============================================
+ *
+ *
+ */
+
+export class RoleFunction {
+ type: string;
+ code: string;
+ action: string;
+ name: string;
+
+ //constructor
+ constructor(type: string, code: string, action: string, name: string) {
+ this.type = type;
+ this.code = code;
+ this.action = action;
+ this.name = name;
+ }
+}
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.html b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.html
new file mode 100644
index 00000000..460f69b3
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.html
@@ -0,0 +1,48 @@
+<!--
+ ============LICENSE_START==========================================
+ ONAP Portal SDK
+ ===================================================================
+ 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="main-container">
+ <div class="role-function-title">
+ <h3 class="heading-page" id="roleFunction"> Role Functions </h3>
+ <span class= "heading-small" *ngIf="isAppCentralized=='true'"><b>Please go to portal to Manage Role Function.</b></span>
+ </div>
+ <span class="ecomp-spinner" *ngIf="showSpinner"></span>
+
+ <rdp-data-table [data]="tableData" [settings]="settings"></rdp-data-table>
+</div>
+ \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.scss b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.scss
new file mode 100644
index 00000000..ec7b2cac
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.scss
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * 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============================================
+ *
+ *
+ */
+ table {
+ width: 100%;
+}
+
+td, th {
+ width: 25%;
+}
+
+td[_ngcontent-c4], th[_ngcontent-c4] {
+ width: 15%;
+}
+
+.icon-trash{
+ cursor: pointer;
+}
+
+::ng-deep .mat-form-field-infix {
+ width: 250px;
+ margin-left: 10px;
+}
+
+:host::ng-deep .mat-header-cell{
+ font-weight: bold;
+ font-size: 14px;
+ color: #343a40;
+} \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.spec.ts
new file mode 100644
index 00000000..dab6af2b
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.spec.ts
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ * Modification Copyright © 2020 IBM.
+ * ===================================================================
+ *
+ * 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, inject } from '@angular/core/testing';
+
+import { RoleFunctionsComponent } from './role-functions.component';
+import { CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { RdpModule } from 'portalsdk-tag-lib';
+import { FormsModule} from '@angular/forms';
+import { AdminService } from '../admin.service';
+import { MatSelectModule} from '@angular/material';
+import { Observable } from 'rxjs';
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { UserService } from '../../shared/services/user/user.service';
+
+describe('RoleFunctionsComponent', () => {
+ let component: RoleFunctionsComponent;
+ let fixture: ComponentFixture<RoleFunctionsComponent>;
+ let userService:UserService;
+ let adminService:AdminService;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
+ declarations: [ RoleFunctionsComponent ],
+ imports: [HttpClientTestingModule,BrowserAnimationsModule,
+ RdpModule,
+ FormsModule,
+ ],
+ providers:[MatSelectModule]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers:[AdminService]
+ })
+ fixture = TestBed.createComponent(RoleFunctionsComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ userService=TestBed.get(UserService);
+ adminService=TestBed.get(AdminService);
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+
+ describe('test for subscribe in ngOnInit',()=>{
+ it('should test ngOnInit method',()=>{
+ let spy=spyOn(userService,'getFunctionalMenuStaticDetailSession').and.returnValue(Observable.of('you object'));
+ component.ngOnInit();
+ expect(spy).toHaveBeenCalled();
+ })
+ })
+ it('Admin service injection check', inject([AdminService],(injectService:AdminService) =>{
+ expect(injectService).toBe(adminService);
+ }));
+
+
+});
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.ts
new file mode 100644
index 00000000..3b97be51
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.component.ts
@@ -0,0 +1,126 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * 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, 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';
+import { NewRoleFunctionComponent } from './new-role-function/new-role-function.component';
+import { Column, DataTableSettings, ColumnTypes } from 'portalsdk-tag-lib';
+import { RoleFunctionsService } from './role-functions.service';
+
+@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;
+ isEditMode: boolean = false;
+ availableRoleFunctions: any;
+ showSpinner: boolean;
+
+ 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,
+ private roleFunctionService: RoleFunctionsService) { }
+
+ @ViewChild(MatPaginator, {}) paginator: MatPaginator;
+ @ViewChild(MatSort, {}) sort: MatSort;
+
+ public settings;
+ public columns: any = [];
+ typeOptions: string[] = ['menu', 'url', 'other'];
+
+ ngOnInit() {
+ this.showSpinner = false;
+ this.availableRoleFunctions = [];
+ this.getRoleFunctions();
+ let result = this.userService.getFunctionalMenuStaticDetailSession();
+ result.subscribe(user => {
+ this.user = user;
+ this.isAppCentralized = this.user.isAppCentralized;
+ });
+ }
+
+ getRoleFunctions() {
+ this.showSpinner = true;
+ let response;
+ this.response = this.adminService.getRoleFunctionList();
+ this.response.subscribe(data => {
+ response = data;
+ this.result = JSON.parse(response.data);
+ this.availableRoleFunctions = this.result.availableRoleFunctions;
+ this.tableData = JSON.parse(this.result.availableRoleFunctions);
+ //console.log("Table data : ", this.tableData);
+ this.columns.push(new Column("name", "Name", ColumnTypes.TEXT, true, null));
+ this.columns.push(new Column("code", "Code", ColumnTypes.TEXT, true, null));
+ this.columns.push(new Column("type", "Type", ColumnTypes.RADIO, true, this.typeOptions));
+ this.columns.push(new Column("action", "Action", ColumnTypes.TEXT, true, null));
+
+ this.settings = new DataTableSettings()
+ this.settings.columns = this.columns;
+ this.settings.isPaginationEnabled = true;
+ this.settings.paginationsSize = "5";
+ this.settings.isReadOnly = false;
+ this.settings.isTableSearchEnabled = true;
+ this.settings.applicationService = this.roleFunctionService;
+ this.showSpinner = false;
+
+ });
+
+ }
+}
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.service.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.service.ts
new file mode 100644
index 00000000..bd44a63d
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/role-functions/role-functions.service.ts
@@ -0,0 +1,57 @@
+import { Injectable } from '@angular/core';
+import { RdpCrudInterface } from 'portalsdk-tag-lib';
+import { AdminService } from '../admin.service';
+import { BehaviorSubject } from 'rxjs';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class RoleFunctionsService implements RdpCrudInterface {
+
+ public statusResponse = new BehaviorSubject("");
+ public updatedData = new BehaviorSubject<any>({});
+
+ loadTableData(filter: any, sortActive: any, sortDirection: any, pageIndex: any, pageSize: any): import("rxjs").Observable<any[]> {
+ throw new Error("Method not implemented.");
+ }
+ getTotalRowCount() {
+ throw new Error("Method not implemented.");
+ }
+
+ constructor(private adminService: AdminService) { }
+
+ add(data: any) {
+ //console.log("Add method is getting called from RoleFunctionService data:: ", data);
+ }
+
+
+ update(data: any): any {
+ console.log("Update method is getting called from RoleFunctionService data:: ", data);
+ return this.adminService.saveRoleFunction(data).subscribe(response => {
+ //console.log("Success Response ", response);
+ this.statusResponse.next("200");
+ }, error => {
+ console.log("Error ", error);
+ })
+ }
+
+ delete(data: any) {
+ //console.log("Delete method is getting called from RoleFunctionService data::>> " + JSON.stringify(data));
+ this.adminService.deleteRoleFunction(data).subscribe(response => {
+ //console.log("Repsonse : ", response);
+ this.statusResponse.next("200");
+
+ })
+ }
+
+ get() {
+ let response = this.adminService.getRoleFunctionList();
+ let editedData;
+ response.subscribe(res => {
+ editedData = res;
+ let data = JSON.parse(JSON.parse(editedData.data).availableRoleFunctions);
+ //console.log("Get Method called : ", data);
+ this.updatedData.next(data);
+ })
+ }
+}