Files
im_manager/web/src/views/imTenant/usage.vue
T

84 lines
3.4 KiB
Vue

<template>
<n-modal
v-model:show="showModal"
preset="dialog"
:show-icon="false"
:title="'租户健康与用量 #' + current.id"
:mask-closable="false"
:style="{ width: dialogWidth }"
>
<n-spin :show="loading" description="请稍候...">
<n-descriptions label-placement="left" bordered :column="settingStore.isMobile ? 1 : 2">
<n-descriptions-item label="租户">{{ usage.name || current.name }}</n-descriptions-item>
<n-descriptions-item label="租户编码">{{ usage.code || current.code }}</n-descriptions-item>
<n-descriptions-item label="业务库">{{ usage.dbName || '-' }}</n-descriptions-item>
<n-descriptions-item label="独立连接串">
{{ usage.dbDsnConfigured ? '已配置' : '未配置' }}
</n-descriptions-item>
<n-descriptions-item label="业务库状态">
<n-tag :type="usage.dbReachable ? 'success' : 'error'" :bordered="false">
{{ usage.dbReachable ? '可达' : '不可达' }}
</n-tag>
</n-descriptions-item>
<n-descriptions-item label="Schema版本">
{{ usage.schemaVersion || '-' }}
</n-descriptions-item>
<n-descriptions-item label="用户数">{{ usage.userCount }}</n-descriptions-item>
<n-descriptions-item label="正常用户数">{{ usage.activeUserCount }}</n-descriptions-item>
<n-descriptions-item label="群数">{{ usage.groupCount }}</n-descriptions-item>
<n-descriptions-item label="设备数">{{ usage.deviceCount }}</n-descriptions-item>
<n-descriptions-item label="Push Token">{{ usage.pushTokenCount }}</n-descriptions-item>
<n-descriptions-item label="邀请码使用">{{ usage.inviteUseCount }}</n-descriptions-item>
<n-descriptions-item label="待处理Outbox">
{{ usage.outboxPendingCount }}
</n-descriptions-item>
<n-descriptions-item v-if="usage.dbCheckError" label="连接错误" :span="2">
{{ usage.dbCheckError }}
</n-descriptions-item>
<n-descriptions-item v-if="usage.warnings?.length" label="检查警告" :span="2">
<n-code :code="usage.warnings.join('\n')" language="text" word-wrap />
</n-descriptions-item>
</n-descriptions>
</n-spin>
<template #action>
<n-space>
<n-button @click="load">刷新</n-button>
<n-button @click="showModal = false">关闭</n-button>
</n-space>
</template>
</n-modal>
</template>
<script lang="ts" setup>
import { computed, ref } from 'vue';
import { Usage } from '@/api/imTenant';
import { newState, State, UsageState } from './model';
import { useProjectSettingStore } from '@/store/modules/projectSetting';
import { adaModalWidth } from '@/utils/hotgo';
const settingStore = useProjectSettingStore();
const showModal = ref(false);
const loading = ref(false);
const current = ref<State>(newState(null));
const usage = ref<UsageState>(new UsageState());
const dialogWidth = computed(() => adaModalWidth(900));
async function load() {
loading.value = true;
try {
usage.value = Object.assign(new UsageState(), await Usage({ id: current.value.id }));
} finally {
loading.value = false;
}
}
function openModal(state: State) {
current.value = newState(state);
usage.value = new UsageState();
showModal.value = true;
load();
}
defineExpose({ openModal });
</script>