Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(frontend): 前端同步v1.3.0代码 #3898 #3899

Merged
merged 6 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dbm-services/mysql/db-priv/handler/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ func (m *PrivService) AddAccount(c *gin.Context) {
return
}

err = input.AddAccount(string(body))
account, err := input.AddAccount(string(body))
if err != nil {
SendResponse(c, err, nil)
return
}
SendResponse(c, nil, nil)
SendResponse(c, nil, account)
return
}

Expand Down
26 changes: 15 additions & 11 deletions dbm-services/mysql/db-priv/service/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ import (
)

// AddAccount 新增账号
func (m *AccountPara) AddAccount(jsonPara string) error {
func (m *AccountPara) AddAccount(jsonPara string) (TbAccounts, error) {
var (
account *TbAccounts
psw string
count uint64
err error
detail TbAccounts
)

if m.BkBizId == 0 {
return errno.BkBizIdIsEmpty
return detail, errno.BkBizIdIsEmpty
}
if m.User == "" || m.Psw == "" {
return errno.PasswordOrAccountNameNull
return detail, errno.PasswordOrAccountNameNull
}
if *m.ClusterType == sqlserver && m.Sid == "" {
return errno.SqlserverSidNull
Expand All @@ -41,30 +42,30 @@ func (m *AccountPara) AddAccount(jsonPara string) error {
err = DB.Self.Model(&TbAccounts{}).Where(&TbAccounts{BkBizId: m.BkBizId, User: m.User, ClusterType: *m.ClusterType}).
Count(&count).Error
if err != nil {
return err
return detail, err
}
if count != 0 {
return errno.AccountExisted.AddBefore(m.User)
return detail, errno.AccountExisted.AddBefore(m.User)
}
psw = m.Psw
// 从旧系统迁移的,不检查是否帐号和密码不同
if psw == m.User && !m.MigrateFlag {
return errno.PasswordConsistentWithAccountName
return detail, errno.PasswordConsistentWithAccountName
}
// 从旧系统迁移的,存储的密码为mysql password()允许迁移,old_password()已过滤不迁移
if m.PasswordFunc {
psw = fmt.Sprintf(`{"old_psw":"","psw":"%s"}`, psw)
} else if *m.ClusterType == mysql || *m.ClusterType == tendbcluster {
psw, err = EncryptPswInDb(psw)
if err != nil {
return err
return detail, err
}
} else {
// 兼容其他数据库类型比如mongo,密码不存储mysql password函数,而是SM4,需要能够查询
psw, err = SM4Encrypt(psw)
if err != nil {
slog.Error("SM4Encrypt", "error", err)
return err
return detail, err
}
psw = fmt.Sprintf(`{"sm4":"%s"}`, psw)
}
Expand All @@ -73,12 +74,15 @@ func (m *AccountPara) AddAccount(jsonPara string) error {
CreateTime: vtime, UpdateTime: vtime, Sid: m.Sid}
err = DB.Self.Model(&TbAccounts{}).Create(&account).Error
if err != nil {
return err
return detail, err
}
err = DB.Self.Model(&TbAccounts{}).First(&detail, account.Id).Error
if err != nil {
return detail, err
}

log := PrivLog{BkBizId: m.BkBizId, Operator: m.Operator, Para: jsonPara, Time: vtime}
AddPrivLog(log)
return nil
return detail, nil
}

// ModifyAccountPassword 修改账号的密码
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func DoAddAccounts(apps map[string]int64, users []PrivModule, clusterType string
}
log, _ := json.Marshal(account)
// 添加帐号
err := account.AddAccount(string(log))
_, err := account.AddAccount(string(log))
if err != nil {
slog.Error("add account error", account, err)
return err
Expand Down
7 changes: 4 additions & 3 deletions dbm-ui/backend/db_services/dbbase/resources/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,6 @@ def filter_instance_func(_query_params, _cluster_queryset, _proxy_queryset, _sto
_cluster_queryset = filter_inst_queryset(
_cluster_queryset, _proxy_queryset, _storage_queryset, cls.build_q_for_instance_filter(_query_params)
)
# 部署时间表头排序
if query_params.get("ordering"):
_cluster_queryset = _cluster_queryset.order_by(query_params.get("ordering"))

return _cluster_queryset

Expand All @@ -428,6 +425,10 @@ def filter_instance_func(_query_params, _cluster_queryset, _proxy_queryset, _sto
query_params, cluster_queryset, proxy_queryset, storage_queryset
)

# 部署时间表头排序
if query_params.get("ordering"):
cluster_queryset = cluster_queryset.order_by(query_params.get("ordering"))

cluster_infos = cls._filter_cluster_hook(
bk_biz_id, cluster_queryset, proxy_queryset, storage_queryset, limit, offset, **kwargs
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
popoverDelay={0}>
{{
default: () => <bk-checkbox style="vertical-align: middle;" disabled />,
content: () => <span>{disabledRowConfig?.tip}</span>,
content: () => <span>{disabledRowConfig.tip}</span>,
}}
</bk-popover>
);
Expand Down Expand Up @@ -234,8 +234,8 @@
const isIndeterminate = computed(() => !isSelectedAll.value
&& selectedMap.value[activeTab.value] && Object.keys(selectedMap.value[activeTab.value]).length > 0);

// eslint-disable-next-line max-len
const mainSelectDisable = computed(() => tableData.value.filter(data => props.disabledRowConfig.find(item => item.handler(data))).length === tableData.value.length);
const mainSelectDisable = computed(() => tableData.value.filter(data => props.disabledRowConfig
.find(item => item.handler(data))).length === tableData.value.length);

const generatedColumns = computed(() => {
if (props.customColums) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
popoverDelay={0}>
{{
default: () => <bk-checkbox style="vertical-align: middle;" disabled />,
content: () => <span>{disabledRowConfig?.tip}</span>,
content: () => <span>{disabledRowConfig.tip}</span>,
}}
</bk-popover>
);
Expand Down Expand Up @@ -236,8 +236,8 @@
const isIndeterminate = computed(() => !isSelectedAll.value
&& selectedMap.value[activeTab.value] && Object.keys(selectedMap.value[activeTab.value]).length > 0);

// eslint-disable-next-line max-len
const mainSelectDisable = computed(() => tableData.value.filter(data => props.disabledRowConfig.find(item => item.handler(data))).length === tableData.value.length);
const mainSelectDisable = computed(() => tableData.value.filter(data => props.disabledRowConfig
.find(item => item.handler(data))).length === tableData.value.length);

const generatedColumns = computed(() => {
if (props.customColums) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
popoverDelay={0}>
{{
default: () => <bk-checkbox style="vertical-align: middle;" disabled />,
content: () => <span>{disabledRowConfig?.tip}</span>,
content: () => <span>{disabledRowConfig.tip}</span>,
}}
</bk-popover>
);
Expand Down Expand Up @@ -249,8 +249,8 @@
const isIndeterminate = computed(() => !isSelectedAll.value
&& selectedMap.value[activeTab.value] && Object.keys(selectedMap.value[activeTab.value]).length > 0);

// eslint-disable-next-line max-len
const mainSelectDisable = computed(() => tableData.value.filter(data => props.disabledRowConfig.find(item => item.handler(data))).length === tableData.value.length);
const mainSelectDisable = computed(() => tableData.value.filter(data => props.disabledRowConfig
.find(item => item.handler(data))).length === tableData.value.length);

const generatedColumns = computed(() => {
if (props.customColums) {
Expand All @@ -265,10 +265,11 @@
if (!props.selected || !props.selected[props.activeTab]) {
return;
}
// eslint-disable-next-line max-len
const tabSelectMap = props.selected[props.activeTab].reduce((selectResult, selectItem) => Object.assign({}, selectResult, {
[selectItem.id]: selectItem,
}), {} as Record<string, ResourceItem>);

const tabSelectMap = props.selected[props.activeTab]
.reduce((selectResult, selectItem) => Object.assign(selectResult, {
[selectItem.id]: selectItem,
}), {} as Record<string, ResourceItem>);
selectedMap.value = {
[props.activeTab]: tabSelectMap,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<bk-popover theme="dark" placement="top" popoverDelay={0}>
{{
default: () => <bk-checkbox style="vertical-align: middle;" disabled />,
content: () => <span>{disabledRowConfig?.tip}</span>,
content: () => <span>{disabledRowConfig.tip}</span>,
}}
</bk-popover>
);
Expand Down Expand Up @@ -245,8 +245,8 @@
const isIndeterminate = computed(() => !isSelectedAll.value
&& selectedMap.value[activeTab.value] && Object.keys(selectedMap.value[activeTab.value]).length > 0);

// eslint-disable-next-line max-len
const mainSelectDisable = computed(() => tableData.value.filter(data => props.disabledRowConfig.find(item => item.handler(data))).length === tableData.value.length);
const mainSelectDisable = computed(() => tableData.value.filter(data => props.disabledRowConfig
.find(item => item.handler(data))).length === tableData.value.length);

const generatedColumns = computed(() => {
if (props.customColums) {
Expand All @@ -261,10 +261,11 @@
if (!props.selected || !props.selected[props.activeTab]) {
return;
}
// eslint-disable-next-line max-len
const tabSelectMap = props.selected[props.activeTab].reduce((selectResult, selectItem) => Object.assign({}, selectResult, {
[selectItem.id]: selectItem,
}), {} as Record<string, ResourceItem>);

const tabSelectMap = props.selected[props.activeTab]
.reduce((selectResult, selectItem) => Object.assign(selectResult, {
[selectItem.id]: selectItem,
}), {} as Record<string, ResourceItem>);
selectedMap.value = {
[props.activeTab]: tabSelectMap,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@
class="pt-2 pb-2"
:class="{ 'is-unavailable': inst.status === 'unavailable' }">
<TextOverflowLayout>
<template #default>
<span
class="pr-4"
:style="{ color: highlightIps.includes(inst.ip)
|| highlightIps.includes(`${inst.ip}:${inst.port}`) ? 'rgb(255 130 4)' : '#63656e' }">
<slot :data="inst">
{{ inst.ip }}:{{ inst.port }}
</slot>
</span>
</template>
<span
class="pr-4"
:style="{ color: highlightIps.includes(inst.ip)
|| highlightIps.includes(`${inst.ip}:${inst.port}`) ? 'rgb(255 130 4)' : '#63656e' }">
<slot :data="inst">
{{ inst.ip }}:{{ inst.port }}
</slot>
</span>
<template #append>
<BkTag v-if="inst.status === 'unavailable'">
{{ $t('不可用') }}
Expand Down
12 changes: 11 additions & 1 deletion dbm-ui/frontend/src/components/system-search/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
:placeholder="t('全站搜索 Ctrl + K')"
type="search"
@enter="handleEnter"
@focus="handleFocus" />
@focus="handleFocus"
@paste="handlePaste" />
</div>
<div
ref="popRef"
Expand Down Expand Up @@ -42,6 +43,8 @@

import { useDebouncedRef } from '@hooks';

import { batchSplitRegex } from '@common/regex';

import SearchResult from './components/search-result/Index.vue';
import SearchHistory from './components/SearchHistory.vue';

Expand All @@ -63,6 +66,13 @@

let tippyIns:Instance | undefined;

const handlePaste = (value: string, event: ClipboardEvent) => {
const pasteValue = (event.clipboardData || window.clipboardData).getData('text');
setTimeout(() => {
serach.value = `${serach.value}${serach.value ? '|' : ''}${pasteValue}`.replace(batchSplitRegex, '|');
});
};

const handleFocus = () => {
if (isFocused.value) {
return;
Expand Down
Loading
Loading