parent
78cbdeb123
commit
ac28ea88df
6 changed files with 78 additions and 35 deletions
@ -0,0 +1,5 @@ |
||||
import toAnvilMemoryCalcable from './toAnvilMemoryCalcable'; |
||||
import toAnvilOverviewHostList from './toAnvilOverviewHostList'; |
||||
import toAnvilOverviewList from './toAnvilOverviewList'; |
||||
|
||||
export { toAnvilMemoryCalcable, toAnvilOverviewHostList, toAnvilOverviewList }; |
@ -0,0 +1,15 @@ |
||||
const toAnvilMemoryCalcable = (data: AnvilMemory): AnvilMemoryCalcable => { |
||||
const { allocated: rAllocated, reserved: rReserved, total: rTotal } = data; |
||||
|
||||
const allocated = BigInt(rAllocated); |
||||
const reserved = BigInt(rReserved); |
||||
const total = BigInt(rTotal); |
||||
|
||||
return { |
||||
allocated, |
||||
reserved, |
||||
total, |
||||
}; |
||||
}; |
||||
|
||||
export default toAnvilMemoryCalcable; |
@ -0,0 +1,13 @@ |
||||
const toAnvilOverviewHostList = ( |
||||
data: APIAnvilOverviewArray[number]['hosts'], |
||||
): APIAnvilOverview['hosts'] => |
||||
data.reduce<APIAnvilOverview['hosts']>( |
||||
(previous, { hostName: name, hostType: type, hostUUID: uuid }) => { |
||||
previous[uuid] = { name, type, uuid }; |
||||
|
||||
return previous; |
||||
}, |
||||
{}, |
||||
); |
||||
|
||||
export default toAnvilOverviewHostList; |
@ -0,0 +1,28 @@ |
||||
import toAnvilOverviewHostList from './toAnvilOverviewHostList'; |
||||
|
||||
const toAnvilOverviewList = ( |
||||
data: APIAnvilOverviewArray, |
||||
): APIAnvilOverviewList => |
||||
data.reduce<APIAnvilOverviewList>( |
||||
( |
||||
previous, |
||||
{ |
||||
anvilDescription: description, |
||||
anvilName: name, |
||||
anvilUUID: uuid, |
||||
hosts, |
||||
}, |
||||
) => { |
||||
previous[uuid] = { |
||||
description, |
||||
hosts: toAnvilOverviewHostList(hosts), |
||||
name, |
||||
uuid, |
||||
}; |
||||
|
||||
return previous; |
||||
}, |
||||
{}, |
||||
); |
||||
|
||||
export default toAnvilOverviewList; |
Loading…
Reference in new issue