github.com/in4it/ecs-deploy@v0.0.42-0.20240508120354-ed77ff16df25/webapp/src/app/service-detail/inspect.component.ts (about) 1 import { Component, OnInit, ViewChild } from '@angular/core'; 2 import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap'; 3 import { ServiceDetail, ServiceDetailService } from './service-detail.service'; 4 5 import * as moment from 'moment'; 6 7 @Component({ 8 selector: 'app-service-detail-inspect', 9 templateUrl: './inspect.component.html', 10 }) 11 export class InspectChildComponent implements OnInit { 12 13 closeResult: string; 14 selectedVersion: string; 15 loading: boolean = false; 16 serviceName: string; 17 deployment: any 18 19 @ViewChild('inspect', { static: true }) inspectModal : NgbModal; 20 21 constructor( 22 private modalService: NgbModal, 23 private sds: ServiceDetailService 24 ) {} 25 26 ngOnInit(): void { 27 28 } 29 30 open(serviceName, selectedVersion) { 31 if(!selectedVersion) { 32 return 33 } 34 this.loading = true 35 this.serviceName = serviceName 36 this.selectedVersion = selectedVersion 37 this.modalService.open(this.inspectModal, { windowClass: 'inspect-modal' } ).result.then((result) => { 38 this.closeResult = `Closed with: ${result}`; 39 }, (reason) => { 40 this.closeResult = `Dismissed ${this.getDismissReason(reason)}`; 41 }); 42 this.sds.getDeployment(selectedVersion).subscribe(data => { 43 this.loading = false 44 data['deployment']["deploymentMoment"] = moment(this.selectedVersion).format('LLL') + " UTC" 45 this.deployment = data["deployment"] 46 }) 47 } 48 private getDismissReason(reason: any): string { 49 if (reason === ModalDismissReasons.ESC) { 50 return 'by pressing ESC'; 51 } else if (reason === ModalDismissReasons.BACKDROP_CLICK) { 52 return 'by clicking on a backdrop'; 53 } else { 54 return `with: ${reason}`; 55 } 56 } 57 }