diff options
author | 2025-01-15 14:34:27 +0800 | |
---|---|---|
committer | 2025-01-15 14:57:45 +0800 | |
commit | d67b4b25e73bba60cc72a5c1c68e178d9ad93b3c (patch) | |
tree | d355b1f34cb9449408e04d380d660f337b159db7 /usecaseui-portal/src/app/views/maas/build/edit-application/edit-application.component.ts | |
parent | c20b305db465c51364c8c62d61fc6c964c8000d7 (diff) |
Add functionality
1. Added upload and delete files on the knowledge base details page.
2. The knowledge base editing page can only edit the description, not the name.
3. Add some editable items to the app editing page.
Issue-ID: USECASEUI-844
Change-Id: I24b9c84021092fc866c029994b21c2e0f8d2a6be
Signed-off-by: kaixiliu <liukaixi@chinamobile.com>
Diffstat (limited to 'usecaseui-portal/src/app/views/maas/build/edit-application/edit-application.component.ts')
-rw-r--r-- | usecaseui-portal/src/app/views/maas/build/edit-application/edit-application.component.ts | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/usecaseui-portal/src/app/views/maas/build/edit-application/edit-application.component.ts b/usecaseui-portal/src/app/views/maas/build/edit-application/edit-application.component.ts deleted file mode 100644 index 380cd5ff..00000000 --- a/usecaseui-portal/src/app/views/maas/build/edit-application/edit-application.component.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { MaasApi } from '@src/app/api/maas.api'; -import { NzMessageService } from 'ng-zorro-antd'; -import { Application } from '../application.type'; - -@Component({ - selector: 'app-edit-application', - templateUrl: './edit-application.component.html', - styleUrls: ['./edit-application.component.less'] -}) -export class EditApplicationComponent implements OnInit { - title = 'Edit Application'; - @Input() showModal: boolean; - @Input() applicationId: string; - @Output() modalOpreation = new EventEmitter(); - validateForm: FormGroup; - defalutApplication: Application = { - 'applicationId': '', - 'applicationName': '', - 'applicationDescription': '', - 'applicationType': '', - 'operatorId': '', - 'operatorName': '', - 'maaSPlatformId': '', - 'maaSPlatformName': '', - 'knowledgeBaseName': '', - 'knowledgeBaseId': '', - 'largeModelName': '', - 'largeModelId': '', - 'prompt': '', - 'temperature': 3, - 'top_p': 3, - 'openingRemarks': '', - } - application: Application = this.defalutApplication; - constructor( - private myhttp: MaasApi, - private message: NzMessageService, - private fb: FormBuilder, - ) { } - - ngOnInit() { - this.validateForm = this.fb.group({ - name: [this.application.applicationName, [Validators.required]], - description: [this.application.applicationDescription], - }); - this.fetchApplication(); - } - - checkForm(): void { - for (const i in this.validateForm.controls) { - this.validateForm.controls[i].markAsDirty(); - this.validateForm.controls[i].updateValueAndValidity(); - } - } - - submitForm(): void { - this.checkForm(); - this.create(); - } - - fetchApplication(): void { - this.myhttp.getApplicationById(this.applicationId) - .subscribe( - (response) => { - if (response.result_header.result_code !== 200) { - this.message.error('get application error'); - return; - } - this.application = response.result_body; - this.validateForm.patchValue({ - name: this.application.applicationName, - description: this.application.applicationDescription - }); - }, - () => { - this.message.error('Failed to obtain knowledge base data'); - } - ) - } - - handleCancel(): void { - this.showModal = false; - this.modalOpreation.emit({ 'cancel': true }); - } - - create() { - const metaData = { - ...this.application, - applicationName: this.validateForm.get('name').value, - applicationDescription: this.validateForm.get('description').value, - }; - this.myhttp.updateApplication(metaData).subscribe( - (response) => { - if (response.result_header.result_code === 200) { - this.message.success('update knowledge base successfully'); - } else { - this.message.error(response.result_header.result_message); - } - this.modalOpreation.emit({ 'cancel': false }); - }, - (error) => { - console.log('Upload failed', error); - } - ); - } - -} |