1 import { Component, OnInit } from '@angular/core';
2 import { NzMessageService, NzModalService } from "ng-zorro-antd";
3 import { Router } from '@angular/router';
4 import { MaasApi } from '@src/app/api/maas.api';
5 import { Application } from './application.type';
6 import { modalClose } from '../knowledge-base-management/knowledge-base.type';
7 import { TranslateService } from '@ngx-translate/core';
10 selector: 'app-application-management',
11 templateUrl: './application-management.component.html',
12 styleUrls: ['./application-management.component.less']
14 export class ApplicationManagementComponent implements OnInit {
15 data: Application[] = [];
16 createModalShow = false;
17 applicationShow = false;
18 applicationDetail: Object = {};
19 editModalShow = false;
24 private myhttp: MaasApi,
25 private message: NzMessageService,
26 private router: Router,
27 private modalService: NzModalService,
28 private translate: TranslateService
32 this.getAllApplicationData()
35 getAllApplicationData(): void {
36 this.myhttp.getAllApplication()
39 this.data = data.result_body
40 this.existedNames = this.data.map(item => item.applicationName);
43 this.message.error('Failed to obtain application data');
49 this.createModalShow = true;
52 createModalClose($event: modalClose): void {
53 this.createModalShow = false;
57 this.getAllApplicationData()
60 delete(data: Application): void {
61 this.myhttp.deleteApplicationById(data.applicationId).subscribe((data) => {
62 this.getAllApplicationData()
63 if (data.result_header.result_code === 200) {
64 this.message.success('Deleted successfully');
66 this.message.error(data.result_header.result_message);
69 this.message.error('Deletion failed');
73 navigateToDetail(data: Application): void {
74 this.router.navigate(['maas/use'], { queryParams: { id: data.applicationId, name: data.applicationName } });
77 applicationDetailClose(): void {
78 this.applicationShow = false;
81 displayApplicationDetails(data: Application): void {
82 this.applicationShow = true;
83 this.myhttp.getApplicationById(data.applicationId)
86 this.applicationDetail = data.result_body;
89 this.message.error('Failed to obtain application data');
94 edit(data: Application) {
95 this.applicationId = data.applicationId;
96 this.editModalShow = true;
99 showDeleteConfirm(data: Application): void {
100 this.modalService.confirm({
101 nzTitle: this.translate.instant('maas.deleteTitle'),
102 nzContent: this.translate.instant('maas.application.deleteApplicationContent'),
105 nzOnOk: () => this.delete(data),
107 nzIconType: 'warning',
111 editModalClose($event: modalClose): void {
112 this.editModalShow = false;
116 this.getAllApplicationData()