From 73e28a8253f5c920d759ec1187009d11b7970c9a Mon Sep 17 00:00:00 2001 From: Thibault Barske Date: Sun, 5 Jan 2025 15:38:32 +0100 Subject: [PATCH] feat(nutanix): reinstall node popin ref: MANAGER-15715 Signed-off-by: Thibault Barske --- .../reinstall-node-modal/component.js | 14 ++++++ .../reinstall-node-modal/controller.js | 44 +++++++++++++++++++ .../component/reinstall-node-modal/module.js | 21 +++++++++ .../reinstall-node-modal/template.html | 30 +++++++++++++ .../translations/Messages_fr_FR.json | 15 +++++++ .../src/dashboard/nodes/list/module.js | 2 + .../nodes/list/reinstall-node/index.js | 22 ++++++++++ .../reinstall-node/reinstall-node.module.js | 24 ++++++++++ .../reinstall-node/reinstall-node.routing.js | 28 ++++++++++++ 9 files changed, 200 insertions(+) create mode 100644 packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/component.js create mode 100644 packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/controller.js create mode 100644 packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/module.js create mode 100644 packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/template.html create mode 100644 packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/translations/Messages_fr_FR.json create mode 100644 packages/manager/modules/nutanix/src/dashboard/nodes/list/reinstall-node/index.js create mode 100644 packages/manager/modules/nutanix/src/dashboard/nodes/list/reinstall-node/reinstall-node.module.js create mode 100644 packages/manager/modules/nutanix/src/dashboard/nodes/list/reinstall-node/reinstall-node.routing.js diff --git a/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/component.js b/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/component.js new file mode 100644 index 000000000000..011d8a1e8bf8 --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/component.js @@ -0,0 +1,14 @@ +import template from './template.html'; +import controller from './controller'; + +export default { + bindings: { + goBack: '<', + availableVersions: '<', + installNode: '<', + handleSuccess: '<', + handleError: '<', + }, + template, + controller, +}; diff --git a/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/controller.js b/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/controller.js new file mode 100644 index 000000000000..e242d585aee7 --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/controller.js @@ -0,0 +1,44 @@ +export default class NutanixDashboardReinstallNodeCtrl { + /* @ngInject */ + constructor(NutanixService, $translate) { + this.NutanixService = NutanixService; + this.$translate = $translate; + this.errorIpMessage = { + notValidIp: $translate.instant( + 'nutanix_dashboard_reinstall_form_not_valid_ip_error', + ), + notPrivateIp: $translate.instant( + 'nutanix_dashboard_reinstall_form_not_private_ip_error', + ), + }; + } + + onSubmit() { + if (this.reinstallNodeForm.$invalid) { + return; + } + + this.isLoading = true; + + this.installNode({ + version: this.version, + }) + .then(() => { + this.handleSuccess( + `${this.$translate.instant( + 'nutanix_dashboard_install_node_success_banner', + )}`, + ); + }) + .catch((error) => { + this.handleError( + `${this.$translate.instant( + 'nutanix_dashboard_install_node_error_banner', + )} ${error.message}`, + ); + }) + .finally(() => { + this.isLoading = false; + }); + } +} diff --git a/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/module.js b/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/module.js new file mode 100644 index 000000000000..74a217f340f2 --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/module.js @@ -0,0 +1,21 @@ +import angular from 'angular'; +import '@ovh-ux/manager-core'; +import '@uirouter/angularjs'; +import 'angular-translate'; +import '@ovh-ux/ui-kit'; + +import component from './component'; + +const moduleName = 'ovhManagerNutanixReinstallNodeModal'; + +angular + .module(moduleName, [ + 'oui', + 'ovhManagerCore', + 'pascalprecht.translate', + 'ui.router', + ]) + .component('nutanixReinstallNodeModal', component) + .run(/* @ngTranslationsInject:json ./translations */); + +export default moduleName; diff --git a/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/template.html b/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/template.html new file mode 100644 index 000000000000..a494844b8dc1 --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/template.html @@ -0,0 +1,30 @@ + +
+

+ + + +
+ + + +
+
+
diff --git a/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/translations/Messages_fr_FR.json b/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/translations/Messages_fr_FR.json new file mode 100644 index 000000000000..f8991d067f9f --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/component/reinstall-node-modal/translations/Messages_fr_FR.json @@ -0,0 +1,15 @@ +{ + "nutanix_dashboard_reinstall_node_title": "Ré-installer le noeud", + "nutanix_dashboard_reinstall_node_description": "Vous allez ré-installer AOS et AHV sur votre noeud. Indiquez des adresses IP inutilisées dans le réseau de votre cluster.", + "nutanix_dashboard_reinstall_node_tips": "Pour une ré-installation simultanée sur plusieurs noeuds, veuillez utiliser l'API", + "nutanix_dashboard_reinstall_node_label_ahv_ip": "IP du noeud", + "nutanix_dashboard_reinstall_node_label_cvm_ip": "IP CVM", + "nutanix_dashboard_reinstall_node_label_version_aos": "Version AOS", + "nutanix_dashboard_reinstall_node_confirm": "Ré-installer", + "nutanix_dashboard_reinstall_node_cancel": "Annuler", + "nutanix_dashboard_reinstall_node_success_banner": "Votre demande d'une ré-installation a été prise en compte. Cette opération peut prendre jusqu'à 1h", + "nutanix_dashboard_reinstall_node_error_banner": "Votre demande dune ré-installation n'a pas été prise en compte : ", + "nutanix_dashboard_reinstall_form_not_valid_ip_error": "Adresse IPv4 invalide", + "nutanix_dashboard_reinstall_form_not_private_ip_error": "Ce champ accepte uniquement les adresses IPv4 privées", + "nutanix_dashboard_reinstall_ip_tooltip": "L'adresse IP doit être incluse dans le sous-réseau du cluster." +} diff --git a/packages/manager/modules/nutanix/src/dashboard/nodes/list/module.js b/packages/manager/modules/nutanix/src/dashboard/nodes/list/module.js index d44b101562aa..4020a222a864 100644 --- a/packages/manager/modules/nutanix/src/dashboard/nodes/list/module.js +++ b/packages/manager/modules/nutanix/src/dashboard/nodes/list/module.js @@ -13,6 +13,7 @@ import addNodes from './add-nodes'; import poweronNode from './poweron-node'; import poweroffNode from './poweroff-node'; import installNode from './install-node'; +import reinstallNode from './reinstall-node'; import uninstallNode from './uninstall-node'; import resiliateNode from './resiliate-node'; @@ -31,6 +32,7 @@ angular poweronNode, poweroffNode, installNode, + reinstallNode, uninstallNode, resiliateNode, ]) diff --git a/packages/manager/modules/nutanix/src/dashboard/nodes/list/reinstall-node/index.js b/packages/manager/modules/nutanix/src/dashboard/nodes/list/reinstall-node/index.js new file mode 100644 index 000000000000..4a28b41a9bdf --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/nodes/list/reinstall-node/index.js @@ -0,0 +1,22 @@ +import angular from 'angular'; + +import '@uirouter/angularjs'; +import 'oclazyload'; + +const moduleName = 'ovhManagerNutanixNodeReinstallLazyLoading'; + +angular.module(moduleName, ['ui.router', 'oc.lazyLoad']).config( + /* @ngInject */ ($stateProvider) => { + $stateProvider.state('nutanix.dashboard.nodes.all.reinstall-node.**', { + url: '/reinstall/:node', + lazyLoad: ($transition$) => { + const $ocLazyLoad = $transition$.injector().get('$ocLazyLoad'); + return import('./reinstall-node.module').then((mod) => + $ocLazyLoad.inject(mod.default || mod), + ); + }, + }); + }, +); + +export default moduleName; diff --git a/packages/manager/modules/nutanix/src/dashboard/nodes/list/reinstall-node/reinstall-node.module.js b/packages/manager/modules/nutanix/src/dashboard/nodes/list/reinstall-node/reinstall-node.module.js new file mode 100644 index 000000000000..a58b308ac8ad --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/nodes/list/reinstall-node/reinstall-node.module.js @@ -0,0 +1,24 @@ +import atInternet from '@ovh-ux/ng-at-internet'; +import angular from 'angular'; +import reinstallModal from '../../../component/reinstall-node-modal/module'; + +import '@ovh-ux/ng-translate-async-loader'; +import '@uirouter/angularjs'; +import 'angular-translate'; +import '@ovh-ux/ui-kit'; + +import routing from './reinstall-node.routing'; + +const moduleName = 'ovhManagerNutanixNodeReinstall'; + +angular + .module(moduleName, [ + atInternet, + 'oui', + 'pascalprecht.translate', + 'ui.router', + reinstallModal, + ]) + .config(routing); + +export default moduleName; diff --git a/packages/manager/modules/nutanix/src/dashboard/nodes/list/reinstall-node/reinstall-node.routing.js b/packages/manager/modules/nutanix/src/dashboard/nodes/list/reinstall-node/reinstall-node.routing.js new file mode 100644 index 000000000000..c353b431c72f --- /dev/null +++ b/packages/manager/modules/nutanix/src/dashboard/nodes/list/reinstall-node/reinstall-node.routing.js @@ -0,0 +1,28 @@ +export default /* @ngInject */ ($stateProvider) => { + $stateProvider.state('nutanix.dashboard.nodes.all.reinstall-node', { + url: '/reinstall/:node', + views: { + modal: { + component: 'nutanixReinstallNodeModal', + }, + }, + layout: 'modal', + resolve: { + nodeId: /* @ngInject */ ($transition$) => $transition$.params().node, + goBack: /* @ngInject */ ($state) => () => + $state.go('nutanix.dashboard.nodes.all'), + handleSuccess: /* @ngInject */ (Alerter, goBack) => (message) => { + Alerter.success(message, 'nutanix_dashboard_alert'); + goBack(); + }, + handleError: /* @ngInject */ (Alerter, goBack) => (message) => { + Alerter.error(message, 'nutanix_dashboard_alert'); + goBack(); + }, + installNode: /* ngInject */ (NutanixService, serviceName, nodeId) => ( + params, + ) => NutanixService.installClusterNode(serviceName, nodeId, params), + availableVersions: /* ngInject */ (cluster) => cluster.availableVersions, + }, + }); +};