Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions includes/hooks/autovm/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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);
}

Expand Down
30 changes: 30 additions & 0 deletions modules/servers/product/views/view/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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

},
Expand Down
2 changes: 1 addition & 1 deletion modules/servers/product/views/view/changeos.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="py-1 pe-3 flex-grow-1" style="min-width:190px;">
<select v-model="templateId" class="form-select">
<option v-for="template in category.templates" :value="template.id">
{{ template.name }}
{{ template.display_name || template.name }}
</option>
</select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion modules/servers/product/views/view/hoststatus.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- TITLE row -->
<div class="d-flex flex-row justify-content-between align-items-center m-0 p-0 pb-5 ps-2">
<!-- Hostname -->
<div class="text-start p-0 m-0" style="max-width: 225px;">
<div class="text-start p-0 m-0" style="max-width: 420px;">
<div class="d-flex flex-row m-0 p-0">

<span class="fs-5 fw-medium m-0 p-0">{{ lang('hostname') }}</span>
Expand Down
5 changes: 4 additions & 1 deletion modules/servers/product/views/view/machinedetals.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@
<img v-if="tempIcon != null" :src="tempIcon" alt="templateicon" width="23">
<img v-if="softIcon != null" :src="softIcon" alt="templateicon" width="23">
</div>
<span v-if="tempName" class="m-0 p-0 fs-4 ms-2">
<span v-if="tempDisplayName" class="m-0 p-0 fs-4 ms-2">
{{ tempDisplayName }}
</span>
<span v-if="tempName && !tempDisplayName" class="m-0 p-0 fs-4 ms-2">
{{ tempName }}
</span>
<span v-if="softName" class="m-0 p-0 fs-4 ms-2">
Expand Down