summaryrefslogtreecommitdiffstats
path: root/portal-FE-common/src/app/pages/admins
diff options
context:
space:
mode:
Diffstat (limited to 'portal-FE-common/src/app/pages/admins')
-rw-r--r--portal-FE-common/src/app/pages/admins/admins.component.html92
-rw-r--r--portal-FE-common/src/app/pages/admins/admins.component.scss42
-rw-r--r--portal-FE-common/src/app/pages/admins/admins.component.spec.ts62
-rw-r--r--portal-FE-common/src/app/pages/admins/admins.component.ts133
-rw-r--r--portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.html96
-rw-r--r--portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.scss58
-rw-r--r--portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.spec.ts62
-rw-r--r--portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.ts228
8 files changed, 773 insertions, 0 deletions
diff --git a/portal-FE-common/src/app/pages/admins/admins.component.html b/portal-FE-common/src/app/pages/admins/admins.component.html
new file mode 100644
index 00000000..a47a6207
--- /dev/null
+++ b/portal-FE-common/src/app/pages/admins/admins.component.html
@@ -0,0 +1,92 @@
+<!--
+ ============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">Admins</h1>
+ </div>
+
+ <mat-form-field>
+ <mat-label>All Applications</mat-label>
+ <mat-select>
+ <mat-option>All Applications</mat-option>
+ <mat-option *ngFor="let app of availableApps" [value]="app.value" (click)="applyFilterByAppName(app.value)">{{app.title}}</mat-option>
+ </mat-select>
+ </mat-form-field>
+ &nbsp;
+ <mat-form-field>
+ <input matInput type="text" (keyup)="applyFilter($event.target.value)" placeholder="Search in entire table">
+ </mat-form-field>
+ <button type="button" class="btn btn-primary" (click)="openAddNewAdminModal()"><i class="icon ion-md-person-add"></i>
+ Add Admin</button>
+ <span class="onap-spinner" *ngIf="showSpinner"></span>
+ <table mat-table [dataSource]="adminsDataSource" matSort>
+ <!-- First Name Column -->
+ <ng-container matColumnDef="firstName">
+ <th id="col1" mat-header-cell *matHeaderCellDef mat-sort-header> First Name </th>
+ <td id="rowheader_t1_{{i}}-firstName" mat-cell *matCellDef="let element; let i = index;"> {{element.firstName}}
+ </td>
+ </ng-container>
+
+ <!-- Last Name Column -->
+ <ng-container matColumnDef="lastName">
+ <th id="col2" mat-header-cell *matHeaderCellDef mat-sort-header> Last Name </th>
+ <td id="rowheader_t1_{{i}}-lastName" mat-cell *matCellDef="let element; let i=index;"> {{element.lastName}}
+ </td>
+ </ng-container>
+
+ <!-- User ID Column -->
+ <ng-container matColumnDef="userId">
+ <th id="col3" mat-header-cell *matHeaderCellDef mat-sort-header> User ID </th>
+ <td id="rowheader_t1_{{i}}-userId" mat-cell *matCellDef="let element; let i=index;"> {{element.orgUserId}}
+ </td>
+ </ng-container>
+
+ <!-- Applications Column -->
+ <ng-container matColumnDef="appName">
+ <th id="col4" mat-header-cell *matHeaderCellDef> Applications </th>
+ <td id="rowheader_t1_{{i}}-applications" mat-cell *matCellDef="let element; let i=index;">
+ <div *ngFor="let element of element.apps; let i=index;"> {{element.appName}} </div>
+ </td>
+ </ng-container>
+
+ <tr [hidden]="adminsData.length === 0" mat-header-row *matHeaderRowDef="displayedColumns"></tr>
+ <tr mat-row *matRowDef="let row; columns: displayedColumns;" (click)="openExistingAdminModal(row)"></tr>
+ </table>
+ <mat-paginator [hidden]="adminsData.length === 0" [pageSizeOptions]="[10, 20]" showFirstLastButtons></mat-paginator>
+</div> \ No newline at end of file
diff --git a/portal-FE-common/src/app/pages/admins/admins.component.scss b/portal-FE-common/src/app/pages/admins/admins.component.scss
new file mode 100644
index 00000000..a7f4d385
--- /dev/null
+++ b/portal-FE-common/src/app/pages/admins/admins.component.scss
@@ -0,0 +1,42 @@
+/*-
+ * ============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';
+
+.mat-row{
+ cursor: pointer;
+}
diff --git a/portal-FE-common/src/app/pages/admins/admins.component.spec.ts b/portal-FE-common/src/app/pages/admins/admins.component.spec.ts
new file mode 100644
index 00000000..563f80ff
--- /dev/null
+++ b/portal-FE-common/src/app/pages/admins/admins.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 { AdminsComponent } from './admins.component';
+
+describe('AdminsComponent', () => {
+ let component: AdminsComponent;
+ let fixture: ComponentFixture<AdminsComponent>;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ AdminsComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(AdminsComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/portal-FE-common/src/app/pages/admins/admins.component.ts b/portal-FE-common/src/app/pages/admins/admins.component.ts
new file mode 100644
index 00000000..d7a839b5
--- /dev/null
+++ b/portal-FE-common/src/app/pages/admins/admins.component.ts
@@ -0,0 +1,133 @@
+/*-
+ * ============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 { AdminsService, ApplicationsService } from 'src/app/shared/services';
+import { Admins, AllApps } from 'src/app/shared/model';
+import { MatTableDataSource, MatSort, MatPaginator } from '@angular/material';
+import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
+import { NewAdminComponent } from './new-admin/new-admin.component';
+
+@Component({
+ selector: 'app-admins',
+ templateUrl: './admins.component.html',
+ styleUrls: ['./admins.component.scss']
+})
+export class AdminsComponent implements OnInit {
+ availableApps: Array<{ index: number, title: string, value: string }> = [];
+
+ constructor(private adminsService: AdminsService, private applicationService: ApplicationsService,
+ public ngModal: NgbModal) { }
+
+ showSpinner = true;
+ displayedColumns: string[] = ['firstName', 'lastName', 'userId', 'appName'];
+ adminsData: Admins[] = [];
+ adminsDataSource = new MatTableDataSource(this.adminsData);
+ @ViewChild(MatSort) sort: MatSort;
+ @ViewChild(MatPaginator) paginator: MatPaginator;
+ ngOnInit() {
+ this.adminsData = [];
+ this.getAccoutAdminsData();
+ this.getAllApps();
+ }
+
+ openAddNewAdminModal() {
+ const modalRef = this.ngModal.open(NewAdminComponent);
+ modalRef.componentInstance.title = 'New Admin';
+ modalRef.componentInstance.dialogState = 1;
+ modalRef.componentInstance.disableBack = false;
+ modalRef.componentInstance.passBackNewAdminPopup.subscribe((_result: any) => {
+ modalRef.close();
+ this.showSpinner = true;
+ this.getAccoutAdminsData();
+ }, (_reason: any) => {
+ return;
+ });
+ }
+
+ openExistingAdminModal(_adminData: Admins) {
+ const modalRef = this.ngModal.open(NewAdminComponent);
+ modalRef.componentInstance.userTitle = `${_adminData.firstName}, ${_adminData.lastName} `+'('+`${_adminData.orgUserId}`+')';
+ modalRef.componentInstance.adminModalData = _adminData;
+ modalRef.componentInstance.dialogState = 2;
+ modalRef.componentInstance.disableBack = true;
+ modalRef.componentInstance.passBackNewAdminPopup.subscribe((_result: any) => {
+ modalRef.close();
+ this.showSpinner = true;
+ this.getAccoutAdminsData();
+ }, (_reason: any) => {
+ return;
+ });
+ }
+
+ applyFilterByAppName(filterValue: string) {
+
+ }
+
+ applyFilter(filterValue: string) {
+ this.adminsDataSource.filter = filterValue.trim().toLowerCase();
+ }
+
+
+ getAccoutAdminsData() {
+ this.adminsService.getAccountAdmins().subscribe((_res: Admins[]) => {
+ this.showSpinner = false;
+ this.adminsData = _res;
+ this.adminsDataSource = new MatTableDataSource(this.adminsData);
+ this.adminsDataSource.sort = this.sort;
+ this.adminsDataSource.paginator = this.paginator;
+ });
+ }
+
+ getAllApps() {
+ this.applicationService.getAvailableApps().subscribe((_res: AllApps[]) => {
+ var realAppIndex = 1;
+ for (let i = 1; i <= _res.length; i++) {
+ if (!_res[i - 1].restrictedApp) {
+ this.availableApps.push({
+ index: realAppIndex,
+ title: _res[i - 1].title,
+ value: _res[i - 1].value
+ });
+ realAppIndex = realAppIndex + 1;
+ } else {
+ }
+ }
+ });
+ }
+
+}
diff --git a/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.html b/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.html
new file mode 100644
index 00000000..c43e4ba1
--- /dev/null
+++ b/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.html
@@ -0,0 +1,96 @@
+<!--
+ ============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" *ngIf="dialogState===1">
+ <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">
+ <app-search-users [searchTitle]="searchTitleText" [placeHolder]="placeholderText" (passBackSelectedUser)='changeSelectedUser($event)'></app-search-users>
+ <span class="onap-spinner" *ngIf="isLoading"></span>
+ </div>
+ <div class="modal-footer">
+ <button type="submit" class="btn btn-primary" [disabled]='!changedSelectedUser'
+ (click)="getAdminAppsRoles()">Next</button> &nbsp;
+ <button type="button" class="btn btn-primary" (click)="activeModal.close('Close')">Close</button>
+ </div>
+</div>
+<div class="container" *ngIf="dialogState===2">
+ <div class="modal-header">
+ <h4 class="modal-title">{{userTitle}}</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 adminApps">
+ <div ngbDropdown class="d-inline-block">
+ <h4>Administrates:</h4>
+ <button class="btn btn-outline-primary" id="dropdownBasic1" ngbDropdownToggle>Select Application</button>
+ <div ngbDropdownMenu aria-labelledby="dropdownBasic1">
+ <button *ngFor="let app of adminDropdownApps" (click)="updateDropdown(app, true)"
+ ngbDropdownItem>{{app.appName}}</button>
+ </div>
+ </div>
+ <!-- User admins list -->
+ <div class="container adminApps" *ngIf="adminAppsRoles.length > 0">
+ <table mat-table [dataSource]="adminsAppsSource">
+ <!-- Search Result Column-->
+ <ng-container matColumnDef="applications">
+ <th id="rowheader-result" mat-header-cell *matHeaderCellDef> Applications <span id="i-delete-application"
+ class="span-remove-title"> Delete </span></th>
+ <td id="table-data-{{i}}" mat-cell *matCellDef="let element; let i = index;">
+ {{element.appName}} <span id="i-delete-application" class="span-remove-admin"
+ (click)="removeAdminApp(element)"><i class="icon ion-md-trash"></i></span>
+ </td>
+ </ng-container>
+ <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
+ <tr mat-row id="table-row-{{i}}" *matRowDef="let row; columns: displayedColumns; let i = index;"></tr>
+ </table>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button [hidden]="disableBack" type="submit" class="btn btn-primary" [disabled]='!changedSelectedUser'
+ (click)="navigateBack()">Back</button> &nbsp;
+ <button type="submit" class="btn btn-primary" [disabled]='!newAppSelected'
+ (click)="updateAdminAppsRoles(adminAppsScreen)">Save</button> &nbsp;
+ <button type="button" class="btn btn-primary" (click)="activeModal.close('Close')">Close</button>
+ </div>
+</div> \ No newline at end of file
diff --git a/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.scss b/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.scss
new file mode 100644
index 00000000..eb6db14c
--- /dev/null
+++ b/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.scss
@@ -0,0 +1,58 @@
+/*-
+ * ============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============================================
+ *
+ *
+ */
+.container.adminApps {
+ overflow-y: auto;
+ height: 250px;
+}
+
+.dropdown-menu.show {
+ overflow-y: auto !important;
+ height: 250px !important;
+}
+.span-remove-title {
+ float: right;
+}
+.span-remove-admin {
+ float: right;
+ 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/admins/new-admin/new-admin.component.spec.ts b/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.spec.ts
new file mode 100644
index 00000000..4040b0d3
--- /dev/null
+++ b/portal-FE-common/src/app/pages/admins/new-admin/new-admin.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 { NewAdminComponent } from './new-admin.component';
+
+describe('NewAdminComponent', () => {
+ let component: NewAdminComponent;
+ let fixture: ComponentFixture<NewAdminComponent>;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ NewAdminComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(NewAdminComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.ts b/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.ts
new file mode 100644
index 00000000..8f80138e
--- /dev/null
+++ b/portal-FE-common/src/app/pages/admins/new-admin/new-admin.component.ts
@@ -0,0 +1,228 @@
+/*-
+ * ============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, Output, EventEmitter, Input } from '@angular/core';
+import { AdminsService } from 'src/app/shared/services';
+import { HttpErrorResponse } from '@angular/common/http';
+import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
+import { NgbModal, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
+import { PortalAdmin } from 'src/app/shared/model';
+import { MatTableDataSource } from '@angular/material';
+import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
+import { Router } from '@angular/router';
+
+@Component({
+ selector: 'app-new-admin',
+ templateUrl: './new-admin.component.html',
+ styleUrls: ['./new-admin.component.scss']
+})
+export class NewAdminComponent implements OnInit {
+
+ @Input() dialogState: number;
+ @Input() userTitle: string;
+ @Input() disableBack: boolean;
+ @Input() adminModalData: any;
+ @Output() passBackNewAdminPopup: EventEmitter<any> = new EventEmitter();
+ searchTitleText = 'Enter First Name, Last Name or Org User Id';
+ placeholderText = 'Search';
+ changedSelectedUser: PortalAdmin;
+ adminAppsRoles: any;
+ adminDropdownApps: any;
+ isLoading: boolean;
+ newAppSelected: boolean;
+ adminAppSelectAndUnselectData: any;
+ displayedColumns: string[] = ['applications'];
+ adminsAppsSource = new MatTableDataSource(this.adminAppsRoles);
+ constructor(public router: Router, private adminsService: AdminsService, public ngModal: NgbModal, public activeModal: NgbActiveModal) { }
+
+ ngOnInit() {
+ this.adminAppsRoles = [];
+ this.changedSelectedUser = null;
+ if (this.disableBack){
+ this.changedSelectedUser = this.adminModalData;
+ this.getAdminAppsRoles();
+ }
+ this.adminDropdownApps = [];
+ this.adminAppSelectAndUnselectData = [];
+ }
+
+ changeSelectedUser(user: PortalAdmin) {
+ this.changedSelectedUser = user;
+ this.userTitle = `${this.changedSelectedUser.firstName}, ` + ` ${this.changedSelectedUser.lastName} ` + ` (${this.changedSelectedUser.orgUserId})`;
+ }
+
+ getAdminAppsRoles() {
+ this.isLoading = true;
+ this.adminsService.getAdminAppsRoles(this.changedSelectedUser.orgUserId).subscribe((_res: any) => {
+ JSON.stringify(_res);
+ if (!_res.appsRoles) {
+ return;
+ }
+ this.adminAppsRoles = [];
+ for (var i = 0; i < _res.appsRoles.length; i++) {
+ if (!_res.appsRoles[i].restrictedApp && _res.appsRoles[i].isAdmin) {
+ this.adminAppsRoles.push({
+ id: _res.appsRoles[i].id,
+ appName: _res.appsRoles[i].appName,
+ isAdmin: _res.appsRoles[i].isAdmin,
+ restrictedApp: _res.appsRoles[i].restrictedApp
+ });
+ } else if (!_res.appsRoles[i].restrictedApp) {
+ this.adminDropdownApps.push({
+ id: _res.appsRoles[i].id,
+ appName: _res.appsRoles[i].appName,
+ isAdmin: _res.appsRoles[i].isAdmin,
+ restrictedApp: _res.appsRoles[i].restrictedApp
+ });
+ }
+ }
+ this.isLoading = false;
+ this.newAppSelected = false;
+ this.dialogState = 2;
+ this.adminsAppsSource = new MatTableDataSource(this.adminAppsRoles);
+ });
+ }
+
+ navigateBack() {
+ this.dialogState = 1;
+ }
+
+ removeAdminApp(app: any) {
+ const modalRef = this.ngModal.open(InformationModalComponent);
+ modalRef.componentInstance.title = "Confirmation";
+ modalRef.componentInstance.message = `Are you sure you want to delete ${app.appName}?`;
+ modalRef.result.then((result) => {
+ if (result === 'Ok') {
+ this.adminAppsRoles.forEach((item: any, index: any) => {
+ if (item === app) this.adminAppsRoles.splice(index, 1);
+ });
+ //call from delete admin app
+ this.updateDropdown(app, false);
+ this.adminsAppsSource = new MatTableDataSource(this.adminAppsRoles);
+ }
+ }, (resut) => {
+ return;
+ })
+ }
+
+ updateDropdown(_newValue: any, isDropdownCall: boolean) {
+ // app is selected from dropdown
+ if (isDropdownCall) {
+ this.adminDropdownApps.forEach((item: any, index: any) => {
+ if (item === _newValue) this.adminDropdownApps.splice(index, 1);
+ });
+ this.getadminAppSelectAndUnselectedData(_newValue);
+ _newValue.isAdmin = true;
+ this.adminAppsRoles.push(_newValue);
+ this.adminsAppsSource = new MatTableDataSource(this.adminAppsRoles);
+ } else { // app is removed from the admin list
+ this.getadminAppSelectAndUnselectedData(_newValue);
+ _newValue.isAdmin = false;
+ this.adminDropdownApps.push(_newValue);
+ }
+
+ // disable save button if nothing new in the admin list
+ if (this.adminAppSelectAndUnselectData.length > 0)
+ this.newAppSelected = true;
+ else
+ this.newAppSelected = false;
+
+ }
+
+ private getadminAppSelectAndUnselectedData(_newValue: any) {
+ const index: number = this.adminAppSelectAndUnselectData.indexOf(_newValue);
+ if (index !== -1) {
+ this.adminAppSelectAndUnselectData.splice(index, 1); // if found, remove selected app from dropdown in the list
+ }
+ else {
+ this.adminAppSelectAndUnselectData.push(_newValue);
+ }
+ }
+
+ remindToAddUserIfNecessary() {
+ let adminAddedToNewApp = true;
+ if ((this.adminAppsRoles != null) && (this.adminAppsRoles.length > 0)) {
+ for (var i = 0; i < this.adminAppSelectAndUnselectData.length; i++) {
+ var foundApp = false;
+ for (var j = 0; j < this.adminAppsRoles.length; j++) {
+ if (this.adminAppsRoles[j] === this.adminAppSelectAndUnselectData[i]) {
+ foundApp = true;
+ }
+ }
+ if (foundApp === false) {
+ adminAddedToNewApp = true;
+ break;
+ }
+ }
+ } else {
+ adminAddedToNewApp = true;
+ }
+ if (adminAddedToNewApp === true) {
+ const modalRef = this.ngModal.open(InformationModalComponent);
+ modalRef.componentInstance.title = "Confirmation";
+ modalRef.componentInstance.message = 'Add this person as an application user? This allows them to access the application from ONAP Portal. Press OK to go to the Add Users page.';
+ modalRef.result.then((_res) => {
+ if (_res === 'Ok') {
+ this.router.navigate(['/users']);
+ }
+ });
+ }
+ }
+
+ updateAdminAppsRoles() {
+ const modalRef = this.ngModal.open(InformationModalComponent);
+ modalRef.componentInstance.title = "Admin Update";
+ modalRef.componentInstance.message = 'Are you sure you want to make these admin changes?';
+ modalRef.result.then((result) => {
+ if (result === 'Ok') {
+ this.adminsService.updateAdminAppsRoles({ orgUserId: this.changedSelectedUser.orgUserId, appsRoles: this.adminAppsRoles }).subscribe(_data => {
+ this.passBackNewAdminPopup.emit(_data);
+ this.remindToAddUserIfNecessary();
+ }, (_err: HttpErrorResponse) => {
+ this.passBackNewAdminPopup.emit(_err);
+ const modalErrorRef = this.ngModal.open(ConfirmationModalComponent);
+ modalErrorRef.componentInstance.title = "Error";
+ if (_err.status) {
+ modalErrorRef.componentInstance.message = "There was a unknown problem while adding admin to selected application(s)." + "Please try again later. Error Status: " + _err.status;
+ }
+ });
+ }
+ }, (reason) => {
+ return;
+ });
+ }
+}