Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
Display IP address(es)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelien committed May 9, 2017
1 parent 93033d3 commit 80764ff
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 26 deletions.
20 changes: 10 additions & 10 deletions public/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,20 @@ function callBackCPU() {
var instance = $(this).data("instance");

if (typeof json[project][instance] === "object") {
$(this).find("td:eq(5)").
$(this).find("td:eq(6)").
html("<span title=\"" + Math.round(json[project][instance][0]) + " " + json[project][instance][1] + "\" class=\"" + (json[project][instance][2] < 50 ? "text-success" : (json[project][instance][2] < 75 ? "text-warning" : "text-danger")) + "\">" + json[project][instance][2] + "%</span>");
if (json[project][instance][3] === -1) {
$(this).find("td:eq(5)").
$(this).find("td:eq(6)").
append(" <i class=\"fa fa-angle-double-down fa-fw\" aria-hidden=\"true\"></i>");
} else if (json[project][instance][3] === 1) {
$(this).find("td:eq(5)").
$(this).find("td:eq(6)").
append(" <i class=\"fa fa-angle-double-up fa-fw\" aria-hidden=\"true\"></i>");
} else {
$(this).find("td:eq(5)").
$(this).find("td:eq(6)").
append(" <i class=\"fa fa-circle-thin fa-fw\" aria-hidden=\"true\" style=\"visibility: hidden;\"></i>");
}
} else {
$(this).find("td:eq(5)").
$(this).find("td:eq(6)").
html("<span class=\"text-muted\">N/A</span><a href=\"#console-" + consoleId + "\"><sup>" + consoleId + "</sup></a>");

$("#console > ol").append("<li id=\"console-" + consoleId + "\"><samp>" + json[project][instance] + "</samp></li>");
Expand All @@ -135,20 +135,20 @@ function callBackRAM() {
var instance = $(this).data("instance");

if (typeof json[project][instance] === "object") {
$(this).find("td:eq(8)").
$(this).find("td:eq(9)").
html("<span title=\"" + Math.round(json[project][instance][0]) + " " + json[project][instance][1] + "\" class=\"" + (json[project][instance][2] < 50 ? "text-success" : (json[project][instance][2] < 75 ? "text-warning" : "text-danger")) + "\">" + json[project][instance][2] + "%</span>");
if (json[project][instance][3] === -1) {
$(this).find("td:eq(8)").
$(this).find("td:eq(9)").
append(" <i class=\"fa fa-angle-double-down fa-fw\" aria-hidden=\"true\"></i>");
} else if (json[project][instance][3] === 1) {
$(this).find("td:eq(8)").
$(this).find("td:eq(9)").
append(" <i class=\"fa fa-angle-double-up fa-fw\" aria-hidden=\"true\"></i>");
} else {
$(this).find("td:eq(8)").
$(this).find("td:eq(9)").
append(" <i class=\"fa fa-circle-thin fa-fw\" aria-hidden=\"true\" style=\"visibility: hidden;\"></i>");
}
} else {
$(this).find("td:eq(8)").
$(this).find("td:eq(9)").
html("<span class=\"text-muted\">N/A</span><a href=\"#console-" + consoleId + "\"><sup>" + consoleId + "</sup></a>");

$("#console > ol").append("<li id=\"console-" + consoleId + "\"><samp>" + json[project][instance] + "</samp></li>");
Expand Down
13 changes: 10 additions & 3 deletions public/cloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@
<table class="table table-bordered table-striped table-sm mt-3">
<thead class="thead-inverse">
<tr>
<th colspan="11">
<th colspan="12">
Instance
<a id="refresh" href="cloud.php?nocache" class="float-right"><i class="fa fa-refresh" aria-hidden="true"></i> Refresh</a>
</th>
<th colspan="5">Volume(s)</th>
</tr>
<tr>
<th></th>
<th>IP</th>
<th>Region</th>
<th>Flavor</th>
<th>Image</th>
Expand All @@ -106,6 +107,13 @@
?>
<tr data-project="<?= $p->project_id ?>" data-instance="<?= $i->id ?>" class="<?= ($index % 2 === 0 ? 'even' : 'odd') ?>">
<th <?= (count($instance_volumes) > 1 ? 'rowspan="'.count($instance_volumes).'"' : '') ?>"><?= $i->name ?><br><small><?= $i->id ?></small></th>
<td <?= (count($instance_volumes) > 1 ? 'rowspan="'.count($instance_volumes).'"' : '') ?>">
<ul class="list-unstyled mb-0">
<?php foreach ($i->ipAddresses as $ip) { ?>
<li><?= $ip->ip ?></li>
<?php } ?>
</ul>
</td>
<td <?= (count($instance_volumes) > 1 ? 'rowspan="'.count($instance_volumes).'"' : '') ?>"><?= $i->region ?></td>
<td <?= (count($instance_volumes) > 1 ? 'rowspan="'.count($instance_volumes).'"' : '') ?>"><?= $i->flavor->type ?> - <?= $i->flavor->name ?> (<?= $i->flavor->osType ?>)</td>
<td <?= (count($instance_volumes) > 1 ? 'rowspan="'.count($instance_volumes).'"' : '') ?>"><?= (isset($i->image) ? $i->image->name : '<span class="text-muted">N/A</span>') ?></td>
Expand Down Expand Up @@ -145,11 +153,10 @@
</tbody>
<tfoot>
<tr>
<td colspan="16" class="text-right small text-muted"><?= _('Last update') ?> : <?= date('d.m.Y H:i', filemtime($cache)) ?></td>
<td colspan="17" class="text-right small text-muted"><?= _('Last update') ?> : <?= date('d.m.Y H:i', filemtime($cache)) ?></td>
</tr>
</tfoot>
</table>
<hr>
<?php
}
?>
Expand Down
24 changes: 12 additions & 12 deletions public/vps.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ function callBackDisk() {

if (disks.length === 1) {
if (typeof disks[0] === "object") {
$(this).find("td:eq(5)").
$(this).find("td:eq(6)").
html("<span title=\"" + Math.round(disks[0][0]) + " " + disks[0][1] + "\" class=\"" + (disks[0][2] < 50 ? "text-success" : (disks[0][2] < 75 ? "text-warning" : "text-danger")) + "\">" + disks[0][2] + "%</span>")
} else {
$(this).find("td:eq(5)").
$(this).find("td:eq(6)").
html("<span class=\"text-muted\">N/A</span><a href=\"#console-" + consoleId + "\"><sup>" + consoleId + "</sup></a>");

$("#console > ol").append("<li id=\"console-" + consoleId + "\"><samp>" + disks[0] + "</samp></li>");
Expand All @@ -172,20 +172,20 @@ function callBackCPU() {
var name = $(this).data("vps");

if (typeof json[name] === "object") {
$(this).find("td:eq(8)").
$(this).find("td:eq(9)").
html("<span title=\"" + Math.round(json[name][0]) + " " + json[name][1] + "\" class=\"" + (json[name][2] < 50 ? "text-success" : (json[name][2] < 75 ? "text-warning" : "text-danger")) + "\">" + json[name][2] + "%</span>");
if (json[name][3] === -1) {
$(this).find("td:eq(8)").
$(this).find("td:eq(9)").
append(" <i class=\"fa fa-angle-double-down fa-fw\" aria-hidden=\"true\"></i>");
} else if (json[name][3] === 1) {
$(this).find("td:eq(8)").
$(this).find("td:eq(9)").
append(" <i class=\"fa fa-angle-double-up fa-fw\" aria-hidden=\"true\"></i>");
} else {
$(this).find("td:eq(8)").
$(this).find("td:eq(9)").
append(" <i class=\"fa fa-circle-thin fa-fw\" aria-hidden=\"true\" style=\"visibility: hidden;\"></i>");
}
} else {
$(this).find("td:eq(8)").
$(this).find("td:eq(9)").
html("<span class=\"text-muted\">N/A</span><a href=\"#console-" + consoleId + "\"><sup>" + consoleId + "</sup></a>");

$("#console > ol").append("<li id=\"console-" + consoleId + "\"><samp>" + json[name] + "</samp></li>");
Expand All @@ -207,20 +207,20 @@ function callBackRAM() {
var name = $(this).data("vps");

if (typeof json[name] === "object") {
$(this).find("td:eq(11)").
$(this).find("td:eq(12)").
html("<span title=\"" + Math.round(json[name][0]) + " " + json[name][1] + "\" class=\"" + (json[name][2] < 25 ? "text-success" : (json[name][2] < 75 ? "text-warning" : "text-danger")) + "\">" + json[name][2] + "%</span>");
if (json[name][3] === -1) {
$(this).find("td:eq(11)").
$(this).find("td:eq(12)").
append(" <i class=\"fa fa-angle-double-down fa-fw\" aria-hidden=\"true\"></i>");
} else if (json[name][3] === 1) {
$(this).find("td:eq(11)").
$(this).find("td:eq(12)").
append(" <i class=\"fa fa-angle-double-up fa-fw\" aria-hidden=\"true\"></i>");
} else {
$(this).find("td:eq(11)").
$(this).find("td:eq(12)").
append(" <i class=\"fa fa-circle-thin fa-fw\" aria-hidden=\"true\" style=\"visibility: hidden;\"></i>");
}
} else {
$(this).find("td:eq(11)").
$(this).find("td:eq(12)").
html("<span class=\"text-muted\">N/A</span><a href=\"#console-" + consoleId + "\"><sup>" + consoleId + "</sup></a>");

$("#console > ol").append("<li id=\"console-" + consoleId + "\"><samp>" + json[name] + "</samp></li>");
Expand Down
11 changes: 10 additions & 1 deletion public/vps.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
foreach ($vps as $v) {
$_v = $ovh->get('/vps/'.$v);
$_v['distribution'] = $ovh->get('/vps/'.$v.'/distribution');
$_v['ipAddresses'] = $ovh->get('/vps/'.$v.'/ips');

$json[] = $_v;
}
Expand Down Expand Up @@ -49,6 +50,7 @@
VPS
<a id="refresh" href="vps.php?nocache" class="float-right"><i class="fa fa-refresh" aria-hidden="true"></i> Refresh</a>
</th>
<th>IP</th>
<th>Zone</th>
<th>Offer</th>
<th colspan="2">OS</th>
Expand All @@ -65,6 +67,13 @@
?>
<tr data-vps="<?= $v->name ?>">
<th class="text-nowrap"><?= $v->name ?><br><small><?= $v->displayName ?></small></th>
<td>
<ul class="list-unstyled mb-0">
<?php foreach ($v->ipAddresses as $ip) { ?>
<li><?= $ip ?></li>
<?php } ?>
</ul>
</td>
<td style="text-nowrap"><?= $v->zone ?></td>
<td class="text-nowrap"><?= $v->model->offer ?><br><em class="small"><?= $v->model->version ?> - <?= $v->model->name ?></em></td>
<td style="vertical-align: middle;"><?= $v->distribution->name ?></td>
Expand Down Expand Up @@ -94,7 +103,7 @@
</tbody>
<tfoot>
<tr>
<td colspan="15" class="text-right small text-muted"><?= _('Last update') ?> : <?= date('d.m.Y H:i', filemtime($cache)) ?></td>
<td colspan="16" class="text-right small text-muted"><?= _('Last update') ?> : <?= date('d.m.Y H:i', filemtime($cache)) ?></td>
</tr>
</tfoot>
</table>
Expand Down

0 comments on commit 80764ff

Please sign in to comment.