fix(striker-ui): add api converter to anvil detail

main
Tsu-ba-me 1 year ago
parent f59ed30ff6
commit bd6bc7f7f6
  1. 2
      striker-ui/lib/api_converters/index.ts
  2. 37
      striker-ui/lib/api_converters/toAnvilDetail.ts
  3. 15
      striker-ui/types/APIAnvil.d.ts

@ -1,9 +1,11 @@
import toAnvilDetail from './toAnvilDetail';
import toAnvilMemoryCalcable from './toAnvilMemoryCalcable';
import toAnvilOverviewHostList from './toAnvilOverviewHostList';
import toAnvilOverviewList from './toAnvilOverviewList';
import toAnvilSharedStorageOverview from './toAnvilSharedStorageOverview';
export {
toAnvilDetail,
toAnvilMemoryCalcable,
toAnvilOverviewHostList,
toAnvilOverviewList,

@ -0,0 +1,37 @@
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,
state,
state_percent: stateProgress,
} = current;
previous[hostUuid] = {
name: hostName,
maintenance,
state,
stateProgress,
uuid: hostUuid,
};
return previous;
}, {});
return {
hosts,
name: anvilName,
state: anvilState,
uuid: anvilUuid,
};
};
export default toAnvilDetail;

@ -129,6 +129,21 @@ type APIAnvilOverview = {
uuid: string;
};
type APIAnvilDetail = {
hosts: {
[uuid: string]: {
maintenance: boolean;
name: string;
state: AnvilStatusHost['state'];
stateProgress: number;
uuid: string;
};
};
name: string;
state: AnvilStatus['anvil_state'];
uuid: string;
};
type APIAnvilOverviewList = {
[uuid: string]: APIAnvilOverview;
};

Loading…
Cancel
Save