Skip to content

Commit

Permalink
Dashboard: Partial replacement and autorefresh
Browse files Browse the repository at this point in the history
- Replaces the jqplot based 24h jobs status partial
- Reorders current available partials on the dashboard
- Adds autorefresh to all partials via ajax interval call
  • Loading branch information
fbergkemper committed Apr 26, 2017
1 parent ee3cdbb commit 38c9b38
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 205 deletions.
110 changes: 52 additions & 58 deletions module/Dashboard/src/Dashboard/Controller/DashboardController.php
Expand Up @@ -5,7 +5,7 @@
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos-webui for the canonical source repository
* @copyright Copyright (c) 2013-2016 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @copyright Copyright (c) 2013-2017 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -60,39 +60,45 @@ public function indexAction()
);
}

try {
$this->bsock = $this->getServiceLocator()->get('director');
$running = $this->getJobs("running", 1, null);
$waiting = $this->getJobs("waiting", 1, null);
$successful = $this->getJobs("successful", 1, null);
$unsuccessful = $this->getJobs("unsuccessful", 1, null);
$this->bsock->disconnect();
}
catch(Exception $e) {
echo $e->getMessage();
}

return new ViewModel(
array(
'runningJobs' => $running,
'waitingJobs' => $waiting,
'successfulJobs' => $successful,
'unsuccessfulJobs' => $unsuccessful,
)
);
return new ViewModel();
}

private function getJobs($status=null, $days=1, $hours=null)
public function getDataAction()
{
$num = null;
$this->RequestURIPlugin()->setRequestURI();

if($status != null) {
if($status == "running") {
$jobs_R = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'R', $days, $hours);
$jobs_l = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'l', $days, $hours);
$num = count($jobs_R) + count($jobs_l);
if(!$this->SessionTimeoutPlugin()->isValid()) {
return $this->redirect()->toRoute('auth', array('action' => 'login'), array('query' => array('req' => $this->RequestURIPlugin()->getRequestURI(), 'dird' => $_SESSION['bareos']['director'])));
}

$result = null;

$data = $this->params()->fromQuery('data');

if($data == "jobslaststatus") {
try {
$this->bsock = $this->getServiceLocator()->get('director');
$result = $this->getJobModel()->getJobsLastStatus($this->bsock);
$this->bsock->disconnect();
}
catch(Exception $e) {
echo $e->getMessage();
}
elseif($status == "waiting") {
}
elseif($data == "jobspast24h") {

$days = 1;
$hours = null;
$waiting = null;
$running = null;
$successful = null;
$failed = null;
$result = null;

try {
$this->bsock = $this->getServiceLocator()->get('director');

// waiting
$jobs_F = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'F', $days, $hours);
$jobs_S = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'S', $days, $hours);
$jobs_s = $this->getJobModel()->getJobsByStatus($this->bsock, null, 's', $days, $hours);
Expand All @@ -105,47 +111,35 @@ private function getJobs($status=null, $days=1, $hours=null)
$jobs_t = $this->getJobModel()->getJobsByStatus($this->bsock, null, 't', $days, $hours);
$jobs_p = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'p', $days, $hours);
$jobs_q = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'q', $days, $hours);
$num = count($jobs_F) + count($jobs_S) +
$waiting = count($jobs_F) + count($jobs_S) +
count($jobs_s) + count($jobs_m) +
count($jobs_M) + count($jobs_j) +
count($jobs_c) + count($jobs_C) +
count($jobs_d) + count($jobs_t) +
count($jobs_p) + count($jobs_q);
}
elseif($status == "successful") {

// running
$jobs_R = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'R', $days, $hours);
$jobs_l = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'l', $days, $hours);
$running = count($jobs_R) + count($jobs_l);

// successful
$jobs_T = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'T', $days, $hours);
$jobs_W = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'W', $days, $hours);
$num = count($jobs_T) + count($jobs_W);
}
elseif($status == "unsuccessful") {
$successful = count($jobs_T) + count($jobs_W);

// failed
$jobs_A = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'A', $days, $hours);
$jobs_E = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'E', $days, $hours);
$jobs_e = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'e', $days, $hours);
$jobs_f = $this->getJobModel()->getJobsByStatus($this->bsock, null, 'f', $days, $hours);
$num = count($jobs_A) + count($jobs_E) + count($jobs_e) + count($jobs_f);
}
}

return $num;
}

public function getDataAction()
{
$this->RequestURIPlugin()->setRequestURI();

if(!$this->SessionTimeoutPlugin()->isValid()) {
return $this->redirect()->toRoute('auth', array('action' => 'login'), array('query' => array('req' => $this->RequestURIPlugin()->getRequestURI(), 'dird' => $_SESSION['bareos']['director'])));
}

$result = null;
$failed = count($jobs_A) + count($jobs_E) + count($jobs_e) + count($jobs_f);

$data = $this->params()->fromQuery('data');

if($data == "jobslaststatus") {
try {
$this->bsock = $this->getServiceLocator()->get('director');
$result = $this->getJobModel()->getJobsLastStatus($this->bsock);
$this->bsock->disconnect();
// json result
$result['waiting'] = $waiting;
$result['running'] = $running;
$result['successful'] = $successful;
$result['failed'] = $failed;
}
catch(Exception $e) {
echo $e->getMessage();
Expand Down

0 comments on commit 38c9b38

Please sign in to comment.