2022-10-09 16:17:15 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
2022-12-07 18:15:56 +08:00
|
|
|
<el-card width="30%" v-if="dockerStatus != 'Running'" class="mask-prompt">
|
|
|
|
<span style="font-size: 14px">{{ $t('container.serviceUnavailable') }}</span>
|
|
|
|
<el-button type="primary" link style="font-size: 14px; margin-bottom: 5px" @click="goSetting">
|
|
|
|
【 {{ $t('container.setting') }} 】
|
|
|
|
</el-button>
|
|
|
|
<span style="font-size: 14px">{{ $t('container.startIn') }}</span>
|
|
|
|
</el-card>
|
2023-01-31 23:28:37 +08:00
|
|
|
|
|
|
|
<LayoutContent v-loading="loading" :title="$t('container.repo')" :class="{ mask: dockerStatus != 'Running' }">
|
|
|
|
<template #toolbar>
|
2023-02-07 18:48:32 +08:00
|
|
|
<el-row>
|
2023-02-10 15:55:56 +08:00
|
|
|
<el-col :span="16">
|
2023-02-13 16:34:02 +08:00
|
|
|
<el-button type="primary" @click="onOpenDialog('add')">
|
2023-02-07 18:48:32 +08:00
|
|
|
{{ $t('container.createRepo') }}
|
|
|
|
</el-button>
|
|
|
|
</el-col>
|
2023-02-10 15:55:56 +08:00
|
|
|
<el-col :span="8">
|
|
|
|
<TableSetting @search="search()" />
|
2023-02-07 18:48:32 +08:00
|
|
|
<div class="search-button">
|
|
|
|
<el-input
|
|
|
|
v-model="searchName"
|
|
|
|
clearable
|
|
|
|
@clear="search()"
|
|
|
|
suffix-icon="Search"
|
|
|
|
@keyup.enter="search()"
|
|
|
|
@blur="search()"
|
|
|
|
:placeholder="$t('commons.button.search')"
|
|
|
|
></el-input>
|
|
|
|
</div>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
2023-01-31 23:28:37 +08:00
|
|
|
</template>
|
|
|
|
<template #main>
|
2023-01-30 09:39:37 +08:00
|
|
|
<ComplexTable
|
|
|
|
:pagination-config="paginationConfig"
|
|
|
|
v-model:selects="selects"
|
|
|
|
:data="data"
|
|
|
|
@search="search"
|
|
|
|
>
|
|
|
|
<el-table-column type="selection" :selectable="selectable" fix />
|
|
|
|
<el-table-column :label="$t('commons.table.name')" prop="name" min-width="60" />
|
|
|
|
<el-table-column
|
|
|
|
:label="$t('container.downloadUrl')"
|
|
|
|
show-overflow-tooltip
|
|
|
|
prop="downloadUrl"
|
|
|
|
min-width="100"
|
|
|
|
fix
|
|
|
|
/>
|
|
|
|
<el-table-column :label="$t('container.protocol')" prop="protocol" min-width="60" fix />
|
|
|
|
<el-table-column :label="$t('commons.table.status')" prop="status" min-width="60" fix>
|
|
|
|
<template #default="{ row }">
|
|
|
|
<el-tag v-if="row.status === 'Success'" type="success">
|
|
|
|
{{ $t('commons.status.success') }}
|
|
|
|
</el-tag>
|
|
|
|
<el-tooltip v-else effect="dark" :content="row.message" placement="bottom">
|
|
|
|
<el-tag type="danger">{{ $t('commons.status.failed') }}</el-tag>
|
|
|
|
</el-tooltip>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2023-02-23 09:31:00 +08:00
|
|
|
<el-table-column
|
|
|
|
prop="createdAt"
|
|
|
|
:label="$t('commons.table.createdAt')"
|
|
|
|
min-width="80"
|
|
|
|
fix
|
|
|
|
:formatter="dateFormat"
|
|
|
|
/>
|
2023-01-30 09:39:37 +08:00
|
|
|
<fu-table-operations :buttons="buttons" :label="$t('commons.table.operate')" />
|
|
|
|
</ComplexTable>
|
2023-01-31 23:28:37 +08:00
|
|
|
</template>
|
|
|
|
</LayoutContent>
|
2022-10-09 16:17:15 +08:00
|
|
|
<OperatorDialog @search="search" ref="dialogRef" />
|
2022-12-20 13:23:01 +08:00
|
|
|
<DeleteDialog @search="search" ref="dialogDeleteRef" />
|
2022-10-09 16:17:15 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-01-30 09:39:37 +08:00
|
|
|
import LayoutContent from '@/layout/layout-content.vue';
|
2022-10-09 16:17:15 +08:00
|
|
|
import ComplexTable from '@/components/complex-table/index.vue';
|
2023-02-10 15:55:56 +08:00
|
|
|
import TableSetting from '@/components/table-setting/index.vue';
|
2022-10-09 16:17:15 +08:00
|
|
|
import OperatorDialog from '@/views/container/repo/operator/index.vue';
|
2022-12-20 13:23:01 +08:00
|
|
|
import DeleteDialog from '@/views/container/repo/delete/index.vue';
|
2022-10-09 16:17:15 +08:00
|
|
|
import { reactive, onMounted, ref } from 'vue';
|
2023-02-23 09:31:00 +08:00
|
|
|
import { dateFormat } from '@/utils/util';
|
2022-10-09 16:17:15 +08:00
|
|
|
import { Container } from '@/api/interface/container';
|
2023-02-14 11:28:38 +08:00
|
|
|
import { deleteImageRepo, loadDockerStatus, searchImageRepo } from '@/api/modules/container';
|
2022-10-09 16:17:15 +08:00
|
|
|
import i18n from '@/lang';
|
2022-12-07 18:15:56 +08:00
|
|
|
import router from '@/routers';
|
2023-02-14 11:28:38 +08:00
|
|
|
import { ElMessageBox } from 'element-plus';
|
2022-10-09 16:17:15 +08:00
|
|
|
|
2023-01-31 23:28:37 +08:00
|
|
|
const loading = ref();
|
2022-10-09 16:17:15 +08:00
|
|
|
const data = ref();
|
|
|
|
const selects = ref<any>([]);
|
|
|
|
const paginationConfig = reactive({
|
2022-12-06 18:24:26 +08:00
|
|
|
currentPage: 1,
|
2022-10-09 16:17:15 +08:00
|
|
|
pageSize: 10,
|
|
|
|
total: 0,
|
|
|
|
});
|
2023-02-07 18:48:32 +08:00
|
|
|
const searchName = ref();
|
2022-10-09 16:17:15 +08:00
|
|
|
|
2022-12-07 18:15:56 +08:00
|
|
|
const dockerStatus = ref();
|
|
|
|
const loadStatus = async () => {
|
|
|
|
const res = await loadDockerStatus();
|
|
|
|
dockerStatus.value = res.data;
|
|
|
|
if (dockerStatus.value === 'Running') {
|
|
|
|
search();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const goSetting = async () => {
|
|
|
|
router.push({ name: 'ContainerSetting' });
|
|
|
|
};
|
|
|
|
|
2022-10-09 16:17:15 +08:00
|
|
|
const search = async () => {
|
2022-10-17 09:10:06 +08:00
|
|
|
let params = {
|
2023-02-07 18:48:32 +08:00
|
|
|
info: searchName.value,
|
2022-12-06 18:24:26 +08:00
|
|
|
page: paginationConfig.currentPage,
|
2022-10-17 09:10:06 +08:00
|
|
|
pageSize: paginationConfig.pageSize,
|
|
|
|
};
|
2023-01-31 23:28:37 +08:00
|
|
|
loading.value = true;
|
|
|
|
await searchImageRepo(params)
|
|
|
|
.then((res) => {
|
|
|
|
loading.value = false;
|
|
|
|
data.value = res.data.items || [];
|
|
|
|
paginationConfig.total = res.data.total;
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
loading.value = false;
|
|
|
|
});
|
2022-10-09 16:17:15 +08:00
|
|
|
};
|
|
|
|
|
2022-12-07 14:30:11 +08:00
|
|
|
function selectable(row) {
|
|
|
|
return !(row.name === 'Docker Hub');
|
|
|
|
}
|
|
|
|
|
2022-10-17 09:10:06 +08:00
|
|
|
const dialogRef = ref();
|
2022-10-09 16:17:15 +08:00
|
|
|
const onOpenDialog = async (
|
|
|
|
title: string,
|
|
|
|
rowData: Partial<Container.RepoInfo> = {
|
|
|
|
auth: true,
|
2022-10-10 16:47:05 +08:00
|
|
|
protocol: 'http',
|
2022-10-09 16:17:15 +08:00
|
|
|
},
|
|
|
|
) => {
|
|
|
|
let params = {
|
|
|
|
title,
|
|
|
|
rowData: { ...rowData },
|
|
|
|
};
|
|
|
|
dialogRef.value!.acceptParams(params);
|
|
|
|
};
|
|
|
|
|
2022-12-20 13:23:01 +08:00
|
|
|
const dialogDeleteRef = ref();
|
2023-02-14 11:28:38 +08:00
|
|
|
const onDelete = async (row: Container.RepoInfo) => {
|
|
|
|
if (row.protocol === 'https') {
|
|
|
|
ElMessageBox.confirm(i18n.global.t('commons.msg.delete'), i18n.global.t('commons.button.delete'), {
|
|
|
|
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
|
|
|
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
|
|
|
}).then(async () => {
|
|
|
|
await deleteImageRepo({ ids: [row.id], deleteInsecure: false });
|
|
|
|
search();
|
2022-10-09 16:17:15 +08:00
|
|
|
});
|
2023-02-14 11:28:38 +08:00
|
|
|
return;
|
2022-10-09 16:17:15 +08:00
|
|
|
}
|
2023-02-14 11:28:38 +08:00
|
|
|
dialogDeleteRef.value!.acceptParams({ ids: [row.id] });
|
2022-10-09 16:17:15 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const buttons = [
|
|
|
|
{
|
|
|
|
label: i18n.global.t('commons.button.edit'),
|
|
|
|
disabled: (row: Container.RepoInfo) => {
|
|
|
|
return row.downloadUrl === 'docker.io';
|
|
|
|
},
|
|
|
|
click: (row: Container.RepoInfo) => {
|
|
|
|
onOpenDialog('edit', row);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: i18n.global.t('commons.button.delete'),
|
|
|
|
disabled: (row: Container.RepoInfo) => {
|
|
|
|
return row.downloadUrl === 'docker.io';
|
|
|
|
},
|
|
|
|
click: (row: Container.RepoInfo) => {
|
2023-02-14 11:28:38 +08:00
|
|
|
onDelete(row);
|
2022-10-09 16:17:15 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
onMounted(() => {
|
2022-12-07 18:15:56 +08:00
|
|
|
loadStatus();
|
2022-10-09 16:17:15 +08:00
|
|
|
});
|
|
|
|
</script>
|