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

fix(auth): use CustomInputPassword component #3160

Merged
merged 4 commits into from
Jan 13, 2025
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
11 changes: 11 additions & 0 deletions src/hooks/Auth/useDatabaseConfigForm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ComputedRef, Ref } from 'vue'
import { computed, ref } from 'vue'
import useFormRules from '@/hooks/useFormRules'
import { isJSONString } from '@emqx/shared-ui-utils'
import { FormRules } from 'element-plus'
import useI18nTl from '../useI18nTl'
import { usePasswordHashRules } from './usePasswordHashAlgorithmData'
Expand Down Expand Up @@ -67,6 +68,16 @@ export default (props: PropsParams, databaseConfig: any): ReturnData => {
...createMongoCommonFormRules(),
/* For mongo type 'rs' */
replica_set_name: createRequiredRule(tl('replicaSetName')),
filter: [
{
validator(rules, value, callback) {
if (!value || isJSONString(value)) {
return callback()
}
callback(new Error(tl('jsonFormatError')))
},
},
],
}
} else if (isMySQL.value || isPgSQL.value) {
ret = { ...ret, ...createMySQLFormRules() }
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export default {
zh: '连接',
en: 'Connections',
},
currentConnection: {
zh: '连接数',
en: 'Current Connections',
},
listeners: {
zh: '监听器',
en: 'Listeners',
Expand Down
2 changes: 1 addition & 1 deletion src/views/Auth/AuthnCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
v-if="['mysql', 'postgresql', 'mongodb', 'redis'].includes(backend)"
v-model="configData"
ref="formCom"
:database="backend as DatabaseAndServerDOM"
:database="(backend as DatabaseAndServerDOM)"
auth-type="authn"
/>
<built-in-config
Expand Down
9 changes: 2 additions & 7 deletions src/views/Auth/components/DatabaseConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,7 @@
</el-col>
<el-col :span="12">
<el-form-item :label="$t('Base.password')">
<el-input
v-model="databaseConfig.password"
type="password"
autocomplete="one-time-code"
show-password
/>
<CustomInputPassword v-model="databaseConfig.password" />
</el-form-item>
</el-col>
<el-col v-if="isAuthn && isMongoDB" :span="12">
Expand Down Expand Up @@ -177,7 +172,7 @@
</el-col>
<!-- Mongodb -->
<el-col :span="24" v-else-if="isMongoDB">
<el-form-item class="label-whole-line">
<el-form-item class="label-whole-line" prop="filter">
<template #label>
<span>{{ $t('Auth.filter') }}</span>
<el-button
Expand Down
7 changes: 1 addition & 6 deletions src/views/Auth/components/JwtConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@
:content="$t('Auth.jwtBase64Tips')"
/>
</template>
<el-input
v-model="jwtConfig.secret"
type="password"
show-password
autocomplete="one-time-code"
/>
<CustomInputPassword v-model="jwtConfig.secret" />
</el-form-item>
</el-col>
<el-col :span="24">
Expand Down
6 changes: 1 addition & 5 deletions src/views/Auth/components/LdapConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
<!-- Password -->
<el-col :span="12">
<el-form-item :label="$t('Base.password')" prop="password">
<el-input
type="password"
v-model="ldapConfig.password"
autocomplete="one-time-code"
/>
<CustomInputPassword v-model="ldapConfig.password" />
</el-form-item>
</el-col>

Expand Down
1 change: 1 addition & 0 deletions src/views/Base/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ $header-heigh: 60px;
.el-header {
padding: 0;
right: 0;
left: 0;
position: fixed;
z-index: 101;
transition: all 0.3s;
Expand Down
26 changes: 3 additions & 23 deletions src/views/Gateway/Gateway.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,10 @@
<span class="g-title">{{ transGatewayName(row.name) }}</span>
</template>
</el-table-column>
<el-table-column :label="tl('connection')" :min-width="160">
<el-table-column :label="tl('currentConnection')" :min-width="160">
<template #default="{ row }">
<template v-if="hasBeenInitialized(row)">
<template v-if="row?.max_connections === INFINITY_VALUE">
{{ connectionCount(row) }}
</template>
<template v-else>
<el-tooltip placement="top" effect="dark" :content="connectionCount(row)">
<el-progress
:stroke-width="20"
:percentage="calcPercentage(row.current_connections, row.max_connections, false)"
:format="() => row.current_connections || 0"
>
</el-progress>
</el-tooltip>
</template>
{{ row.current_connections ?? 0 }}
</template>
</template>
</el-table-column>
Expand Down Expand Up @@ -69,7 +57,7 @@
<script lang="ts">
import { getGatewayList, toggleGatewayEnable } from '@/api/gateway'
import { INFINITY_VALUE } from '@/common/constants'
import { calcPercentage, caseInsensitiveCompare } from '@/common/tools'
import { caseInsensitiveCompare } from '@/common/tools'
import useI18nTl from '@/hooks/useI18nTl'
import useTransName from '@/hooks/useTransName'
import { GatewayStatus } from '@/types/enum'
Expand Down Expand Up @@ -116,12 +104,6 @@ export default defineComponent({
router.push({ name: 'gateway-create', params: { name: listener.name } })
}

const connectionCount = ({ current_connections, max_connections }: any) => {
const max =
max_connections === INFINITY_VALUE ? 'Infinity' : max_connections ? max_connections : 0
return `${current_connections || 0}/${max}`
}

const gatewayStartStop = async function (instance: any) {
const { name } = instance
try {
Expand Down Expand Up @@ -164,12 +146,10 @@ export default defineComponent({
tl,
tbLoading,
tbData,
calcPercentage,
GatewayStatus,
isRunning,
isUnload,
INFINITY_VALUE,
connectionCount,
hasBeenInitialized,
getRowClassName,
transGatewayName,
Expand Down
Loading