From a08deff7909b68a89662f8b93845918bdc613732 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 7 Sep 2017 17:22:24 +0200 Subject: Finish rack mode machine list rendering --- public/img/topology/cpu-icon.png | Bin 0 -> 4062 bytes public/img/topology/gpu-icon.png | Bin 0 -> 2227 bytes public/img/topology/memory-icon.png | Bin 0 -> 1980 bytes public/img/topology/storage-icon.png | Bin 0 -> 4038 bytes src/actions/topology.js | 2 +- src/api/routes/tiles.js | 2 +- src/auth/index.js | 4 +- .../sidebars/topology/rack/EmptySlotComponent.js | 14 +++--- .../sidebars/topology/rack/MachineComponent.js | 54 +++++++++++++++------ .../sidebars/topology/rack/MachineListComponent.js | 7 +-- .../topology/rack/MachineListComponent.sass | 2 + .../sidebars/topology/rack/RackSidebarComponent.js | 7 ++- .../topology/rack/RackSidebarComponent.sass | 8 +++ src/index.sass | 2 +- src/sagas/topology.js | 5 +- 15 files changed, 74 insertions(+), 33 deletions(-) create mode 100644 public/img/topology/cpu-icon.png create mode 100644 public/img/topology/gpu-icon.png create mode 100644 public/img/topology/memory-icon.png create mode 100644 public/img/topology/storage-icon.png create mode 100644 src/components/sidebars/topology/rack/MachineListComponent.sass create mode 100644 src/components/sidebars/topology/rack/RackSidebarComponent.sass diff --git a/public/img/topology/cpu-icon.png b/public/img/topology/cpu-icon.png new file mode 100644 index 00000000..07cfbd31 Binary files /dev/null and b/public/img/topology/cpu-icon.png differ diff --git a/public/img/topology/gpu-icon.png b/public/img/topology/gpu-icon.png new file mode 100644 index 00000000..55d4fb05 Binary files /dev/null and b/public/img/topology/gpu-icon.png differ diff --git a/public/img/topology/memory-icon.png b/public/img/topology/memory-icon.png new file mode 100644 index 00000000..36e8a44e Binary files /dev/null and b/public/img/topology/memory-icon.png differ diff --git a/public/img/topology/storage-icon.png b/public/img/topology/storage-icon.png new file mode 100644 index 00000000..7a39cb6f Binary files /dev/null and b/public/img/topology/storage-icon.png differ diff --git a/src/actions/topology.js b/src/actions/topology.js index 4d9f1e52..04d9f102 100644 --- a/src/actions/topology.js +++ b/src/actions/topology.js @@ -245,7 +245,7 @@ export function addMachineSucceeded(machine) { const {objects, interactionLevel} = getState(); const rack = objects.rack[objects.tile[interactionLevel.tileId].objectId]; const machineIds = [...rack.machineIds]; - machineIds[machine.position] = machine.id; + machineIds[machine.position - 1] = machine.id; dispatch(addPropToStoreObject("rack", rack.id, {machineIds})); }; } diff --git a/src/api/routes/tiles.js b/src/api/routes/tiles.js index 927a074b..b1c594d5 100644 --- a/src/api/routes/tiles.js +++ b/src/api/routes/tiles.js @@ -32,7 +32,7 @@ export function getMachinesOfRackByTile(tileId) { export function addMachineToRackOnTile(tileId, machine) { return sendRequest({ path: "/tiles/{tileId}/rack/machines", - method: "GET", + method: "POST", parameters: { body: { machine diff --git a/src/auth/index.js b/src/auth/index.js index fb2a7038..418d816c 100644 --- a/src/auth/index.js +++ b/src/auth/index.js @@ -3,7 +3,7 @@ import {DELETE_CURRENT_USER_SUCCEEDED} from "../actions/users"; const getAuthObject = () => { const authItem = localStorage.getItem("auth"); - if (!authItem) { + if (!authItem || authItem === "{}") { return undefined; } return JSON.parse(authItem); @@ -34,7 +34,7 @@ export const saveAuthLocalStorage = (payload) => { }; export const clearAuthLocalStorage = () => { - localStorage.setItem("auth", "{}"); + localStorage.setItem("auth", ""); }; export const authRedirectMiddleware = store => next => action => { diff --git a/src/components/sidebars/topology/rack/EmptySlotComponent.js b/src/components/sidebars/topology/rack/EmptySlotComponent.js index 5234ee63..1ca13b67 100644 --- a/src/components/sidebars/topology/rack/EmptySlotComponent.js +++ b/src/components/sidebars/topology/rack/EmptySlotComponent.js @@ -2,13 +2,13 @@ import React from "react"; import FontAwesome from "react-fontawesome"; const EmptySlotComponent = ({position, onAdd}) => ( -
  • - - {position} - - Add machine -
  • ); diff --git a/src/components/sidebars/topology/rack/MachineComponent.js b/src/components/sidebars/topology/rack/MachineComponent.js index e328951e..56e723bc 100644 --- a/src/components/sidebars/topology/rack/MachineComponent.js +++ b/src/components/sidebars/topology/rack/MachineComponent.js @@ -1,23 +1,49 @@ import React from "react"; import Shapes from "../../../../shapes"; +const UnitIcon = ({id, type}) => ( +
    + {"Machine +
    +); + const MachineComponent = ({position, machine, onClick}) => ( -
  • - +
  • + {position} - - {machine.cpuIds.length} CPUs - - - {machine.gpuIds.length} GPUs - - - {machine.memoryIds.length} Memories - - - {machine.storageIds.length} Storages - +
    + {machine.cpuIds.length > 0 ? + : + undefined + } + {machine.gpuIds.length > 0 ? + : + undefined + } + {machine.memoryIds.length > 0 ? + : + undefined + } + {machine.storageIds.length > 0 ? + : + undefined + } + {machine.cpuIds.length + machine.gpuIds.length + machine.memoryIds.length + machine.storageIds.length === 0 ? + + Machine with no units + : + undefined + } +
  • ); diff --git a/src/components/sidebars/topology/rack/MachineListComponent.js b/src/components/sidebars/topology/rack/MachineListComponent.js index d8a31ddc..41522e36 100644 --- a/src/components/sidebars/topology/rack/MachineListComponent.js +++ b/src/components/sidebars/topology/rack/MachineListComponent.js @@ -1,15 +1,16 @@ import React from "react"; import EmptySlotContainer from "../../../../containers/sidebars/topology/rack/EmptySlotContainer"; import MachineContainer from "../../../../containers/sidebars/topology/rack/MachineContainer"; +import "./MachineListComponent.css"; const MachineListComponent = ({machineIds}) => { return ( -