Skip to content

Commit

Permalink
fix(frontend): 修复密码修改成功失败数量不对问题 #8250
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 25316
  • Loading branch information
JustaCattt committed Nov 29, 2024
1 parent 6e0342e commit 70ff5ae
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
8 changes: 4 additions & 4 deletions dbm-ui/frontend/src/services/source/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export const modifyAdminPassword = (params: {
}) =>
http.post<
| {
success: AdminPasswordResultItem[] | null;
fail: AdminPasswordResultItem[] | null;
success: AdminPasswordResultItem[];
fail: AdminPasswordResultItem[];
}
| string // 异步修改时返回root_id
>(`${path}/modify_admin_password/`, params);
Expand Down Expand Up @@ -121,8 +121,8 @@ export const queryAsyncModifyResult = (params: { root_id: string }) =>
status: string;
error?: string;
data: {
success: AdminPasswordResultItem[] | null;
fail: AdminPasswordResultItem[] | null;
success: AdminPasswordResultItem[];
fail: AdminPasswordResultItem[];
};
result?: boolean;
}>(`${path}/query_async_modify_result/`, params);
Expand Down
2 changes: 1 addition & 1 deletion dbm-ui/frontend/src/types/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ declare global {
// for type re-export
declare global {
// @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
import('vue')
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
</RenderSuccess>
</template>
<script setup lang="ts">
import _ from 'lodash';
import { useI18n } from 'vue-i18n';

import { queryAsyncModifyResult } from '@services/source/permission';
Expand Down Expand Up @@ -140,25 +141,30 @@
return '';
});
const errorList = computed(() =>
(props?.submitResult?.data?.fail || []).reduce((errorPrev, errorItem) => {
const { bk_cloud_id, cluster_type } = errorItem;
_.flatMap(props?.submitResult?.data?.fail || [], (item) => {
const { bk_cloud_id, cluster_type } = item;
const roleMap = props.submitRoleMap;
const retryItems = errorItem.instances.reduce((retryItemsPrev, instanceItem) => {
const newInstanceItem = instanceItem.addresses.map((addressItem) => ({
return _.flatMap(item.instances, (insItem) =>
insItem.addresses.map((addressItem) => ({
...addressItem,
bk_cloud_id,
cluster_type,
role: roleMap[`${addressItem.ip}:${addressItem.port}`],
}));

return [...retryItemsPrev, ...newInstanceItem];
}, [] as RetryItem[]);

return [...errorPrev, ...retryItems];
}, [] as RetryItem[]),
})),
);
}),
);
const successListLength = computed(() =>
_.sumBy(props.submitResult?.data?.success, (item) =>
_.sumBy(item.instances, (insItem) => insItem.addresses.length),
),
);
const errorListLength = computed(
() =>
_.sumBy(props.submitResult?.data?.fail, (item) =>
_.sumBy(item.instances, (insItem) => insItem.addresses.length),
) || props.submitLength - successListLength.value,
);
const errorListLength = computed(() => errorList.value.length);
const successListLength = computed(() => props.submitLength - errorListLength.value);

const handleShowPassword = () => {
isShowPassword.value = !isShowPassword.value;
Expand All @@ -169,7 +175,7 @@
};

const handleCopy = () => {
const copyList = errorList.value.map((errorItem) => `${errorItem.ip}:${errorItem.port}`);
const copyList = errorList.value.map((item) => `${item.ip}:${item.port}`);
copy(copyList.join('\n'));
};

Expand Down

0 comments on commit 70ff5ae

Please sign in to comment.