Skip to content

Commit

Permalink
chore(frontend): 完善 model 类型定义、service 路径调整 #7131
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 19411
  • Loading branch information
hailinxiao authored and hLinx committed Sep 25, 2024
1 parent def821e commit b14fb66
Show file tree
Hide file tree
Showing 284 changed files with 1,800 additions and 2,701 deletions.
16 changes: 8 additions & 8 deletions dbm-ui/frontend/src/components/cluster-selector/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@
T extends
| RedisModel
| TendbhaModel
| SpiderModel
| TendbclusterModel
| TendbsingleModel
| MongodbModel
| SqlServerHaClusterModel
| SqlServerSingleClusterModel
| SqlServerHaModel
| SqlServerSingleModel
">
import _ from 'lodash';
import { useI18n } from 'vue-i18n';
Expand All @@ -136,14 +136,14 @@
import TendbhaModel from '@services/model/mysql/tendbha';
import TendbsingleModel from '@services/model/mysql/tendbsingle';
import RedisModel from '@services/model/redis/redis';
import SpiderModel from '@services/model/spider/tendbCluster';
import SqlServerHaClusterModel from '@services/model/sqlserver/sqlserver-ha-cluster';
import SqlServerSingleClusterModel from '@services/model/sqlserver/sqlserver-single-cluster';
import SqlServerHaModel from '@services/model/sqlserver/sqlserver-ha';
import SqlServerSingleModel from '@services/model/sqlserver/sqlserver-single';
import TendbclusterModel from '@services/model/tendbcluster/tendbcluster';
import { getMongoList } from '@services/source/mongodb';
import { getRedisList } from '@services/source/redis';
import { getSpiderList } from '@services/source/spider';
import { getHaClusterList } from '@services/source/sqlserveHaCluster';
import { getSingleClusterList } from '@services/source/sqlserverSingleCluster';
import { getTendbClusterList } from '@services/source/tendbcluster';
import { getTendbhaList, getTendbhaSalveList } from '@services/source/tendbha';
import { getTendbsingleList } from '@services/source/tendbsingle';
import type { ListBase } from '@services/types';
Expand Down Expand Up @@ -229,7 +229,7 @@
},
],
multiple: true,
getResourceList: getSpiderList,
getResourceList: getTendbClusterList,
tableContent: SpiderTable,
resultContent: ResultPreview,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import { shallowRef } from 'vue';
import { useI18n } from 'vue-i18n';

import SqlServerHaClusterModel from '@services/model/sqlserver/sqlserver-ha-cluster';
import SqlServerSingleClusterModel from '@services/model/sqlserver/sqlserver-single-cluster';
import SqlServerHaModel from '@services/model/sqlserver/sqlserver-ha';
import SqlServerSingleModel from '@services/model/sqlserver/sqlserver-single';

import { useLinkQueryColumnSerach } from '@hooks';

Expand All @@ -63,7 +63,7 @@

interface Props {
activeTab: ClusterTypes,
selected: Record<string, (SqlServerSingleClusterModel | SqlServerHaClusterModel)[]>,
selected: Record<string, (SqlServerSingleModel | SqlServerHaModel)[]>,
getResourceList: NonNullable<TabItem['getResourceList']>,
disabledRowConfig: NonNullable<TabItem['disabledRowConfig']>,
columnStatusFilter?: TabItem['columnStatusFilter'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import { shallowRef } from 'vue';
import { useI18n } from 'vue-i18n';

import SqlServerHaClusterModel from '@services/model/sqlserver/sqlserver-ha-cluster';
import SqlServerSingleClusterModel from '@services/model/sqlserver/sqlserver-single-cluster';
import SqlServerHaModel from '@services/model/sqlserver/sqlserver-ha';
import SqlServerSingleModel from '@services/model/sqlserver/sqlserver-single';

import { useLinkQueryColumnSerach } from '@hooks';

Expand All @@ -63,7 +63,7 @@

interface Props {
activeTab: ClusterTypes,
selected: Record<string, (SqlServerSingleClusterModel | SqlServerHaClusterModel)[]>,
selected: Record<string, (SqlServerSingleModel | SqlServerHaModel)[]>,
getResourceList: NonNullable<TabItem['getResourceList']>,
disabledRowConfig: NonNullable<TabItem['disabledRowConfig']>,
columnStatusFilter?: TabItem['columnStatusFilter'],
Expand Down
18 changes: 9 additions & 9 deletions dbm-ui/frontend/src/components/instance-selector/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<script lang="ts">
import type { InjectionKey, Ref } from 'vue';

import SpiderMachineModel from '@services/model/spider/spiderMachine';
import TendbclusterMachineModel from '@services/model/tendbcluster/tendbcluster-machine';
import type { ListBase } from '@services/types';

import { t } from '@locales/index';
Expand All @@ -121,7 +121,7 @@
instance: string;
status: string;
}[];
spec_config?: SpiderMachineModel['spec_config'];
spec_config?: TendbclusterMachineModel['spec_config'];
role: string;
}

Expand Down Expand Up @@ -192,7 +192,6 @@
queryClusters as queryMysqlCluster,
} from '@services/source/mysqlCluster';
import { getRedisClusterList, getRedisMachineList } from '@services/source/redis';
import { getSpiderInstanceList, getSpiderMachineList } from '@services/source/spider';
import {
getHaClusterWholeList as getSqlServerHaCluster,
getSqlServerInstanceList,
Expand All @@ -201,6 +200,7 @@
getSingleClusterList,
getSqlServerInstanceList as getSqlServerSingleInstanceList,
} from '@services/source/sqlserverSingleCluster';
import { getTendbclusterInstanceList, getTendbclusterMachineList } from '@services/source/tendbcluster';
import { getTendbhaInstanceList } from '@services/source/tendbha';
import { getTendbsingleInstanceList } from '@services/source/tendbsingle';

Expand Down Expand Up @@ -366,7 +366,7 @@
getTopoList: getMysqlClusterList,
},
tableConfig: {
getTableList: getSpiderInstanceList,
getTableList: getTendbclusterInstanceList,
firsrColumn: {
label: 'remote_master',
field: 'instance_address',
Expand All @@ -379,7 +379,7 @@
id: 'manualInput',
name: t('手动输入'),
tableConfig: {
getTableList: getSpiderInstanceList,
getTableList: getTendbclusterInstanceList,
firsrColumn: {
label: 'remote_master',
field: 'instance_address',
Expand Down Expand Up @@ -493,7 +493,7 @@
id: 'manualInput',
name: t('手动输入'),
tableConfig: {
getTableList: getSpiderInstanceList,
getTableList: getTendbclusterInstanceList,
firsrColumn: {
label: 'IP',
field: 'ip',
Expand Down Expand Up @@ -523,7 +523,7 @@
},
},
tableConfig: {
getTableList: getSpiderMachineList,
getTableList: getTendbclusterMachineList,
firsrColumn: {
label: t('主库主机'),
field: 'ip',
Expand All @@ -540,7 +540,7 @@
id: 'manualInput',
name: t('手动输入'),
tableConfig: {
getTableList: getSpiderMachineList,
getTableList: getTendbclusterMachineList,
firsrColumn: {
label: 'remote_master',
field: 'ip',
Expand All @@ -549,7 +549,7 @@
columnsChecked: ['ip', 'related_instances', 'cloud_area', 'alive', 'host_name', 'os_name'],
},
manualConfig: {
checkInstances: getSpiderMachineList,
checkInstances: getTendbclusterMachineList,
checkType: 'ip',
checkKey: 'ip',
activePanelId: 'TendbClusterHost',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import type { Ref } from 'vue';
import { useI18n } from 'vue-i18n';

import T from '@services/model/spider/spiderMachine';
import T from '@services/model/tendbcluster/tendbcluster-machine';

import DbStatus from '@components/db-status/index.vue';

Expand Down
24 changes: 12 additions & 12 deletions dbm-ui/frontend/src/components/ip-selector/IpSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@

import { checkHost, getHostDetails, getHosts, getHostTopo } from '@services/source/ipchooser';
import { getWhitelist } from '@services/source/whitelist';
import type { HostDetails } from '@services/types';
import type { HostInfo } from '@services/types';

import { useCopy, useFormItem } from '@hooks';

Expand All @@ -132,7 +132,7 @@
/** IP 选择器返回结果 */
export type IPSelectorResult = {
dynamic_group_list: any[];
host_list: Array<HostDetails>;
host_list: Array<HostInfo>;
node_list: any[];
dbm_whitelist: any[];
};
Expand All @@ -144,7 +144,7 @@
buttonText?: string;
searchPlaceholder?: string;
tableProps?: TablePropTypes;
data?: HostDetails[];
data?: HostInfo[];
title?: string;
showView?: boolean;
required?: boolean;
Expand Down Expand Up @@ -402,50 +402,50 @@
{
label: t('管控区域'),
field: 'cloud_area',
render: ({data}: {data: HostDetails}) => data.cloud_area || '--',
render: ({data}: {data: HostInfo}) => data.cloud_area || '--',
},
{
label: t('Agent状态'),
field: 'alive',
render: ({data}: {data: HostDetails}) => {
render: ({data}: {data: HostInfo}) => {
const info = data.alive === 1 ? { theme: 'success', text: t('正常') } : { theme: 'danger', text: t('异常') };
return <DbStatus theme={info.theme}>{info.text}</DbStatus>;
},
},
{
label: t('主机名称'),
field: 'host_name',
render: ({data}: {data: HostDetails}) => data.host_name || '--',
render: ({data}: {data: HostInfo}) => data.host_name || '--',
},
{
label: t('OS名称'),
field: 'os_name',
render: ({data}: {data: HostDetails}) => data.os_name || '--',
render: ({data}: {data: HostInfo}) => data.os_name || '--',
},
{
label: t('所属云厂商'),
field: 'cloud_vendor',
render: ({data}: {data: HostDetails}) => data.cloud_vendor || '--',
render: ({data}: {data: HostInfo}) => data.cloud_vendor || '--',
},
{
label: t('OS类型'),
field: 'os_type',
render: ({data}: {data: HostDetails}) => data.os_type || '--',
render: ({data}: {data: HostInfo}) => data.os_type || '--',
},
{
label: t('主机ID'),
field: 'host_id',
render: ({data}: {data: HostDetails}) => data.host_id || '--',
render: ({data}: {data: HostInfo}) => data.host_id || '--',
},
{
label: 'Agent ID',
field: 'agent_id',
render: ({data}: {data: HostDetails}) => data.agent_id || '--',
render: ({data}: {data: HostInfo}) => data.agent_id || '--',
},
{
label: 'IPv6',
field: 'ipv6',
render: ({data}: {data: HostDetails}) => data.ipv6 || '--',
render: ({data}: {data: HostInfo}) => data.ipv6 || '--',
},
{
label: t('操作'),
Expand Down
6 changes: 3 additions & 3 deletions dbm-ui/frontend/src/components/more-action-extend/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
};
</script>

<style lang="less" scoped>
<style lang="less">
.operation-more-main {
color: #3a84ff;
display: flex;
align-items: center;
color: #3a84ff;
cursor: pointer;
align-items: center;
.more-icon {
transform: rotate(0deg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
* the specific language governing permissions and limitations under the License.
*/

import SpiderModel from '@services/model/spider/spider';
import TendbclusterModel from '@services/model/tendbcluster/tendbcluster';
import type { SpiderMNTApplyDetails } from '@services/model/ticket/details/spider';
import TicketModel from '@services/model/ticket/ticket';
import { getSpiderList } from '@services/source/spider';
import { getTendbClusterList } from '@services/source/tendbcluster';

import { random } from '@utils';

// Spider 临时节点添加
export async function generateSpiderAddMntDataCloneData(ticketData: TicketModel<SpiderMNTApplyDetails>) {
const { infos } = ticketData.details;
const clusterListResult = await getSpiderList({
const clusterListResult = await getTendbClusterList({
cluster_ids: infos.map((item) => item.cluster_id),
});
const clusterListMap = clusterListResult.results.reduce<Record<number, SpiderModel>>((obj, item) => {
const clusterListMap = clusterListResult.results.reduce<Record<number, TendbclusterModel>>((obj, item) => {
Object.assign(obj, {
[item.id]: item,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import type { MysqlAuthorizationDetails } from '@services/model/ticket/details/mysql';
import TicketModel from '@services/model/ticket/ticket';
import { checkHost } from '@services/source/ipchooser';
import { getSpiderList } from '@services/source/spider';
import { getTendbClusterList } from '@services/source/tendbcluster';

import { ClusterTypes } from '@common/const';

Expand All @@ -34,7 +34,7 @@ export async function generateSpiderAuthorizeRuleCloneData(ticketData: TicketMod
sourceIpList.push(...checkIpInfo);
}

const clustersResult = await getSpiderList({
const clustersResult = await getTendbClusterList({
cluster_ids: authorizeData.cluster_ids,
limit: -1,
offset: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
* the specific language governing permissions and limitations under the License.
*/

import SpiderModel from '@services/model/spider/spider';
import TendbclusterModel from '@services/model/tendbcluster/tendbcluster';
import type { SpiderNodeRebalanceDetails } from '@services/model/ticket/details/spider';
import TicketModel from '@services/model/ticket/ticket';
import { getSpiderList } from '@services/source/spider';
import { getTendbClusterList } from '@services/source/tendbcluster';

import { random } from '@utils';

Expand All @@ -27,10 +27,10 @@ export async function generateSpiderCapacityChangeCloneData(ticketData: TicketMo
trigger_checksum_time: triggerChecksumTime,
backup_source: backupSource,
} = ticketData.details;
const clusterListResult = await getSpiderList({
const clusterListResult = await getTendbClusterList({
cluster_ids: infos.map((item) => item.cluster_id),
});
const clusterListMap = clusterListResult.results.reduce<Record<number, SpiderModel>>((obj, item) => {
const clusterListMap = clusterListResult.results.reduce<Record<number, TendbclusterModel>>((obj, item) => {
Object.assign(obj, {
[item.id]: item,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
* the specific language governing permissions and limitations under the License.
*/

import SpiderMachineModel from '@services/model/spider/spiderMachine';
import TendbclusterMachineModel from '@services/model/tendbcluster/tendbcluster-machine';
import type { SpiderMigrateCluster } from '@services/model/ticket/details/spider';
import TicketModel from '@services/model/ticket/ticket';
import { getSpiderMachineList } from '@services/source/spider';
import { getTendbclusterMachineList } from '@services/source/tendbcluster';

import { random } from '@utils';

// spider 迁移主从
export async function generateSpiderMasterSlaveCloneCloneData(ticketData: TicketModel<SpiderMigrateCluster>) {
const { infos, backup_source: backupSource } = ticketData.details;
const masterMachineResult = await getSpiderMachineList({
const masterMachineResult = await getTendbclusterMachineList({
ip: infos.map((item) => item.old_master.ip).join(','),
instance_role: 'remote_master',
});
const masterMachineMap = masterMachineResult.results.reduce<Record<string, SpiderMachineModel>>((obj, item) => {
const masterMachineMap = masterMachineResult.results.reduce<Record<string, TendbclusterMachineModel>>((obj, item) => {
Object.assign(obj, {
[item.ip]: item,
});
Expand Down
Loading

0 comments on commit b14fb66

Please sign in to comment.