Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bkunyun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bkunyun
Commits
fb4b38d9
Commit
fb4b38d9
authored
Oct 12, 2022
by
chenshouchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 硬件队列选择器的key由id改为partition
parent
9edf10e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
19 deletions
+29
-19
index.tsx
src/components/BusinessComponents/QueueSelect/index.tsx
+29
-19
No files found.
src/components/BusinessComponents/QueueSelect/index.tsx
View file @
fb4b38d9
...
...
@@ -18,6 +18,7 @@ export type IQueueLi = {
memory
:
number
;
total
:
number
;
id
:
string
;
partition
:
string
;
};
type
IQueueSelectProps
=
{
...
...
@@ -34,6 +35,7 @@ type IMemoryLi = {
memory
:
number
;
total
:
number
;
id
:
string
;
partition
:
string
;
};
export
type
IShowCPULi
=
{
...
...
@@ -42,6 +44,7 @@ export type IShowCPULi = {
cpuName
:
string
;
coreNum
:
number
;
id
:
string
;
partition
:
string
;
memoryList
:
Array
<
IMemoryLi
>
;
};
...
...
@@ -67,20 +70,20 @@ const QueueSelect = (props: IQueueSelectProps) => {
disabled
,
}
=
props
;
const
Message
=
useMessage
();
const
[
active
Id
,
setActiveId
]
=
useState
(
""
);
const
[
active
Partition
,
setActivePartition
]
=
useState
(
""
);
const
[
open
,
setOpen
]
=
useState
(
false
);
const
[
queueType
,
setQueueType
]
=
useState
(
"CPU"
);
const
[
showCpuList
,
setShowCpuList
]
=
useState
<
Array
<
IShowCPULi
>>
([]);
const
handleOpen
=
()
=>
{
// setActiveId("");
setOpen
(
true
);
};
// 队列id和前端展示的队列信息的映射关系
// 队列id
、partition
和前端展示的队列信息的映射关系
const
idInfoMap
=
useMemo
(()
=>
{
return
[
...
originalCpuList
.
map
((
item
)
=>
({
id
:
item
.
id
,
partition
:
item
.
partition
,
title
:
`
${
item
.
name
}
/
${
item
.
coreNum
}
核
${
item
.
coreNum
*
item
.
memory
}
G/
${
item
.
coreNum
}
总核心数`
,
...
...
@@ -88,6 +91,7 @@ const QueueSelect = (props: IQueueSelectProps) => {
})),
...
originalGpuList
.
map
((
item
)
=>
({
id
:
item
.
id
,
partition
:
item
.
partition
,
title
:
`
${
item
.
name
}
/
${
item
.
gpuNum
}
卡
${
item
.
coreNum
}
核
${
item
.
memory
}
G/
${
item
.
gpuNum
}
总卡数`
,
total
:
item
.
total
,
})),
...
...
@@ -107,11 +111,13 @@ const QueueSelect = (props: IQueueSelectProps) => {
cpuName
:
item
.
cpuName
,
coreNum
:
item
.
coreNum
,
id
:
item
.
id
,
partition
:
item
.
partition
,
memoryList
:
[
{
memory
:
item
.
memory
,
total
:
item
.
total
,
id
:
item
.
id
,
partition
:
item
.
partition
,
},
],
});
...
...
@@ -120,6 +126,7 @@ const QueueSelect = (props: IQueueSelectProps) => {
memory
:
item
.
memory
,
total
:
item
.
total
,
id
:
item
.
id
,
partition
:
item
.
partition
,
});
}
});
...
...
@@ -191,17 +198,17 @@ const QueueSelect = (props: IQueueSelectProps) => {
return
item
.
memory
+
"GB"
;
};
const
setMemory
=
(
id
:
string
)
=>
{
const
setMemory
=
(
partition
:
string
)
=>
{
const
copyShowCpuList
:
Array
<
IShowCPULi
>
=
cloneDeep
(
showCpuList
);
const
selectIndex
=
copyShowCpuList
.
findIndex
((
item
)
=>
{
return
item
.
id
===
activeId
;
return
item
.
partition
===
activePartition
;
});
if
(
selectIndex
!==
-
1
)
{
copyShowCpuList
[
selectIndex
].
id
=
id
;
copyShowCpuList
[
selectIndex
].
partition
=
partition
;
}
// 防止被 handleRow 中的 setActiveId覆盖
setTimeout
(()
=>
{
setActive
Id
(
id
);
setActive
Partition
(
partition
);
},
10
);
setShowCpuList
(
copyShowCpuList
);
};
...
...
@@ -209,18 +216,19 @@ const QueueSelect = (props: IQueueSelectProps) => {
const
renderMemory
=
(
item
:
IShowCPULi
)
=>
{
return
(
<
MyMenu
value=
{
item
.
id
}
value=
{
item
.
partition
}
options=
{
item
.
memoryList
.
map
((
memoryLi
)
=>
({
label
:
`${memoryLi.memory}GB/核`
,
value
:
memoryLi
.
id
,
value
:
memoryLi
.
partition
,
}))
}
hasTriangle=
{
true
}
setValue=
{
setMemory
}
>
<
span
className=
{
style
.
cpuMemory
}
>
{
item
.
memoryList
.
filter
((
memoryLi
)
=>
memoryLi
.
id
===
item
.
id
)[
0
]
.
memory
item
.
memoryList
.
filter
(
(
memoryLi
)
=>
memoryLi
.
partition
===
item
.
partition
)[
0
].
memory
}
GB/核
</
span
>
...
...
@@ -229,12 +237,12 @@ const QueueSelect = (props: IQueueSelectProps) => {
};
const
handleRow
=
(
e
:
any
)
=>
{
setActive
Id
(
e
.
id
);
setActive
Partition
(
e
.
partition
);
};
const
handleConfirm
=
()
=>
{
if
(
active
Id
)
{
onChange
&&
onChange
(
active
Id
);
if
(
active
Partition
)
{
onChange
&&
onChange
(
active
Partition
);
setOpen
(
false
);
}
else
{
Message
.
error
(
"请先选择一个硬件队列。"
);
...
...
@@ -244,7 +252,7 @@ const QueueSelect = (props: IQueueSelectProps) => {
const
getTotal
=
()
=>
{
let
total
=
0
;
idInfoMap
.
forEach
((
item
)
=>
{
if
(
item
.
id
===
activeId
)
{
if
(
item
.
partition
===
activePartition
)
{
total
=
item
.
total
;
}
});
...
...
@@ -254,7 +262,7 @@ const QueueSelect = (props: IQueueSelectProps) => {
const
getTitle
=
()
=>
{
let
title
=
""
;
idInfoMap
.
forEach
((
item
)
=>
{
if
(
item
.
id
===
value
)
{
if
(
item
.
partition
===
value
)
{
title
=
item
.
title
;
}
});
...
...
@@ -281,7 +289,7 @@ const QueueSelect = (props: IQueueSelectProps) => {
<
div
className=
{
style
.
totalBox
}
>
费用(每小时):
<
span
className=
{
style
.
total
}
>
¥
{
active
Id
?
getTotal
()
:
"-"
}
¥
{
active
Partition
?
getTotal
()
:
"-"
}
</
span
>
</
div
>
}
...
...
@@ -306,7 +314,8 @@ const QueueSelect = (props: IQueueSelectProps) => {
headCells=
{
cpuHeadCells
}
fixedHead=
{
true
}
handleRow=
{
(
e
:
any
)
=>
handleRow
(
e
)
}
activeId=
{
activeId
}
activeId=
{
activePartition
}
tableKey=
"partition"
></
MyTable
>
)
}
{
queueType
===
"GPU"
&&
(
...
...
@@ -321,7 +330,8 @@ const QueueSelect = (props: IQueueSelectProps) => {
headCells=
{
gpuHeadCells
}
fixedHead=
{
true
}
handleRow=
{
(
e
:
any
)
=>
handleRow
(
e
)
}
activeId=
{
activeId
}
activeId=
{
activePartition
}
tableKey=
"partition"
></
MyTable
>
)
}
</
div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment