|
1 | | -<?php |
2 | | - |
| 1 | +<?php /* vim: set colorcolumn=: */ |
3 | 2 | namespace BNETDocs\Templates; |
4 | | - |
5 | 3 | use \BNETDocs\Libraries\Server; |
6 | 4 | use \BNETDocs\Libraries\ServerType; |
7 | 5 | use \CarlBennett\MVC\Libraries\Common; |
8 | 6 | use \CarlBennett\MVC\Libraries\Pair; |
9 | | - |
10 | | -$title = "Servers"; |
11 | | -$description = "A list of servers that our automated system checks the status of. The status represents if the port is opened or closed, not if the service is functioning correctly."; |
12 | | -$this->opengraph->attach(new Pair("url", "/servers")); |
| 7 | +$title = 'Servers'; |
| 8 | +$description = 'A list of servers that our automated system checks the status of. The status represents if the port is opened or closed, not if the service is functioning correctly.'; |
| 9 | +$this->opengraph->attach(new Pair('url', '/servers')); |
13 | 10 |
|
14 | 11 | $servers_by_type = []; |
15 | 12 | foreach ($this->context->servers as $server) { |
16 | 13 | $servers_by_type[$server->getTypeId()][] = $server; |
17 | 14 | } |
18 | 15 | ksort($servers_by_type); |
19 | 16 |
|
20 | | -$this->additional_css[] = "/a/servers.css"; |
21 | | -require("./header.inc.phtml"); |
| 17 | +require('./header.inc.phtml'); |
22 | 18 | ?> |
23 | | - <article> |
24 | | - <header>Server List</header> |
25 | | - <section> |
26 | | - <p>Below is a list of servers that our automated system checks the status of. The status represents if the port is opened or closed, not if the service is functioning correctly.</p> |
27 | | - <p>We have a total of <strong><?php echo number_format(count($this->context->servers)); ?> servers</strong> that we monitor. <a href="<?php echo Common::relativeUrlToAbsolute("/servers.json"); ?>">Click here</a> to see this list in JSON format.</p> |
28 | | - </section> |
29 | | - <section> |
30 | | - <table class="servers"> |
31 | | - <thead> |
32 | | - <tr> |
33 | | - <th class="status">Status</th> |
34 | | - <th class="label">Label</th> |
35 | | - <th class="address">Address</th> |
36 | | - <th class="details"></th> |
37 | | - </tr> |
38 | | - </thead> |
39 | | - <tbody> |
40 | | -<?php foreach ($servers_by_type as $type_id => $servers) { |
| 19 | +<div class="container mb-3"> |
| 20 | + <h1>Server List</h1> |
| 21 | + <div class="row"><div class="col"> |
| 22 | + <p>Below is a list of servers that our automated system checks the status of. The status represents if the port is opened or closed, not if the service is functioning correctly.</p> |
| 23 | + <p>We have a total of <strong><? echo number_format(count($this->context->servers)); ?> servers</strong> that we monitor. <a href="<? echo Common::relativeUrlToAbsolute("/servers.json"); ?>">Click here</a> to see this list in JSON format.</p> |
| 24 | + </div></div> |
| 25 | + <div class="row"><div class="col"> |
| 26 | + <table class="table table-hover table-sm table-striped" id="servers_tbl"> |
| 27 | + <thead><tr><th scope="col">Status</th><th scope="col">Label</th><th scope="col">Address</th><th scope="col"></th></tr></thead><tbody> |
| 28 | +<? foreach ($servers_by_type as $type_id => $servers) |
| 29 | + { |
41 | 30 | $server_type = new ServerType($type_id); |
42 | | -?> |
43 | | - <tr><th colspan="4"><?php echo $server_type->getLabel(); ?></th></tr> |
44 | | -<?php foreach ($servers as $server) { |
| 31 | + echo '<tr><th colspan="4">' . filter_var($server_type->getLabel(), FILTER_SANITIZE_FULL_SPECIAL_CHARS) . '</th></tr>'; |
| 32 | + foreach ($servers as $server) |
| 33 | + { |
45 | 34 | $status_bitmask = $server->getStatusBitmask(); |
46 | 35 | if ($status_bitmask & Server::STATUS_ONLINE) { |
47 | | - $status_subclass = "online"; $status = "Online"; |
| 36 | + $status_subclass = 'success'; $status = 'Online'; |
48 | 37 | } else if ($status_bitmask & Server::STATUS_DISABLED) { |
49 | | - $status_subclass = "disabled"; $status = "Disabled"; |
| 38 | + $status_subclass = 'danger'; $status = 'Disabled'; |
50 | 39 | } else { |
51 | | - $status_subclass = "offline"; $status = "Offline"; |
52 | | - } |
53 | | -?> |
54 | | - <tr> |
55 | | - <td class="status center <?php echo $status_subclass; ?>"><?php echo $status; ?></td> |
56 | | - <td class="label"><?php echo ($server->getLabel() != $server->getAddress() && !empty($server->getLabel()) ? $server->getLabel() : " "); ?></td> |
57 | | - <td class="address" onclick="bnetdocs.fSelectText(this);"><?php echo $server->getAddress(); ?>:<?php echo $server->getPort(); ?></td> |
58 | | - <td class="details center"><a href="<?php echo $server->getURI(); ?>">View Details</a></td> |
59 | | - </tr> |
60 | | -<?php } ?> |
61 | | -<?php } ?> |
62 | | - </tbody> |
63 | | - </table> |
64 | | - </section> |
65 | | - </article> |
66 | | -<?php require("./footer.inc.phtml"); ?> |
| 40 | + $status_subclass = 'danger'; $status = 'Offline'; |
| 41 | + } ?> |
| 42 | + <tr> |
| 43 | + <td class="text-center"><span class="text-<?=$status_subclass?>"><?=$status?></span></td> |
| 44 | + <td><?=($server->getLabel() != $server->getAddress() && !empty($server->getLabel()) ? $server->getLabel() : ' ')?></td> |
| 45 | + <td><code><? echo $server->getAddress(); ?>:<? echo $server->getPort(); ?></code></td> |
| 46 | + <td><a class="btn btn-sm btn-primary" href="<? echo $server->getURI(); ?>" title="Details">ℹ</a></td> |
| 47 | + </tr> |
| 48 | +<? } |
| 49 | + } ?> |
| 50 | + </tbody> |
| 51 | + </table> |
| 52 | + </div></div> |
| 53 | +</div> |
| 54 | +<? ob_start(); ?> |
| 55 | + <script type="text/javascript"> |
| 56 | + $(document).ready(function(){ |
| 57 | + $('#servers_tbl').DataTable({ |
| 58 | + "language": {"zeroRecords": "No matching servers found"}, |
| 59 | + "responsive": true, |
| 60 | + }); |
| 61 | + }); |
| 62 | + </script> |
| 63 | +<? $_footer_script = ob_get_clean(); require('./footer.inc.phtml'); ?> |
0 commit comments