diff --git a/backend/app/service/app.go b/backend/app/service/app.go
index 464a0fd9f..cdcae46e8 100644
--- a/backend/app/service/app.go
+++ b/backend/app/service/app.go
@@ -258,95 +258,6 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) (
return &appInstall, nil
}
-//func (a AppService) SyncInstalled(installId uint) error {
-// appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(installId))
-// if err != nil {
-// return err
-// }
-//
-// containerNames, err := getContainerNames(appInstall)
-// if err != nil {
-// return err
-// }
-//
-// cli, err := docker.NewClient()
-// if err != nil {
-// return err
-// }
-// containers, err := cli.ListContainersByName(containerNames)
-// if err != nil {
-// return err
-// }
-// var (
-// errorContainers []string
-// notFoundContainers []string
-// runningContainers []string
-// )
-//
-// for _, n := range containers {
-// if n.State != "running" {
-// errorContainers = append(errorContainers, n.Names[0])
-// } else {
-// runningContainers = append(runningContainers, n.Names[0])
-// }
-// }
-// for _, old := range containerNames {
-// exist := false
-// for _, new := range containers {
-// if common.ExistWithStrArray(old, new.Names) {
-// exist = true
-// break
-// }
-// }
-// if !exist {
-// notFoundContainers = append(notFoundContainers, old)
-// }
-// }
-//
-// containerCount := len(containers)
-// errCount := len(errorContainers)
-// notFoundCount := len(notFoundContainers)
-// normalCount := len(containerNames)
-// runningCount := len(runningContainers)
-//
-// if containerCount == 0 {
-// appInstall.Status = constant.ContainerNotFound
-// appInstall.Message = "container is not found"
-// return appInstallRepo.Save(&appInstall)
-// }
-// if errCount == 0 && notFoundCount == 0 {
-// appInstall.Status = constant.Running
-// return appInstallRepo.Save(&appInstall)
-// }
-// if errCount == normalCount {
-// appInstall.Status = constant.Error
-// }
-// if notFoundCount == normalCount {
-// appInstall.Status = constant.Stopped
-// }
-// if runningCount < normalCount {
-// appInstall.Status = constant.UnHealthy
-// }
-//
-// var errMsg strings.Builder
-// if errCount > 0 {
-// errMsg.Write([]byte(string(rune(errCount)) + " error containers:"))
-// for _, e := range errorContainers {
-// errMsg.Write([]byte(e))
-// }
-// errMsg.Write([]byte("\n"))
-// }
-// if notFoundCount > 0 {
-// errMsg.Write([]byte(string(rune(notFoundCount)) + " not found containers:"))
-// for _, e := range notFoundContainers {
-// errMsg.Write([]byte(e))
-// }
-// errMsg.Write([]byte("\n"))
-// }
-// appInstall.Message = errMsg.String()
-// return appInstallRepo.Save(&appInstall)
-//}
-
func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) {
res := &response.AppUpdateRes{
CanUpdate: false,
diff --git a/frontend/src/api/interface/app.ts b/frontend/src/api/interface/app.ts
index 279cca192..a140281fd 100644
--- a/frontend/src/api/interface/app.ts
+++ b/frontend/src/api/interface/app.ts
@@ -56,6 +56,25 @@ export namespace App {
default: any;
envKey: string;
key?: string;
+ values?: ServiceParam[];
+ child?: FromFieldChild;
+ params?: FromParam[];
+ }
+
+ export interface FromFieldChild extends FromField {
+ services: App.AppService[];
+ }
+
+ export interface FromParam {
+ type: string;
+ key: string;
+ value: string;
+ envKey: string;
+ }
+
+ export interface ServiceParam {
+ label: '';
+ value: '';
}
export interface AppInstall {
diff --git a/frontend/src/views/app-store/detail/params/index.vue b/frontend/src/views/app-store/detail/params/index.vue
index 880616586..b112bd947 100644
--- a/frontend/src/views/app-store/detail/params/index.vue
+++ b/frontend/src/views/app-store/detail/params/index.vue
@@ -35,11 +35,47 @@
:label="service.label"
>
-
-
- {{ $t('app.toInstall') }}
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t('app.toInstall') }}
+
+
+
+
@@ -57,6 +93,7 @@ interface ParamObj extends App.FromField {
services: App.AppService[];
prop: string;
disabled: false;
+ childProp: string;
}
const emit = defineEmits(['update:form', 'update:rules']);
@@ -120,18 +157,30 @@ const handleParams = () => {
form[p.envKey] = p.default;
}
if (p.required) {
- if (p.type === 'service') {
+ if (p.type === 'service' || p.type === 'apps') {
rules[p.envKey] = [Rules.requiredSelect];
+ if (p.child) {
+ p.childProp = p.child.envKey;
+ if (p.child.type === 'service') {
+ rules[p.child.envKey] = [Rules.requiredSelect];
+ }
+ }
} else {
rules[p.envKey] = [Rules.requiredInput];
- if (p.rule && p.rule != '') {
- rules[p.envKey].push(Rules[p.rule]);
- }
+ }
+ if (p.rule && p.rule != '') {
+ rules[p.envKey].push(Rules[p.rule]);
}
}
- if (p.key) {
+ if (p.type === 'apps') {
+ getServices(p.child.envKey, p.default, p);
+ p.child.services = [];
+ form[p.child.envKey] = '';
+ }
+ if (p.type === 'service') {
+ getServices(p.envKey, p.key, p);
+ p.services = [];
form[p.envKey] = '';
- getServices(p.envKey, p.key, pObj);
}
emit('update:rules', rules);
updateParam();
@@ -139,28 +188,28 @@ const handleParams = () => {
}
};
-const getServices = async (envKey: string, key: string | undefined, pObj: ParamObj) => {
+const getServices = async (childKey: string, key: string | undefined, pObj: ParamObj | undefined) => {
+ pObj.services = [];
await GetAppService(key).then((res) => {
- pObj.services = res.data;
+ pObj.services = res.data || [];
+ form[childKey] = '';
if (res.data && res.data.length > 0) {
- form[envKey] = res.data[0].value;
- if (res.data[0].config) {
- Object.entries(res.data[0].config).forEach(([k, v]) => {
- params.value.formFields.forEach((field) => {
- if (field.envKey === k) {
- form[k] = v;
- }
- });
+ form[childKey] = res.data[0].value;
+ if (pObj.params) {
+ pObj.params.forEach((param: App.FromParam) => {
+ if (param.key === key) {
+ form[param.envKey] = param.value;
+ }
});
}
- updateParam();
+ changeService(form[childKey], pObj.services);
}
});
};
const changeService = (value: string, services: App.AppService[]) => {
services.forEach((item) => {
- if (item.value === value) {
+ if (item.value === value && item.config) {
Object.entries(item.config).forEach(([k, v]) => {
if (form.hasOwnProperty(k)) {
form[k] = v;