diff --git a/app/Domain/Nodes/Actions/CreateNodeAction.php b/app/Domain/Nodes/Actions/CreateNodeAction.php index cf7ead5..f210f06 100644 --- a/app/Domain/Nodes/Actions/CreateNodeAction.php +++ b/app/Domain/Nodes/Actions/CreateNodeAction.php @@ -70,7 +70,14 @@ public function execute( ]); $configDB->putConfig(App::Info, $uuid, [ - "name" => $nodeName . '/' . $destinationCluster . '/' . $destinationNode, + "name" => sprintf("%s/%s (%s)", + $group->name, $nodeName, $destinationNode), + ]); + + // Register the Sparkplug address the EA should use + $configDB->putConfig(App::SparkplugAddress, $uuid, [ + "group_id" => $group->name, + "node_id" => $nodeName, ]); // Split the $charts string (comma-delimited) into an array of UUIDs @@ -78,7 +85,7 @@ public function execute( // Create an entry in the Edge Agent Deployment app to trigger the deployment of the edge agent $configDB->putConfig(App::EdgeAgentDeployment, $uuid, [ - "name" => $nodeName, + "name" => sprintf("%s.%s", $group->name, $nodeName), "charts" => $charts, "cluster" => $destinationCluster, "hostname" => $destinationNode, diff --git a/app/Domain/Nodes/Actions/DeleteNodeAction.php b/app/Domain/Nodes/Actions/DeleteNodeAction.php index 41676cd..631e58f 100644 --- a/app/Domain/Nodes/Actions/DeleteNodeAction.php +++ b/app/Domain/Nodes/Actions/DeleteNodeAction.php @@ -54,6 +54,12 @@ public function execute(Node $node) $configDB = $fplus->getConfigDB(); $configDB->deleteConfig(App::EdgeAgentDeployment, $node->uuid); + $configDB->deleteConfig(App::SparkplugAddress, $node->uuid); + + /* XXX This should be a library method to mark an object deleted */ + $info = $configDB->getConfig(App::Info, $node->uuid); + $info["deleted"] = true; + $configDB->putConfig(App::Info, $node->uuid, $info); $node->delete(); diff --git a/resources/js/components/Containers/EdgeClusterContainer.vue b/resources/js/components/Containers/EdgeClusterContainer.vue index bf972ba..ef0ebfe 100644 --- a/resources/js/components/Containers/EdgeClusterContainer.vue +++ b/resources/js/components/Containers/EdgeClusterContainer.vue @@ -24,7 +24,7 @@
-
{{item.status?.nodes.length}} Nodes +
{{item.status?.hosts?.length}} Nodes
@@ -71,7 +71,7 @@ export default { }, copyBootstrapCommand (item) { - axios.get(`/api/edge-clusters/${item.name}/bootstrap-command`).then((response) => { + axios.get(`/api/edge-clusters/${item.uuid}/bootstrap-command`).then((response) => { if (response.data.data) { this.copyToClipboard(response.data.data) window.showNotification({ @@ -93,6 +93,7 @@ export default { try { await navigator.clipboard.writeText(text) } catch (err) { + console.warn(`Failed to copy to clipboard: ${text}`); window.showNotification({ title: 'Failed to copy to clipboard.', description: err, diff --git a/resources/js/components/Nodes/NewNodeOverlay.vue b/resources/js/components/Nodes/NewNodeOverlay.vue index f2a5c6c..e1c15c8 100644 --- a/resources/js/components/Nodes/NewNodeOverlay.vue +++ b/resources/js/components/Nodes/NewNodeOverlay.vue @@ -75,18 +75,20 @@ export default { immediate: true, handler: function (val) { if (val) { - this.steps.nodeSelection.controls.destination_node.options = Object.keys(val).map((edgeCluster) => { + const control = this.steps.nodeSelection.controls.destination_node; + const params = this.steps.__request.parameters; + control.options = Object.entries(val).map(([edgeCluster, config]) => { return { title: edgeCluster, value: edgeCluster, - options: val[edgeCluster].nodes && Object.keys(val[edgeCluster].nodes)?.map(e => { + options: config.status.hosts.map(host => { return { - title: val[edgeCluster].nodes[e].hostname, - value: val[edgeCluster].nodes[e].hostname, + title: `${host.hostname} (${host.arch})`, + value: host.hostname, action: () => { - this.steps.__request.parameters.destination_cluster.data = val[edgeCluster].uuid - this.steps.__request.parameters.destination_node.data = val[edgeCluster].nodes[e].hostname - this.steps.nodeSelection.controls.destination_node.value = val[edgeCluster].nodes[e].hostname + params.destination_cluster.data = config.uuid; + params.destination_node.data = host.hostname; + control.value = host.hostname; }, } })