diff options
author | liuwh7 <liuwh7@asiainfo.com> | 2021-09-15 09:57:09 +0800 |
---|---|---|
committer | liu wenhao <liuwh7@asiainfo.com> | 2021-09-16 07:15:07 +0000 |
commit | c437d5360c75c1af5417c3681235a0f8015a9a85 (patch) | |
tree | 69059fede467020a0b964f08ae56a999f85ffeb2 /usecaseui-portal/src/app/views/services/intent-based-services/smart-cloud-leased-modal/smart-cloud-leased-modal.component.ts | |
parent | 9c8070280f88e0094acb83ee78251bb4f9690e2e (diff) |
feat: add intent based service
Signed-off-by: liuwh7 <liuwh7@asiainfo.com>
Change-Id: If63eb5e61f01751771ad090728f33214077edd6f
Issue-ID: USECASEUI-605
Diffstat (limited to 'usecaseui-portal/src/app/views/services/intent-based-services/smart-cloud-leased-modal/smart-cloud-leased-modal.component.ts')
-rw-r--r-- | usecaseui-portal/src/app/views/services/intent-based-services/smart-cloud-leased-modal/smart-cloud-leased-modal.component.ts | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/usecaseui-portal/src/app/views/services/intent-based-services/smart-cloud-leased-modal/smart-cloud-leased-modal.component.ts b/usecaseui-portal/src/app/views/services/intent-based-services/smart-cloud-leased-modal/smart-cloud-leased-modal.component.ts new file mode 100644 index 00000000..014a1c4c --- /dev/null +++ b/usecaseui-portal/src/app/views/services/intent-based-services/smart-cloud-leased-modal/smart-cloud-leased-modal.component.ts @@ -0,0 +1,90 @@ +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +import { NzMessageService } from 'ng-zorro-antd'; +import { intentBaseService } from '../../../../core/services/intentBase.service'; +import { Recorder } from '../../../../shared/utils/recorder'; +import { Util } from '../../../../shared/utils/utils'; + +@Component({ + selector: 'app-smart-cloud-leased-modal', + templateUrl: './smart-cloud-leased-modal.component.html', + styleUrls: ['./smart-cloud-leased-modal.component.less'] +}) +export class SmartCloudLeasedModalComponent implements OnInit { + + constructor( + private Util: Util, + private Recorder: Recorder, + private myhttp: intentBaseService, + private msg: NzMessageService + ) {} + + @Input() samrtCloudLeasedLineShowFlag: boolean; + @Output() resolveEmitter = new EventEmitter(); + + communicationMessage: String = ""; + validateRulesShow: any[] = []; + rulesText: any[] = []; + radioValue: String = 'text'; + isPlay: boolean = false; + clickRepeat: boolean = false; + isDisable: boolean = true; + + ngOnInit() { + this.validateRulesShow = []; + this.rulesText = []; + this.communicationMessage = ''; + } + + ngOnChange() {} + + handleCancel(flag): void { + this.samrtCloudLeasedLineShowFlag = false; + this.communicationMessage = ""; + this.resolveEmitter.emit({ "cancel": flag }); + } + + handleOk(): void { + if (this.radioValue === 'text') { + this.submitFormMessage(); + return; + } + + } + + submitFormAudio() { + this.handleCancel(false); + } + + submitFormMessage(): void { + let params = { + "title": "predict", + "text": this.communicationMessage + }; + this.myhttp.intentInstancePredict(params).subscribe( + (response) => { + console.log(response); + this.handleCancel(false); + }, + (err) => { + console.log(err); + } + ) + } + + startAudio(): void { + this.isPlay = true; + this.isDisable = true; + this.Recorder.beforeStartRecord(); + } + + stopAudio(): void { + this.isPlay = false; + this.isDisable = false; + this.Recorder.stopRecord(); + } + + playAudio(): void { + let audio = document.querySelector('audio'); + audio["src"] = this.Recorder.playRecord(); + } +} |