1 import { Component, OnInit } from '@angular/core';
2 import { NzMessageService } from "ng-zorro-antd";
3 import { MaasService } from '@src/app/core/services/maas.service';
4 import { KnowledgeBase } from './knowledge-base.type';
7 selector: 'app-knowledge-base-management',
8 templateUrl: './knowledge-base-management.component.html',
9 styleUrls: ['./knowledge-base-management.component.less']
11 export class KnowledgeBaseManagementComponent implements OnInit {
12 editKnowledgeBaseShow = false;
14 data: KnowledgeBase[] = [];
15 createModalShow: boolean = false;
16 knowledgeBaseShow: boolean = false;
17 knowledgeBaseDetail: Object = {};
20 private myhttp: MaasService,
21 private message: NzMessageService
25 this.getKnowledgeBaseData()
28 getKnowledgeBaseData(): void {
29 this.myhttp.getKnowledgeBaseRecord()
32 this.data = data.result_body
35 this.message.error('Failed to obtain knowledgeBase data');
41 this.createModalShow = true;
43 createModalClose($event: any): void {
44 this.createModalShow = false;
48 this.getKnowledgeBaseData()
51 editKnowledgeBaseModuleClose($event: any): void {
52 this.editKnowledgeBaseShow = false;
56 this.getKnowledgeBaseData()
59 knowledgeBaseDetailClose($event: any): void {
60 this.knowledgeBaseShow = false;
63 deleteKnowledgeBase(data): void {
64 this.myhttp.deleteKnowledgeBaseData(data.knowledgeBaseId).subscribe((data) => {
65 this.getKnowledgeBaseData()
66 if (data.result_header.result_code === 200) {
67 this.message.success('Deleted successfully');
69 this.message.error(data.result_header.result_message);
72 this.message.error('Deletion failed');
76 displayKnowledgeDetails(data): void {
77 this.knowledgeBaseShow = true;
78 this.myhttp.getKnowledgeBaseById(data.knowledgeBaseId)
81 this.knowledgeBaseDetail = data.result_body;
84 this.message.error('Failed to obtain knowledge base data');
89 editKnowedgeBase(data) {
90 this.knowledgeBaseId = data.knowledgeBaseId;
91 this.editKnowledgeBaseShow = true;