From fa522344076fdd65d7d3e8ac3893670b360dc594 Mon Sep 17 00:00:00 2001 From: Thibault Barske Date: Fri, 22 Nov 2024 17:48:38 +0100 Subject: [PATCH] feat(nutanix): add nodes sections on nutanix dashboard ref: MANAGER-14695 Signed-off-by: Thibault Barske --- .../manager/modules/nutanix/src/constants.js | 14 ++++++ .../src/dashboard/general-info/controller.js | 23 +++++++++ .../src/dashboard/general-info/template.html | 47 +++++++++++++++++++ .../translations/Messages_fr_FR.json | 7 ++- .../manager/modules/nutanix/src/node.class.js | 17 +++++++ .../manager/modules/nutanix/src/service.js | 12 ++++- 6 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 packages/manager/modules/nutanix/src/node.class.js diff --git a/packages/manager/modules/nutanix/src/constants.js b/packages/manager/modules/nutanix/src/constants.js index 2da8b499f0f1..4f04b432112a 100644 --- a/packages/manager/modules/nutanix/src/constants.js +++ b/packages/manager/modules/nutanix/src/constants.js @@ -8,6 +8,19 @@ export const CLUSTER_STATUS = { DEPLOYING: 'deploying', ERROR: 'error', }; + +export const NODE_STATUS = { + DEPLOYED: 'deployed', + DEPLOYING: 'deploying', + DEPLOY_CANCELLED: 'deploy_cancelled', + DEPLOY_FAILURE: 'deploy_failure', + UNDEPLOYED: 'undeployed', + UNDEPLOYING: 'undeploying', + UNDEPLOY_CANCELLED: 'undeploy_cancelled', + UNDEPLOY_FAILURE: 'undeploy_failure', + UNKNOWN: 'unknown', +}; + export const NUTANIX_SERVICE_TYPE = 'NUTANIX'; export const NUTANIX_ORDER_URL = { @@ -44,6 +57,7 @@ export function getNutanixOrderUrl(subsidiary) { export default { CLUSTER_STATUS, + NODE_STATUS, NOT_SUBSCRIBED, SERVER_OPTIONS, NUTANIX_SERVICE_TYPE, diff --git a/packages/manager/modules/nutanix/src/dashboard/general-info/controller.js b/packages/manager/modules/nutanix/src/dashboard/general-info/controller.js index 8828c72781ba..0db9c82d1bf4 100644 --- a/packages/manager/modules/nutanix/src/dashboard/general-info/controller.js +++ b/packages/manager/modules/nutanix/src/dashboard/general-info/controller.js @@ -28,10 +28,12 @@ export default class NutanixGeneralInfoCtrl { this.REPLICATION_FACTOR_PREFIX = REPLICATION_FACTOR_PREFIX; this.NUTANIX_PERSONAL_LICENSE_EDITION = NUTANIX_PERSONAL_LICENSE_EDITION; this.GENERAL_INFO_TILE_TITLE = GENERAL_INFO_TILE_TITLE; + this.nodes = []; } $onInit() { this.loadServicesDetails(); + this.loadNodesStatus(); this.setPrivateBandwidthServiceId(); this.clusterRedeploying = this.cluster.status === CLUSTER_STATUS.DEPLOYING; this.showRedeployWarningModal = false; @@ -61,6 +63,27 @@ export default class NutanixGeneralInfoCtrl { }); } + loadNodesStatus() { + this.loadingNodeStatus = true; + return this.NutanixService.getNodeWithState(this.serviceInfo.serviceName) + .then((nodes) => { + this.nodes = nodes; + }) + .finally(() => { + this.loadingNodeStatus = false; + }); + } + + get numberNodeDeployed() { + if (this.loadingNodeStatus) return '-'; + return this.nodes.filter((node) => node.isDeployed).length; + } + + get numberNodeToDeploy() { + if (this.loadingNodeStatus) return '-'; + return this.nodes.filter((node) => !node.isDeployed).length; + } + setPrivateBandwidthServiceId() { this.privateBandwidthServiceId = this.clusterAddOns.find((addOn) => addOn.billing?.plan?.code?.startsWith(PRIVATE_BANDWIDTH_SERVICE_PREFIX), diff --git a/packages/manager/modules/nutanix/src/dashboard/general-info/template.html b/packages/manager/modules/nutanix/src/dashboard/general-info/template.html index f92bdb579c28..8c2bcaa15044 100644 --- a/packages/manager/modules/nutanix/src/dashboard/general-info/template.html +++ b/packages/manager/modules/nutanix/src/dashboard/general-info/template.html @@ -128,6 +128,53 @@ + + + +
+ {{ $ctrl.nodes.length }} + {{ "nutanix_dashboard_cluster_total_suscribed" | + translate }} +
+
+ +
+
+ +
+
+ + Gérer mes noeuds + + +
+
+ + + + + +
+ res); } + getNodeWithState(serviceName) { + return this.$http + .get(`/nutanix/${serviceName}/nodes`, { + serviceType: 'aapi', + }) + .then(({ data }) => { + data.map((node) => new Node(node)); + }); + } + getServer(nodeId) { return this.$http .get(`/sws/dedicated/server/${nodeId}`, {