Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
24 changes: 18 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,17 @@ 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';
if (statusText === 'Exited') {
return `${statusText}`;
} else {
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
Loading