Skip to content

Commit

Permalink
Merge branch 'ft_tenant' of https://github.com/TencentBlueKing/bk-user
Browse files Browse the repository at this point in the history
…into local_data_source_io
  • Loading branch information
narasux committed Sep 20, 2023
2 parents 3a6eecb + 909952c commit 700dc8b
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 36 deletions.
14 changes: 14 additions & 0 deletions src/pages/src/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,17 @@
visibility: hidden;
}
}

.datasource-type-icon {
display: flex;
align-items: center;

img {
width: 14px;
height: 14px;
}

span {
margin-left: 8px;
}
}
2 changes: 1 addition & 1 deletion src/pages/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default createRouter({
],
},
{
path: 'local-details/:id',
path: 'local-details/:id/:status',
name: 'dataConfDetails',
meta: {
routeParentName: 'dataSource',
Expand Down
11 changes: 9 additions & 2 deletions src/pages/src/views/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ const toIndividualCenter = () => {

<style lang="less" scoped>
.main-navigation {
min-width: 1200px;
:deep(.bk-navigation-header) {
background-color: #0e1525;
Expand All @@ -173,8 +175,13 @@ const toIndividualCenter = () => {
}
}
:deep(.container-content) {
padding: 0 !important;
:deep(.navigation-container) {
min-width: 1200px;
.container-content {
padding: 0 !important;
overflow: hidden;
}
}
:deep(.header-right) {
Expand Down
10 changes: 6 additions & 4 deletions src/pages/src/views/data-source/LocalDataSource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@
</bk-table-column>
<bk-table-column prop="plugin_id" label="数据源类型">
<template #default="{ row }">
<div>
<i :class="[dataSourceType[row.plugin_id]?.icon, 'type-icon']" />
<div class="datasource-type-icon" v-for="item in state.typeList" :key="item">
<img v-if="item.id === row.plugin_id && item.logo" :src="item.logo">
<i v-else :class="[dataSourceType[row.plugin_id]?.icon, 'type-icon']" />
<span>{{ dataSourceType[row.plugin_id]?.text }}</span>
</div>
</template>
Expand Down Expand Up @@ -156,6 +157,7 @@ function handleClick(item) {
name: 'dataConfDetails',
params: {
id: item.id,
status: item.status,
},
});
}
Expand Down Expand Up @@ -235,8 +237,8 @@ function newDataSource(item) {
align-items: center;
img {
width: 16px;
height: 16px;
width: 24px;
height: 24px;
}
.user-icon {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/src/views/data-source/local-details/PswInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
</li>
<li>
<span class="key">密码不允许:</span>
<span class="value">
<span class="value" v-if="passwordRule?.not_continuous_count === 0">--</span>
<span class="value" v-else>
连续{{ passwordRule?.not_continuous_count }}位出现
{{ passwordNotAllowedMap(passwordRule) }}
</span>
Expand Down
7 changes: 6 additions & 1 deletion src/pages/src/views/data-source/local-details/UserInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

<script setup lang="ts">
import { Message } from 'bkui-vue';
import { computed, inject, onMounted, reactive, ref, watch } from 'vue';
import { computed, defineProps, inject, onMounted, reactive, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import EditUser from './EditUser.vue';
Expand All @@ -119,6 +119,11 @@ import ViewUser from './ViewUser.vue';
import Empty from '@/components/Empty.vue';
import { getDataSourceUserDetails, getDataSourceUsers } from '@/http/dataSourceFiles';
defineProps({
dataSourceId: {
type: Number,
},
});
const route = useRoute();
const currentId = computed(() => Number(route.params.id));
Expand Down
45 changes: 22 additions & 23 deletions src/pages/src/views/data-source/local-details/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
<bk-loading :loading="isLoading">
<MainBreadcrumbsDetails :subtitle="subtitle">
<template #tag>
<bk-tag v-if="typeText">
<bk-tag>
<template #icon>
<i :class="typeIcon" />
<div class="datasource-type-icon" v-for="item in typeList" :key="item">
<img v-if="item.id === pluginId && item.logo" :src="item.logo">
<i v-else :class="dataSourceType[pluginId].icon" />
<span>{{ dataSourceType[pluginId].text }}</span>
</div>
</template>
{{ typeText }}
</bk-tag>
</template>
<template #right>
<bk-button v-if="statusText" class="w-[64px]" @click="handleClick">
{{ statusText }}
<bk-button class="w-[64px]" hover-theme="primary" @click="handleClick">
{{ statusText === 'disabled' ? '启用' : '停用' }}
</bk-button>
</template>
</MainBreadcrumbsDetails>
Expand All @@ -26,7 +29,9 @@
:name="item.name"
:label="item.label"
>
<UserInfo v-if="activeKey === 'user'" />
<UserInfo
v-if="activeKey === 'user'"
:data-source-id="currentId" />
<PswInfo v-else />
</bk-tab-panel>
</bk-tab>
Expand All @@ -42,7 +47,7 @@ import PswInfo from './PswInfo.vue';
import UserInfo from './UserInfo.vue';
import MainBreadcrumbsDetails from '@/components/layouts/MainBreadcrumbsDetails.vue';
import { changeSwitchStatus, getDataSourceList } from '@/http/dataSourceFiles';
import { changeSwitchStatus, getDataSourceList, getDataSourcePlugins } from '@/http/dataSourceFiles';
import { dataSourceType } from '@/utils';
const route = useRoute();
Expand All @@ -58,40 +63,34 @@ const panels = reactive([
const isLoading = ref(false);
const subtitle = ref('');
const typeText = ref('');
const typeIcon = ref('');
const statusText = ref('');
const switchStatus = ref('');
const typeList = ref([]);
const pluginId = ref('');
onMounted(async () => {
isLoading.value = true;
statusText.value = route.params.status;
const res = await getDataSourceList('');
await getSwitchStatus();
res.data.forEach((item) => {
if (item.id === currentId.value) {
const { text, icon } = dataSourceType[item.plugin_id];
subtitle.value = item.name;
typeText.value = text;
typeIcon.value = icon;
pluginId.value = item.plugin_id;
}
});
const pluginsRes = await getDataSourcePlugins();
typeList.value = pluginsRes.data;
isLoading.value = false;
});
const getSwitchStatus = async () => {
const res = await changeSwitchStatus(route.params.id);
switchStatus.value = res.data?.status;
statusText.value = res.data?.status === 'disabled' ? '启用' : '停用';
};
const handleClick = async () => {
await getSwitchStatus();
const message = switchStatus.value === 'disabled' ? '停用成功' : '启用成功';
const res = await changeSwitchStatus(route.params.id);
statusText.value = res.data?.status;
const message = res.data?.status === 'disabled' ? '停用成功' : '启用成功';
Message({ theme: 'success', message });
};
</script>

<style lang="less">
<style lang="less" scoped>
.main-breadcrumbs-details {
box-shadow: none;
}
Expand Down
15 changes: 11 additions & 4 deletions src/pages/src/views/data-source/new-data/NewLocalData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
<template #tag>
<bk-tag>
<template #icon>
<i :class="dataSourceType[route.params.type].icon" />
<div class="datasource-type-icon" v-for="item in typeList" :key="item">
<img v-if="item.id === route.params.type && item.logo" :src="item.logo">
<i v-else :class="dataSourceType[route.params.type].icon" />
<span>{{ dataSourceType[route.params.type].text }}</span>
</div>
</template>
{{ dataSourceType[route.params.type].text }}
</bk-tag>
</template>
</MainBreadcrumbsDetails>
Expand Down Expand Up @@ -36,7 +39,7 @@
type="number"
suffix="至32位"
:min="10"
:max="31"
:max="32"
v-model="formData.config.password_rule.min_length"
@change="handleChange"
/>
Expand Down Expand Up @@ -243,7 +246,7 @@ import { useRoute } from 'vue-router';
import MainBreadcrumbsDetails from '@/components/layouts/MainBreadcrumbsDetails.vue';
import NotifyEditorTemplate from '@/components/notify-editor/NotifyEditorTemplate.vue';
import useValidate from '@/hooks/use-validate';
import { getDataSourceDetails, getDefaultConfig, newDataSource, putDataSourceDetails } from '@/http/dataSourceFiles';
import { getDataSourceDetails, getDataSourcePlugins, getDefaultConfig, newDataSource, putDataSourceDetails } from '@/http/dataSourceFiles';
import router from '@/router';
import { useMainViewStore } from '@/store/mainView';
import { dataSourceType, passwordMustIncludes, passwordNotAllowed } from '@/utils';
Expand Down Expand Up @@ -283,9 +286,13 @@ const rulesInfo = {
min_length: [validate.required],
};
const typeList = ref([]);
onMounted(async () => {
isLoading.value = true;
try {
const pluginsRes = await getDataSourcePlugins();
typeList.value = pluginsRes.data;
if (currentId.value) {
store.breadCrumbsTitle = '编辑数据源';
const res = await getDataSourceDetails(currentId.value);
Expand Down
1 change: 1 addition & 0 deletions src/pages/src/views/organization/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ const updateTenantsList = () => {
height: calc(100vh - 52px);
.organization-main {
width: calc(100% - 280px);
height: calc(100% - 52px);
header {
Expand Down

0 comments on commit 700dc8b

Please sign in to comment.