|
| 1 | +@extends('layouts.admin') |
| 2 | + |
| 3 | +@section('title') |
| 4 | + Managing Node: {{ $node->name }} |
| 5 | +@endsection |
| 6 | + |
| 7 | +@section('content') |
| 8 | +<div class="col-md-12"> |
| 9 | + <ul class="breadcrumb"> |
| 10 | + <li><a href="/admin">Admin Control</a></li> |
| 11 | + <li><a href="/admin/nodes">Nodes</a></li> |
| 12 | + <li class="active">{{ $node->name }}</li> |
| 13 | + </ul> |
| 14 | + <ul class="nav nav-tabs tabs_with_panel" id="config_tabs"> |
| 15 | + <li class="active"><a href="#tab_about" data-toggle="tab">About</a></li> |
| 16 | + <li><a href="#tab_settings" data-toggle="tab">Settings</a></li> |
| 17 | + <li><a href="#tab_allocation" data-toggle="tab">Allocation</a></li> |
| 18 | + <li><a href="#tab_servers" data-toggle="tab">Servers</a></li> |
| 19 | + <li><a href="#tab_delete" data-toggle="tab">Delete</a></li> |
| 20 | + </ul> |
| 21 | + <div class="tab-content"> |
| 22 | + <div class="tab-pane active" id="tab_about"> |
| 23 | + <div class="panel panel-default"> |
| 24 | + <div class="panel-heading"></div> |
| 25 | + <div class="panel-body"> |
| 26 | + About Node |
| 27 | + </div> |
| 28 | + </div> |
| 29 | + </div> |
| 30 | + <div class="tab-pane" id="tab_settings"> |
| 31 | + <div class="panel panel-default"> |
| 32 | + <div class="panel-heading"></div> |
| 33 | + <div class="panel-body"> |
| 34 | + Settings |
| 35 | + </div> |
| 36 | + </div> |
| 37 | + </div> |
| 38 | + <div class="tab-pane" id="tab_allocation"> |
| 39 | + <div class="panel panel-default"> |
| 40 | + <div class="panel-heading"></div> |
| 41 | + <div class="panel-body"> |
| 42 | + Allocations |
| 43 | + </div> |
| 44 | + </div> |
| 45 | + </div> |
| 46 | + <div class="tab-pane" id="tab_servers"> |
| 47 | + <div class="panel panel-default"> |
| 48 | + <div class="panel-heading"></div> |
| 49 | + <div class="panel-body"> |
| 50 | + <div class="alert alert-info"> |
| 51 | + The data below is updated every 30 seconds, or on page load. CPU usage is displayed relative to the assigned CPU allocation. For example, if a server is assigned <code>10%</code> and the CPU usage below displays <code>90%</code> that means the server is using <code>9%</code> of the total system CPU. |
| 52 | + </div> |
| 53 | + <table class="table table-striped" style="margin-bottom: 0;"> |
| 54 | + <thead> |
| 55 | + <tr> |
| 56 | + <th>Name</th> |
| 57 | + <th>Owner</th> |
| 58 | + <th>Service</th> |
| 59 | + <th class="text-center">Memory</th> |
| 60 | + <th class="text-center">Disk</th> |
| 61 | + <th class="text-center">CPU</th> |
| 62 | + <th class="text-center">Status</th> |
| 63 | + </tr> |
| 64 | + </thead> |
| 65 | + <tbody> |
| 66 | + @foreach($servers as $server) |
| 67 | + <tr data-server="{{ $server->uuid }}"> |
| 68 | + <td><a href="/admin/servers/view/{{ $server->id }}">{{ $server->name }}</a></td> |
| 69 | + <td><a href="/admin/users/view/{{ $server->owner }}"><code>{{ $server->a_ownerEmail }}</a></a></td> |
| 70 | + <td>{{ $server->a_serviceName }}</td> |
| 71 | + <td class="text-center"><span data-action="memory">--</span> / {{ $server->memory }} MB</td> |
| 72 | + <td class="text-center">{{ $server->disk }} MB</td> |
| 73 | + <td class="text-center"><span data-action="cpu" data-cpumax="{{ $server->cpu }}">--</span> %</td> |
| 74 | + <td class="text-center" data-action="status">--</td> |
| 75 | + </tr> |
| 76 | + @endforeach |
| 77 | + </tbody> |
| 78 | + </table> |
| 79 | + <div class="row"> |
| 80 | + <div class="col-md-12 text-center">{!! $servers->appends(['tab' => 'tab_servers'])->render() !!}</div> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + </div> |
| 84 | + </div> |
| 85 | + <div class="tab-pane" id="tab_delete"> |
| 86 | + <div class="panel panel-default"> |
| 87 | + <div class="panel-heading"></div> |
| 88 | + <div class="panel-body"> |
| 89 | + Delete |
| 90 | + </div> |
| 91 | + </div> |
| 92 | + </div> |
| 93 | + </div> |
| 94 | +</div> |
| 95 | +<script> |
| 96 | +$(document).ready(function () { |
| 97 | + $('#sidebar_links').find("a[href='/admin/nodes']").addClass('active'); |
| 98 | +
|
| 99 | + // Gets all of the server data in one go. |
| 100 | + function getServerData() { |
| 101 | + var Status = { |
| 102 | + 0: 'Off', |
| 103 | + 1: 'On', |
| 104 | + 2: 'Starting', |
| 105 | + 3: 'Stopping' |
| 106 | + }; |
| 107 | + $.ajax({ |
| 108 | + method: 'GET', |
| 109 | + url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/servers', |
| 110 | + headers: { |
| 111 | + 'X-Access-Token': '{{ $node->daemonSecret }}' |
| 112 | + } |
| 113 | + }).done(function (data) { |
| 114 | + $.each(data, function (uuid, info) { |
| 115 | + var element = $('tr[data-server="' + uuid + '"]'); |
| 116 | + element.find('[data-action="status"]').html(Status[info.status]); |
| 117 | + if (info.status !== 0) { |
| 118 | + var cpuMax = element.find('[data-action="cpu"]').data('cpumax'); |
| 119 | + var currentCpu = info.proc.cpu.total; |
| 120 | + if (cpuMax !== 0) { |
| 121 | + currentCpu = parseFloat(((info.proc.cpu.total / cpuMax) * 100).toFixed(2).toString()); |
| 122 | + } |
| 123 | + element.find('[data-action="memory"]').html(parseInt(info.proc.memory.total / (1024 * 1024))); |
| 124 | + element.find('[data-action="cpu"]').html(currentCpu); |
| 125 | + } else { |
| 126 | + element.find('[data-action="memory"]').html('--'); |
| 127 | + element.find('[data-action="cpu"]').html('--'); |
| 128 | + } |
| 129 | + }); |
| 130 | + }).fail(function (jqXHR) { |
| 131 | + console.error(jqXHR); |
| 132 | + }); |
| 133 | + } |
| 134 | + getServerData(); |
| 135 | + window.setInterval(function() { |
| 136 | + getServerData(); |
| 137 | + }, 30000); |
| 138 | +}); |
| 139 | +</script> |
| 140 | +@endsection |
0 commit comments