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 zhangzhw8 committed Mar 28, 2024
1 parent c6a2d81 commit 74b3806
Show file tree
Hide file tree
Showing 31 changed files with 405 additions and 332 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default defineComponent({
},
bizId: {
type: [String, Number],
default: undefined,
},
},
setup(props) {
Expand Down
2 changes: 2 additions & 0 deletions dbm-ui/frontend/src/components/auth-component/use-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ const withBizActionList = [
'mysql_partition_update',
'mysql_partition_create',
'mysql_partition_enable_disable',
'mysql_openarea_config_create',
'tendbcluster_apply',
'tendbcluster_account_create',
'tendbcluster_account_delete',
'tendbcluster_add_account_rule',
'tendb_excel_authorize_rules',
'tendb_openarea_config_create',
'tendbcluster_cluster_clone_rules',
'tendbcluster_temporary_destroy',
'tendbcluster_partition_create',
Expand Down
5 changes: 5 additions & 0 deletions dbm-ui/frontend/src/services/model/db-resource/Operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export default class Operation {
create_time: string;
operation_type: string;
operator: string;
permission: {
flow_detail: boolean;
ticket_view: boolean;
};
request_id: string;
status: string;
task_id: string;
Expand All @@ -52,6 +56,7 @@ export default class Operation {
this.create_time = payload.create_time;
this.operation_type = payload.operation_type;
this.operator = payload.operator;
this.permission = payload.permission;
this.request_id = payload.request_id;
this.status = payload.status;
this.task_id = payload.task_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export default class DirtyMachines {
ticket_type: string;
ticket_type_display: string;
operator: string;
permission: {
dirty_pool_manage: boolean;
flow_detail: boolean;
ticket_view: boolean;
};

constructor(payload = {} as DirtyMachines) {
this.bk_biz_id = payload.bk_biz_id;
Expand All @@ -23,5 +28,6 @@ export default class DirtyMachines {
this.ticket_type = payload.ticket_type;
this.ticket_type_display = payload.ticket_type_display;
this.operator = payload.operator;
this.permission = payload.permission;
}
}
53 changes: 28 additions & 25 deletions dbm-ui/frontend/src/services/model/influxdb/influxdbInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ export default class InfluxDBInstance {
bk_cloud_id: number;
bk_cloud_name: string;
bk_host_id: number;
cpu: number;
create_at: string;
restart_at: string;
update_at: string;
domain: string;
creator: string;
disk: number;
group_id: null | number;
group_name: null | string;
id: number;
instance_address: string;
instance_name: string;
mem: number;
operations: Array<{
flow_id: number;
instance_id: number;
Expand All @@ -51,41 +54,41 @@ export default class InfluxDBInstance {
ticket_type: string;
title: string;
}>;
permission: {
influxdb_destroy: boolean;
influxdb_enable_disable: boolean;
influxdb_reboot: boolean;
influxdb_replace: boolean;
influxdb_view: boolean;
};
phase: string;
restart_at: string;
role: string;
status: string;
group_id: null | number;
group_name: null | string;
creator: string;
phase: string;
disk: number;
cpu: number;
mem: number;
permission: Record<
'influxdb_view' | 'influxdb_enable_disable' | 'influxdb_destroy' | 'influxdb_replace' | 'influxdb_reboot',
boolean
>;
update_at: string;
version: string;

constructor(payload = {} as InfluxDBInstance) {
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.cpu = payload.cpu;
this.create_at = payload.create_at;
this.restart_at = payload.restart_at;
this.update_at = payload.update_at;
this.domain = payload.domain;
this.creator = payload.creator;
this.disk = payload.disk;
this.group_id = payload.group_id;
this.group_name = payload.group_name;
this.id = payload.id;
this.instance_address = payload.instance_address;
this.instance_name = payload.instance_name;
this.mem = payload.mem;
this.permission = payload.permission;
this.phase = payload.phase;
this.restart_at = payload.restart_at;
this.role = payload.role;
this.status = payload.status;
this.group_id = payload.group_id;
this.group_name = payload.group_name;
this.creator = payload.creator;
this.phase = payload.phase;
this.disk = payload.disk;
this.mem = payload.mem;
this.cpu = payload.cpu;
this.permission = payload.permission || {};
this.update_at = payload.update_at;
this.version = payload.version;

this.operations = this.initOperations(payload.operations);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default class MonitorPolicy {
policy_status: string; // 策略状态:valid(正常)|invalid(异常)
parent_id: number;
permission: {
global_monitor_policy_clone: boolean;
global_monitor_policy_edit: boolean;
global_monitor_policy_start_stop: boolean;
monitor_policy_alarm_view: boolean;
Expand Down
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/services/model/mysql/tendbha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default class Tendbha {
mysql_enable_disable: boolean;
mysql_view: boolean;
access_entry_edit: boolean;
tbinlogdumper_install: boolean;
};
phase: string;
phase_name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default class TicketFlowDescribe {
configs: {
need_itsm: boolean;
need_manual_confirm: boolean;
}
};
creator: string;
editable: boolean;
flow_desc: string[];
Expand All @@ -17,15 +17,13 @@ export default class TicketFlowDescribe {
update_at: string;
updater: string;

constructor(payload = {} as TicketFlowDescribe){
constructor(payload = {} as TicketFlowDescribe) {
this.configs = payload.configs;
this.creator = payload.creator;
this.editable = payload.editable;
this.flow_desc = payload.flow_desc || [];
this.group = payload.group;
this.permission = {
ticket_config_set: false
};
this.permission = payload.permission;
this.ticket_type = payload.ticket_type;
this.ticket_type_display = payload.ticket_type_display;
this.update_at = payload.update_at;
Expand All @@ -35,5 +33,4 @@ export default class TicketFlowDescribe {
get updateAtDisplay() {
return utcDisplayTime(this.update_at);
}

}
}
3 changes: 2 additions & 1 deletion dbm-ui/frontend/src/services/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ export const getAlarmGroupList = (params: { bk_biz_id: number; db_type?: string;
// 查询轮值规则列表
export const queryDutyRuleList = (
params: { db_type: string; limit: number; offset: number },
payload = {} as IRequestPayload,) =>
payload = {} as IRequestPayload,
) =>
http.get<ListBase<DutyRuleModel[]>>('/apis/monitor/duty_rule/', params, payload).then((data) => ({
...data,
results: data.results.map((item) => new DutyRuleModel(item)),
Expand Down
4 changes: 2 additions & 2 deletions dbm-ui/frontend/src/services/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ export const deleteAccount = (params: { bizId: number; account_id: number; accou
/**
* 添加账号规则
*/
export const createAccountRule = (params: AccountRule & { bizId: number }) =>
http.post(`/apis/mysql/bizs/${params.bizId}/permission/account/add_account_rule/`, params);
export const createAccountRule = (params: AccountRule & { bk_biz_id: number }) =>
http.post(`/apis/mysql/bizs/${params.bk_biz_id}/permission/account/add_account_rule/`, params);

/**
* 授权规则前置检查
Expand Down
20 changes: 10 additions & 10 deletions dbm-ui/frontend/src/services/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,26 @@ export const getmysqlCheckFullBackup = function (params: Record<string, any>, pa
};

// dbmon心跳超时检查报告
export const getDbmonHeartbeat = function (params: Record<string, any>) {
return http.get<IResult>('/db_report/dbmon/heartbeat', params);
export const getDbmonHeartbeat = function (params: Record<string, any>, payload = {} as IRequestPayload) {
return http.get<IResult>('/db_report/dbmon/heartbeat', params, payload);
};

// redis binlog检查报告
export const getRedisCheckBinlogBackup = function (params: Record<string, any>) {
return http.get<IResult>('/db_report/redis_check/binlog_backup', params);
export const getRedisCheckBinlogBackup = function (params: Record<string, any>, payload = {} as IRequestPayload) {
return http.get<IResult>('/db_report/redis_check/binlog_backup', params, payload);
};

// redis 全备检查报告
export const getRedisCheckFullBackup = function (params: Record<string, any>) {
return http.get<IResult>('/db_report/redis_check/full_backup', params);
export const getRedisCheckFullBackup = function (params: Record<string, any>, payload = {} as IRequestPayload) {
return http.get<IResult>('/db_report/redis_check/full_backup', params, payload);
};

// redis 孤立节点检查报告
export const getRedisMetaCheckAloneInstance = function (params: Record<string, any>) {
return http.get<IResult>('/db_report/redis_meta_check/alone_instance', params);
export const getRedisMetaCheckAloneInstance = function (params: Record<string, any>, payload = {} as IRequestPayload) {
return http.get<IResult>('/db_report/redis_meta_check/alone_instance', params, payload);
};

// 实例状态异常检查
export const getRedisMetaCheckStatusAbnormal = function (params: Record<string, any>) {
return http.get<IResult>('/db_report/redis_meta_check/status_abnormal', params);
export const getRedisMetaCheckStatusAbnormal = function (params: Record<string, any>, payload = {} as IRequestPayload) {
return http.get<IResult>('/db_report/redis_meta_check/status_abnormal', params, payload);
};
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/services/source/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export function saveModulesDeployInfo(params: CreateModuleDeployInfo) {
* 修改业务配置信息
*/
interface BizConfDetailsUpdateParams {
name: string;
meta_cluster_type: string;
conf_type: string;
bk_biz_id: number;
Expand Down
9 changes: 8 additions & 1 deletion dbm-ui/frontend/src/services/source/dbdirty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ export function getDirtyMachines(params: { limit: number; offset: number }) {
})
.then((res) => ({
...res,
results: res.results.map((item) => new DirtyMachinesModel(item)),
results: res.results.map(
(item) =>
new DirtyMachinesModel(
Object.assign(item, {
permission: Object.assign(item.permission, res.permission),
}),
),
),
}));
}

Expand Down
13 changes: 13 additions & 0 deletions dbm-ui/frontend/src/services/source/monitorNoticeGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,16 @@ export function getAlarmGroupNotifyList(params: { bk_biz_id: number; name?: stri
}[]
>(`${path}/get_msg_type/`, params);
}

export function getSimpleList(params: { bk_biz_id: number; db_type: string }) {
return http.get<
{
id: string;
name: string;
receivers: {
id: string;
type: string;
}[];
}[]
>(`${path}/list_group_name/`, params);
}
8 changes: 4 additions & 4 deletions dbm-ui/frontend/src/services/source/ticket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ export function queryTicketFlowDescribe(params: {
limit?: number,
offset?: number,
}) {
return http.get<ListBase<TicketFlowDescribeModel[]>>(`${path}/query_ticket_flow_describe/`, params).then((data) => ({
...data,
results: data.results.map(
return http.get<ListBase<TicketFlowDescribeModel[]>>(`${path}/query_ticket_flow_describe/`, params).then((result) => ({
...result,
results: result.results.map(
(item) =>
new TicketFlowDescribeModel(
Object.assign(item, {
permission: Object.assign({}, item.permission, data.permission),
permission: Object.assign({}, item.permission, result.permission),
}),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,20 @@
<span
v-bk-tooltips="{ content: $t('请选择实例'), disabled: hasSelectedInstances }"
class="inline-block">
<AuthButton
action-id="influxdb_reboot"
<BkButton
:disabled="!hasSelectedInstances"
@click="handleBatchRestart">
{{ $t('重启') }}
</AuthButton>
</BkButton>
</span>
<span
v-bk-tooltips="{ content: $t('请选择实例'), disabled: hasSelectedInstances }"
class="inline-block">
<AuthButton
action-id="influxdb_replace"
<BkButton
:disabled="!hasSelectedInstances"
@click="handleShowReplace()">
{{ $t('替换') }}
</AuthButton>
</BkButton>
</span>
<BkDropdown
:disabled="!hasSelectedInstances"
Expand Down Expand Up @@ -262,7 +260,10 @@
<TextOverflowLayout>
{{
default: () => (
<router-link
<auth-router-link
action-id="influxdb_view"
resource={data.id}
permission={data.permission.influxdb_view}
to={{
name: 'InfluxDBInstDetails',
params: {
Expand All @@ -273,7 +274,7 @@
},
}}>
{data.instance_address}
</router-link>
</auth-router-link>
),
append: () => (
<>
Expand Down
Loading

0 comments on commit 74b3806

Please sign in to comment.