mirror of https://github.com/veops/cmdb.git
Dev UI 240520 (#517)
* feat(ui): Model configuration supports search models * fix(ui): Jump to the first subscription by default
This commit is contained in:
parent
a889fe503a
commit
f89c18db51
|
@ -166,7 +166,7 @@ const genCmdbRoutes = async () => {
|
||||||
if (lastTypeId && preference.type_ids.some(item => item === Number(lastTypeId))) {
|
if (lastTypeId && preference.type_ids.some(item => item === Number(lastTypeId))) {
|
||||||
routes.redirect = `/cmdb/instances/types/${lastTypeId}`
|
routes.redirect = `/cmdb/instances/types/${lastTypeId}`
|
||||||
} else if (routes.children[2]?.children?.length > 0) {
|
} else if (routes.children[2]?.children?.length > 0) {
|
||||||
routes.redirect = routes.children[2].children.find(item => !item.hidden)?.path
|
routes.redirect = routes.children[2].children.find(item => !item.hidden && !item.meta.disabled)?.path
|
||||||
} else {
|
} else {
|
||||||
routes.redirect = '/cmdb/dashboard'
|
routes.redirect = '/cmdb/dashboard'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="ci-types-wrap" :style="{ height: `${windowHeight - 66}px` }">
|
<div class="ci-types-wrap" :style="{ height: `${windowHeight - 96}px` }">
|
||||||
<div v-if="!CITypeGroups.length" class="ci-types-empty">
|
<div v-if="!CITypeGroups.length" class="ci-types-empty">
|
||||||
<a-empty :image="emptyImage" description=""></a-empty>
|
<a-empty :image="emptyImage" description=""></a-empty>
|
||||||
<a-button icon="plus" size="small" type="primary" @click="handleClickAddGroup">{{
|
<a-button icon="plus" size="small" type="primary" @click="handleClickAddGroup">{{
|
||||||
|
@ -15,6 +15,13 @@
|
||||||
:triggerLength="18"
|
:triggerLength="18"
|
||||||
>
|
>
|
||||||
<template #one>
|
<template #one>
|
||||||
|
<a-input
|
||||||
|
:placeholder="$t('cmdb.preference.searchPlaceholder')"
|
||||||
|
class="cmdb-ci-types-left-input"
|
||||||
|
@pressEnter="handleSearch"
|
||||||
|
>
|
||||||
|
<a-icon slot="prefix" type="search" />
|
||||||
|
</a-input>
|
||||||
<div class="ci-types-left">
|
<div class="ci-types-left">
|
||||||
<div class="ci-types-left-title">
|
<div class="ci-types-left-title">
|
||||||
<a-button
|
<a-button
|
||||||
|
@ -62,8 +69,8 @@
|
||||||
</a-dropdown>
|
</a-dropdown>
|
||||||
</a-space>
|
</a-space>
|
||||||
</div>
|
</div>
|
||||||
<draggable class="ci-types-left-content" :list="CITypeGroups" @end="handleChangeGroups" filter=".undraggable">
|
<draggable class="ci-types-left-content" :list="computedCITypeGroups" @end="handleChangeGroups" filter=".undraggable">
|
||||||
<div v-for="g in CITypeGroups" :key="g.id || g.name">
|
<div v-for="g in computedCITypeGroups" :key="g.id || g.name">
|
||||||
<div
|
<div
|
||||||
:class="
|
:class="
|
||||||
`${currentGId === g.id && !currentCId ? 'selected' : ''} ci-types-left-group ${
|
`${currentGId === g.id && !currentCId ? 'selected' : ''} ci-types-left-group ${
|
||||||
|
@ -74,6 +81,7 @@
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<OpsMoveIcon
|
<OpsMoveIcon
|
||||||
|
v-if="g.id !== -1"
|
||||||
style="width: 17px; height: 17px; display: none; position: absolute; left: -3px; top: 10px"
|
style="width: 17px; height: 17px; display: none; position: absolute; left: -3px; top: 10px"
|
||||||
/>
|
/>
|
||||||
<span style="font-weight: 700">{{ g.name || $t('other') }}</span>
|
<span style="font-weight: 700">{{ g.name || $t('other') }}</span>
|
||||||
|
@ -103,6 +111,7 @@
|
||||||
@start="start(g)"
|
@start="start(g)"
|
||||||
@end="end(g)"
|
@end="end(g)"
|
||||||
@add="add(g)"
|
@add="add(g)"
|
||||||
|
filter=".undraggable"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-for="ci in g.ci_types"
|
v-for="ci in g.ci_types"
|
||||||
|
@ -110,8 +119,9 @@
|
||||||
:class="`${currentCId === ci.id ? 'selected' : ''} ci-types-left-detail`"
|
:class="`${currentCId === ci.id ? 'selected' : ''} ci-types-left-detail`"
|
||||||
@click="handleClickCIType(g.id, ci.id, ci.name)"
|
@click="handleClickCIType(g.id, ci.id, ci.name)"
|
||||||
>
|
>
|
||||||
<div>
|
<div :class="`${ g.id === -1 ? 'undraggable' : '' }`">
|
||||||
<OpsMoveIcon
|
<OpsMoveIcon
|
||||||
|
v-if="g.id !== -1"
|
||||||
style="width: 17px; height: 17px; display: none; position: absolute; left: -1px; top: 8px"
|
style="width: 17px; height: 17px; display: none; position: absolute; left: -1px; top: 8px"
|
||||||
/>
|
/>
|
||||||
<span class="ci-types-left-detail-icon">
|
<span class="ci-types-left-detail-icon">
|
||||||
|
@ -464,6 +474,8 @@ export default {
|
||||||
isInherit: false,
|
isInherit: false,
|
||||||
|
|
||||||
unique_id: null,
|
unique_id: null,
|
||||||
|
|
||||||
|
searchValue: '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -536,6 +548,16 @@ export default {
|
||||||
}
|
}
|
||||||
return _showIdSelectOptions
|
return _showIdSelectOptions
|
||||||
},
|
},
|
||||||
|
computedCITypeGroups() {
|
||||||
|
if (this.searchValue) {
|
||||||
|
const ciTypes = _.cloneDeep(this.CITypeGroups)
|
||||||
|
ciTypes.forEach((item) => {
|
||||||
|
item.ci_types = item.ci_types.filter((_item) => _item.alias.toLowerCase().includes(this.searchValue.toLowerCase()))
|
||||||
|
})
|
||||||
|
return ciTypes
|
||||||
|
}
|
||||||
|
return this.CITypeGroups
|
||||||
|
},
|
||||||
},
|
},
|
||||||
provide() {
|
provide() {
|
||||||
return {
|
return {
|
||||||
|
@ -565,6 +587,9 @@ export default {
|
||||||
this.allTreeDepAndEmp = res
|
this.allTreeDepAndEmp = res
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
handleSearch(e) {
|
||||||
|
this.searchValue = e.target.value
|
||||||
|
},
|
||||||
async loadCITypes(isResetCurrentId = false) {
|
async loadCITypes(isResetCurrentId = false) {
|
||||||
const groups = await getCITypeGroupsConfig({ need_other: true })
|
const groups = await getCITypeGroupsConfig({ need_other: true })
|
||||||
let alreadyReset = false
|
let alreadyReset = false
|
||||||
|
@ -1021,6 +1046,14 @@ export default {
|
||||||
top: 40%;
|
top: 40%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
}
|
}
|
||||||
|
/deep/.cmdb-ci-types-left-input {
|
||||||
|
input {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
.ant-input:focus {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
.ci-types-left {
|
.ci-types-left {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="cmdb-preference-group" v-for="(subType, index) in myPreferences" :key="subType.name">
|
<div class="cmdb-preference-group" v-for="(subType, index) in myPreferences" :key="subType.name">
|
||||||
<div class="cmdb-preference-group-title">
|
<div class="cmdb-preference-group-title">
|
||||||
<span> <ops-icon :style="{ marginRight: '10px' }" :type="subType.icon" />{{ subType.name }} </span>
|
<span> <ops-icon :style="{ marginRight: '10px' }" :type="subType.icon" />{{ subType.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
<draggable class="ci-types-left-content" :list="subType.groups" @end="handleChangeGroups" filter=".undraggable">
|
<draggable class="ci-types-left-content" :list="subType.groups" @end="handleChangeGroups" filter=".undraggable">
|
||||||
<div v-for="group in subType.groups" :key="group.id || group.name">
|
<div v-for="group in subType.groups" :key="group.id || group.name">
|
||||||
|
@ -44,8 +44,8 @@
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div v-if="index === 0 && subType.groups.length > 1" class="cmdb-preference-group-content">
|
<div v-if="index === 0 && subType.groups.length > 1" class="cmdb-preference-group-content">
|
||||||
<OpsMoveIcon class="cmdb-preference-move-icon" v-if="group.name || index === 1"/>
|
<OpsMoveIcon class="cmdb-preference-move-icon" v-if="group.name"/>
|
||||||
<span style="font-weight: 500; color: #a5a9bc">{{ group.name || $t('other') }}</span>
|
<span style="font-weight: 500; color: #a5a9bc"><ellipsis :length="25" tooltip>{{ group.name || $t('other') }}</ellipsis></span>
|
||||||
<span :style="{ color: '#c3cdd7' }">({{ group.ci_types.length }})</span>
|
<span :style="{ color: '#c3cdd7' }">({{ group.ci_types.length }})</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -212,6 +212,7 @@ import store from '@/store'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import draggable from 'vuedraggable'
|
import draggable from 'vuedraggable'
|
||||||
|
import { Ellipsis } from '@/components'
|
||||||
import { getCITypeGroups } from '../../api/ciTypeGroup'
|
import { getCITypeGroups } from '../../api/ciTypeGroup'
|
||||||
import {
|
import {
|
||||||
getPreference,
|
getPreference,
|
||||||
|
@ -227,7 +228,7 @@ import { ops_move_icon as OpsMoveIcon } from '@/core/icons'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Preference',
|
name: 'Preference',
|
||||||
components: { CollapseTransition, SubscribeSetting, draggable, OpsMoveIcon },
|
components: { CollapseTransition, SubscribeSetting, draggable, OpsMoveIcon, Ellipsis },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
citypeData: [],
|
citypeData: [],
|
||||||
|
@ -496,6 +497,11 @@ export default {
|
||||||
.undraggable{
|
.undraggable{
|
||||||
.cmdb-preference-group-content {
|
.cmdb-preference-group-content {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
|
margin-left: 20px;
|
||||||
|
&:hover {
|
||||||
|
background: transparent;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue