diff --git a/backend/app/model/compose_template.go b/backend/app/model/compose_template.go index c7f9824ea..f604caea7 100644 --- a/backend/app/model/compose_template.go +++ b/backend/app/model/compose_template.go @@ -9,3 +9,9 @@ type ComposeTemplate struct { Path string `gorm:"type:varchar(64)" json:"path"` Content string `gorm:"type:longtext" json:"content"` } + +type Compose struct { + BaseModel + + Name string `gorm:"type:varchar(256)" json:"name"` +} diff --git a/backend/app/repo/compose_template.go b/backend/app/repo/compose_template.go index f0bd27864..b72f98062 100644 --- a/backend/app/repo/compose_template.go +++ b/backend/app/repo/compose_template.go @@ -14,6 +14,9 @@ type IComposeTemplateRepo interface { Create(compose *model.ComposeTemplate) error Update(id uint, vars map[string]interface{}) error Delete(opts ...DBOption) error + + CreateRecord(compose *model.Compose) error + DeleteRecord(opts ...DBOption) error } func NewIComposeTemplateRepo() IComposeTemplateRepo { @@ -67,3 +70,23 @@ func (u *ComposeTemplateRepo) Delete(opts ...DBOption) error { } return db.Delete(&model.ComposeTemplate{}).Error } + +func (u *ComposeTemplateRepo) ListRecord() ([]model.Compose, error) { + var composes []model.Compose + if err := global.DB.Find(&composes).Error; err != nil { + return nil, err + } + return composes, nil +} + +func (u *ComposeTemplateRepo) CreateRecord(compose *model.Compose) error { + return global.DB.Create(compose).Error +} + +func (u *ComposeTemplateRepo) DeleteRecord(opts ...DBOption) error { + db := global.DB + for _, opt := range opts { + db = opt(db) + } + return db.Delete(&model.Compose{}).Error +} diff --git a/backend/init/migration/migrations/init.go b/backend/init/migration/migrations/init.go index 4a1391a3f..9cd34ad74 100644 --- a/backend/init/migration/migrations/init.go +++ b/backend/init/migration/migrations/init.go @@ -157,7 +157,7 @@ var AddTableApp = &gormigrate.Migration{ var AddTableImageRepo = &gormigrate.Migration{ ID: "20201009-add-table-imagerepo", Migrate: func(tx *gorm.DB) error { - if err := tx.AutoMigrate(&model.ImageRepo{}, &model.ComposeTemplate{}); err != nil { + if err := tx.AutoMigrate(&model.ImageRepo{}, &model.ComposeTemplate{}, &model.Compose{}); err != nil { return err } item := &model.ImageRepo{ diff --git a/frontend/src/routers/modules/container.ts b/frontend/src/routers/modules/container.ts index 370ca97ff..068997eb2 100644 --- a/frontend/src/routers/modules/container.ts +++ b/frontend/src/routers/modules/container.ts @@ -11,7 +11,7 @@ const containerRouter = { }, children: [ { - path: ':filters?', + path: '', name: 'Container', component: () => import('@/views/container/container/index.vue'), props: true, @@ -20,6 +20,16 @@ const containerRouter = { activeMenu: '/containers', }, }, + { + path: 'composeDetail/:filters?', + name: 'ComposeDetail', + component: () => import('@/views/container/compose/detail/index.vue'), + props: true, + hidden: true, + meta: { + activeMenu: '/containers', + }, + }, { path: 'image', name: 'Image', diff --git a/frontend/src/views/container/compose/operator/index.vue b/frontend/src/views/container/compose/create/index.vue similarity index 100% rename from frontend/src/views/container/compose/operator/index.vue rename to frontend/src/views/container/compose/create/index.vue diff --git a/frontend/src/views/container/compose/detail/index.vue b/frontend/src/views/container/compose/detail/index.vue new file mode 100644 index 000000000..72e2bce61 --- /dev/null +++ b/frontend/src/views/container/compose/detail/index.vue @@ -0,0 +1,271 @@ + + + diff --git a/frontend/src/views/container/compose/index.vue b/frontend/src/views/container/compose/index.vue index 974039522..aa2ad6dc5 100644 --- a/frontend/src/views/container/compose/index.vue +++ b/frontend/src/views/container/compose/index.vue @@ -7,28 +7,7 @@ {{ $t('commons.button.create') }} - - - {{ $t('container.start') }} - - - {{ $t('container.stop') }} - - - {{ $t('container.pause') }} - - - {{ $t('container.unpause') }} - - - {{ $t('container.restart') }} - - - {{ $t('container.down') }} - - - - - - - + - + + diff --git a/frontend/src/views/container/container/reName/index.vue b/frontend/src/views/container/container/reName/index.vue new file mode 100644 index 000000000..69589699d --- /dev/null +++ b/frontend/src/views/container/container/reName/index.vue @@ -0,0 +1,78 @@ + + +