This is an automated email from the ASF dual-hosted git repository.
gongchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
The following commit(s) were added to refs/heads/master by this push:
new 467c59580 Fixed issue of plugin-upload form (#2267)
467c59580 is described below
commit 467c595802b761b655e2ca0250d1ff2680076e0b
Author: Kerwin Bryant <[email protected]>
AuthorDate: Thu Jul 11 15:58:05 2024 +0800
Fixed issue of plugin-upload form (#2267)
---
.../routes/setting/plugins/plugin.component.html | 15 +++++++--
.../app/routes/setting/plugins/plugin.component.ts | 37 +++++++++++++++-------
2 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/web-app/src/app/routes/setting/plugins/plugin.component.html
b/web-app/src/app/routes/setting/plugins/plugin.component.html
index 3eec55b24..fd749ed97 100644
--- a/web-app/src/app/routes/setting/plugins/plugin.component.html
+++ b/web-app/src/app/routes/setting/plugins/plugin.component.html
@@ -124,15 +124,24 @@
<form [formGroup]="pluginForm" nz-form>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired="true" nzFor="name">{{
'plugin.name' | i18n }}</nz-form-label>
- <nz-form-control [nzSpan]="14" nzErrorTip="Please input the name">
+ <nz-form-control [nzSpan]="14" [nzErrorTip]="'validation.required' |
i18n">
<input nz-input formControlName="name" id="name" />
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired="true" nzFor="jarFile">{{
'plugin.jar.file' | i18n }}</nz-form-label>
- <nz-form-control [nzSpan]="14" nzErrorTip="Please upload a file">
- <nz-upload nzAccept=".jar" nzAction="" nzListType="text"
[(nzFileList)]="fileList" [nzBeforeUpload]="beforeUpload">
+ <nz-form-control [nzSpan]="14" [nzErrorTip]="'validation.required' |
i18n">
+ <nz-upload
+ nzAccept=".jar"
+ nzAction=""
+ nzListType="text"
+ ngDefaultControl
+ formControlName="jarFile"
+ [(nzFileList)]="fileList"
+ [nzRemove]="fileRemove"
+ [nzBeforeUpload]="beforeUpload"
+ >
<button nz-button>
<i nz-icon nzType="upload"></i>
{{ 'common.file.select' | i18n }}
diff --git a/web-app/src/app/routes/setting/plugins/plugin.component.ts
b/web-app/src/app/routes/setting/plugins/plugin.component.ts
index b07239abb..450cbb2b4 100644
--- a/web-app/src/app/routes/setting/plugins/plugin.component.ts
+++ b/web-app/src/app/routes/setting/plugins/plugin.component.ts
@@ -76,6 +76,13 @@ export class SettingPluginsComponent implements OnInit {
return false;
};
+ fileRemove = (): boolean => {
+ this.pluginForm.patchValue({
+ jarFile: null
+ });
+ return true;
+ };
+
loadPluginsTable() {
this.tableLoading = true;
let pluginsInit$ = this.pluginService.loadPlugins(this.search, 1,
this.pageIndex - 1, this.pageSize).subscribe(
@@ -232,17 +239,24 @@ export class SettingPluginsComponent implements OnInit {
formData.append('name', this.pluginForm.get('name')?.value);
formData.append('jarFile', this.fileList[0] as any);
formData.append('enableStatus',
this.pluginForm.get('enableStatus')?.value);
- this.pluginService.uploadPlugin(formData).subscribe((message: any) => {
- if (message.code === 0) {
- this.isManageModalVisible = false;
- this.resetForm();
-
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.new-success'), '');
- this.loadPluginsTable();
- } else {
- this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'),
message.msg);
- }
- this.isManageModalOkLoading = false;
- });
+ const uploadPlugin$ = this.pluginService
+ .uploadPlugin(formData)
+ .pipe(
+ finalize(() => {
+ uploadPlugin$.unsubscribe();
+ this.isManageModalOkLoading = false;
+ })
+ )
+ .subscribe((message: any) => {
+ if (message.code === 0) {
+ this.isManageModalVisible = false;
+ this.resetForm();
+
this.notifySvc.success(this.i18nSvc.fanyi('common.notify.new-success'), '');
+ this.loadPluginsTable();
+ } else {
+ this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'),
message.msg);
+ }
+ });
} else {
Object.values(this.pluginForm.controls).forEach(control => {
if (control.invalid) {
@@ -250,6 +264,7 @@ export class SettingPluginsComponent implements OnInit {
control.updateValueAndValidity({ onlySelf: true });
}
});
+ this.isManageModalOkLoading = false;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]