diff --git a/backend/app/api/v1/compose_template.go b/backend/app/api/v1/compose_template.go index 75f1ea8a3..18ed7af43 100644 --- a/backend/app/api/v1/compose_template.go +++ b/backend/app/api/v1/compose_template.go @@ -89,8 +89,6 @@ func (b *BaseApi) UpdateComposeTemplate(c *gin.Context) { } upMap := make(map[string]interface{}) - upMap["from"] = req.From - upMap["path"] = req.Path upMap["content"] = req.Content upMap["description"] = req.Description if err := composeTemplateService.Update(id, upMap); err != nil { diff --git a/backend/app/dto/compose_template.go b/backend/app/dto/compose_template.go index 140ae6143..9c41aa2bf 100644 --- a/backend/app/dto/compose_template.go +++ b/backend/app/dto/compose_template.go @@ -4,16 +4,12 @@ import "time" type ComposeTemplateCreate struct { Name string `json:"name" validate:"required"` - From string `json:"from" validate:"required,oneof=edit path"` Description string `json:"description"` - Path string `json:"path"` Content string `json:"content"` } type ComposeTemplateUpdate struct { - From string `json:"from" validate:"required,oneof=edit path"` Description string `json:"description"` - Path string `json:"path"` Content string `json:"content"` } @@ -21,8 +17,6 @@ type ComposeTemplateInfo struct { ID uint `json:"id"` CreatedAt time.Time `json:"createdAt"` Name string `json:"name"` - From string `json:"from"` Description string `json:"description"` - Path string `json:"path"` Content string `json:"content"` } diff --git a/backend/app/dto/container.go b/backend/app/dto/container.go index 9be3bdae8..61683a17e 100644 --- a/backend/app/dto/container.go +++ b/backend/app/dto/container.go @@ -135,7 +135,7 @@ type ComposeCreate struct { type ComposeOperation struct { Name string `json:"name" validate:"required"` Path string `json:"path" validate:"required"` - Operation string `json:"operation" validate:"required,oneof=up stop down"` + Operation string `json:"operation" validate:"required,oneof=start stop down"` } type ComposeUpdate struct { Path string `json:"path" validate:"required"` diff --git a/backend/app/model/compose_template.go b/backend/app/model/compose_template.go index f604caea7..5d5192eb3 100644 --- a/backend/app/model/compose_template.go +++ b/backend/app/model/compose_template.go @@ -4,9 +4,7 @@ type ComposeTemplate struct { BaseModel Name string `gorm:"type:varchar(64);not null;unique" json:"name"` - From string `gorm:"type:varchar(64);not null" json:"from"` Description string `gorm:"type:varchar(256)" json:"description"` - Path string `gorm:"type:varchar(64)" json:"path"` Content string `gorm:"type:longtext" json:"content"` } diff --git a/backend/app/service/container_compose.go b/backend/app/service/container_compose.go index 0c898673b..6d904c37a 100644 --- a/backend/app/service/container_compose.go +++ b/backend/app/service/container_compose.go @@ -114,12 +114,8 @@ func (u *ContainerService) CreateCompose(req dto.ComposeCreate) error { if err != nil { return err } - req.From = template.From - if req.From == "edit" { - req.File = template.Content - } else { - req.Path = template.Path - } + req.From = "edit" + req.File = template.Content } if req.From == "edit" { dir := fmt.Sprintf("%s/%s", constant.TmpComposeBuildDir, req.Name) @@ -159,6 +155,7 @@ func (u *ContainerService) ComposeOperation(req dto.ComposeOperation) error { global.LOG.Debugf("docker-compose %s %s successful", req.Operation, req.Name) if req.Operation == "down" { _ = composeRepo.DeleteRecord(commonRepo.WithByName(req.Name)) + _ = os.RemoveAll(strings.ReplaceAll(req.Path, req.Name+"/docker-compose.yml", "")) } return nil diff --git a/frontend/src/api/interface/container.ts b/frontend/src/api/interface/container.ts index b3cc176f9..6e86df8be 100644 --- a/frontend/src/api/interface/container.ts +++ b/frontend/src/api/interface/container.ts @@ -193,6 +193,7 @@ export namespace Container { template: number; } export interface ComposeOpration { + name: string; operation: string; path: string; } diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 874840323..5f8e77c82 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -446,7 +446,9 @@ export default { containerNumber: 'Container number', down: 'Down', up: 'Up', - operatorComposeHelper: '{0} will be performed on the selected compose. Do you want to continue?', + composeDetailHelper: + 'The compose is created external to 1Panel. The start and stop operations are not supported.', + composeOperatorHelper: '{1} operation will be performed on {0}. Do you want to continue?', }, cronjob: { cronTask: 'Task', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index f80fc4cc8..98d5c4c96 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -355,7 +355,7 @@ export default { pause: '暂停', unpause: '恢复', rename: '重命名', - remove: '移除', + remove: '删除', container: '容器', upTime: '运行时长', all: '全部', @@ -455,7 +455,8 @@ export default { containerNumber: '容器数量', down: '删除', up: '启动', - operatorComposeHelper: '将对选中 Compose 进行 {0} 操作,是否继续?', + composeDetailHelper: '该 compose 为 1Panel 编排外部创建。暂不支持启停操作。', + composeOperatorHelper: '将对 {0} 进行 {1} 操作,是否继续?', setting: '容器配置', mirrors: '镜像加速', diff --git a/frontend/src/views/container/compose/detail/index.vue b/frontend/src/views/container/compose/detail/index.vue index 72e2bce61..cb0aecc6e 100644 --- a/frontend/src/views/container/compose/detail/index.vue +++ b/frontend/src/views/container/compose/detail/index.vue @@ -1,100 +1,102 @@