diff options
author | kaixiliu <liukaixi@chinamobile.com> | 2024-12-04 15:10:45 +0800 |
---|---|---|
committer | Kaixi LIU <liukaixi@chinamobile.com> | 2024-12-24 02:22:17 +0000 |
commit | b71bd34b5baa8e3dfedf83f777d62c988c6b9c97 (patch) | |
tree | a5a6a30e6735fe1e2a406746822080043afc65bb /usecaseui-portal/src/app/views/maas/use/use-application.component.ts | |
parent | e5de10348e38a4cac9f70da856ab7c6941bfc347 (diff) |
1. Create a new descripition component code
2. Optimize the code to extract a MaaS feature module and a common module.
3. Optimize the service code and create a new maasService.
4.Click the Q&A Assistant menu, the front-end interface does not deliver an application ID.
Issue-ID: USECASEUI-844
Change-Id: If57938f9c57b186691798eb0fb2cdd2fd64ed58a
Signed-off-by: kaixiliu <liukaixi@chinamobile.com>
Diffstat (limited to 'usecaseui-portal/src/app/views/maas/use/use-application.component.ts')
-rw-r--r-- | usecaseui-portal/src/app/views/maas/use/use-application.component.ts | 76 |
1 files changed, 36 insertions, 40 deletions
diff --git a/usecaseui-portal/src/app/views/maas/use/use-application.component.ts b/usecaseui-portal/src/app/views/maas/use/use-application.component.ts index f2b147c5..96b17fd0 100644 --- a/usecaseui-portal/src/app/views/maas/use/use-application.component.ts +++ b/usecaseui-portal/src/app/views/maas/use/use-application.component.ts @@ -3,8 +3,7 @@ import { NzMessageService } from 'ng-zorro-antd'; import { HttpClient } from '@angular/common/http'; import { SSE } from "sse.js"; import { ActivatedRoute } from '@angular/router'; -import { IntentManagementService } from '../../../core/services/intentManagement.service' - +import { MaasService } from '@src/app/core/services/maas.service'; @Component({ selector: 'app-use-application', @@ -22,53 +21,50 @@ export class UseApplicationComponent implements OnInit { options: any[] = []; constructor( - private http: HttpClient, - private message: NzMessageService, - private route: ActivatedRoute, - private myhttp: IntentManagementService, + private http: HttpClient, + private message: NzMessageService, + private route: ActivatedRoute, + private myhttp: MaasService, ) { } + ngOnInit() { - this.getIntentManagementData(); - this.route.queryParams.subscribe(params => { + this.fetchAllApplication(); + this.route.queryParams.subscribe(params => { this.queryParams = params; - console.log(params.id); - this.selectedName = this.queryParams.id ; + this.selectedName = this.queryParams.id; }); } submitQuestion() { const chatParam = { - applicationId: this.queryParams.id, - question: this.question - }; - var source = new SSE(this.apiUrl,{headers: {'Content-Type': 'application/json'},payload: JSON.stringify(chatParam),method:'POST'}); - var lin = this.question; - const length = this.chatHistory.length; - source.addEventListener('message',(event)=>{ - const existingEntryIndex = this.chatHistory.findIndex(entry => entry.question === lin); - console.log(event.data); - if (existingEntryIndex !== -1) { - this.chatHistory[existingEntryIndex].answer += event.data.replace(/__SPACE__/g, ' '); - } else { - this.chatHistory.push({ question: lin, answer: event.data }); - } - }); - this.question = ''; - } + applicationId: this.selectedName, + question: this.question + }; + const source = new SSE(this.apiUrl, { headers: { 'Content-Type': 'application/json' }, payload: JSON.stringify(chatParam), method: 'POST' }); + const lin = this.question; + source.addEventListener('message', (event) => { + const existingEntryIndex = this.chatHistory.findIndex(entry => entry.question === lin); + if (existingEntryIndex !== -1) { + this.chatHistory[existingEntryIndex].answer += event.data.replace(/__SPACE__/g, ' '); + } else { + this.chatHistory.push({ question: lin, answer: event.data }); + } + }); + this.question = ''; + } - getIntentManagementData():void{ + fetchAllApplication(): void { this.myhttp.getAllApplication() - .subscribe( - (data) => { - this.options = data.result_body.map(item => ({ - nzValue: item.applicationId, - nzLabel: item.applicationName - })); - - }, - () => { - this.message.error('Failed to obtain intent data'); - } - ) + .subscribe( + (data) => { + this.options = data.result_body.map(item => ({ + nzValue: item.applicationId, + nzLabel: item.applicationName + })); + }, + () => { + this.message.error('Failed to obtain intent data'); + } + ) } } |