feat: 容器编排显示容器状态,编排模板样式优化

This commit is contained in:
zhoujunhong 2024-09-19 13:51:20 +08:00
parent 43f95fd40e
commit de5d94c571
5 changed files with 23 additions and 9 deletions

View file

@ -783,6 +783,7 @@ const message = {
content: 'Content',
contentEmpty: 'Compose content cannot be empty, please enter and try again!',
containerNumber: 'Container number',
containerStatus: 'Container Status',
down: 'Down',
up: 'Up',
composeDetailHelper:

View file

@ -752,6 +752,7 @@ const message = {
content: '內容',
contentEmpty: '編排內容不能為空請輸入後重試',
containerNumber: '容器數量',
containerStatus: '容器狀態',
down: '刪除',
up: '啟動',
composeDetailHelper: ' compose 1Panel 編排外部創建暫不支持啟停操作',

View file

@ -755,6 +755,7 @@ const message = {
content: '内容',
contentEmpty: '编排内容不能为空请输入后重试',
containerNumber: '容器数量',
containerStatus: '容器状态',
down: '删除',
up: '启动',
composeDetailHelper: ' compose 1Panel 编排外部创建暂不支持启停操作',

View file

@ -64,12 +64,13 @@
<span v-if="row.createdBy === '1Panel'">1Panel</span>
</template>
</el-table-column>
<el-table-column
:label="$t('container.containerNumber')"
prop="containerNumber"
min-width="80"
fix
/>
<el-table-column :label="$t('container.containerStatus')" min-width="80" fix>
<template #default="scope">
<div>
{{ getContainerStatus(scope.row.containers) }}
</div>
</template>
</el-table-column>
<el-table-column :label="$t('commons.table.createdAt')" prop="createdAt" min-width="80" fix />
<fu-table-operations
width="200px"
@ -173,6 +174,13 @@ const loadDetail = async (row: Container.ComposeInfo) => {
isOnDetail.value = true;
composeDetailRef.value!.acceptParams(params);
};
const getContainerStatus = (containers) => {
const safeContainers = containers || [];
const runningCount = safeContainers.filter((container) => container.state.toLowerCase() === 'running').length;
const totalCount = safeContainers.length;
const statusText = runningCount > 0 ? 'Running' : 'Exited';
return `${statusText} (${runningCount}/${totalCount})`;
};
const backList = async () => {
isOnDetail.value = false;
search();

View file

@ -7,9 +7,7 @@
size="50%"
>
<template #header>
<div class="card-header">
<span>{{ $t('commons.button.view') }}</span>
</div>
<DrawerHeader :header="$t('commons.button.view')" :back="handleClose" />
</template>
<codemirror
:autofocus="true"
@ -38,6 +36,7 @@ import { javascript } from '@codemirror/lang-javascript';
import { oneDark } from '@codemirror/theme-one-dark';
import { ref } from 'vue';
import { Codemirror } from 'vue-codemirror';
import DrawerHeader from '@/components/drawer-header/index.vue';
const extensions = [javascript(), oneDark];
const detailVisible = ref(false);
@ -51,6 +50,10 @@ const acceptParams = (params: DialogProps): void => {
detailVisible.value = true;
};
const handleClose = () => {
detailVisible.value = false;
};
defineExpose({
acceptParams,
});