simple proxmox
This commit is contained in:
114
nodejs/views/proxmox.ejs
Normal file
114
nodejs/views/proxmox.ejs
Normal file
@@ -0,0 +1,114 @@
|
||||
<%- include('top') %>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
var proxmoxSites = {};
|
||||
|
||||
function formatBytes(a,b=2){if(0===a)return"0 Bytes";const c=0>b?0:b,d=Math.floor(Math.log(a)/Math.log(1024));return parseFloat((a/Math.pow(1024,d)).toFixed(c))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][d]}
|
||||
|
||||
|
||||
var parseNodeData = function(data){
|
||||
cluster = data.data
|
||||
cluster.onlineCount = 0;
|
||||
cluster.cpu = 0
|
||||
cluster.maxcpu = 0
|
||||
cluster.maxmem = 0
|
||||
cluster.mem = 0
|
||||
|
||||
|
||||
for(let node of data.data.node){
|
||||
// console.log('parse', node)
|
||||
if(node.status === "offline") continue;
|
||||
cluster.onlineCount++
|
||||
cluster.cpu += node.cpu
|
||||
cluster.maxcpu += node.maxcpu
|
||||
cluster.maxmem += node.maxmem
|
||||
cluster.mem += node.mem
|
||||
}
|
||||
|
||||
cluster.cpu = parseFloat(((cluster.cpu/cluster.onlineCount)*100).toFixed(2));
|
||||
cluster.maxmem = formatBytes(cluster.maxmem)
|
||||
cluster.mem = formatBytes(cluster.mem)
|
||||
|
||||
|
||||
$.extend(data.data, cluster);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
app.subscribe('proxmox-cluster', function(data){
|
||||
if(!proxmoxSites[data.vpnSite.name]){
|
||||
let index = $.scope.proxmox.push(parseNodeData(data));
|
||||
proxmoxSites[data.vpnSite.name] = {
|
||||
data:data,
|
||||
index: index
|
||||
}
|
||||
}else{
|
||||
|
||||
$.scope.proxmox.update(proxmoxSites[data.vpnSite.name].index, parseNodeData(data));
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
<div class="shadow-lg card mb-3" jq-repeat="proxmox">
|
||||
<div class="card-header">
|
||||
{{ vpnSite.name }}
|
||||
</div>
|
||||
<div class="card-header actionMessage" style="display:none">
|
||||
</div>
|
||||
<div class="card-body">
|
||||
Nodes online {{data.onlineCount}} of {{data.node.length}} <br />
|
||||
CPU: {{data.cpu}}% of {{data.maxcpu}} cores <br />
|
||||
Ram: {{data.mem}} of {{data.maxmem}}
|
||||
<ul>
|
||||
{{#data.lxc}}
|
||||
<li>{{name}} -- {{status}}</li>
|
||||
{{/data.lxc}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- <div id="email_card" class="card-deck">
|
||||
<div class="shadow-lg card mb-3">
|
||||
<div class="card-header">
|
||||
Validate Email
|
||||
</div>
|
||||
<div class="card-header actionMessage" style="display:none">
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>
|
||||
Invited By: <b></b>,.
|
||||
</p>
|
||||
<p>
|
||||
Please enter a valid email address. A link will be sent to
|
||||
the supplied address to complete the registration process.
|
||||
</p>
|
||||
<p>
|
||||
The supplied email will also be used as the linked email for
|
||||
the new user.
|
||||
</p>
|
||||
<form action="auth/invite/" onsubmit="formAJAX(this)" evalAJAX="emailSent()">
|
||||
<div class="form-group">
|
||||
<label class="control-label">Email</label>
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text" ><i class="fad fa-at"></i></span>
|
||||
</div>
|
||||
<input type="email" name="mail" class="form-control" placeholder="jsmith@gmail.com" validate="email:3" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-outline-dark"><i class="fad fa-paper-plane"></i> Send It!</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<%- include('bottom') %>
|
||||
Reference in New Issue
Block a user