fix: compose 创建的容器禁用重命名按钮

pull/149/head
ssongliu 2023-02-17 17:59:45 +08:00 committed by ssongliu
parent e2c6da3f9e
commit 85058fe7ba
5 changed files with 20 additions and 17 deletions

View File

@ -21,6 +21,8 @@ type ContainerInfo struct {
CreateTime string `json:"createTime"`
State string `json:"state"`
RunTime string `json:"runTime"`
IsFromCompose bool `json:"isFromCompose"`
}
type ContainerCreate struct {

View File

@ -94,14 +94,19 @@ func (u *ContainerService) Page(req dto.PageContainer) (int64, interface{}, erro
}
for _, container := range records {
IsFromCompose := false
if _, ok := container.Labels[composeProjectLabel]; ok {
IsFromCompose = true
}
backDatas = append(backDatas, dto.ContainerInfo{
ContainerID: container.ID,
CreateTime: time.Unix(container.Created, 0).Format("2006-01-02 15:04:05"),
Name: container.Names[0][1:],
ImageId: strings.Split(container.ImageID, ":")[1],
ImageName: container.Image,
State: container.State,
RunTime: container.Status,
ContainerID: container.ID,
CreateTime: time.Unix(container.Created, 0).Format("2006-01-02 15:04:05"),
Name: container.Names[0][1:],
ImageId: strings.Split(container.ImageID, ":")[1],
ImageName: container.Image,
State: container.State,
RunTime: container.Status,
IsFromCompose: IsFromCompose,
})
}

View File

@ -42,6 +42,8 @@ export namespace Container {
createTime: string;
state: string;
runTime: string;
isFromCompose: string;
}
export interface ContainerStats {
cpuPercent: number;

View File

@ -6,7 +6,7 @@
<div>
<el-tag effect="dark" type="success">{{ composeName }}</el-tag>
</div>
<div v-if="createdBy === '1Panel'">
<div v-if="createdBy === '1Panel'" style="margin-left: 50px">
<el-button link type="primary" @click="onComposeOperate('start')">
{{ $t('container.start') }}
</el-button>
@ -111,7 +111,6 @@
<CodemirrorDialog ref="mydetail" />
<ReNameDialog @search="search" ref="dialogReNameRef" />
<ContainerLogDialog ref="dialogContainerLogRef" />
<CreateDialog @search="search" ref="dialogCreateRef" />
<MonitorDialog ref="dialogMonitorRef" />
@ -124,7 +123,6 @@
<script lang="ts" setup>
import { reactive, ref } from 'vue';
import LayoutContent from '@/layout/layout-content.vue';
import ReNameDialog from '@/views/container/container/rename/index.vue';
import CreateDialog from '@/views/container/container/create/index.vue';
import MonitorDialog from '@/views/container/container/monitor/index.vue';
import ContainerLogDialog from '@/views/container/container/log/index.vue';
@ -290,7 +288,6 @@ const onTerminal = (containerID: string) => {
};
const dialogContainerLogRef = ref();
const dialogReNameRef = ref();
const buttons = [
{
@ -311,12 +308,6 @@ const buttons = [
onMonitor(row.containerID);
},
},
{
label: i18n.global.t('container.rename'),
click: (row: Container.ContainerInfo) => {
dialogReNameRef.value!.acceptParams({ containerID: row.containerID, container: row.name });
},
},
{
label: i18n.global.t('commons.button.log'),
click: (row: Container.ContainerInfo) => {

View File

@ -309,6 +309,9 @@ const buttons = [
console.log(row.name);
dialogReNameRef.value!.acceptParams({ container: row.name });
},
disabled: (row: any) => {
return row.isFromCompose;
},
},
{
label: i18n.global.t('commons.button.log'),