Skip to content

Commit

Permalink
fix(frontend): mongodb实例视图 #2920
Browse files Browse the repository at this point in the history
  • Loading branch information
styLjc committed Jan 10, 2024
1 parent d2be9d7 commit 60708fa
Show file tree
Hide file tree
Showing 21 changed files with 1,085 additions and 12 deletions.
6 changes: 4 additions & 2 deletions dbm-ui/frontend/src/common/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,10 @@ export enum TicketTypes {
RIAK_CLUSTER_ENABLE = 'RIAK_CLUSTER_ENABLE', // Riak 集群启用
RIAK_CLUSTER_SCALE_OUT = 'RIAK_CLUSTER_SCALE_OUT', // Riak 集群扩容
RIAK_CLUSTER_SCALE_IN = 'RIAK_CLUSTER_SCALE_IN', // Riak 集群缩容
RIAK_CLUSTER_REBOOT = 'RIAK_CLUSTER_REBOOT' // Riak 节点重启
}
RIAK_CLUSTER_REBOOT = 'RIAK_CLUSTER_REBOOT', // Riak 节点重启
MONGODB_DISABLE = 'MONGODB_DISABLE', // mongodb禁用
MONGODB_INSTANCE_RELOAD = 'MONGODB_INSTANCE_RELOAD'// mongodb重启
}
export type TicketTypesStrings = keyof typeof TicketTypes;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@
import { exportHdfsClusterToExcel, exportHdfsInstanceToExcel } from '@services/source/hdfs';
import { exportInfluxdbClusterToExcel, exportInfluxdbInstanceToExcel } from '@services/source/influxdb';
import { exportKafkaClusterToExcel, exportKafkaInstanceToExcel } from '@services/source/kafka';
import { exportMongodbInstanceToExcel } from '@services/source/mongodbInstance';
import { exportPulsarClusterToExcel, exportPulsarInstanceToExcel } from '@services/source/pulsar';
import { exportRedisClusterToExcel, exportRedisInstanceToExcel } from '@services/source/redis';
import { exportSpiderClusterToExcel, exportSpiderInstanceToExcel } from '@services/source/spider';
import { exportTendbhaClusterToExcel, exportTendbhaInstanceToExcel } from '@services/source/tendbha';
import { exportTendbsingleClusterToExcel, exportTendbsingleInstanceToExcel } from '@services/source/tendbsingle';
interface Props {
type: 'tendbsingle' | 'tendbha' | 'spider' | 'redis' | 'pulsar' | 'kafka' | 'influxdb' | 'hdfs' | 'es';
type: 'tendbsingle' | 'tendbha' | 'spider' | 'redis' | 'pulsar' | 'kafka' | 'influxdb' | 'hdfs' | 'es' | 'mongodb';
ids?: number[];
exportType?: 'cluster' | 'instance';
hasSelected?: boolean;
Expand Down Expand Up @@ -98,6 +99,9 @@
cluster: exportEsClusterToExcel,
instance: exportEsInstanceToExcel,
},
mongodb: {
instance: exportMongodbInstanceToExcel,
},
};
const handleExport = async (type: 'all' | 'selected') => {
Expand Down
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/layout/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
'DatabaseWhitelist',
'ticketManage',
'DBPasswordTemporaryModify',
'Mongodb',
],
[menuEnum.observableManage]: [
'DBHASwitchEvents',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@
value: 'riak',
icon: 'cluster',
},
// {
// name: 'MongoDB',
// value: 'mongoDB',
// icon: 'mysql',
// },
{
name: 'MongoDB',
value: 'mongodb',
icon: 'mysql',
},
],
[t('时序数据库')]: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Hdfs from './Hdfs.vue';
import Influxdb from './Influxdb.vue';
import Kafka from './Kafka.vue';
import MongoDB from './MongoDB.vue';
import Mysql from './Mysql.vue';
import Pulsar from './Pulsar.vue';
import Redis from './Redis.vue';
Expand All @@ -30,6 +31,7 @@
redis: Redis,
tendbCluster: TendbCluster,
riak: Riak,
mongodb: MongoDB,
};
const renderCom = computed(() => comMap[props.name as keyof typeof comMap]);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<FunController module-id="mongodb">
<BkMenuGroup name="mongodb">
<BkSubmenu
:title="t('集群管理')">
<template #icon>
<DbIcon type="cluster" />
</template>
<BkMenuItem key="mongodbInstance">
<span
v-overflow-tips.right
class="text-overflow">
{{ t('实例视图') }}
</span>
</BkMenuItem>
</BkSubmenu>
</BkMenuGroup>
</FunController>
</template>
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
</script>
12 changes: 12 additions & 0 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2553,5 +2553,17 @@
"规则下存在实例_不可删除": "规则下存在实例,不可删除",
"确认删除该规则?": "确认删除该规则?",
"IP_PORT_或_域名_端口": "IP:PORT 或 域名:端口",
"mongDB实例视图": "【MongDB】实例视图",
"实例:name": "实例:{name}",
"主域名": "主域名",
"从域名": "从域名",
"请输入关键字或选择条件搜索": "请输入关键字或选择条件搜索",
"集群架构": "集群架构",
"分片集群": "分片集群",
"分片名": "分片名",
"副本集": "副本集",
"导出": "导出",
"副本集集群": "副本集集群",
"分片集群实例": "分片集群实例",
"这行勿动!新增翻译请在上一行添加!": ""
}
4 changes: 4 additions & 0 deletions dbm-ui/frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {

import type {
BigdataFunctions,
MongoFunctions,
MySQLFunctions,
RedisFunctions,
} from '@services/model/function-controller/functionController';
Expand All @@ -36,6 +37,7 @@ import getHDFSRoutes from '@views/hdfs-manage/routes';
import getInfluxDBRoutes from '@views/influxdb-manage/routes';
import getInspectionRoutes from '@views/inspection-manage/routes';
import getKafkaRoutes from '@views/kafka-manage/routes';
import getMongoRoutes from '@views/mongodb-manage/routes';
import getDBMonitorAlarmRoutes from '@views/monitor-alarm-db/routes';
import getPlatMonitorAlarmRoutes from '@views/monitor-alarm-plat/routes';
import getMysqlRoutes from '@views/mysql/routes';
Expand Down Expand Up @@ -86,6 +88,7 @@ export default () => {
const mysqlController = funControllerData.getFlatData<MySQLFunctions, 'mysql'>('mysql');
const redisController = funControllerData.getFlatData<RedisFunctions, 'redis'>('redis');
const bigdataController = funControllerData.getFlatData<BigdataFunctions, 'bigdata'>('bigdata');
const mongdbController = funControllerData.getFlatData<MongoFunctions, 'mongodb'>('mongodb');

appRouter = createRouter({
history: createWebHistory(),
Expand Down Expand Up @@ -129,6 +132,7 @@ export default () => {
...getTemporaryPasswordModify(),
...getRiakManage(bigdataController),
...getTicketFlowSettingRoutes(),
...getMongoRoutes(mongdbController),
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-len */
/*
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available.
*
Expand All @@ -16,7 +17,8 @@ export type MySQLFunctions = 'toolbox' | 'tendbsingle' | 'tendbha' | 'tendbclust
export type RedisFunctions = 'PredixyTendisplusCluster' | 'TwemproxyRedisInstance' | 'TwemproxyTendisSSDInstance' | 'toolbox';
export type BigdataFunctions = 'es' | 'kafka' | 'hdfs' | 'influxdb' | 'pulsar' | 'riak';
export type MonitorFunctions = 'duty_rule' | 'monitor_policy' | 'notice_group';
export type FunctionKeys = AddonsFunctions | MySQLFunctions | RedisFunctions | BigdataFunctions | MonitorFunctions
export type MongoFunctions = 'mongodb';
export type FunctionKeys = AddonsFunctions | MySQLFunctions | RedisFunctions | BigdataFunctions | MonitorFunctions | MongoFunctions

export interface ControllerBaseInfo {
is_enabled: boolean,
Expand All @@ -32,6 +34,7 @@ interface ControllerData {
redis: ControllerItem<RedisFunctions>,
bigdata: ControllerItem<BigdataFunctions>,
monitor: ControllerItem<MonitorFunctions>,
mongodb: ControllerItem<MongoFunctions>,
}

export type ExtractedControllerDataKeys = Extract<keyof ControllerData, string>;
Expand All @@ -42,13 +45,15 @@ export default class FunctionController {
redis: ControllerItem<RedisFunctions>;
bigdata: ControllerItem<BigdataFunctions>;
monitor: ControllerItem<MonitorFunctions>;
mongodb: ControllerItem<MongoFunctions>;

constructor(payload = {} as ControllerData) {
this.addons = payload.addons;
this.mysql = payload.mysql;
this.redis = payload.redis;
this.bigdata = payload.bigdata;
this.monitor = payload.monitor;
this.mongodb = payload.mongodb;
}

getFlatData<
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
export default class mongodbInstanceDetail {
bk_agent_id: string;
bk_cloud_id: number;
bk_cloud_name: string;
bk_cpu: number;
bk_disk: number;
bk_host_id: number;
bk_host_innerip: string;
bk_idc_id: string;
bk_idc_name: string;
bk_mem: number;
bk_os_name: string;
cluster_id: number;
cluster_name: string;
cluster_type: string;
create_at: string;
db_module_id: number;
db_version: null;
id: number;
instance_address: string;
ip: string;
machine_type: string;
master_domain: string;
port: number;
role: string;
shard: string;
slave_domain: string;
spec_config: string;
status: string;
version: string;

constructor(payload: mongodbInstanceDetail) {
this.bk_agent_id = payload.bk_agent_id;
this.bk_cloud_id = payload.bk_cloud_id;
this.bk_cloud_name = payload.bk_cloud_name;
this.bk_cpu = payload.bk_cpu;
this.bk_disk = payload.bk_disk;
this.bk_host_id = payload.bk_host_id;
this.bk_host_innerip = payload.bk_host_innerip;
this.bk_idc_id = payload.bk_idc_id;
this.bk_idc_name = payload.bk_idc_name;
this.bk_mem = payload.bk_mem;
this.bk_os_name = payload.bk_os_name;
this.cluster_id = payload.cluster_id;
this.cluster_name = payload.cluster_name;
this.cluster_type = payload.cluster_type;
this.create_at = payload.create_at;
this.db_module_id = payload.db_module_id;
this.db_version = payload.db_version;
this.id = payload.id;
this.instance_address = payload.instance_address;
this.ip = payload.ip;
this.machine_type = payload.machine_type;
this.master_domain = payload.master_domain;
this.port = payload.port;
this.role = payload.role;
this.shard = payload.shard;
this.slave_domain = payload.slave_domain;
this.spec_config = payload.spec_config;
this.status = payload.status;
this.version = payload.version;
}
}
71 changes: 71 additions & 0 deletions dbm-ui/frontend/src/services/model/mongodb/mongodb-instance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import dayjs from 'dayjs';

import { t } from '@locales';

export default class mongodbInstance {
static themes: Record<string, string> = {
running: 'success',
};
static statusMap: Record<string, string> = {
running: '正常',
unavailable: '异常',
};
bk_cloud_id: number;
bk_cloud_name: string;
bk_host_id: number;
cluster_id: number;
cluster_name: string;
cluster_type: string;
create_at: string;
db_module_id: string;
id: number;
ip: number;
instance_address: string;
machine_type: string;
master_domain: string;
port: number;
role: string;
shard: string;
slave_domain: string;
spec_config: string;
status: string;
version: string;

constructor(payload = {} as mongodbInstance) {
this.bk_cloud_id = payload.bk_cloud_id;
this.bk_cloud_name = payload.bk_cloud_name;
this.bk_host_id = payload.bk_host_id;
this.cluster_id = payload.cluster_id;
this.cluster_name = payload.cluster_name;
this.cluster_type = payload.cluster_type;
this.create_at = payload.create_at;
this.db_module_id = payload.db_module_id;
this.id = payload.id;
this.instance_address = payload.instance_address;
this.ip = payload.ip;
this.machine_type = payload.machine_type;
this.master_domain = payload.master_domain;
this.port = payload.port;
this.role = payload.role;
this.shard = payload.shard;
this.spec_config = payload.spec_config;
this.slave_domain = payload.slave_domain;
this.status = payload.status;
this.version = payload.version;
}

get isNew() {
return dayjs().isBefore(dayjs(this.create_at).add(24, 'hour'));
}

get dbStatusConfigureObj() {
const text = mongodbInstance.statusMap[this.status] || '--';
const theme = mongodbInstance.themes[this.status] || 'danger';
return { text, theme };
}

get clusterTypeText() {
return this.cluster_type === 'MongoReplicaSet' ? t('副本集') : t('分片集群');
}
}

Loading

0 comments on commit 60708fa

Please sign in to comment.