2022-09-26 16:32:40 +08:00
|
|
|
<template>
|
2022-09-29 18:16:56 +08:00
|
|
|
<div style="float: right; margin-bottom: 5px">
|
|
|
|
<el-button @click="sync">{{ $t('app.sync') }}</el-button>
|
|
|
|
</div>
|
2022-09-26 18:20:21 +08:00
|
|
|
<ComplexTable :pagination-config="paginationConfig" :data="data" @search="search" v-loading="loading">
|
2022-10-12 10:54:09 +08:00
|
|
|
<el-table-column :label="$t('app.name')" prop="name">
|
|
|
|
<template #default="{ row }">
|
|
|
|
{{ row.name }}
|
|
|
|
<el-tag round effect="dark" v-if="row.canUpdate">{{ $t('app.canUpdate') }}</el-tag>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2022-09-26 22:54:38 +08:00
|
|
|
<!-- <el-table-column :label="$t('app.description')" prop="description"></el-table-column> -->
|
2022-10-12 18:57:22 +08:00
|
|
|
<el-table-column :label="$t('app.appName')" prop="app.name"></el-table-column>
|
2022-09-26 16:32:40 +08:00
|
|
|
<el-table-column :label="$t('app.version')" prop="version"></el-table-column>
|
2022-10-12 18:57:22 +08:00
|
|
|
<el-table-column :label="$t('app.backup')">
|
|
|
|
<template #default="{ row }">
|
|
|
|
<el-link :underline="false" @click="openBackups(row.id)" type="primary">
|
|
|
|
{{ $t('app.backup') }} ({{ row.backups.length }})
|
|
|
|
</el-link>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2022-09-26 16:32:40 +08:00
|
|
|
<el-table-column :label="$t('app.status')">
|
|
|
|
<template #default="{ row }">
|
2022-09-26 18:20:21 +08:00
|
|
|
<el-popover
|
|
|
|
v-if="row.status === 'Error'"
|
2022-09-27 16:57:23 +08:00
|
|
|
placement="bottom"
|
2022-09-26 18:20:21 +08:00
|
|
|
:width="400"
|
|
|
|
trigger="hover"
|
|
|
|
:content="row.message"
|
|
|
|
>
|
|
|
|
<template #reference>
|
|
|
|
<el-tag type="error">{{ row.status }}</el-tag>
|
|
|
|
</template>
|
|
|
|
</el-popover>
|
2022-10-10 15:10:53 +08:00
|
|
|
|
|
|
|
<el-tag v-else>
|
|
|
|
<el-icon v-if="row.status === 'Installing'" class="is-loading">
|
|
|
|
<Loading />
|
|
|
|
</el-icon>
|
|
|
|
{{ row.status }}
|
|
|
|
</el-tag>
|
2022-09-26 16:32:40 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
|
|
prop="createdAt"
|
|
|
|
:label="$t('commons.table.date')"
|
|
|
|
:formatter="dateFromat"
|
|
|
|
show-overflow-tooltip
|
|
|
|
/>
|
2022-09-27 16:57:23 +08:00
|
|
|
<fu-table-operations
|
2022-10-12 18:57:22 +08:00
|
|
|
width="300px"
|
2022-09-27 16:57:23 +08:00
|
|
|
:ellipsis="10"
|
|
|
|
:buttons="buttons"
|
|
|
|
:label="$t('commons.table.operate')"
|
|
|
|
fixed="right"
|
|
|
|
fix
|
|
|
|
/>
|
2022-09-26 16:32:40 +08:00
|
|
|
</ComplexTable>
|
2022-09-27 16:57:23 +08:00
|
|
|
<el-dialog v-model="open" :title="$t('commons.msg.operate')" :before-close="handleClose" width="30%">
|
2022-10-13 18:56:53 +08:00
|
|
|
<el-alert
|
|
|
|
v-if="operateReq.operate != 'update'"
|
|
|
|
:title="getMsg(operateReq.operate)"
|
|
|
|
type="warning"
|
|
|
|
:closable="false"
|
|
|
|
show-icon
|
|
|
|
/>
|
|
|
|
<div v-else style="text-align: center">
|
|
|
|
<p>{{ $t('app.versioneSelect') }}</p>
|
|
|
|
<el-select v-model="operateReq.detailId">
|
|
|
|
<el-option
|
|
|
|
v-for="(version, index) in versions"
|
|
|
|
:key="index"
|
|
|
|
:value="version.detailId"
|
|
|
|
:label="version.version"
|
|
|
|
></el-option>
|
|
|
|
</el-select>
|
|
|
|
</div>
|
2022-09-27 16:57:23 +08:00
|
|
|
<template #footer>
|
|
|
|
<span class="dialog-footer">
|
|
|
|
<el-button @click="handleClose">{{ $t('commons.button.cancel') }}</el-button>
|
2022-10-17 16:32:31 +08:00
|
|
|
<el-button
|
|
|
|
type="primary"
|
|
|
|
@click="operate"
|
|
|
|
:disabled="operateReq.operate == 'update' && versions == null"
|
|
|
|
>
|
2022-10-13 18:56:53 +08:00
|
|
|
{{ $t('commons.button.confirm') }}
|
|
|
|
</el-button>
|
2022-09-27 16:57:23 +08:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
</el-dialog>
|
2022-10-13 16:46:38 +08:00
|
|
|
<Backups ref="backupRef" @close="search"></Backups>
|
2022-09-26 16:32:40 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2022-10-13 18:56:53 +08:00
|
|
|
import { GetAppInstalled, InstalledOp, SyncInstalledApp, GetAppUpdateVersions } from '@/api/modules/app';
|
2022-10-10 15:10:53 +08:00
|
|
|
import { onMounted, onUnmounted, reactive, ref } from 'vue';
|
2022-09-26 16:32:40 +08:00
|
|
|
import ComplexTable from '@/components/complex-table/index.vue';
|
|
|
|
import { dateFromat } from '@/utils/util';
|
|
|
|
import i18n from '@/lang';
|
2022-11-22 14:22:25 +08:00
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
2022-10-12 18:57:22 +08:00
|
|
|
import Backups from './backups.vue';
|
2022-10-13 18:56:53 +08:00
|
|
|
import { App } from '@/api/interface/app';
|
2022-09-26 16:32:40 +08:00
|
|
|
|
|
|
|
let data = ref<any>();
|
2022-09-26 18:20:21 +08:00
|
|
|
let loading = ref(false);
|
2022-10-17 17:28:58 +08:00
|
|
|
let timer: NodeJS.Timer | null = null;
|
2022-09-26 16:32:40 +08:00
|
|
|
const paginationConfig = reactive({
|
|
|
|
currentPage: 1,
|
|
|
|
pageSize: 20,
|
|
|
|
total: 0,
|
|
|
|
});
|
2022-09-27 16:57:23 +08:00
|
|
|
let open = ref(false);
|
|
|
|
let operateReq = reactive({
|
|
|
|
installId: 0,
|
|
|
|
operate: '',
|
2022-10-13 18:56:53 +08:00
|
|
|
detailId: 0,
|
2022-09-27 16:57:23 +08:00
|
|
|
});
|
2022-10-13 18:56:53 +08:00
|
|
|
let versions = ref<App.VersionDetail[]>();
|
2022-10-12 18:57:22 +08:00
|
|
|
const backupRef = ref();
|
2022-09-26 16:32:40 +08:00
|
|
|
|
2022-09-29 18:16:56 +08:00
|
|
|
const sync = () => {
|
|
|
|
loading.value = true;
|
|
|
|
SyncInstalledApp()
|
|
|
|
.then(() => {
|
|
|
|
ElMessage.success(i18n.global.t('app.syncSuccess'));
|
|
|
|
search();
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
loading.value = false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-09-26 16:32:40 +08:00
|
|
|
const search = () => {
|
|
|
|
const req = {
|
|
|
|
page: paginationConfig.currentPage,
|
|
|
|
pageSize: paginationConfig.pageSize,
|
|
|
|
};
|
|
|
|
|
|
|
|
GetAppInstalled(req).then((res) => {
|
|
|
|
data.value = res.data.items;
|
|
|
|
paginationConfig.total = res.data.total;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-09-27 16:57:23 +08:00
|
|
|
const openOperate = (row: any, op: string) => {
|
|
|
|
operateReq.installId = row.id;
|
|
|
|
operateReq.operate = op;
|
2022-10-13 18:56:53 +08:00
|
|
|
if (op == 'update') {
|
|
|
|
GetAppUpdateVersions(row.id).then((res) => {
|
|
|
|
versions.value = res.data;
|
|
|
|
if (res.data != null && res.data.length > 0) {
|
|
|
|
operateReq.detailId = res.data[0].detailId;
|
|
|
|
}
|
|
|
|
open.value = true;
|
|
|
|
});
|
|
|
|
} else {
|
2022-11-22 14:22:25 +08:00
|
|
|
onOperate(op);
|
2022-10-13 18:56:53 +08:00
|
|
|
}
|
2022-09-27 16:57:23 +08:00
|
|
|
};
|
2022-09-26 18:20:21 +08:00
|
|
|
|
2022-09-27 16:57:23 +08:00
|
|
|
const operate = async () => {
|
|
|
|
open.value = false;
|
|
|
|
loading.value = true;
|
|
|
|
await InstalledOp(operateReq)
|
|
|
|
.then(() => {
|
|
|
|
ElMessage.success(i18n.global.t('commons.msg.operationSuccess'));
|
|
|
|
search();
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
loading.value = false;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleClose = () => {
|
|
|
|
open.value = false;
|
|
|
|
};
|
|
|
|
|
2022-11-22 14:22:25 +08:00
|
|
|
const onOperate = async (operation: string) => {
|
|
|
|
ElMessageBox.confirm(
|
|
|
|
i18n.global.t('app.operatorHelper', [i18n.global.t('app.' + operation)]),
|
|
|
|
i18n.global.t('app.' + operation),
|
|
|
|
{
|
|
|
|
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
|
|
|
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
|
|
|
type: 'info',
|
|
|
|
},
|
|
|
|
).then(() => {
|
|
|
|
open.value = false;
|
|
|
|
loading.value = true;
|
|
|
|
InstalledOp(operateReq)
|
|
|
|
.then(() => {
|
|
|
|
ElMessage.success(i18n.global.t('commons.msg.operationSuccess'));
|
|
|
|
search();
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
loading.value = false;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-09-27 16:57:23 +08:00
|
|
|
const getMsg = (op: string) => {
|
|
|
|
let tip = '';
|
|
|
|
switch (op) {
|
|
|
|
case 'up':
|
|
|
|
tip = i18n.global.t('app.up');
|
|
|
|
break;
|
|
|
|
case 'down':
|
|
|
|
tip = i18n.global.t('app.down');
|
|
|
|
break;
|
|
|
|
case 'restart':
|
|
|
|
tip = i18n.global.t('app.restart');
|
|
|
|
break;
|
|
|
|
case 'delete':
|
|
|
|
tip = i18n.global.t('app.deleteWarn');
|
|
|
|
break;
|
2022-09-29 18:16:56 +08:00
|
|
|
case 'sync':
|
|
|
|
tip = i18n.global.t('app.sync');
|
|
|
|
break;
|
2022-09-27 16:57:23 +08:00
|
|
|
default:
|
|
|
|
}
|
|
|
|
return tip;
|
2022-09-26 18:20:21 +08:00
|
|
|
};
|
|
|
|
|
2022-09-26 16:32:40 +08:00
|
|
|
const buttons = [
|
2022-09-29 18:16:56 +08:00
|
|
|
{
|
|
|
|
label: i18n.global.t('app.sync'),
|
|
|
|
click: (row: any) => {
|
|
|
|
openOperate(row, 'sync');
|
|
|
|
},
|
|
|
|
},
|
2022-10-13 18:56:53 +08:00
|
|
|
{
|
|
|
|
label: i18n.global.t('app.update'),
|
|
|
|
click: (row: any) => {
|
|
|
|
openOperate(row, 'update');
|
|
|
|
},
|
2022-10-17 16:32:31 +08:00
|
|
|
disabled: (row: any) => {
|
|
|
|
return !row.canUpdate;
|
|
|
|
},
|
2022-10-13 18:56:53 +08:00
|
|
|
},
|
2022-09-26 16:32:40 +08:00
|
|
|
{
|
|
|
|
label: i18n.global.t('app.restart'),
|
2022-09-26 18:20:21 +08:00
|
|
|
click: (row: any) => {
|
2022-09-27 16:57:23 +08:00
|
|
|
openOperate(row, 'restart');
|
2022-09-26 18:20:21 +08:00
|
|
|
},
|
2022-09-26 16:32:40 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: i18n.global.t('app.up'),
|
2022-09-26 18:20:21 +08:00
|
|
|
click: (row: any) => {
|
2022-09-27 16:57:23 +08:00
|
|
|
openOperate(row, 'up');
|
2022-09-26 18:20:21 +08:00
|
|
|
},
|
2022-10-17 16:32:31 +08:00
|
|
|
disabled: (row: any) => {
|
|
|
|
return row.status === 'Running';
|
|
|
|
},
|
2022-09-26 16:32:40 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: i18n.global.t('app.down'),
|
2022-09-26 18:20:21 +08:00
|
|
|
click: (row: any) => {
|
2022-09-27 16:57:23 +08:00
|
|
|
openOperate(row, 'down');
|
2022-09-26 18:20:21 +08:00
|
|
|
},
|
2022-09-26 16:32:40 +08:00
|
|
|
},
|
2022-09-26 22:54:38 +08:00
|
|
|
{
|
|
|
|
label: i18n.global.t('app.delete'),
|
|
|
|
click: (row: any) => {
|
2022-09-27 16:57:23 +08:00
|
|
|
openOperate(row, 'delete');
|
2022-09-26 22:54:38 +08:00
|
|
|
},
|
|
|
|
},
|
2022-09-26 16:32:40 +08:00
|
|
|
];
|
|
|
|
|
2022-10-12 18:57:22 +08:00
|
|
|
const openBackups = (installId: number) => {
|
|
|
|
let params = {
|
|
|
|
appInstallId: installId,
|
|
|
|
};
|
|
|
|
backupRef.value.acceptParams(params);
|
|
|
|
};
|
|
|
|
|
2022-09-26 16:32:40 +08:00
|
|
|
onMounted(() => {
|
|
|
|
search();
|
2022-10-17 17:28:58 +08:00
|
|
|
timer = setInterval(() => {
|
|
|
|
search();
|
|
|
|
}, 1000 * 8);
|
|
|
|
});
|
|
|
|
|
2022-10-10 15:10:53 +08:00
|
|
|
onUnmounted(() => {
|
2022-10-17 17:28:58 +08:00
|
|
|
clearInterval(Number(timer));
|
2022-09-26 16:32:40 +08:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.i-card {
|
|
|
|
height: 60px;
|
|
|
|
cursor: pointer;
|
|
|
|
.content {
|
|
|
|
.image {
|
|
|
|
width: auto;
|
|
|
|
height: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.i-card:hover {
|
|
|
|
border: 1px solid;
|
|
|
|
border-color: $primary-color;
|
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
</style>
|