diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/user-profile/profile/search/search.component.ts')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/user-profile/profile/search/search.component.ts | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/user-profile/profile/search/search.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/user-profile/profile/search/search.component.ts new file mode 100644 index 00000000..734aaf09 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/user-profile/profile/search/search.component.ts @@ -0,0 +1,134 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 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 { ProfileService } from '../profile.service'; +import { MatTableDataSource } from '@angular/material/table'; +import { MatPaginator } from '@angular/material/paginator'; +import { MatSort } from '@angular/material/sort'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; +import { Router } from '@angular/router'; + +@Component({ + selector: 'app-search', + templateUrl: './search.component.html', + styleUrls: ['./search.component.scss'] +}) +export class SearchComponent implements OnInit { + + showSpinner:boolean =false; + response: any; + result: any; + profileList:any; + userHeaders = ["User ID","Last Name","First Name","Email","Org User ID","Org Manager User ID","Edit","Active?"]; + constructor(public profileservice:ProfileService, public ngbModal: NgbModal,private _router: Router) { } + dataSource: MatTableDataSource<[]>; + + @ViewChild(MatPaginator, {}) paginator: MatPaginator; + @ViewChild(MatSort, {}) sort: MatSort; + + ngOnInit() { + this.getUsers(); + } + + getUsers(){ + this.showSpinner = true; + let response; + this.response = this.profileservice.getAllUsers(); + this.response.subscribe(data => { + response = data; + this.result = JSON.parse(response.data); + this.profileList = JSON.parse(this.result.profileList); + this.dataSource = new MatTableDataSource(this.profileList); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + this.showSpinner = false; + }); + } + + toggleUserActive(user, e){ + let activeOrInactive = (e.checked) ? 'activate' : 'inactivate'; + let confirmationMsg = 'You are about to ' + activeOrInactive + ' the user ' + user.first_name +" "+user.last_name+ '. Do you want to continue?'; + const modalInfoRef = this.ngbModal.open(InformationModalComponent); + modalInfoRef.componentInstance.title = 'Confirmation'; + modalInfoRef.componentInstance.message = confirmationMsg; + modalInfoRef.result.then((_res) => { + if (_res === 'Ok') { + this.showSpinner = true; + this.profileservice.toggleProfileActive(user.id) + .subscribe( _data => { + this.result = _data; + this.openConfirmationModal("Success",'Record updated successfully.'); + this.showSpinner = false; + }, error => { + this.showSpinner = false; + console.log(error); + this.openConfirmationModal("Error",error); + }); + } else { + this.ngOnInit(); + } + }, (result) => { + + }) + } + + applyFilter(filterValue: string) { + this.dataSource.filter = filterValue.trim().toLowerCase(); + } + + openConfirmationModal(_title: string, _message: string) { + const modalInfoRef = this.ngbModal.open(ConfirmationModalComponent); + modalInfoRef.componentInstance.title = _title; + modalInfoRef.componentInstance.message = _message; + } + + openInformationModal(_title: string, _message: string){ + const modalInfoRef = this.ngbModal.open(InformationModalComponent); + modalInfoRef.componentInstance.title = _title; + modalInfoRef.componentInstance.message = _message; + return modalInfoRef; + } + + + getUser(id: any) { + this._router.navigate(['v2/userProfile/self_profile'], { queryParams: { profile_id: id } }); +} +} |