summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/views/maas/use
diff options
context:
space:
mode:
Diffstat (limited to 'usecaseui-portal/src/app/views/maas/use')
-rw-r--r--usecaseui-portal/src/app/views/maas/use/use-application.component.html47
-rw-r--r--usecaseui-portal/src/app/views/maas/use/use-application.component.ts76
2 files changed, 60 insertions, 63 deletions
diff --git a/usecaseui-portal/src/app/views/maas/use/use-application.component.html b/usecaseui-portal/src/app/views/maas/use/use-application.component.html
index c0a8fe78..52322960 100644
--- a/usecaseui-portal/src/app/views/maas/use/use-application.component.html
+++ b/usecaseui-portal/src/app/views/maas/use/use-application.component.html
@@ -14,30 +14,31 @@
limitations under the License.
-->
<div class="container">
-<div class="fixed-select-wrapper">
- <nz-select nzPlaceHolder="Select Application" style="width: 200px;" [(ngModel)]="selectedName">
- <nz-option *ngFor="let option of options" [nzValue]="option.nzValue" [nzLabel]="option.nzLabel"></nz-option>
- </nz-select>
-</div>
-<div class="chat-container">
- <div *ngFor="let chat of chatHistory">
- <div class="question">
- <img src="assets/images/user.png">
- <span>{{ chat.question }}</span>
- </div>
- <br>
- <div class="answer">
- <img src="assets/images/answer.png">
- <span>{{ chat.answer }}</span>
+ <div class="fixed-select-wrapper">
+ <nz-select nzPlaceHolder="Select Application" style="width: 200px;" [(ngModel)]="selectedName">
+ <nz-option *ngFor="let option of options" [nzValue]="option.nzValue" [nzLabel]="option.nzLabel"></nz-option>
+ </nz-select>
+ </div>
+ <div class="chat-container">
+ <div *ngFor="let chat of chatHistory">
+ <div class="question">
+ <img src="assets/images/user.png">
+ <span>{{ chat.question }}</span>
+ </div>
+ <br>
+ <div class="answer">
+ <img src="assets/images/answer.png">
+ <span>{{ chat.answer }}</span>
+ </div>
+ <br>
</div>
- <br>
</div>
-</div>
-<div class="input-wrapper">
- <textarea nz-tooltip nz-input [nzAutosize]="{ minRows: 2, maxRows: 2 }" [(ngModel)]="question" class="text-input"></textarea>
- <i class="icon" (click)="submitQuestion()">
- <img src="assets/images/send.png">
- </i>
-</div>
+ <div class="input-wrapper">
+ <textarea nz-tooltip nz-input [nzAutosize]="{ minRows: 2, maxRows: 2 }" [(ngModel)]="question"
+ class="text-input"></textarea>
+ <i class="icon" (click)="submitQuestion()">
+ <img src="assets/images/send.png">
+ </i>
+ </div>
</div> \ No newline at end of file
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');
+ }
+ )
}
}