Skip to content

Commit

Permalink
feat: add ipaddress to the existed devices in dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Meng-20 committed Dec 2, 2024
1 parent 073dc24 commit d67c8ae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
30 changes: 15 additions & 15 deletions webui/src/components/Dashboard/initial-control-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export const useControlData = () => {
style: { backgroundColor: "#f2ae72", color: "#000" },
type: applianceNodeType,
},
...appliance.bladeIds.map((bladeId, bladeIndex) => ({
id: `blade-${bladeId}`,
data: { label: bladeId, url: `/appliances/${appliance.id}/blades/${bladeId}`, associatedAppliance: appliance.id },
...appliance.blades.map((blade, bladeIndex) => ({
id: `blade-${blade.id}`,
data: { label: blade.id, url: `/appliances/${appliance.id}/blades/${blade.id}`, associatedAppliance: appliance.id },
position: position,
style: { backgroundColor: "#f2e394", color: "#000" },
type: bladeNodeType,
Expand All @@ -49,8 +49,8 @@ export const useControlData = () => {
);

const hostNodes = hostStore.hostIds.map((host, index) => ({
id: `host-${host}`,
data: { label: host, url: `/hosts/${host}` },
id: `host-${host.id}`,
data: { label: host.id, url: `/hosts/${host.id}` },
position: position,
style: { backgroundColor: "#d9ecd0", color: "#000" },
type: hostNodeType,
Expand All @@ -67,18 +67,18 @@ export const useControlData = () => {
source: "cfm-service",
target: `appliance-${appliance.id}`,
},
...appliance.bladeIds.map((bladeId) => ({
id: `appliance-blade-${appliance.id}-${bladeId}`,
...appliance.blades.map((blade) => ({
id: `appliance-blade-${appliance.id}-${blade.id}`,
source: `appliance-${appliance.id}`,
target: `blade-${bladeId}`,
target: `blade-${blade.id}`,
})),
])
: [];

const hostEdges = hostStore.hostIds.map((host) => ({
id: `cfm-${host}`,
id: `cfm-${host.id}`,
source: "cfm-service",
target: `host-${host}`,
target: `host-${host.id}`,
}));

return [...coreEdges, ...hostEdges];
Expand All @@ -97,19 +97,19 @@ export const useControlData = () => {
target: `appliance-${appliance.id}`,
animated: true,
},
...appliance.bladeIds.map((bladeId) => ({
id: `appliance-blade-${appliance.id}-${bladeId}`,
...appliance.blades.map((blade) => ({
id: `appliance-blade-${appliance.id}-${blade.id}`,
source: `appliance-${appliance.id}`,
target: `blade-${bladeId}`,
target: `blade-${blade.id}`,
animated: true,
})),
])
: [];

const hostEdges = hostStore.hostIds.map((host) => ({
id: `cfm-${host}`,
id: `cfm-${host.id}`,
source: "cfm-service",
target: `host-${host}`,
target: `host-${host.id}`,
animated: true,
}));

Expand Down
14 changes: 7 additions & 7 deletions webui/src/components/Dashboard/initial-data-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useData = () => {
let currentYPosition = 0;
const applianceNodes = applianceStore.applianceIds.flatMap(
(appliance, index) => {
const bladeCount = appliance.bladeIds.length;
const bladeCount = appliance.blades.length;
const applianceHeight = 50 + bladeCount * 50; // Adjust height based on number of blades
const applianceWidth = 270; // Width of the appliance node
const bladeWidth = 250; // Width of the blade node
Expand All @@ -34,9 +34,9 @@ export const useData = () => {
targetPosition: 'left',
};

const bladeNodes = appliance.bladeIds.map((bladeId, bladeIndex) => ({
id: `blade-${bladeId}`,
data: { label: bladeId, url: `/appliances/${appliance.id}/blades/${bladeId}`, associatedAppliance: appliance.id },
const bladeNodes = appliance.blades.map((blade, bladeIndex) => ({
id: `blade-${blade.id}`,
data: { label: blade.id, url: `/appliances/${appliance.id}/blades/${blade.id}`, associatedAppliance: appliance.id },
position: { x: bladeXPosition, y: 50 + bladeIndex * 50 }, // Center blades within the appliance node
style: { backgroundColor: "#f2e394", color: "#000", width: `${bladeWidth}px` },
type: bladeNodeType,
Expand All @@ -54,11 +54,11 @@ export const useData = () => {
);

const hostNodes = hostStore.hostIds.map((host, index) => {
const { width, height } = useLayout().measureText(host);
const { width, height } = useLayout().measureText(host.id);

return {
id: `host-${host}`,
data: { label: host, url: `/hosts/${host}` },
id: `host-${host.id}`,
data: { label: host.id, url: `/hosts/${host.id}` },
position: { x: 500, y: index * 200 },
style: {
backgroundColor: "#d9ecd0",
Expand Down

0 comments on commit d67c8ae

Please sign in to comment.