Show Offline routers in the dashboard

This commit is contained in:
Ibnu Maksum 2024-08-28 14:18:19 +07:00
parent 7963c2f388
commit 11ec4185e7
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
3 changed files with 76 additions and 45 deletions

View File

@ -209,6 +209,12 @@ if (file_exists($cacheMSfile) && time() - filemtime($cacheMSfile) < 43200) {
file_put_contents($cacheMSfile, json_encode($monthlySales));
}
if ($config['router_check']) {
$routeroffs = ORM::for_table('tbl_routers')->selects(['id', 'name', 'last_seen'])->where('status', 'Offline')->order_by_desc('name')->find_array();
print_r($routeroffs);
$ui->assign('routeroffs', $routeroffs);
}
// Assign the monthly sales data to Smarty
$ui->assign('start_date', $start_date);
$ui->assign('current_date', $current_date);

View File

@ -175,6 +175,25 @@
<div class="col-md-5">
{if $_c['router_check']}
<div class="panel panel-danger">
<div class="panel-heading text-bold">{Lang::T('Routers Offline')}</div>
<div class="table-responsive">
<table class="table table-condensed">
<tbody>
{foreach $routeroffs as $ros}
<tr>
<td><a href="{$_url}routers/edit/{$ros['id']}" class="text-bold text-red">{$ros['name']}</a></td>
<td data-toggle="tooltip" data-placement="top" class="text-red"
title="{Lang::dateTimeFormat($ros['last_seen'])}">{Lang::timeElapsed($ros['last_seen'])}
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
</div>
{/if}
{if $_c['hide_pg'] != 'yes'}
<div class="panel panel-success panel-hovered mb20 activities">
<div class="panel-heading">{Lang::T('Payment Gateway')}: {str_replace(',',', ',$_c['payment_gateway'])}
@ -337,7 +356,7 @@
//lets calculate the inactive users as reported
var expired = u_all - u_act;
var inactive = c_all - u_all;
if(inactive < 0){
if (inactive < 0) {
inactive = 0;
}
// Create the chart data

View File

@ -5,10 +5,10 @@
<div class="col-sm-12">
<div class="panel panel-hovered mb20 panel-primary">
<div class="panel-heading">{Lang::T('Routers')}
<div class="btn-group pull-right">
<a class="btn btn-primary btn-xs" title="save" href="{$_url}routers/maps">
<span class="glyphicon glyphicon-map-marker"></span></a>
</div>
<div class="btn-group pull-right">
<a class="btn btn-primary btn-xs" title="save" href="{$_url}routers/maps">
<span class="glyphicon glyphicon-map-marker"></span></a>
</div>
</div>
<div class="panel-body">
<div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px">
@ -28,8 +28,8 @@
</form>
</div>
<div class="col-md-4">
<a href="{$_url}routers/add" class="btn btn-primary btn-block"><i
class="ion ion-android-add"> </i> {Lang::T('New Router')}</a>
<a href="{$_url}routers/add" class="btn btn-primary btn-block"><i class="ion ion-android-add">
</i> {Lang::T('New Router')}</a>
</div>&nbsp;
</div>
<div class="table-responsive">
@ -40,10 +40,10 @@
<th>{Lang::T('IP Address')}</th>
<th>{Lang::T('Username')}</th>
<th>{Lang::T('Description')}</th>
{if $config['router_check']}
{if $_c['router_check']}
<th>{Lang::T('Online Status')}</th>
<th>{Lang::T('Last Seen')}</th>
{/if}
<th>{Lang::T('Last Seen')}</th>
<th>{Lang::T('Status')}</th>
<th>{Lang::T('Manage')}</th>
<th>ID</th>
@ -51,48 +51,54 @@
</thead>
<tbody>
{foreach $d as $ds}
<tr {if $ds['enabled'] !=1}class="danger" title="disabled" {/if}>
<td>
{if $ds['coordinates']}
<a href="https://www.google.com/maps/dir//{$ds['coordinates']}/" target="_blank"
class="btn btn-default btn-xs" title="{$ds['coordinates']}"><i
class="glyphicon glyphicon-map-marker"></i></a>
{/if}
{$ds['name']}
</td>
<td style="background-color: black; color: black;"
onmouseleave="this.style.backgroundColor = 'black';"
onmouseenter="this.style.backgroundColor = 'white';">{$ds['ip_address']}</td>
<td style="background-color: black; color: black;"
onmouseleave="this.style.backgroundColor = 'black';"
onmouseenter="this.style.backgroundColor = 'white';">{$ds['username']}</td>
<td>{$ds['description']}</td>
{if $config['router_check']}
<td><span
class="label {if $ds['status'] == 'Online'}label-success {else}label-danger {/if}">{if
$ds['status'] == 'Online'}{Lang::T('Online')}{else}{Lang::T('Offline')}{/if}</span>
<tr {if $ds['enabled'] !=1}class="danger" title="disabled" {/if}>
<td>
{if $ds['coordinates']}
<a href="https://www.google.com/maps/dir//{$ds['coordinates']}/" target="_blank"
class="btn btn-default btn-xs" title="{$ds['coordinates']}"><i
class="glyphicon glyphicon-map-marker"></i></a>
{/if}
{$ds['name']}
</td>
{/if}
<td>{$ds['last_seen']}</td>
<td>{if $ds['enabled'] == 1}{Lang::T('Enabled')}{else}{Lang::T('Disabled')}{/if}</td>
<td>
<a href="{$_url}routers/edit/{$ds['id']}"
class="btn btn-info btn-xs">{Lang::T('Edit')}</a>
<a href="{$_url}routers/delete/{$ds['id']}" id="{$ds['id']}"
onclick="return confirm('{Lang::T('Delete')}?')"
class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>
</td>
<td>{$ds['id']}</td>
</tr>
<td style="background-color: black; color: black;"
onmouseleave="this.style.backgroundColor = 'black';"
onmouseenter="this.style.backgroundColor = 'white';">{$ds['ip_address']}</td>
<td style="background-color: black; color: black;"
onmouseleave="this.style.backgroundColor = 'black';"
onmouseenter="this.style.backgroundColor = 'white';">{$ds['username']}</td>
<td>{$ds['description']}</td>
{if $_c['router_check']}
<td>
<span
class="label {if $ds['status'] == 'Online'}label-success {else}label-danger {/if}">
{if $ds['status'] == 'Online'}
{Lang::T('Online')}
{else}
{Lang::T('Offline')}
{/if}
</span>
</td>
<td>{$ds['last_seen']}</td>
{/if}
<td>{if $ds['enabled'] == 1}{Lang::T('Enabled')}{else}{Lang::T('Disabled')}{/if}</td>
<td>
<a href="{$_url}routers/edit/{$ds['id']}"
class="btn btn-info btn-xs">{Lang::T('Edit')}</a>
<a href="{$_url}routers/delete/{$ds['id']}" id="{$ds['id']}"
onclick="return confirm('{Lang::T('Delete')}?')"
class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>
</td>
<td>{$ds['id']}</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
{include file="pagination.tpl"}
<div class="bs-callout bs-callout-info" id="callout-navbar-role">
<h4>{Lang::T('Check if Mikrotik Online?')}</h4>
<p>{Lang::T('To check if Mikrotik is Online or not, go to Settings, set Router Check Enabled')}</p>
</div>
<h4>{Lang::T('Check if Mikrotik Online?')}</h4>
<p>{Lang::T('To check if Mikrotik is Online or not, go to Settings, set Router Check Enabled')}</p>
</div>
</div>
</div>
</div>