-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
const eggSelect = document.getElementById('egg'); | ||
const nodeSelect = document.getElementById('node'); | ||
const planDetailsDiv = document.getElementById('plan-details'); | ||
|
||
eggSelect.addEventListener('change', updatePlans); | ||
nodeSelect.addEventListener('change', updatePlans); | ||
|
||
function updatePlans() { | ||
const selectedEgg = eggSelect.value; | ||
const selectedNode = nodeSelect.value; | ||
|
||
if (selectedEgg && selectedNode) { | ||
fetch(`/api/plans?egg=${selectedEgg}&node=${selectedNode}`) | ||
.then(response => response.json()) | ||
.then(plans => { | ||
// Clear existing plan details | ||
planDetailsDiv.innerHTML = ''; | ||
// Populate new plan details | ||
plans.forEach(plan => { | ||
const planDiv = document.createElement('div'); | ||
planDiv.classList.add('p-4', 'bg-slate-600', 'rounded-md', 'text-center'); | ||
planDiv.innerHTML = ` | ||
<h1 class="text-lg text-white">${plan.name}</h1> | ||
<ul class="text-base text-white"> | ||
<li><i class="fa-solid fa-microchip"></i> CPU: ${plan.cpu} %</li> | ||
<li><i class="fa-solid fa-memory"></i> RAM: ${plan.ram} MB</li> | ||
<li><i class="fa-solid fa-hdd"></i> Disk: ${plan.disk} MB</li> | ||
<li><i class="fa-solid fa-wifi"></i> Ports: ${plan.allocations}</li> | ||
<li><i class="fa-solid fa-clock"></i> Databases: ${plan.databases}</li> | ||
<li><i class="fa-solid fa-arrow-up"></i> Backups: ${plan.backups}</li> | ||
<li><i class="fa-solid fa-money-bill"></i> ${plan.price}/mo</li> | ||
</ul>`; | ||
planDetailsDiv.appendChild(planDiv); | ||
}); | ||
}) | ||
.catch(error => console.error('Error fetching plans:', error)); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% extends "modals/modal.html" %} | ||
|
||
|
||
{% block content %} | ||
<form class="grid grid-cols-2 gap-4 p-5" action="/auth/login" method="post"> | ||
<div class="flex flex-col gap-2 col-span-1"> | ||
<label for="servername" class="text-white mr-2">Server name</label> | ||
<input type="text" class="rounded-md h-10 pl-2 bg-slate-700 border-2 border-slate-400 text-white" placeholder="Server name" id="servername" name="servername" required> | ||
</div> | ||
<div class="flex flex-col gap-2 col-span-1"> | ||
<label for="egg" class="text-white mr-2">Egg</label> | ||
<select class="text-white bg-slate-700 border-2 border-slate-400 rounded-md h-10" id="egg" name="egg" required> | ||
<option value="" disabled selected>Select an egg</option> | ||
{% for nest in nests %} | ||
<optgroup label="{{ nest.name }}"> | ||
{% for egg in eggs %} | ||
{% if egg.nestId == nest.id %} | ||
<option value="{{ egg.id }}">{{ egg.name }}</option> | ||
{% endif %} | ||
{% endfor %} | ||
</optgroup> | ||
{% endfor %} | ||
</select> | ||
</div> | ||
<div class="flex flex-col gap-2 col-span-2"> | ||
<label for="node" class="text-white mr-2">Node</label> | ||
<select class="text-white bg-slate-700 border-2 border-slate-400 rounded-md h-10" id="node" name="node" required> | ||
<option value="" disabled selected>Select a node</option> | ||
{% for node in nodes %} | ||
<option value="{{ node.id }}">{{ node.name }}</option> | ||
{% endfor %} | ||
</select> | ||
</div> | ||
<div id="plan-details" class="grid grid-cols-3 gap-2 col-span-2 text-white"> | ||
</div> | ||
<button class="bg-slate-800 hover:bg-slate-600 duration-300 text-white font-bold rounded-md h-10 w-40 mt-5" type="submit">Create a server</button> | ||
</form> | ||
|
||
|
||
|
||
<script src="/js/fetchPlans.js"></script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters