Skip to content

Commit

Permalink
cleaning up the server status views
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Nov 20, 2012
1 parent 34f8895 commit 2cfed82
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 107 deletions.
56 changes: 32 additions & 24 deletions Core/ServerStatus/Lib/ServerStatusEvents.php
@@ -1,36 +1,44 @@
<?php
class ServerStatusEvents extends AppEvents {
public function onAdminMenu(Event $Event) {
$menu['main']['Dashboard'] = array('controller' => 'server_status', 'action' => 'dashboard');
switch($Event->Handler->params['controller']) {
case 'php':
$menu['main']['Php Info'] = array('controller' => 'php', 'action' => 'info');
$menu['main']['APC'] = array('controller' => 'php', 'action' => 'apc');
break;
}

return $menu;
class ServerStatusEvents extends AppEvents {
public function onAdminMenu(Event $Event) {
$menu['main']['Dashboard'] = array('controller' => 'server_status', 'action' => 'dashboard');
switch($Event->Handler->params['controller']) {
case 'php':
$menu['main']['Php Info'] = array('controller' => 'php', 'action' => 'info');
$menu['main']['APC'] = array('controller' => 'php', 'action' => 'apc');
break;
}

public function onSetupRoutes(Event $Event) {
InfinitasRouter::connect(
'/admin/server_status',
array(
'plugin' => 'server_status',
'controller' => 'server_status',
'action' => 'dashboard',
'admin' => true,
'prefix' => 'admin'
)
return $menu;
}

public function onSetupRoutes(Event $Event) {
InfinitasRouter::connect(
'/admin/server_status',
array(
'plugin' => 'server_status',
'controller' => 'server_status',
'action' => 'dashboard',
'admin' => true,
'prefix' => 'admin'
)
);
}

public function onRequireJavascriptToLoad(Event $Event) {
if($Event->Handler->request->params['plugin'] == 'server_status') {
return array(
'ServerStatus.server_status'
);
}
}

/**
* Return the server status for IRC bots
*
*
* @param Event $Event The event being run
* @param array $data the message data being parsed
*
*
* @return boolean
*/
public function onIrcMessage(Event $Event, $data = null) {
Expand Down Expand Up @@ -60,5 +68,5 @@ public function onIrcMessage(Event $Event, $data = null) {

return true;
}

}
2 changes: 1 addition & 1 deletion Core/ServerStatus/View/Elements/modules/admin/all_time.ctp
Expand Up @@ -3,7 +3,7 @@
return false;
}
?>
<div class="dashboard half">
<div class="page-header span6">
<?php
echo sprintf(__('<h1>%s</h1>'), __('Overall usage statistics'));
?>
Expand Down
4 changes: 2 additions & 2 deletions Core/ServerStatus/View/Elements/modules/admin/by_day.ctp
Expand Up @@ -3,15 +3,15 @@
return false;
}
?>
<div class="dashboard grid_16">
<div class="page-header span12">
<?php
echo sprintf(
__('<h1>%s<small>Data between %s and %s</small></h1>'),
__('Server load average by day'),
$this->Time->niceShort($byDay['start_date']),
$this->Time->niceShort($byDay['end_date'])
);

if(empty($byDay['day'])) {
echo $this->ViewCounter->noData();
}
Expand Down
6 changes: 3 additions & 3 deletions Core/ServerStatus/View/Elements/modules/admin/by_hour.ctp
Expand Up @@ -3,12 +3,12 @@
return false;
}
?>
<div class="dashboard grid_16">
<div class="page-header span12">
<?php
if(empty($byHour)) {
$byHour = ClassRegistry::init('ServerStatus.ServerStatus')->reportByHour();
}

echo sprintf(
__('<h1>Server load average by hour<small>Data between %s and %s</small></h1>'),
$this->Time->niceShort($byHour['start_date']),
Expand All @@ -18,7 +18,7 @@
if(empty($byHour['hour'])) {
echo $this->ViewCounter->noData();
}

else{
echo $this->Charts->draw(
'line',
Expand Down
4 changes: 2 additions & 2 deletions Core/ServerStatus/View/Elements/modules/admin/current.ctp
@@ -1,12 +1,12 @@
<div class="dashboard half" style="height: 645px;">
<div class="page-header span6" style="height: 645px;">
<?php
echo sprintf(
__('<h1>%s<small>%s<br/>%s</small></h1>'),
$current['Server']['name'],
$current['Server']['version'],
$current['Server']['release']
);

$plugins = App::objects('plugin');
?>
<table class="listing" style="margin: auto; width: 96%; background: none;">
Expand Down
Expand Up @@ -3,18 +3,18 @@
return false;
}
?>
<div class="dashboard half">
<div class="page-header span6">
<?php
echo sprintf(
__('<h1>Load for the last six months<small>Data between %s and %s</small></h1>'),
$this->Time->niceShort($lastSixMonths['start_date']),
$this->Time->niceShort($lastSixMonths['end_date'])
);

if(empty($lastSixMonths['month'])) {
echo $this->ViewCounter->noData();
}

else{
echo $this->Charts->draw(
array(
Expand Down
Expand Up @@ -3,18 +3,18 @@
return false;
}
?>
<div class="dashboard half">
<div class="page-header span6">
<?php
echo sprintf(
__('<h1>Last two weeks<small>Data between %s and %s</small></h1>'),
$this->Time->niceShort($lastTwoWeeks['start_date']),
$this->Time->niceShort($lastTwoWeeks['end_date'])
);

if(empty($lastTwoWeeks['day'])) {
echo $this->ViewCounter->noData();
}

else{
echo $this->Charts->draw(
'line',
Expand Down
22 changes: 6 additions & 16 deletions Core/ServerStatus/View/Php/admin_info.ctp
@@ -1,35 +1,25 @@
<?php
/*
/*
* Short Description / title.
*
*
* Overview of what the file does. About a paragraph or two
*
*
* Copyright (c) 2010 Carl Sutton ( dogmatic69 )
*
*
* @filesource
* @copyright Copyright (c) 2010 Carl Sutton ( dogmatic69 )
* @link http://www.infinitas-cms.org
* @package {see_below}
* @subpackage {see_below}
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since {check_current_milestone_in_lighthouse}
*
*
* @author {your_name}
*
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*/
?>
<style type="text/css">
.listing.no-gap{
margin-bottom: 0;
}

h1.no-gap{
margin-top: 10px;
}
</style>
<?php
ob_start();
phpinfo();
$pinfo = ob_get_contents();
Expand Down
23 changes: 11 additions & 12 deletions Core/ServerStatus/View/ServerStatus/admin_cache_status.ctp
Expand Up @@ -53,26 +53,25 @@
'description' => 'Clear all cached data',
'icon' => '/server_status/img/cache.png',
'author' => 'Infinitas',
'dashboard' => array('plugin' => 'server_status', 'controller' => 'server_status', 'action' => 'cache_status', 'clear' => 1),
'dashboard' => array('controller' => 'server_status', 'action' => 'cache_status', 'clear' => 1),
)
)
?>
<div class="dashboard grid_8">
<h1><?php echo __d('server_status', 'Cache Options'); ?></h1>
<ul class="icons"><li><?php echo implode('</li><li>', current((array)$this->Menu->builDashboardLinks($icons, 'cache_status'))); ?></li></ul>
</div>
);

echo $this->Html->tag('div', implode('', array(
$this->Html->tag('h1', __d('server_status', 'Cache Options')),
$this->Design->arrayToList(current((array)$this->Menu->builDashboardLinks($icons, 'cache_status')), array('ul' => 'icons'))
)), array('class' => 'dashboard'));

<?php
if(empty($clearedCache)) {
return;
}
?>
<div class="dashboard grid_16">
<div class="dashboard">
<h1><?php echo __d('server_status', 'Cleared'); ?></h1>
<table class="listing" cellpadding="0" cellspacing="0">
<table>
<thead>
<td><?php __d('server_status', 'Type'); ?></td>
<td><?php __d('server_status', 'What'); ?></td>
<th class="xlarge"><?php echo __d('server_status', 'Cache'); ?></th>
<th class="small"><?php echo __d('server_status', 'Action'); ?></th>
</thead>
<tbody>
<?php
Expand Down
70 changes: 35 additions & 35 deletions Core/ServerStatus/View/ServerStatus/admin_dashboard.ctp
@@ -1,36 +1,36 @@
<?php
$devIcons = array(
array(
'name' => 'Status',
'description' => 'Check on the health of your setup',
'icon' => '/server_status/img/icon.png',
'author' => 'Infinitas',
'dashboard' => array('plugin' => 'server_status', 'controller' => 'server_status', 'action' => 'status'),
),
array(
'name' => 'Php',
'description' => 'See and manage your Php configuration',
'icon' => '/server_status/img/php.png',
'author' => 'Infinitas',
'dashboard' => array('plugin' => 'server_status', 'controller' => 'php', 'action' => 'info'),
),
array(
'name' => 'MySQL',
'description' => 'Information regarding the MySQL server currently running',
'icon' => '/server_status/img/mysql.png',
'author' => 'Infinitas',
'dashboard' => array('plugin' => 'server_status', 'controller' => 'databases', 'action' => 'mysql'),
),
array(
'name' => 'Cache',
'description' => 'Clear all cached data',
'icon' => '/server_status/img/cache.png',
'author' => 'Infinitas',
'dashboard' => array('plugin' => 'server_status', 'controller' => 'server_status', 'action' => 'cache_status'),
)
);
?>
<div class="dashboard grid_16">
<h1><?php echo __('Manage your server'); ?></h1>
<ul class="icons"><li><?php echo implode('</li><li>', current((array)$this->Menu->builDashboardLinks($devIcons, 'server_status'))); ?></li></ul>
</div>
$devIcons = array(
array(
'name' => 'Status',
'description' => 'Check on the health of your setup',
'icon' => '/server_status/img/icon.png',
'author' => 'Infinitas',
'dashboard' => array('controller' => 'server_status', 'action' => 'status'),
),
array(
'name' => 'Php',
'description' => 'See and manage your Php configuration',
'icon' => '/server_status/img/php.png',
'author' => 'Infinitas',
'dashboard' => array('controller' => 'php', 'action' => 'info'),
),
array(
'name' => 'MySQL',
'description' => 'Information regarding the MySQL server currently running',
'icon' => '/server_status/img/mysql.png',
'author' => 'Infinitas',
'dashboard' => array('controller' => 'databases', 'action' => 'mysql'),
),
array(
'name' => 'Cache',
'description' => 'Clear all cached data',
'icon' => '/server_status/img/cache.png',
'author' => 'Infinitas',
'dashboard' => array('controller' => 'server_status', 'action' => 'cache_status'),
)
);

echo $this->Html->tag('div', implode('', array(
$this->Html->tag('h1', __d('server_status', 'Manage your server')),
$this->Design->arrayToList(current((array)$this->Menu->builDashboardLinks($devIcons, 'server_status')), array('ul' => 'icons'))
)), array('class' => 'dashboard'));
14 changes: 8 additions & 6 deletions Core/ServerStatus/View/ServerStatus/admin_status.ctp
@@ -1,7 +1,9 @@
<?php
echo $this->ModuleLoader->loadDirect('ServerStatus.current', array('current' => $current));
echo $this->ModuleLoader->loadDirect('ServerStatus.all_time', array('allTime' => $allTime));
echo $this->ModuleLoader->loadDirect('ServerStatus.last_two_weeks', array('lastTwoWeeks' => $lastTwoWeeks));
echo $this->ModuleLoader->loadDirect('ServerStatus.last_six_months', array('lastSixMonths' => $lastSixMonths));
echo $this->ModuleLoader->loadDirect('ServerStatus.by_hour', array('byHour' => $byHour));
echo $this->ModuleLoader->loadDirect('ServerStatus.by_day', array('byDay' => $byDay));
echo $this->Html->tag('div', implode('', array(
$this->ModuleLoader->loadDirect('ServerStatus.current', array('current' => $current)),
$this->ModuleLoader->loadDirect('ServerStatus.all_time', array('allTime' => $allTime)),
$this->ModuleLoader->loadDirect('ServerStatus.last_two_weeks', array('lastTwoWeeks' => $lastTwoWeeks)),
$this->ModuleLoader->loadDirect('ServerStatus.last_six_months', array('lastSixMonths' => $lastSixMonths)),
$this->ModuleLoader->loadDirect('ServerStatus.by_hour', array('byHour' => $byHour)),
$this->ModuleLoader->loadDirect('ServerStatus.by_day', array('byDay' => $byDay))
)), array('class' => 'row-fluid'));
18 changes: 18 additions & 0 deletions Core/ServerStatus/webroot/js/server_status.js
@@ -0,0 +1,18 @@
$(document).ready(function() {
$('.server_status.admin_info').prepend('<div class="tags"></div>');
var a = $('h1.no-gap a'),
tags = [],
$tags = $('.server_status.admin_info .tags');

$.each(a, function(k, v) {
v = $(v);
var data = {
anchor: v.attr('name'),
value: v.html()
};
tags.push(data);

v.parent().attr('id', data.anchor);
$tags.append('<a href="#' + data.anchor + '" class="btn">' + data.value + '</a>')
});
});

0 comments on commit 2cfed82

Please sign in to comment.