You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
782 B
39 lines
782 B
const toAnvilDetail = (data: AnvilListItem): APIAnvilDetail => { |
|
const { |
|
anvil_name: anvilName, |
|
anvil_state: anvilState, |
|
anvil_uuid: anvilUuid, |
|
hosts: rHosts, |
|
} = data; |
|
|
|
const hosts = rHosts.reduce<APIAnvilDetail['hosts']>((previous, current) => { |
|
const { |
|
host_name: hostName, |
|
host_uuid: hostUuid, |
|
maintenance_mode: maintenance, |
|
server_count: serverCount, |
|
state, |
|
state_percent: stateProgress, |
|
} = current; |
|
|
|
previous[hostUuid] = { |
|
name: hostName, |
|
maintenance, |
|
serverCount, |
|
state, |
|
stateProgress, |
|
uuid: hostUuid, |
|
}; |
|
|
|
return previous; |
|
}, {}); |
|
|
|
return { |
|
hosts, |
|
name: anvilName, |
|
state: anvilState, |
|
uuid: anvilUuid, |
|
}; |
|
}; |
|
|
|
export default toAnvilDetail;
|
|
|