Skip to content

Commit

Permalink
fix(frontend): 权限问题修复 #3682
Browse files Browse the repository at this point in the history
  • Loading branch information
hLinx authored and iSecloud committed May 23, 2024
1 parent da86147 commit dde972e
Show file tree
Hide file tree
Showing 39 changed files with 358 additions and 474 deletions.
2 changes: 1 addition & 1 deletion dbm-ui/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@blueking/bk-weweb": "0.0.24",
"@blueking/bkflow.js": "0.1.10",
"@blueking/date-picker": "0.0.72",
"@blueking/ip-selector": "0.0.1-beta.138",
"@blueking/ip-selector": "0.3.0-beta.23",
"@blueking/notice-component": "2.0.4",
"@blueking/sub-saas": "^0.0.0-beta.6",
"@icon-cool/bk-icon-bk-biz-components": "0.0.4",
Expand Down
15 changes: 9 additions & 6 deletions dbm-ui/frontend/src/components/instance-selector/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,21 @@

export interface IValue {
[key: string]: any;
bk_host_id: number;
bk_cloud_id: number;
bk_cloud_name: string;
bk_host_id: number;
cluster_id: number;
cluster_name: string;
cluster_type: string;
db_module_id: number;
db_module_name: string;
id: number;
ip: string;
port: number;
instance_address: string;
cluster_id: number;
cluster_type: string;
status?: string;
host_info?: any;
id?: number;
master_domain?: string;
master_domain: string;
related_instances?: {
instance: string;
status: string;
Expand Down Expand Up @@ -254,7 +257,7 @@
}

interface Emits {
(e: 'change', value: Props['selected']): void;
(e: 'change', value: NonNullable<Props['selected']>): void;
}

const props = withDefaults(defineProps<Props>(), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
bk_cloud_id: data.host_info.cloud_id,
port: data.port,
ip: data.ip,
db_module_id: data.db_module_id,
db_module_name: data.db_module_name,
});

const search = ref('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
ip: data.ip || '',
port: data.port,
cluster_type: data.cluster_type as MySQLClusterTypes,
db_module_id: data.db_module_id,
db_module_name: data.db_module_name,
});

const { t } = useI18n();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@
related_instances: (data.related_instances || []).map(instanceItem => ({
instance: instanceItem.instance,
status: instanceItem.status
}))
})),
db_module_id: data.db_module_id,
db_module_name: data.db_module_name,
});

const { t } = useI18n();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
ip: data.ip || '',
port: data.port,
cluster_type: data.cluster_type,
db_module_id: data.db_module_id,
db_module_name: data.db_module_name,
});

const { t } = useI18n();
Expand Down Expand Up @@ -286,7 +288,6 @@
checkedMap.value = lastCheckMap;
triggerChange();
};

</script>

<style lang="less">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
ip: data.ip || '',
port: data.port,
cluster_type: data.cluster_type,
db_module_id: data.db_module_id,
db_module_name: data.db_module_name,
});

const { t } = useI18n();
Expand Down Expand Up @@ -340,7 +342,6 @@
checkedMap.value = lastCheckMap;
triggerChange();
};

</script>

<style lang="less">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@
instance: instanceItem.instance,
status: instanceItem.status
})),
spec_config: data.spec_config
spec_config: data.spec_config,
db_module_id: data.db_module_id,
db_module_name: data.db_module_name,
});

const { t } = useI18n();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
ip: data.ip || '',
port: data.port,
cluster_type: data.cluster_type,
db_module_id: data.db_module_id,
db_module_name: data.db_module_name,
});

const { t } = useI18n();
Expand Down Expand Up @@ -335,17 +337,16 @@
checkedMap.value = lastCheckMap;
triggerChange();
};

</script>

<style lang="less">
.instance-selector-render-topo-host {
padding: 0 24px;
.instance-selector-render-topo-host {
padding: 0 24px;

.bk-table-body {
tr {
cursor: pointer;
.bk-table-body {
tr {
cursor: pointer;
}
}
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@
instance: instanceItem.instance,
status: instanceItem.status
})),
spec_config: data.spec_config
spec_config: data.spec_config,
db_module_id: data.db_module_id,
db_module_name: data.db_module_name,
});

const { t } = useI18n();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
:pagination="pagination.count < 10 ? false : pagination"
:remote-pagination="isRemotePagination"
:settings="tableSetting"
style="margin-top: 12px;"
style="margin-top: 12px"
@clear-search="clearSearchValue"
@column-filter="columnFilterChange"
@page-limit-change="handeChangeLimit"
Expand Down Expand Up @@ -106,7 +106,9 @@
cluster_type: data.cluster_type,
id: data.id,
master_domain: data.master_domain,
bk_cloud_name: data.bk_cloud_name
bk_cloud_name: data.bk_cloud_name,
db_module_id: data.db_module_id,
db_module_name: data.db_module_name,
});

const { t } = useI18n();
Expand Down Expand Up @@ -342,7 +344,6 @@
checkedMap.value = lastCheckMap;
triggerChange();
};

</script>

<style lang="less">
Expand Down
1 change: 0 additions & 1 deletion dbm-ui/frontend/src/components/ip-selector/IpSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@

const showDialog = defineModel<boolean>('showDialog', {
default: false,
local: true,
});

const copy = useCopy();
Expand Down
31 changes: 17 additions & 14 deletions dbm-ui/frontend/src/components/vue2/ip-selector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { h, onBeforeUnmount, onMounted, ref, watch } from 'vue';

import { Component, merge, Vue2 } from '@blueking/ip-selector/dist/vue2.6.x.esm';

Component.props.mode.default = 'section';

export default function (options) {
merge(options);

Expand All @@ -25,7 +27,13 @@ export default function (options) {
setup(props, context) {
const rootRef = ref();

let app = new Vue2(Component);
let app = new Vue2({
render: (h) =>
h(Component, {
ref: 'componentRef',
props,
}),
});

const syncProps = () => {
Object.keys(props).forEach((propName) => {
Expand All @@ -39,13 +47,13 @@ export default function (options) {
{},
);
// eslint-disable-next-line no-underscore-dangle
app._props[propName] = Object.freeze(v);
app.$refs.componentRef._props[propName] = Object.freeze(v);
} else if (Object.prototype.toString.call(newValue) === '[object Array]') {
// eslint-disable-next-line no-underscore-dangle
app._props[propName] = [...newValue];
app.$refs.componentRef._props[propName] = [...newValue];
} else {
// eslint-disable-next-line no-underscore-dangle
app._props[propName] = newValue;
app.$refs.componentRef._props[propName] = newValue;
}
});
};
Expand All @@ -57,22 +65,17 @@ export default function (options) {
() => {
syncProps();
},
{
immediate: true,
},
);
propWatchStack.push(unwatch);
});

Component.emits.forEach((eventName) => {
app.$on(eventName, (...agrs) => {
context.emit(eventName, ...agrs);
});
});
syncProps();

onMounted(() => {
app.$mount();
Component.emits.forEach((eventName) => {
app.$refs.componentRef.$on(eventName, (...agrs) => {
context.emit(eventName, ...agrs);
});
});
rootRef.value.appendChild(app.$el);
});

Expand Down
2 changes: 2 additions & 0 deletions dbm-ui/frontend/src/services/model/mysql/tendbha-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class tendbhaInstance {
cluster_type: string;
create_at: string;
db_module_id: number;
db_module_name: string;
host_info: {
alive: number;
biz: {
Expand Down Expand Up @@ -94,6 +95,7 @@ export default class tendbhaInstance {
this.cluster_type = payload.cluster_type || '';
this.create_at = payload.create_at || '';
this.db_module_id = payload.db_module_id || 0;
this.db_module_name = payload.db_module_name || '';
this.host_info = payload.host_info || {};
this.id = payload.id || 0;
this.instance_address = payload.instance_address || '';
Expand Down
5 changes: 4 additions & 1 deletion dbm-ui/frontend/src/services/model/redis/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,18 @@ export default class Redis {
title: string;
}[];
permission: {
access_entry_edit: boolean;
redis_access_entry_view: boolean;
redis_backup: boolean;
redis_destroy: boolean;
redis_keys_delete: boolean;
redis_keys_extract: boolean;
redis_open_close: boolean;
redis_plugin_create_clb: boolean;
redis_plugin_create_polaris: boolean;
redis_plugin_dns_bind_clb: boolean;
redis_purge: boolean;
redis_view: boolean;
access_entry_edit: boolean;
};
phase: string;
proxy: Node[];
Expand Down
39 changes: 29 additions & 10 deletions dbm-ui/frontend/src/services/source/dbbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
* the specific language governing permissions and limitations under the License.
*/

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

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

import http from '../http';
Expand All @@ -31,13 +28,35 @@ export function verifyDuplicatedClusterName(params: { cluster_type: string; name
* 根据过滤条件查询集群详细信息
*/
export function filterClusters(params: { bk_biz_id: number; exact_domain: string }) {
return http.get<any[]>(`${path}/filter_clusters/`, params).then((data: { cluster_type: string }[]) => {
const ModelMap: Record<string, any> = {
[ClusterTypes.SQLSERVER_SINGLE]: SqlServerSingleClusterModel,
[ClusterTypes.SQLSERVER_HA]: SqlServerHaClusterModel,
};
return data.map((item) => new ModelMap[data[0].cluster_type](item));
});
return http.get<
{
bk_biz_id: number;
bk_biz_name: string;
bk_cloud_id: number;
bk_cloud_name: string;
cluster_capacity: number;
cluster_shard_num: number;
cluster_spec: {
cpu: {
max: number;
min: number;
};
mem: {
max: number;
min: number;
};
qps: {
max: number;
min: number;
};
spec_name: string;
};
db_module_id: number;
id: number;
machine_pair_cnt: number;
master_domain: string;
}[]
>(`${path}/filter_clusters/`, params);
}

/*
Expand Down
4 changes: 3 additions & 1 deletion dbm-ui/frontend/src/services/source/mysqlCluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ export function queryClusters(params: {
/**
* 通过集群域名获取集群详情
*/
export function getClusterInfoByDomains(params: Record<'cluster_filters', Array<{ immute_domain: string }>> & { bizId: number }) {
export function getClusterInfoByDomains(
params: Record<'cluster_filters', Array<{ immute_domain: string }>> & { bizId: number },
) {
return http.post<TendbhaModel[]>(`${path}/query_clusters/`, params);
}
2 changes: 2 additions & 0 deletions dbm-ui/frontend/src/services/types/clusters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ export interface InstanceInfos {
cluster_type: string;
cluster_domain: string;
create_at: string;
db_module_id: number;
db_module_name: string;
host_info: HostDetails;
instance_address: string;
ip: string;
Expand Down
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/services/types/resourceInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface ResourceInstance {
cluster_type: string;
create_at: string;
db_module_id: number;
db_module_name: string;
host_info: HostDetails;
id: number;
instance_address: string;
Expand Down
Loading

0 comments on commit dde972e

Please sign in to comment.