From 092cbbf8dad7103cca9a025493207dc21d35ba2e Mon Sep 17 00:00:00 2001
From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com>
Date: Wed, 22 Mar 2023 15:38:30 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BA=94=E7=94=A8=E7=BC=96=E8=BE=91?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=20select=20=E7=B1=BB=E5=9E=8B=E5=A4=84?=
=?UTF-8?q?=E7=90=86=20(#363)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/app/dto/app.go | 24 ++++++++++++-------
backend/app/dto/response/app.go | 16 +++++++------
backend/app/service/app_install.go | 16 +++++++++----
cmd/server/docs/docs.go | 10 +++++---
cmd/server/docs/swagger.json | 10 +++++---
cmd/server/docs/swagger.yaml | 7 ++++--
frontend/src/api/interface/app.ts | 2 ++
.../views/app-store/detail/params/index.vue | 9 ++++++-
.../app-store/installed/detail/index.vue | 13 +++++++++-
9 files changed, 76 insertions(+), 31 deletions(-)
diff --git a/backend/app/dto/app.go b/backend/app/dto/app.go
index f8245e994..112db01f2 100644
--- a/backend/app/dto/app.go
+++ b/backend/app/dto/app.go
@@ -69,15 +69,21 @@ type AppForm struct {
}
type AppFormFields struct {
- Type string `json:"type"`
- LabelZh string `json:"labelZh"`
- LabelEn string `json:"labelEn"`
- Required bool `json:"required"`
- Default interface{} `json:"default"`
- EnvKey string `json:"envKey"`
- Disabled bool `json:"disabled"`
- Edit bool `json:"edit"`
- Rule string `json:"rule"`
+ Type string `json:"type"`
+ LabelZh string `json:"labelZh"`
+ LabelEn string `json:"labelEn"`
+ Required bool `json:"required"`
+ Default interface{} `json:"default"`
+ EnvKey string `json:"envKey"`
+ Disabled bool `json:"disabled"`
+ Edit bool `json:"edit"`
+ Rule string `json:"rule"`
+ Values []AppFormValue `json:"values"`
+}
+
+type AppFormValue struct {
+ Label string `json:"label"`
+ Value string `json:"value"`
}
type AppResource struct {
diff --git a/backend/app/dto/response/app.go b/backend/app/dto/response/app.go
index 338865dd5..60acbb500 100644
--- a/backend/app/dto/response/app.go
+++ b/backend/app/dto/response/app.go
@@ -61,11 +61,13 @@ type AppService struct {
}
type AppParam struct {
- Value interface{} `json:"value"`
- Edit bool `json:"edit"`
- Key string `json:"key"`
- Rule string `json:"rule"`
- LabelZh string `json:"labelZh"`
- LabelEn string `json:"labelEn"`
- Type string `json:"type"`
+ Value interface{} `json:"value"`
+ Edit bool `json:"edit"`
+ Key string `json:"key"`
+ Rule string `json:"rule"`
+ LabelZh string `json:"labelZh"`
+ LabelEn string `json:"labelEn"`
+ Type string `json:"type"`
+ Values interface{} `json:"values"`
+ ShowValue string `json:"showValue"`
}
diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go
index 1d6ff022d..d7d78b021 100644
--- a/backend/app/service/app_install.go
+++ b/backend/app/service/app_install.go
@@ -486,14 +486,20 @@ func (a *AppInstallService) GetParams(id uint) ([]response.AppParam, error) {
}
appParam.LabelZh = form.LabelZh
appParam.LabelEn = form.LabelEn
+ appParam.Value = v
if form.Type == "service" {
appInstall, _ := appInstallRepo.GetFirst(appInstallRepo.WithServiceName(v.(string)))
- appParam.Value = appInstall.Name
- res = append(res, appParam)
- } else {
- appParam.Value = v
- res = append(res, appParam)
+ appParam.ShowValue = appInstall.Name
+ } else if form.Type == "select" {
+ for _, fv := range form.Values {
+ if fv.Value == v {
+ appParam.ShowValue = fv.Label
+ break
+ }
+ }
+ appParam.Values = form.Values
}
+ res = append(res, appParam)
}
}
return res, nil
diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go
index bfa2ca21a..26d6ba65e 100644
--- a/cmd/server/docs/docs.go
+++ b/cmd/server/docs/docs.go
@@ -1073,7 +1073,7 @@ var doc = `{
],
"responses": {
"200": {
- "description": ""
+ "description": "OK"
}
},
"x-panel-log": {
@@ -6914,7 +6914,7 @@ var doc = `{
],
"responses": {
"200": {
- "description": ""
+ "description": "OK"
}
}
},
@@ -12327,10 +12327,14 @@ var doc = `{
"rule": {
"type": "string"
},
+ "showValue": {
+ "type": "string"
+ },
"type": {
"type": "string"
},
- "value": {}
+ "value": {},
+ "values": {}
}
},
"response.FileInfo": {
diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json
index 3f59dba72..75a2d5312 100644
--- a/cmd/server/docs/swagger.json
+++ b/cmd/server/docs/swagger.json
@@ -1059,7 +1059,7 @@
],
"responses": {
"200": {
- "description": ""
+ "description": "OK"
}
},
"x-panel-log": {
@@ -6900,7 +6900,7 @@
],
"responses": {
"200": {
- "description": ""
+ "description": "OK"
}
}
},
@@ -12313,10 +12313,14 @@
"rule": {
"type": "string"
},
+ "showValue": {
+ "type": "string"
+ },
"type": {
"type": "string"
},
- "value": {}
+ "value": {},
+ "values": {}
}
},
"response.FileInfo": {
diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml
index 5943cb78b..41522706c 100644
--- a/cmd/server/docs/swagger.yaml
+++ b/cmd/server/docs/swagger.yaml
@@ -2441,9 +2441,12 @@ definitions:
type: string
rule:
type: string
+ showValue:
+ type: string
type:
type: string
value: {}
+ values: {}
type: object
response.FileInfo:
properties:
@@ -3288,7 +3291,7 @@ paths:
$ref: '#/definitions/dto.ComposeCreate'
responses:
"200":
- description: ""
+ description: OK
security:
- ApiKeyAuth: []
summary: Test compose
@@ -7005,7 +7008,7 @@ paths:
$ref: '#/definitions/dto.Upgrade'
responses:
"200":
- description: ""
+ description: OK
security:
- ApiKeyAuth: []
summary: Load release notes by version
diff --git a/frontend/src/api/interface/app.ts b/frontend/src/api/interface/app.ts
index 87d731c9c..cc2372251 100644
--- a/frontend/src/api/interface/app.ts
+++ b/frontend/src/api/interface/app.ts
@@ -163,5 +163,7 @@ export namespace App {
key: string;
rule: string;
type: string;
+ values?: any;
+ showValue?: string;
}
}
diff --git a/frontend/src/views/app-store/detail/params/index.vue b/frontend/src/views/app-store/detail/params/index.vue
index ad2561510..9aedb4bee 100644
--- a/frontend/src/views/app-store/detail/params/index.vue
+++ b/frontend/src/views/app-store/detail/params/index.vue
@@ -42,7 +42,14 @@
{{ $t('app.toInstall') }}
-
+
+
+
diff --git a/frontend/src/views/app-store/installed/detail/index.vue b/frontend/src/views/app-store/installed/detail/index.vue
index d15ff4c9e..a9e35e8ee 100644
--- a/frontend/src/views/app-store/installed/detail/index.vue
+++ b/frontend/src/views/app-store/installed/detail/index.vue
@@ -11,7 +11,7 @@
- {{ param.value }}
+ {{ param.showValue && param.showValue != '' ? param.showValue : param.value }}
@@ -26,6 +26,15 @@
v-model.number="paramModel[p.key]"
:disabled="!p.edit"
>
+
+
+
@@ -116,6 +125,8 @@ const get = async () => {
edit: d.edit,
key: d.key,
type: d.type,
+ values: d.values,
+ showValue: d.showValue,
});
rules[d.key] = [Rules.requiredInput];
if (d.rule) {