Skip to content

Commit

Permalink
feat: 容器编排显示容器状态,编排模板样式优化
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnZjh1994 committed Sep 19, 2024
1 parent 43f95fd commit de5d94c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ const message = {
content: '內',
contentEmpty: '編排內容不能為空請輸入後重試!',
containerNumber: '容器數量',
containerStatus: '容器狀態',
down: '刪',
up: '啟',
composeDetailHelper: '該 compose 1Panel 編排外部創建暫不支持啟停操作。',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ const message = {
content: '内',
contentEmpty: '编排内容不能为空请输入后重试!',
containerNumber: '容器数量',
containerStatus: '容器状态',
down: '删',
up: '启',
composeDetailHelper: '该 compose 1Panel 编排外部创建暂不支持启停操作。',
Expand Down
20 changes: 14 additions & 6 deletions frontend/src/views/container/compose/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/views/container/template/detail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -51,6 +50,10 @@ const acceptParams = (params: DialogProps): void => {
detailVisible.value = true;
};
const handleClose = () => {
detailVisible.value = false;
};
defineExpose({
acceptParams,
});
Expand Down

0 comments on commit de5d94c

Please sign in to comment.