From aaa4ba7ccd6e28944f7d19016eb5186618a274fa Mon Sep 17 00:00:00 2001 From: William Mantly Date: Thu, 27 Aug 2020 16:01:49 -0400 Subject: [PATCH] proxmox looks nice --- nodejs/app.js | 7 +- nodejs/public/js/app.js | 2 +- nodejs/views/proxmox.ejs | 144 +++++++++++++++++++++++++++++++++++---- 3 files changed, 139 insertions(+), 14 deletions(-) diff --git a/nodejs/app.js b/nodejs/app.js index 7dd0c7b..da0185f 100755 --- a/nodejs/app.js +++ b/nodejs/app.js @@ -18,7 +18,11 @@ module.exports = app; // Build the conf object from the conf files. app.conf = require('./conf/conf'); -app.p2p = new P2PSub(app.conf.p2p); +app.p2p = new P2PSub({...app.conf.p2p, preBroadcast: function(data){ + let thisData = {...data} + delete thisData.__noSocket; + return thisData; +}}); app.onListen.push(function(){ app.p2p.subscribe(/./g, function(data, topic){ @@ -31,6 +35,7 @@ app.onListen.push(function(){ // console.log('connection io', socket) socket.on('P2PSub', (msg) => { msg.data.__noSocket = true; + console.log('connection ondata', msg) app.p2p.publish(msg.topic, msg.data); socket.broadcast.emit('P2PSub', msg) diff --git a/nodejs/public/js/app.js b/nodejs/public/js/app.js index 9c70efd..f42c9f9 100755 --- a/nodejs/public/js/app.js +++ b/nodejs/public/js/app.js @@ -52,7 +52,7 @@ app.io = (function(app){ }); app.subscribe(/./g, function(data, topic){ - console.log('local_pubs', data, topic) + // console.log('local_pubs', data, topic) if(data.__noSocket) return; // console.log('local_pubs 2', data, topic) diff --git a/nodejs/views/proxmox.ejs b/nodejs/views/proxmox.ejs index b15e1d4..acac3f9 100644 --- a/nodejs/views/proxmox.ejs +++ b/nodejs/views/proxmox.ejs @@ -5,6 +5,7 @@ var parseNodeData = function(data){ + data.siteId = data.vpnSite.id; cluster = data.data cluster.onlineCount = 0; cluster.cpu = 0 @@ -23,7 +24,9 @@ cluster.mem += node.mem } + cluster.nodePercent = Math.ceil((cluster.onlineCount*100)/data.data.node.length) cluster.cpu = parseFloat(((cluster.cpu/cluster.onlineCount)*100).toFixed(2)); + cluster.memPercent = Math.ceil((cluster.mem*100)/cluster.maxmem) cluster.maxmem = formatBytes(cluster.maxmem) cluster.mem = formatBytes(cluster.mem) @@ -33,7 +36,16 @@ return data; } + $(document).ready(function(){ + $.scope.proxmox.__put = function(obj){ + console.log(obj) + if(obj.openTab){ + $(obj.openTab).tab('show'); + } + this.show() + }; + $ app.subscribe('proxmox-cluster', function(data){ if($.scope.proxmox.indexOf('siteId', data.vpnSite.id,) == -1){ data.siteId = data.vpnSite.id; @@ -42,25 +54,133 @@ $.scope.proxmox.update('siteId', data.vpnSite.id, parseNodeData(data)); } }); + + $(document).ready(function(){ + $('div.prox-cards').on('click', 'a[data-toggle="tab"]', function(e){ + e.preventDefault(); + var id = $(this).closest('div[data-siteid]').data('siteid'); + var scopeId = $.scope.proxmox.indexOf('siteId', id+''); + var tab = '#'+$(this).attr('id'); + $.scope.proxmox[scopeId].openTab = tab; + }); + }); }); + -
-
-
- {{ vpnSite.name }} -- {{vpnSite.admin}} +
+
+
+

+ {{ vpnSite.name }} + {{vpnSite.admin}} +

+ +
- Nodes online {{data.onlineCount}} of {{data.node.length}}
- CPU: {{data.cpu}}% of {{data.maxcpu}} cores
- Ram: {{data.mem}} of {{data.maxmem}} -
    - {{#data.lxc}} -
  • {{name}} -- {{status}}
  • - {{/data.lxc}} -
+ + + + + + + + + + + + + + + + +
+ Nodes + +
+
{{data.nodePercent}}%
+
+
+ {{data.node.length}} +
+ CPU + +
+
{{data.cpu}}%
+
+
+ {{data.maxcpu}} Threads +
+ RAM + +
+
{{data.mem}} - {{data.memPercent}}%
+
+
+ of {{data.maxmem}} +
+ +
+
+ +
+
    + {{#data.node}} +
  • {{node}} -- {{status}}
  • + {{/data.node}} +
+
+
+
    + {{#data.lxc}} +
  • {{name}} -- {{status}}
  • + {{/data.lxc}} +
+
+
+
    + {{#data.qemu}} +
  • {{name}} -- {{status}}
  • + {{/data.qemu}} +
+
+
+
    + {{#data.storage}} +
  • {{id}} -- {{status}}
  • + {{/data.storage}} +
+
+