From a76168d1ab4c66de828cfd424c34ebbc6036578a Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Thu, 6 Apr 2023 04:21:03 +0000 Subject: [PATCH] add more info to insatnce container --- index.html | 11 ++++++++--- scripts/index.js | 13 ++++++++++++- scripts/instance.js | 34 +++++++++++++++++----------------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/index.html b/index.html index 3201a02..ae76ce6 100644 --- a/index.html +++ b/index.html @@ -12,15 +12,20 @@ diff --git a/scripts/index.js b/scripts/index.js index 883cb0c..86eba52 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -33,7 +33,18 @@ async function populateInstances () { instances.sort((a, b) => (a.vmid > b.vmid) ? 1 : -1); - instanceContainer.innerText = ""; + instanceContainer.innerHTML = ` +
+

VM ID

+

VM Name

+

VM Type

+

VM Status

+

Host Name

+

Host Status

+ +

Actions

+
+ `; for(let i = 0; i < instances.length; i++) { let newInstance = document.createElement("instance-obj"); newInstance.data = instances[i]; diff --git a/scripts/instance.js b/scripts/instance.js index 55a6a0a..c2d64af 100644 --- a/scripts/instance.js +++ b/scripts/instance.js @@ -10,15 +10,13 @@ export class Instance extends HTMLElement { -
- instance node -

-
-
- -

-

-
+

+

+

+

+

+

+
@@ -44,21 +42,23 @@ export class Instance extends HTMLElement { } update () { - let typeImg = this.shadowElement.querySelector("#instance-type"); - typeImg.src = `images/instances/${this.type}/${this.status}.svg`; - typeImg.alt = `${this.status} instance`; - let vmidParagraph = this.shadowElement.querySelector("#instance-id"); vmidParagraph.innerText = this.vmid; let nameParagraph = this.shadowElement.querySelector("#instance-name"); nameParagraph.innerText = this.name ? this.name : ""; - let nodeImg = this.shadowElement.querySelector("#node-status"); - nodeImg.src = `images/nodes/${this.node.status}.svg`; + let typeParagraph = this.shadowElement.querySelector("#instance-type"); + typeParagraph.innerText = this.type; - let nodeParagraph = this.shadowElement.querySelector("#node-name"); - nodeParagraph.innerText = this.node.name; + let statusParagraph = this.shadowElement.querySelector("#instance-status"); + statusParagraph.innerText = this.status; + + let nodeNameParagraph = this.shadowElement.querySelector("#node-name"); + nodeNameParagraph.innerText = this.node.name; + + let nodeStatusParagraph = this.shadowElement.querySelector("#node-status"); + nodeStatusParagraph.innerText = this.node.status; let powerButton = this.shadowElement.querySelector("#power-btn"); powerButton.src = instances[this.status].powerButtonSrc;