7070 <div class =" group-nodes" >
7171 <el-empty v-if =" !groups.length" :image-size =" 60" />
7272 <div
73- v-for =" group in groups "
73+ v-for =" group in orderedGroups "
7474 :key =" group.id"
7575 :data-group =" group.id"
7676 class =" relation-group"
7777 :class =" { active: activeGroups.has(group.id) }"
78+ @click ="
79+ focus =
80+ focus?.type === 'group' && focus.id === group.id
81+ ? undefined
82+ : { type: 'group', id: group.id }
83+ "
7884 >
79- <button
80- type =" button"
81- class =" node-button"
82- :aria-pressed =" focus?.type === 'group' && focus.id === group.id"
83- @click ="
84- focus =
85- focus?.type === 'group' && focus.id === group.id
86- ? undefined
87- : { type: 'group', id: group.id }
88- "
89- >
90- <strong >{{ group.name }}</strong >
91- <span class =" input-help" >{{ group.gpu.deviceIDs.length }} GPU · {{ group.imageType }}</span >
92- </button >
85+ <div class =" group-heading" >
86+ <button
87+ type =" button"
88+ class =" node-button"
89+ :aria-pressed =" focus?.type === 'group' && focus.id === group.id"
90+ >
91+ <strong >{{ group.name }}</strong >
92+ <span class =" input-help" >
93+ {{ group.gpu.deviceIDs.length }} GPU · {{ group.imageType }}
94+ </span >
95+ </button >
96+ <div class =" group-actions" @click.stop >
97+ <el-tooltip :content =" $t('commons.button.edit')" placement =" top" >
98+ <el-button
99+ v-permission =" 'ai_gpu_manage'"
100+ text
101+ :icon =" EditPen"
102+ :aria-label =" $t('commons.button.edit')"
103+ @click =" $emit('edit', group)"
104+ />
105+ </el-tooltip >
106+ <el-tooltip :content =" $t('commons.button.delete')" placement =" top" >
107+ <el-button
108+ v-permission =" 'ai_gpu_manage'"
109+ text
110+ :icon =" Delete"
111+ :aria-label =" $t('commons.button.delete')"
112+ @click =" $emit('remove', group)"
113+ />
114+ </el-tooltip >
115+ </div >
116+ </div >
117+ <p v-if =" group.description" class =" detail-description" >{{ group.description }}</p >
118+ <dl class =" detail-fields" >
119+ <div v-if =" nodes.length > 1 || (group.gpu.numa && group.gpu.numa.mode !== 'off')" >
120+ <dt >{{ $t('aiTools.gpuGroup.affinity') }}</dt >
121+ <dd >
122+ <span >
123+ {{
124+ $t(
125+ group.gpu.numa?.mode === 'auto'
126+ ? 'aiTools.gpuGroup.followGPU'
127+ : group.gpu.numa?.mode === 'manual'
128+ ? 'aiTools.model.numaManual'
129+ : 'aiTools.model.numaOff',
130+ )
131+ }}
132+ </span >
133+ <div v-if =" group.gpu.numa?.mode === 'manual'" class =" detail-tags" >
134+ <el-tag
135+ v-for =" node in group.gpu.numa.nodes"
136+ :key =" node"
137+ size =" small"
138+ type =" info"
139+ effect =" plain"
140+ >
141+ NUMA {{ node }}
142+ </el-tag >
143+ </div >
144+ </dd >
145+ </div >
146+ <div >
147+ <dt >{{ $t('aiTools.gpuGroup.deployments') }}</dt >
148+ <dd class =" detail-tags" >
149+ <el-tag
150+ v-for =" deployment in group.deployments"
151+ :key =" deployment"
152+ size =" small"
153+ type =" info"
154+ effect =" plain"
155+ >
156+ {{ deployment }}
157+ </el-tag >
158+ <span v-if =" !group.deployments.length" class =" detail-empty" >—</span >
159+ </dd >
160+ </div >
161+ </dl >
93162 <span class =" relation-port" />
94163 </div >
95164 </div >
96165 </div >
97166 </div >
98- <div v-if =" focusedGroup" class =" relation-detail" >
99- <div class =" detail-heading" >
100- <div class =" detail-title" >
101- <strong >{{ focusedGroup.name }}</strong >
102- <el-tag size =" small" type =" info" effect =" plain" >{{ focusedGroup.gpu.deviceIDs.length }} GPU</el-tag >
103- </div >
104- <div class =" detail-actions" >
105- <el-button v-permission =" 'ai_gpu_manage'" link type =" primary" @click =" $emit('edit', focusedGroup)" >
106- {{ $t('commons.button.edit') }}
107- </el-button >
108- <el-button
109- v-permission =" 'ai_gpu_manage'"
110- link
111- type =" primary"
112- @click =" $emit('remove', focusedGroup)"
113- >
114- {{ $t('commons.button.delete') }}
115- </el-button >
116- </div >
117- </div >
118- <p v-if =" focusedGroup.description" class =" detail-description" >{{ focusedGroup.description }}</p >
119- <dl class =" detail-fields" >
120- <div v-if =" nodes.length > 1 || (focusedGroup.gpu.numa && focusedGroup.gpu.numa.mode !== 'off')" >
121- <dt >{{ $t('aiTools.gpuGroup.affinity') }}</dt >
122- <dd >
123- <span >
124- {{
125- $t(
126- focusedGroup.gpu.numa?.mode === 'auto'
127- ? 'aiTools.gpuGroup.followGPU'
128- : focusedGroup.gpu.numa?.mode === 'manual'
129- ? 'aiTools.model.numaManual'
130- : 'aiTools.model.numaOff',
131- )
132- }}
133- </span >
134- <div v-if =" focusedGroup.gpu.numa?.mode === 'manual'" class =" detail-tags" >
135- <el-tag
136- v-for =" node in focusedGroup.gpu.numa.nodes"
137- :key =" node"
138- size =" small"
139- type =" info"
140- effect =" plain"
141- >
142- NUMA {{ node }}
143- </el-tag >
144- </div >
145- </dd >
146- </div >
147- <div >
148- <dt >{{ $t('aiTools.gpuGroup.deployments') }}</dt >
149- <dd class =" detail-tags" >
150- <el-tag
151- v-for =" deployment in focusedGroup.deployments"
152- :key =" deployment"
153- size =" small"
154- type =" info"
155- effect =" plain"
156- >
157- {{ deployment }}
158- </el-tag >
159- <span v-if =" !focusedGroup.deployments.length" class =" detail-empty" >—</span >
160- </dd >
161- </div >
162- </dl >
163- </div >
164- <div v-else-if =" focusedDevice" class =" relation-detail" >
167+ <div v-if =" focusedDevice" class =" relation-detail" >
165168 <div class =" detail-heading" >
166169 <div class =" detail-title" >
167170 <strong >{{ focusedDevice.name }}</strong >
199202<script setup lang="ts">
200203import { computed , nextTick , ref , watch } from ' vue' ;
201204import { useResizeObserver } from ' @vueuse/core' ;
202- import { InfoFilled } from ' @element-plus/icons-vue' ;
205+ import { Delete , EditPen , InfoFilled } from ' @element-plus/icons-vue' ;
203206import { AI } from ' @/api/interface/ai' ;
204207import i18n from ' @/lang' ;
205208
@@ -217,8 +220,11 @@ const lines = ref<{ key: string; path: string; active: boolean }[]>([]);
217220const sections = computed (() => {
218221 if (! props .nodes .length ) return [{ key: ' devices' , label: ' ' , devices: props .devices }];
219222 const available = props .devices .filter ((device ) => device .available );
220- const result: { key: string ; label: string ; node? : AI .ModelNUMANode ; devices: AI .ModelGPUDevice [] }[] =
221- props .nodes .map ((node ) => ({
223+ const result: { key: string ; label: string ; node? : AI .ModelNUMANode ; devices: AI .ModelGPUDevice [] }[] = [
224+ ... props .nodes ,
225+ ]
226+ .sort ((a , b ) => a .id - b .id )
227+ .map ((node ) => ({
222228 key: ` numa-${node .id } ` ,
223229 label: ` NUMA ${node .id } ` ,
224230 node ,
@@ -237,6 +243,23 @@ const sections = computed(() => {
237243 result .push ({ key: ' unassigned' , label: i18n .global .t (' aiTools.gpuGroup.unknownNode' ), devices: unassigned });
238244 return result ;
239245});
246+ const orderedGroups = computed (() => {
247+ const deviceOrder = new Map (
248+ sections .value .flatMap ((section ) => section .devices ).map ((device , index ) => [device .id , index ]),
249+ );
250+ const groupOrder = new Map (
251+ props .groups .map ((group ) => [
252+ group .id ,
253+ Math .min (... group .gpu .deviceIDs .map ((id ) => deviceOrder .get (id ) ?? Infinity )),
254+ ]),
255+ );
256+ return [... props .groups ].sort (
257+ (a , b ) =>
258+ groupOrder .get (a .id )! - groupOrder .get (b .id )! ||
259+ a .name .localeCompare (b .name , undefined , { numeric: true }) ||
260+ a .id - b .id ,
261+ );
262+ });
240263const activeGroups = computed (
241264 () =>
242265 new Set (
@@ -259,9 +282,6 @@ const activeDevices = computed(
259282 .flatMap ((group ) => group .gpu .deviceIDs ),
260283 ),
261284);
262- const focusedGroup = computed (() =>
263- props .groups .find ((group ) => focus .value ?.type === ' group' && group .id === focus .value .id ),
264- );
265285const focusedDevice = computed (() =>
266286 props .devices .find ((device ) => focus .value ?.type === ' device' && device .id === focus .value .id ),
267287);
@@ -339,14 +359,14 @@ watch(
339359 grid-column : 3 ;
340360 display : flex ;
341361 flex-direction : column ;
342- gap : 20 px ;
362+ gap : 16 px ;
343363}
344364.group-nodes {
345365 display : flex ;
346366 flex : 1 ;
347367 flex-direction : column ;
348- justify-content : space-around ;
349- gap : 20 px ;
368+ justify-content : center ;
369+ gap : 16 px ;
350370 padding-bottom : 16px ;
351371}
352372.hardware-column ,
@@ -410,7 +430,47 @@ h3 {
410430 color : var (--el-text-color-secondary );
411431}
412432.relation-group {
413- padding : 16px ;
433+ padding : 12px 16px ;
434+ display : flex ;
435+ flex-direction : column ;
436+ gap : 8px ;
437+ font-size : 13px ;
438+ line-height : 20px ;
439+ overflow-wrap : anywhere;
440+ cursor : pointer ;
441+ }
442+ .group-heading {
443+ display : flex ;
444+ align-items : center ;
445+ gap : 8px ;
446+ }
447+ .group-heading > .node-button {
448+ flex : 1 ;
449+ min-width : 0 ;
450+ gap : 2px ;
451+ }
452+ .relation-group .detail-fields {
453+ grid-template-columns : minmax (0 , 1fr );
454+ gap : 8px ;
455+ padding-top : 8px ;
456+ border-top : 1px solid var (--el-border-color-lighter );
457+ }
458+ .relation-group .detail-fields > div {
459+ display : flex ;
460+ align-items : baseline ;
461+ flex-wrap : wrap ;
462+ gap : 4px 12px ;
463+ }
464+ .relation-group .detail-fields dt {
465+ margin-bottom : 0 ;
466+ }
467+ .relation-group .detail-fields dd {
468+ flex : 1 ;
469+ min-width : 80px ;
470+ flex-direction : row ;
471+ flex-wrap : wrap ;
472+ align-items : center ;
473+ gap : 6px ;
414474}
415475.node-button {
416476 position : relative ;
@@ -488,15 +548,25 @@ h3 {
488548 font-size : 15px ;
489549 font-weight : 600 ;
490550}
491- .detail -actions {
551+ .group -actions {
492552 display : flex ;
493553 align-items : center ;
494- gap : 16 px ;
554+ gap : 4 px ;
495555 flex-shrink : 0 ;
496556}
497- .detail -actions :deep(.el-button + .el-button ) {
557+ .group -actions :deep(.el-button + .el-button ) {
498558 margin-left : 0 ;
499559}
560+ .group-actions .el-button {
561+ width : 28px ;
562+ height : 28px ;
563+ padding : 4px ;
564+ color : var (--el-text-color-regular );
565+ }
566+ .group-actions .el-button :hover ,
567+ .group-actions .el-button :focus-visible {
568+ color : var (--el-color-primary );
569+ }
500570.detail-description {
501571 margin : 0 ;
502572 color : var (--el-text-color-secondary );
0 commit comments