support fractional cpu and memory in calc and set better defaults
This commit is contained in:
parent
c0c27cd056
commit
83504f6b7c
2 changed files with 38 additions and 34 deletions
|
@ -474,10 +474,12 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
|
||||
// Set slider maximums with some padding
|
||||
if (maxCpus > 0) {
|
||||
this.cpuRange.min = "0.25";
|
||||
this.cpuRange.max = Math.ceil(maxCpus);
|
||||
}
|
||||
|
||||
if (maxMemory > 0) {
|
||||
this.memoryRange.min = "0.25";
|
||||
this.memoryRange.max = Math.ceil(maxMemory);
|
||||
}
|
||||
|
||||
|
@ -511,10 +513,10 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
|
||||
// Sort plans by vCPU, then by RAM
|
||||
availablePlans.sort((a, b) => {
|
||||
if (parseInt(a.vcpus) !== parseInt(b.vcpus)) {
|
||||
return parseInt(a.vcpus) - parseInt(b.vcpus);
|
||||
if (parseFloat(a.vcpus) !== parseFloat(b.vcpus)) {
|
||||
return parseFloat(a.vcpus) - parseFloat(b.vcpus);
|
||||
}
|
||||
return parseInt(a.ram) - parseInt(b.ram);
|
||||
return parseFloat(a.ram) - parseFloat(b.ram);
|
||||
});
|
||||
|
||||
// Add plans to dropdown
|
||||
|
@ -599,8 +601,8 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
updateAddonPrices() {
|
||||
if (!this.addonsContainer) return;
|
||||
|
||||
const cpus = parseInt(this.cpuRange?.value || 2);
|
||||
const memory = parseInt(this.memoryRange?.value || 4);
|
||||
const cpus = parseFloat(this.cpuRange?.value || 0.5);
|
||||
const memory = parseFloat(this.memoryRange?.value || 1);
|
||||
const storage = parseInt(this.storageRange?.value || 20);
|
||||
const instances = parseInt(this.instancesRange?.value || 1);
|
||||
|
||||
|
@ -638,8 +640,8 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
|
||||
// Get current plan based on configuration
|
||||
getCurrentPlan() {
|
||||
const cpus = parseInt(this.cpuRange?.value || 2);
|
||||
const memory = parseInt(this.memoryRange?.value || 4);
|
||||
const cpus = parseFloat(this.cpuRange?.value || 0.5);
|
||||
const memory = parseFloat(this.memoryRange?.value || 1);
|
||||
const serviceLevel = document.querySelector('input[name="serviceLevel"]:checked')?.value;
|
||||
|
||||
if (this.planSelect?.value) {
|
||||
|
@ -662,8 +664,8 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
|
||||
if (group[serviceLevel]) {
|
||||
group[serviceLevel].forEach(plan => {
|
||||
const planCpus = parseInt(plan.vcpus);
|
||||
const planMemory = parseInt(plan.ram);
|
||||
const planCpus = parseFloat(plan.vcpus);
|
||||
const planMemory = parseFloat(plan.ram);
|
||||
|
||||
// Check if plan meets minimum requirements
|
||||
if (planCpus >= cpus && planMemory >= memory) {
|
||||
|
@ -708,8 +710,8 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
|
||||
// Reset plan selection if in auto-select mode
|
||||
if (!this.planSelect?.value) {
|
||||
const cpus = parseInt(this.cpuRange.value);
|
||||
const memory = parseInt(this.memoryRange.value);
|
||||
const cpus = parseFloat(this.cpuRange.value);
|
||||
const memory = parseFloat(this.memoryRange.value);
|
||||
const storage = parseInt(this.storageRange.value);
|
||||
const instances = parseInt(this.instancesRange.value);
|
||||
const serviceLevel = document.querySelector('input[name="serviceLevel"]:checked')?.value;
|
||||
|
@ -958,16 +960,16 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
|
||||
// Reset sliders to their default values
|
||||
resetSlidersToDefaults() {
|
||||
// Reset CPU slider to default value (2)
|
||||
// Reset CPU slider to default value (0.5 vCPUs)
|
||||
if (this.cpuRange) {
|
||||
this.cpuRange.value = '2';
|
||||
if (this.cpuValue) this.cpuValue.textContent = '2';
|
||||
this.cpuRange.value = '0.5';
|
||||
if (this.cpuValue) this.cpuValue.textContent = '0.5';
|
||||
}
|
||||
|
||||
// Reset Memory slider to default value (4 GB)
|
||||
// Reset Memory slider to default value (1 GB)
|
||||
if (this.memoryRange) {
|
||||
this.memoryRange.value = '4';
|
||||
if (this.memoryValue) this.memoryValue.textContent = '4';
|
||||
this.memoryRange.value = '1';
|
||||
if (this.memoryValue) this.memoryValue.textContent = '1';
|
||||
}
|
||||
|
||||
// Reset Storage slider to default value (20 GB)
|
||||
|
@ -1345,10 +1347,12 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
|
||||
// Set slider maximums with some padding
|
||||
if (maxCpus > 0) {
|
||||
this.cpuRange.min = "0.25";
|
||||
this.cpuRange.max = Math.ceil(maxCpus);
|
||||
}
|
||||
|
||||
if (maxMemory > 0) {
|
||||
this.memoryRange.min = "0.25";
|
||||
this.memoryRange.max = Math.ceil(maxMemory);
|
||||
}
|
||||
|
||||
|
@ -1382,10 +1386,10 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
|
||||
// Sort plans by vCPU, then by RAM
|
||||
availablePlans.sort((a, b) => {
|
||||
if (parseInt(a.vcpus) !== parseInt(b.vcpus)) {
|
||||
return parseInt(a.vcpus) - parseInt(b.vcpus);
|
||||
if (parseFloat(a.vcpus) !== parseFloat(b.vcpus)) {
|
||||
return parseFloat(a.vcpus) - parseFloat(b.vcpus);
|
||||
}
|
||||
return parseInt(a.ram) - parseInt(b.ram);
|
||||
return parseFloat(a.ram) - parseFloat(b.ram);
|
||||
});
|
||||
|
||||
// Add plans to dropdown
|
||||
|
@ -1470,8 +1474,8 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
updateAddonPrices() {
|
||||
if (!this.addonsContainer) return;
|
||||
|
||||
const cpus = parseInt(this.cpuRange?.value || 2);
|
||||
const memory = parseInt(this.memoryRange?.value || 4);
|
||||
const cpus = parseFloat(this.cpuRange?.value || 0.5);
|
||||
const memory = parseFloat(this.memoryRange?.value || 1);
|
||||
const storage = parseInt(this.storageRange?.value || 20);
|
||||
const instances = parseInt(this.instancesRange?.value || 1);
|
||||
|
||||
|
@ -1509,8 +1513,8 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
|
||||
// Get current plan based on configuration
|
||||
getCurrentPlan() {
|
||||
const cpus = parseInt(this.cpuRange?.value || 2);
|
||||
const memory = parseInt(this.memoryRange?.value || 4);
|
||||
const cpus = parseFloat(this.cpuRange?.value || 0.5);
|
||||
const memory = parseFloat(this.memoryRange?.value || 1);
|
||||
const serviceLevel = document.querySelector('input[name="serviceLevel"]:checked')?.value;
|
||||
|
||||
if (this.planSelect?.value) {
|
||||
|
@ -1533,8 +1537,8 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
|
||||
if (group[serviceLevel]) {
|
||||
group[serviceLevel].forEach(plan => {
|
||||
const planCpus = parseInt(plan.vcpus);
|
||||
const planMemory = parseInt(plan.ram);
|
||||
const planCpus = parseFloat(plan.vcpus);
|
||||
const planMemory = parseFloat(plan.ram);
|
||||
|
||||
// Check if plan meets minimum requirements
|
||||
if (planCpus >= cpus && planMemory >= memory) {
|
||||
|
@ -1579,8 +1583,8 @@ Please contact me with next steps for ordering this configuration.`;
|
|||
|
||||
// Reset plan selection if in auto-select mode
|
||||
if (!this.planSelect?.value) {
|
||||
const cpus = parseInt(this.cpuRange.value);
|
||||
const memory = parseInt(this.memoryRange.value);
|
||||
const cpus = parseFloat(this.cpuRange.value);
|
||||
const memory = parseFloat(this.memoryRange.value);
|
||||
const storage = parseInt(this.storageRange.value);
|
||||
const instances = parseInt(this.instancesRange.value);
|
||||
const serviceLevel = document.querySelector('input[name="serviceLevel"]:checked')?.value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue