Просмотр исходного кода

Update minion machine status field.

Nashwan Azhari 5 лет назад
Родитель
Сommit
cb99f9a8a4

+ 10 - 1
src/components/atoms/StatusPill/StatusPill.tsx

@@ -40,6 +40,10 @@ const LABEL_MAP: { [status: string]: string } = {
   IN_MAINTENANCE: 'MAINTENANCE',
   RESCALING: 'SCALING',
   IN_USE: 'IN USE',
+  // Minion Machine power statuses
+  POWERED_ON: 'POWERED ON',
+  POWERED_OFF: 'POWERED OFF',
+  POWER_ERROR: 'ERROR'
 }
 
 const statuses = (status: any) => {
@@ -56,6 +60,7 @@ const statuses = (status: any) => {
     case 'FAILED_TO_CANCEL':
     case 'ERROR':
     case 'ERROR_ALLOCATING_MINIONS':
+    case 'POWER_ERROR': // Minion Machine power status
       return css`
         background: ${Palette.alert};
         color: white;
@@ -91,6 +96,7 @@ const statuses = (status: any) => {
     case 'RESCALING': // Minion Pool status
     case 'DEPLOYING': // Minion Pool status
     case 'IN_USE': // Minion Pool status
+    case 'POWERED_ON': // Minion Machine status
     case 'HEALTHCHECKING': // Minion Pool status
       return css`
         background: url('${runningImage}');
@@ -102,6 +108,7 @@ const statuses = (status: any) => {
           100% { background-position: 0 -1px; }
         }
       `
+
     case 'CANCELLING':
     case 'UNINITIALIZING':
     case 'DEALLOCATING':
@@ -126,9 +133,11 @@ const statuses = (status: any) => {
         border-color: transparent;
       `
     case 'UNSCHEDULED':
-    case 'UNINITIALIZED': // Minion Pool status
+    case 'UNKNOWN': // Minion Pool/Machine status
+    case 'UNINITIALIZED': // Minion Pool/Machine status
     case 'DEALLOCATED': // Minion Pool status
     case 'INITIALIZED': // Minion Pool status
+    case 'POWERED_OFF': // Minion Machine status
       return css`
         background: ${Palette.grayscale[2]};
         color: ${Palette.black};

+ 1 - 1
src/components/molecules/MinionPoolListItem/MinionPoolListItem.tsx

@@ -136,7 +136,7 @@ class MinionPoolListItem extends React.Component<Props> {
   }
 
   renderCreatedCount() {
-    const createdCount = this.props.item.minion_machines.filter(m => m.status === 'ALLOCATED' || m.status === 'AVAILABLE').length
+    const createdCount = this.props.item.minion_machines.filter(m => m.allocation_status === 'IN_USE' || m.allocation_status === 'AVAILABLE').length
     const totalCount = this.props.item.minion_machines.length
 
     return (

+ 7 - 4
src/components/organisms/MinionPoolDetailsContent/MinionPoolMachines.tsx

@@ -149,9 +149,9 @@ class MinionPoolMachines extends React.Component<Props, State> {
       case 'all':
         return this.machines
       case 'allocated':
-        return this.machines.filter(m => m.status === 'ALLOCATED' || m.status === 'AVAILABLE')
+        return this.machines.filter(m => m.allocation_status === 'ALLOCATED' || m.allocation_status === 'AVAILABLE')
       default:
-        return this.machines.filter(m => m.status !== 'ALLOCATED' && m.status !== 'AVAILABLE')
+        return this.machines.filter(m => m.allocation_status !== 'ALLOCATED' && m.allocation_status !== 'AVAILABLE')
     }
   }
 
@@ -193,7 +193,7 @@ class MinionPoolMachines extends React.Component<Props, State> {
           />
         </HeaderFilter>
         <HeaderText>
-          {this.machines.length} minion machine{plural}, {this.machines.filter(m => m.status === 'ALLOCATED' || m.status === 'AVAILABLE').length} allocated
+          {this.machines.length} minion machine{plural}, {this.machines.filter(m => m.allocation_status === 'ALLOCATED' || m.allocation_status === 'AVAILABLE').length} allocated
         </HeaderText>
       </Header>
     )
@@ -245,7 +245,10 @@ class MinionPoolMachines extends React.Component<Props, State> {
             <MachineTitle>ID: {machine.id}</MachineTitle>
             <MachineBody>
               <MachineRow style={{ marginBottom: '8px', display: 'flex' }}>
-                Status: <StatusPill style={{ marginLeft: '8px' }} status={machine.status} />
+                Power Status: <StatusPill style={{ marginLeft: '8px' }} status={machine.power_status} />
+              </MachineRow>
+              <MachineRow style={{ marginBottom: '8px', display: 'flex' }}>
+                Allocation Status: <StatusPill style={{ marginLeft: '8px' }} status={machine.allocation_status} />
               </MachineRow>
               <MachineRow secondary>Created At: {moment(machine.created_at).format('YYYY-MM-DD HH:mm:ss')}</MachineRow>
               {machine.updated_at ? <MachineRow secondary>Updated At: {moment(machine.updated_at).format('YYYY-MM-DD HH:mm:ss')}</MachineRow> : null}