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

Commit

Permalink
Action dropdown menu
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergkemper committed Feb 7, 2014
1 parent 1a9972a commit 7149491
Show file tree
Hide file tree
Showing 12 changed files with 342 additions and 66 deletions.
18 changes: 9 additions & 9 deletions module/Application/src/Application/View/Helper/Date.php
Expand Up @@ -7,6 +7,7 @@
* @link http://github.com/fbergkemper/barbossa for the canonical source repository
* @copyright Copyright (c) 2013-2014 dass-IT GmbH (http://www.dass-it.de/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
* @author Frank Bergkemper
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand All @@ -32,33 +33,32 @@
class Date extends AbstractHelper
{

public function __invoke($dateString, $mode = 'medium')
public function __invoke($dateString, $mode = 'iso8601')
{
if ($dateString == '0000-00-00 00:00:00' || $dateString == '') {
return '-';
}

switch ($mode) {
case 'full':
$dateType = IntlDateFormatter::FULL;
$timeType = IntlDateFormatter::FULL;
break;
case 'long':
$dateType = IntlDateFormatter::LONG;
$timeType = IntlDateFormatter::LONG;
break;

case 'short':
$dateType = IntlDateFormatter::SHORT;
$timeType = IntlDateFormatter::SHORT;
break;

case 'dateonly':
$dateType = IntlDateFormatter::MEDIUM;
$timeType = IntlDateFormatter::NONE;
break;

default:
case 'medium':
$dateType = IntlDateFormatter::MEDIUM;
$timeType = IntlDateFormatter::MEDIUM;
break;
default:
case 'iso8601':
return $dateString;
}

$dateTime = new DateTime($dateString);
Expand Down
2 changes: 1 addition & 1 deletion module/Client/src/Client/Controller/ClientController.php
Expand Up @@ -54,6 +54,6 @@ public function getJobTable()
}
return $this->jobTable;
}

}

76 changes: 54 additions & 22 deletions module/Dashboard/view/dashboard/dashboard/index.phtml
Expand Up @@ -83,8 +83,7 @@ $flash->setMessageOpenFormat('
<th><?php echo $this->translate("Start"); ?></th>
<!-- <th>Duration</th> -->
<th><?php echo $this->translate("Status"); ?></th>
<th><?php echo $this->translate("Log"); ?></th>
<th></th>
<th><?php echo $this->translate("Action"); ?></th>
</tr>

<?php foreach ($this->runningJobs as $item) : ?>
Expand All @@ -99,9 +98,22 @@ $flash->setMessageOpenFormat('
<td><?php echo $this->printDate($item->starttime); ?></td>
<!-- <td><?php echo $this->printJobDuration($item->starttime, $item->endtime); ?></td> -->
<td><?php echo $this->printJobStatus($item->jobstatus); ?></td>
<td><a href="<?php echo $this->url('log', array('action' => 'job', 'id' => $item->jobid)); ?>" title="<?php echo $this->translate("View logs"); ?>"><span class="glyphicon glyphicon-file"></a></td>
<td><a href="<?php ?>" title="<?php echo $this->translate("Cancel"); ?>"><span class="glyphicon glyphicon-trash"></span></a></td>
<td>

<div class="btn-group">
<button type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-cog"></span></button>
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="<?php echo $this->url('log', array('action' => 'job', 'id' => $item->jobid)); ?>" title="<?php echo $this->translate("View logs"); ?>"><span class="glyphicon glyphicon-file"> View messages</a></li>
<li class="divider"></li>
<li><a href="<?php ?>" title="<?php echo $this->translate("Cancel"); ?>"><span class="glyphicon glyphicon-trash"></span> Cancel job</a></li>
</ul>
</div>

</td>
</tr>

<?php endforeach; ?>
Expand Down Expand Up @@ -151,11 +163,8 @@ $flash->setMessageOpenFormat('
<th><?php echo $this->translate("Client"); ?></th>
<th><?php echo $this->translate("Type"); ?></th>
<th><?php echo $this->translate("Level"); ?></th>
<th><?php echo $this->translate("Start"); ?></th>
<!-- <th>Duration</th> -->
<th><?php echo $this->translate("Status"); ?></th>
<th><?php echo $this->translate("Log"); ?></th>
<th></th>
<th><?php echo $this->translate("Action"); ?></th>
</tr>

<?php foreach ($this->waitingJobs as $item) : ?>
Expand All @@ -167,12 +176,23 @@ $flash->setMessageOpenFormat('
<td><a href="<?php echo $this->url('client', array('action' => 'details', 'id' => $item->clientid)); ?>"><?php echo $this->escapeHtml($item->clientname); ?></a></td>
<td><?php echo $this->printJobType($item->type); ?></td>
<td><?php echo $this->printJobLevel($item->level); ?></td>
<td><?php echo $this->printDate($item->starttime); ?></td>
<!-- <td><?php echo $this->printJobDuration($item->starttime, $item->endtime); ?></td> -->
<td><?php echo $this->printJobStatus($item->jobstatus); ?></td>
<td><a href="<?php echo $this->url('log', array('action' => 'job', 'id' => $item->jobid)); ?>" title="<?php echo $this->translate("View logs"); ?>"><span class="glyphicon glyphicon-file"></a></td>
<td><a href="<?php ?>>" title="<?php echo $this->translate("Cancel"); ?>"><span class="glyphicon glyphicon-trash"></span></a></td>

<td>

<div class="btn-group">
<button type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-cog"></span></button>
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="<?php echo $this->url('log', array('action' => 'job', 'id' => $item->jobid)); ?>" title="<?php echo $this->translate("View logs"); ?>"><span class="glyphicon glyphicon-file"> View messages</a></li>
<li class="divider"></li>
<li><a href="<?php ?>" title="<?php echo $this->translate("Cancel"); ?>"><span class="glyphicon glyphicon-trash"></span> Cancel job</a></li>
<ul>
</div>

</td>
</tr>

<?php endforeach; ?>
Expand Down Expand Up @@ -223,10 +243,10 @@ $flash->setMessageOpenFormat('
<th><?php echo $this->translate("Type"); ?></th>
<th><?php echo $this->translate("Level"); ?></th>
<th><?php echo $this->translate("Start"); ?></th>
<th><?php echo $this->translate("End"); ?></th>
<th><?php echo $this->translate("Duration") ?></th>
<th><?php echo $this->translate("Status"); ?></th>
<th><?php echo $this->translate("Log"); ?></th>
<th></th>
<th><?php echo $this->translate("Action"); ?></th>
</tr>

<?php foreach ($this->lastUnsuccessfulJobs as $jobUnsuccess) : ?>
Expand All @@ -239,10 +259,25 @@ $flash->setMessageOpenFormat('
<td><?php echo $this->printJobType($jobUnsuccess->type); ?></td>
<td><?php echo $this->printJobLevel($jobUnsuccess->level); ?></td>
<td><?php echo $this->printDate($jobUnsuccess->starttime); ?></td>
<td><?php echo $this->printDate($jobUnsuccess->endtime); ?></td>
<td><?php echo $this->printJobDuration($jobUnsuccess->starttime, $jobUnsuccess->endtime); ?></td>
<td><?php echo $this->printJobStatus($jobUnsuccess->jobstatus); ?></td>
<td><a href="<?php echo $this->url('log', array('action' => 'job', 'id' => $jobUnsuccess->jobid)); ?>" title="<?php echo $this->translate("View logs"); ?>"><span class="glyphicon glyphicon-file"></a></td>
<td><a href="<?php ?>" title="<?php echo $this->translate("Rerun"); ?>"><span class="glyphicon glyphicon-repeat"></span></a></td>
<td>
<?php if($jobUnsuccess->type == "B") : ?>
<div class="btn-group">
<button type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-cog"></span></button>
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="<?php echo $this->url('log', array('action' => 'job', 'id' => $jobUnsuccess->jobid)); ?>" title="<?php echo $this->translate("View logs"); ?>"><span class="glyphicon glyphicon-file"></span> View messages</a></li>
<li class="divider"></li>
<li><a href="<?php ?>" title="<?php echo $this->translate("Rerun"); ?>"><span class="glyphicon glyphicon-repeat"></span> Re-run job</a></li>
</ul>
</div>
<?php endif; ?>
</td>
</tr>

<?php endforeach; ?>
Expand Down Expand Up @@ -296,6 +331,7 @@ $flash->setMessageOpenFormat('
<th><?php echo $this->translate("Type"); ?></th>
<th><?php echo $this->translate("Level"); ?></th>
<th><?php echo $this->translate("Start"); ?></th>
<th><?php echo $this->translate("End"); ?></th>
<th><?php echo $this->translate("Duration"); ?></th>
<th><?php echo $this->translate("Status"); ?></th>
<!--<th><?php echo $this->translate("Log"); ?></th>-->
Expand All @@ -312,13 +348,9 @@ $flash->setMessageOpenFormat('
<td><?php echo $this->printJobLevel($jobSuccess->level); ?></td>
<td><?php echo $this->printJobType($jobSuccess->type); ?></td>
<td><?php echo $this->printDate($jobSuccess->starttime); ?></td>
<td><?php echo $this->printDate($jobSuccess->endtime); ?></td>
<td><?php echo $this->printJobDuration($jobSuccess->starttime, $jobSuccess->endtime); ?></td>
<td><?php echo $this->printJobStatus($jobSuccess->jobstatus); ?></td>
<!--
<td>
<a href="<?php echo $this->url('log', array('action' => 'job', 'id' => $jobSuccess->jobid)); ?>" title="<?php echo $this->translate("View logs"); ?>"><span class="glyphicon glyphicon-file"></span></a>
</td>
-->
<td>
<?php if($jobSuccess->type == "B") : ?>
<div class="btn-group">
Expand Down
Expand Up @@ -7,6 +7,7 @@
* @link http://github.com/fbergkemper/barbossa for the canonical source repository
* @copyright Copyright (c) 2013-2014 dass-IT GmbH (http://www.dass-it.de/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
* @author Frank Bergkemper
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand Down
18 changes: 17 additions & 1 deletion module/Job/src/Job/Controller/JobController.php
Expand Up @@ -7,6 +7,7 @@
* @link http://github.com/fbergkemper/barbossa for the canonical source repository
* @copyright Copyright (c) 2013-2014 dass-IT GmbH (http://www.dass-it.de/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
* @author Frank Bergkemper
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand Down Expand Up @@ -84,7 +85,7 @@ public function waitingAction()
);
}

public function problemAction()
public function unsuccessfulAction()
{
$paginator = $this->getJobTable()->getLast24HoursUnsuccessfulJobs(true);
$paginator->setCurrentPageNumber( (int) $this->params()->fromQuery('page', 1) );
Expand All @@ -98,6 +99,21 @@ public function problemAction()
);
}

public function successfulAction()
{
$paginator = $this->getJobTable()->getLast24HoursSuccessfulJobs(true);
$paginator->setCurrentPageNumber( (int) $this->params()->fromQuery('page', 1) );
$paginator->setItemCountPerPage(10);

return new ViewModel(
array(
'paginator' => $paginator,
'lastSuccessfulJobs' => $this->getJobTable()->getLast24HoursSuccessfulJobs(),
)
);

}

public function timelineAction()
{
return new ViewModel();
Expand Down
26 changes: 19 additions & 7 deletions module/Job/src/Job/Model/JobTable.php
Expand Up @@ -140,26 +140,38 @@ public function getWaitingJobs($paginated=false)
}
}

public function getLast24HoursSuccessfulJobs()
public function getLast24HoursSuccessfulJobs($paginated=false)
{
$current_time = date("Y-m-d H:i:s",time());
$back24h_time = date("Y-m-d H:i:s",time() - (60*60*23));
$back24h_time = date("Y-m-d H:i:s",time() - (60*60*24));

$select = new Select();
$select->from('job');
$select->join('client', 'job.clientid = client.clientid', array('clientname' => 'name'));
$select->order('job.jobid DESC');
$select->where("jobstatus = 'T' AND starttime >= '" . $back24h_time . "' AND endtime >= '" . $back24h_time . "'");

$resultSet = $this->tableGateway->selectWith($select);

return $resultSet;

if($paginated) {
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Job());
$paginatorAdapter = new DbSelect(
$select,
$this->tableGateway->getAdapter(),
$resultSetPrototype
);
$paginator = new Paginator($paginatorAdapter);
return $paginator;
}
else {
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
}

public function getLast24HoursUnsuccessfulJobs($paginated=false)
{
$current_time = date("Y-m-d H:i:s",time());
$back24h_time = date("Y-m-d H:i:s",time() - (60*60*23));
$back24h_time = date("Y-m-d H:i:s",time() - (60*60*24));

$select = new Select();
$select->from('job');
Expand Down
34 changes: 23 additions & 11 deletions module/Job/view/job/job/index.phtml
Expand Up @@ -7,6 +7,7 @@
* @link http://github.com/fbergkemper/barbossa for the canonical source repository
* @copyright Copyright (c) 2013-2014 dass-IT GmbH (http://www.dass-it.de/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
* @author Frank Bergkemper
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand Down Expand Up @@ -35,7 +36,8 @@ $this->headTitle($title);
<li class="active"><a href="<?php echo $this->url('job', array('action'=>'index')); ?>"><?php echo $this->translate('Overview'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'running')); ?>"><?php echo $this->translate('Running'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'waiting')); ?>"><?php echo $this->translate('Waiting'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'problem')); ?>"><?php echo $this->translate('Unsuccessful'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'unsuccessful')); ?>"><?php echo $this->translate('Unsuccessful'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'successful')); ?>"><?php echo $this->translate('Successful'); ?></a></li>
<li><a href="<?php echo $this->url('job', array('action'=>'timeline')); ?>"><?php echo $this->translate('Timeline'); ?></a></li>
</ul>

Expand All @@ -60,9 +62,7 @@ $this->headTitle($title);
<th><?php echo $this->translate("End"); ?></th>
<th><?php echo $this->translate("Duration"); ?></th>
<th><?php echo $this->translate("Status"); ?></th>
<th><?php echo $this->translate("Log"); ?></th>
<th></th>
<th></th>
<th><?php echo $this->translate("Action"); ?></th>

</tr>

Expand All @@ -84,15 +84,27 @@ $this->headTitle($title);
<td><?php echo $this->escapeHtml("-"); ?></td>
<?php endif; ?>
<td><?php echo $this->printJobStatus($job->jobstatus); ?></td>
<td><a href="<?php echo $this->url('log', array('action' => 'job', 'id' => $job->jobid)); ?>" title="<?php echo $this->translate("View logs"); ?>"><span class="glyphicon glyphicon-file"></span></a></td>
<td>
<?php if($job->type == "B") : ?>
<a href="<?php ?>" title="<?php echo $this->translate("Rerun"); ?>"><span class="glyphicon glyphicon-repeat"></span></a>
<?php endif; ?>
</td>
<td>
<?php if($job->type == "B") : ?>
<a href="<?php ?>" title="<?php echo $this->translate("Restore"); ?>"><span class="glyphicon glyphicon-import"></span></a>
<div class="btn-group">
<button type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-cog"></span></button>
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="<?php echo $this->url('log', array('action' => 'job', 'id' => $job->jobid)); ?>" title="<?php echo $this->translate("View logs"); ?>"><span class="glyphicon glyphicon-file"></span> View messages</a></li>
<li class="divider"></li>
<?php if($job->jobstatus == "T") : ?>
<li><a href="<?php ?>" title="<?php echo $this->translate("Rerun"); ?>"><span class="glyphicon glyphicon-repeat"></span> Re-run job</a></li>
<li><a href="<?php ?>" title="<?php echo $this->translate("Restore"); ?>"><span class="glyphicon glyphicon-import"></span> Restore job</a></li>
<?php elseif($job->jobstatus == "E" || $job->jobstatus == "e" || $job->jobstatus == "f" || $job->jobstatus == "A") : ?>
<li><a href="<?php ?>" title="<?php echo $this->translate("Rerun"); ?>"><span class="glyphicon glyphicon-repeat"></span> Re-run job</a></li>
<?php else : ?>
<li><a href="<?php ?>" title="<?php echo $this->translate("Cancel"); ?>"><span class="glyphicon glyphicon-trash"></span> Cancel job</a></li>
<?php endif; ?>
</ul>
</div>
<?php endif; ?>
</td>

Expand Down

0 comments on commit 7149491

Please sign in to comment.