diff --git a/includes/hooks/autovm/controller.php b/includes/hooks/autovm/controller.php index 40339c7..8166550 100644 --- a/includes/hooks/autovm/controller.php +++ b/includes/hooks/autovm/controller.php @@ -240,23 +240,27 @@ public function desiredTemplates() // Find allowed templates $params = ['packageId' => $service->packageid]; - $templates = Capsule::select("SELECT a.optionname as name FROM tblproductconfigoptionssub a INNER JOIN tblproductconfigoptions b ON b.id = a.configid INNER JOIN tblproductconfiglinks c ON c.gid = b.gid WHERE b.optionname LIKE '%template%' AND c.pid = :packageId", $params); + $templates = Capsule::select("SELECT a.optionname as name FROM tblproductconfigoptionssub a INNER JOIN tblproductconfigoptions b ON b.id = a.configid INNER JOIN tblproductconfiglinks c ON c.gid = b.gid WHERE a.hidden=0 AND b.optionname LIKE '%template%' AND c.pid = :packageId", $params); // List allowed templates - $allowdTemplates = []; + $allowedTemplates = []; + $allowedTemplatesDisplayNames = []; foreach ($templates as $template) { - - $allowdTemplates[] = $template->name; + $nameParts = explode('|', $template->name); + $allowedTemplates[] = $nameParts[0]; + $allowedTemplatesDisplayNames[] = $nameParts[1] ?? $nameParts[0]; } // Remove templates foreach ($response->data as $key => $template) { - $allowed = in_array($template->name, $allowdTemplates); + $allowed = in_array($template->name, $allowedTemplates); if (!$allowed) { unset($response->data[$key]); + } else { + $response->data[$key]->display_name = $allowedTemplatesDisplayNames[array_search($template->name, $allowedTemplates)] ?? $template->name; } } @@ -300,6 +304,22 @@ public function show() // Send request $response = $this->sendShowRequest($machineId); + // Find service + $service = Service::find($this->serviceId); + + $templateName = $response->data->template->name ?? null; + + if ($service && $templateName) { + // Find template config option and retrieve the display name + $params = ['packageId' => $service->packageid, 'templateName' => $templateName.'|%']; + $template = Capsule::select("SELECT a.optionname as name FROM tblproductconfigoptionssub a INNER JOIN tblproductconfigoptions b ON b.id = a.configid INNER JOIN tblproductconfiglinks c ON c.gid = b.gid WHERE a.optionname LIKE :templateName AND b.optionname LIKE '%template%' AND c.pid = :packageId", $params); + if (is_array($template) && count($template) > 0 && isset($template[0]->name)) { + $nameParts = explode('|', $template[0]->name); + $templateDisplayName = $nameParts[1] ?? $nameParts[0]; + $response->data->template->display_name = $templateDisplayName; + } + } + $this->response($response); } diff --git a/modules/servers/product/views/view/assets/js/main.js b/modules/servers/product/views/view/assets/js/main.js index f6a6655..f0db6b9 100644 --- a/modules/servers/product/views/view/assets/js/main.js +++ b/modules/servers/product/views/view/assets/js/main.js @@ -338,6 +338,28 @@ const app = Vue.createApp({ }, + findTemplateDisplayName() { + + let cats = this.categories + + let id = this.templateId + + for (let i = 0; i < cats.length; i++) { + + let temp = cats[i].templates + + for (let j = 0; j < temp.length; j++) { + if (temp[j].id == id) { + this.tempDisplayNameSetup = temp[j].name + return temp[j].name; + } + } + } + + return 'er'; + + }, + findTemplateIcon() { let cats = this.categories @@ -562,6 +584,12 @@ const app = Vue.createApp({ return tempName }, + tempDisplayName() { + let tempDisplayName = null + tempDisplayName = this.getMachineProperty('template.display_name') + return tempDisplayName + }, + tempIcon() { let tempIcon = null; tempIcon = this.getMachineProperty('template.icon.address') @@ -2095,8 +2123,10 @@ const app = Vue.createApp({ } let templateName = templates.find(findname).name + let templateDisplayName = templates.find(findname).display_name let templateIcon = templates.find(findname).icon.address this.tempNameSetup = templateName + this.tempDisplayNameSetup = templateDisplayName this.tempIconSetup = templateIcon }, diff --git a/modules/servers/product/views/view/changeos.php b/modules/servers/product/views/view/changeos.php index 03df233..0eaf5d9 100644 --- a/modules/servers/product/views/view/changeos.php +++ b/modules/servers/product/views/view/changeos.php @@ -22,7 +22,7 @@
diff --git a/modules/servers/product/views/view/hoststatus.php b/modules/servers/product/views/view/hoststatus.php index ab69d9c..6b11147 100644 --- a/modules/servers/product/views/view/hoststatus.php +++ b/modules/servers/product/views/view/hoststatus.php @@ -1,7 +1,7 @@
-
+
{{ lang('hostname') }} diff --git a/modules/servers/product/views/view/machinedetals.php b/modules/servers/product/views/view/machinedetals.php index 3cca490..e9e3319 100644 --- a/modules/servers/product/views/view/machinedetals.php +++ b/modules/servers/product/views/view/machinedetals.php @@ -133,7 +133,10 @@ templateicon templateicon
- + + {{ tempDisplayName }} + + {{ tempName }}