2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
39 import { Component, OnInit, ViewChild, Input } from '@angular/core';
40 import { MicroserviceService, WidgetOnboardingService } from '../../shared/services/index'
41 import { IMircroservies } from 'src/app/shared/model/microservice-onboarding/microservices';
42 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
43 import { MatTableDataSource } from '@angular/material';
44 import { MatSort, MatPaginator } from '@angular/material';
45 import { MicroserviceAddDetailsComponent } from './microservice-add-details/microservice-add-details.component';
46 import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
47 import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
50 selector: 'app-microservice-onboarding',
51 templateUrl: './microservice-onboarding.component.html',
52 styleUrls: ['./microservice-onboarding.component.scss']
54 export class MicroserviceOnboardingComponent implements OnInit {
57 microServiceList: Array<IMircroservies> = [];
59 isEditMode: boolean = false;
61 displayedColumns: string[] = ['microserviceName', 'serviceEndPointURL', 'securityType','delete'];
62 dataSource = new MatTableDataSource(this.microServiceList);
63 @ViewChild(MatSort) sort: MatSort;
64 @ViewChild(MatPaginator) paginator: MatPaginator;
66 constructor(public microservice: MicroserviceService, public ngbModal: NgbModal ) { }
69 this.getOnboardingServices();
72 getOnboardingServices(){
73 //console.log("getOnboardingServices called");
74 this.microservice.getServiceList()
77 if (this.result == null || this.result == 'undefined') {
78 console.log('MicroserviceService::getServiceList Failed: Result or result.data is null');
80 this.microServiceList = this.result;
81 this.populateTableData(this.microServiceList);
88 deleteService(microserviceObj: IMircroservies, isConfirmed: boolean): void {
89 let confirmationMsg = 'You are about to delete this Microservice : ' + microserviceObj.name+ '. Click OK to continue.';
90 this.openInformationModal("Confirmation",confirmationMsg).result.then((result) => {
91 if (result === 'Ok') {
92 if(!microserviceObj || microserviceObj == null){
93 console.log('MicroserviceOnboardingCtrl::deleteService: No service or ID... cannot delete');
96 //console.log("service id to delete", microserviceObj.id)
97 this.microServiceList.splice(this.microServiceList.indexOf(microserviceObj), 1);
98 this.populateTableData(this.microServiceList);
99 this.microservice.deleteService(microserviceObj.id)
100 .subscribe( data => {
102 this.microServiceList = [];
103 this.getOnboardingServices();
114 openAddNewMicroserviceModal(rowData: any){
115 //console.log("openAddNewMicroserviceModal getting called...");
116 const modalRef = this.ngbModal.open(MicroserviceAddDetailsComponent, { size: 'lg' });
117 modalRef.componentInstance.title = 'Microservice Onboarding';
118 if(rowData != 'undefined' && rowData){
119 modalRef.componentInstance.ms = rowData;
120 this.isEditMode = true;
122 modalRef.componentInstance.ms = {};
123 this.isEditMode = false;
125 modalRef.componentInstance.passEntry.subscribe((receivedEntry: any) => {
126 //console.log("receivedEntry >>> ",receivedEntry);
128 this.microServiceList = [];
129 this.getOnboardingServices();
134 populateTableData(microServiceList: Array<IMircroservies>){
135 this.dataSource = new MatTableDataSource(microServiceList);
136 this.dataSource.sort = this.sort;
137 this.dataSource.paginator = this.paginator;
140 applyFilter(filterValue: string) {
141 this.dataSource.filter = filterValue.trim().toLowerCase();
144 openConfirmationModal(_title: string, _message: string) {
145 const modalInfoRef = this.ngbModal.open(ConfirmationModalComponent);
146 modalInfoRef.componentInstance.title = _title;
147 modalInfoRef.componentInstance.message = _message;
150 openInformationModal(_title: string, _message: string){
151 const modalInfoRef = this.ngbModal.open(InformationModalComponent);
152 modalInfoRef.componentInstance.title = _title;
153 modalInfoRef.componentInstance.message = _message;