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

Commit

Permalink
Fix logs browser
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Jun 3, 2013
1 parent cd552cb commit 53024ab
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
9 changes: 6 additions & 3 deletions assets/css/less/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,10 @@ a.brand
color: lighten(@textColor, 35);
}

.page-header + .alert {
margin-top: 1em;
}

.console {
background: @colorShadePlusOne;
padding: @insidePadding;
Expand Down Expand Up @@ -735,9 +739,8 @@ h4.sep
background: @greyBorderColor;
font-weight: bold;
color: @gray;

padding-top: 4px;
padding-bottom: 2px;

padding: 4px 2px 4px 10px;

border-top: 1px solid lighten(@greyBorderColor, 10);
border-bottom: 1px solid darken(@greyBorderColor, 5);
Expand Down
4 changes: 2 additions & 2 deletions src/ResqueBoard/View/logs_browser.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

} elseif (empty($logs)) {

echo '<div class="alert"><i class="icon-search" style="font-size:32px; float:left;margin: 10px 10px 0 0;"></i><h4>No results found</h4>Try searchiung again :)</div>';
echo '<div class="knight-unit"><i class="icon-search icon"></i><h2>No results found</h2></div>';

} else {

Expand Down Expand Up @@ -121,7 +121,7 @@
<div class="sidebar">
<div class="bloc">
<h3>Search</h3>
<form id="log-browser-form" role="form">
<form id="log-browser-form" role="form" method="GET" action="logs/browse">
<fieldset><legend>Verbosity</legend>
<select class="span2" name="event_level[]" multiple="" size="<?php echo count($logLevels)?>">
<?php
Expand Down
2 changes: 1 addition & 1 deletion src/ResqueBoard/webroot/css/main.min.css

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions src/ResqueBoard/webroot/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,11 @@ function () use ($app, $logLevels, $logTypes) {
'date_before' => null
);

$params = cleanArgs($app->request()->params());

$searchData = array_merge(
$defaults,
cleanArgs($app->request()->params())
$params
);
array_walk(
$searchData,
Expand All @@ -471,10 +473,10 @@ function (&$key) {

$pagination = new stdClass();
$pagination->current = $searchData['page'];
$pagination->limit = (($app->request()->params('limit') != '') && in_array($app->request()->params('limit'), $resultLimits))
? $app->request()->params('limit')
$pagination->limit = (isset($params['limit']) && in_array($params['limit'], $resultLimits))
? $params['limit']
: PAGINATION_LIMIT;
$pagination->baseUrl = '/logs/browse?';
$pagination->baseUrl = 'logs/browse?';

$conditions = array();

Expand All @@ -485,21 +487,18 @@ function (&$key) {
'event_type' => $searchData['event_type'],
'date_after' => $searchData['date_after'],
'date_before' => $searchData['date_before']

);


// Validate search datas
$dateTimePattern = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])*?$/';
$dateTimePattern = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])(\s+([0-1][0-9]|2[0-4]):[0-5]\d(:[0-5]\d)?)?$/';
if (!empty($conditions['date_after']) && preg_match($dateTimePattern, $conditions['date_after']) == 0) {
$errors['date_after'] = 'Date is not valid';
}
if (!empty($conditions['date_before']) && preg_match($dateTimePattern, $conditions['date_before']) == 0) {
$errors['date_before'] = 'Date is not valid';
}


if (empty($errors) && cleanArgs($app->request()->params()) != array()) {
if (empty($errors) && $params != array()) {
$resqueStat = new ResqueBoard\Lib\ResqueStat();
$logs = $resqueStat->getLogs($conditions);
$pagination->totalResult = $resqueStat->getLogs(array_merge($conditions, array('type' => 'count')));
Expand All @@ -509,7 +508,7 @@ function (&$key) {
}

$pagination->totalPage = ceil($pagination->totalResult / $pagination->limit);
$pagination->uri = cleanArgs($app->request()->params());
$pagination->uri = $params;

render(
$app,
Expand All @@ -529,7 +528,7 @@ function (&$key) {
$app->error($e);
}
}
)->via('GET', 'POST');
)->via('GET');

/**
* Return all the jobs between a start and end date
Expand Down

0 comments on commit 53024ab

Please sign in to comment.