diff --git a/application/controllers/dashboard.php b/application/controllers/dashboard.php index e1ef901..c2b113c 100644 --- a/application/controllers/dashboard.php +++ b/application/controllers/dashboard.php @@ -27,7 +27,7 @@ class Dashboard extends CI_Controller { /** - * Constructor. + * Constructor. */ public function __construct() { parent::__construct(); @@ -35,7 +35,46 @@ class Dashboard extends CI_Controller { } public function index() { - $this->load->view('dashboard'); + $tpl['action_buttons'] = array( + array( + 'icon' => 'tango/folder-new.png', + 'text' => _('New project'), + 'target' => site_url('projects/create'), + ), + array( + 'icon' => 'tango/document-open.png', + 'text' => _('Recent results'), + 'target' => site_url('jobs/results'), + ), + ); + + $tpl['recent_buttons'] = array( + array( + 'count' => 4, + 'text' => _('Jobs finished'), + 'title' => sprintf(_('%d jobs finished recently'), 3), + 'target' => '#', + ), + array( + 'count' => 2, + 'text' => _('Newly shared projects'), + 'title' => sprintf(_('You were invited to join %d projects'), 2), + 'target' => '#', + ), + array( + 'count' => 1, + 'text' => _('Job running'), + 'title' => sprintf(_('There is %d job currently running'), 1), + 'target' => '#', + ), + array( + 'count' => 2, + 'text' => _('Jobs pending'), + 'title' => sprintf(_('There are %2 job currently pending'), 1), + 'target' => '#', + ), + ); + $this->load->view('dashboard', $tpl); } } diff --git a/application/controllers/xmlrpc.php b/application/controllers/xmlrpc.php index 402550a..f965559 100644 --- a/application/controllers/xmlrpc.php +++ b/application/controllers/xmlrpc.php @@ -108,7 +108,9 @@ class Xmlrpc extends CI_Controller { $update = array( 'os' => $parameters[0], - 'workload' => $parameters[1], + 'uptime' => $parameters[1], + 'workload' => $parameters[3], + 'hardware' => $parameters[2], 'last_update' => mysql_now() ); $this->server->update($server->id, $update); diff --git a/application/helpers/MY_date_helper.php b/application/helpers/MY_date_helper.php index 30f7147..5bb365e 100644 --- a/application/helpers/MY_date_helper.php +++ b/application/helpers/MY_date_helper.php @@ -35,5 +35,68 @@ if ( ! function_exists('mysql_now')) } } +/** + * Function to calculate date or time difference. + * + * Function to calculate date or time difference. Returns an array or + * false on error. + * + * @author J de Silva + * @copyright Copyright © 2005, J de Silva + * @link http://www.gidnetwork.com/b-16.html Get the date / time difference with PHP + * @param string $start + * @param string $end + * @return array + */ +if ( ! function_exists('time_diff')) +{ + function time_diff($start, $end) + { + $uts['start'] = strtotime($start); + $uts['end'] = strtotime($end); + if ($uts['start'] !== -1 && $uts['end'] !== -1) { + if ($uts['end'] >= $uts['start']) { + $diff = $uts['end'] - $uts['start']; + $diff = intval($diff); + return ($diff); + } + } + return (false); + } +} + +/** + * Function to convert seconds to a pretty string. + * + * @author Karsten Heiken + * @param integer $secs the amount of seconds + * @param boolean $includeseconds should seconds be appended to the string? + * @return string + */ +if ( ! function_exists('secondsToString')) +{ + function secondsToString($secs, $includeseconds = false) + { + $days = intval($secs / 86400); + $hours = intval($secs / 3600 % 24); + $minutes = intval($secs / 60 % 60); + $seconds = intval($secs % 60); + if (($minutes + $hours + $days) < 1) + return (sprintf(_('%d seconds'), $seconds)); + else if (($minutes + $hours) < 1) + $string = sprintf(_('%d minutes'), $minutes); + else if ($days < 1) + $string = sprintf(_('%d hours, %d minutes'), $hours, $minutes); + else + $string = sprintf(_('%d days, %d hours, %d minutes'), $days, $hours, + $minutes); + + if ($includeseconds) + $string .= ' ' . sprintf(_('and %d seconds'), $seconds); + + return $string; + } +} + /* End of file MY_date_helper.php */ -/* Location: ./application/helpers/MY_date_helper.php */ \ No newline at end of file +/* Location: ./application/helpers/MY_date_helper.php */ diff --git a/application/models/job.php b/application/models/job.php index f2a9647..698fcb2 100644 --- a/application/models/job.php +++ b/application/models/job.php @@ -81,7 +81,17 @@ class Job extends CI_Model { $this->db->where('project_id', $projectId); } - return $this->db->get('jobs')->result_array(); + $jobs = $this->db->get('jobs')->result_array(); + return array_map(function($var) { + if($var['started_at'] == '0000-00-00 00:00:00') { + $var['status'] = 'pending'; + } elseif($var['finished_at'] == '0000-00-00 00:00:00') { + $var['status'] = 'running'; + } else { + $var['status'] = 'complete'; + } + return $var; + }, $jobs); } /** diff --git a/application/models/server.php b/application/models/server.php index 3f62a2e..e33ee7a 100644 --- a/application/models/server.php +++ b/application/models/server.php @@ -52,7 +52,11 @@ class Server extends CI_Model { * @return array List of all available servers. */ public function getAll() { - return $this->db->get('servers')->result_array(); + $servers = $this->db->get('servers')->result_array(); + return array_map(function($var) { + $var['available'] = time_diff($var['last_update'], mysql_now()) < 120 ? true : false; + return $var; + }, $servers); } /** @@ -97,7 +101,12 @@ class Server extends CI_Model { * @param string $serverId */ public function getById($serverId) { - return $this->db->get_where('servers', array('id' => $serverId))->row(); + $this->load->helper('date'); + $server = $this->db->get_where('servers', array('id' => $serverId))->row(); + $server->uptimestring = secondsToString($server->uptime); + $server->lastheartbeat = sprintf(_('%s ago'), + secondsToString(time_diff($server->last_update, mysql_now()))); + return $server; } } diff --git a/application/views/admin/server/detail.php b/application/views/admin/server/detail.php index 5c047e3..99bd95c 100644 --- a/application/views/admin/server/detail.php +++ b/application/views/admin/server/detail.php @@ -17,10 +17,11 @@

Technical information

Hardware & OS

- CPU: Intel Xeon E5540, 2533 MHz
- Uptime: 254 Tage, 13 Stunden
- OS: Debian/GNU 5.0r1
- Workload: 2.01, 1.05, 0.85 + CPU: hardware;?>
+ Uptime: uptimestring;?>
+ OS: os;?>
+ Workload: workload);?>
+ Last heartbeat: lastheartbeat;?>

ScattPort-Statistics

diff --git a/application/views/admin/server/list.php b/application/views/admin/server/list.php index b72f29f..3e4b3b9 100644 --- a/application/views/admin/server/list.php +++ b/application/views/admin/server/list.php @@ -21,7 +21,7 @@ 2) { + if ($server['workload'] > 0.8) { $server['class'] = "pending"; $server['status'] = 'busy'; } else { diff --git a/application/views/dashboard.php b/application/views/dashboard.php index 6a4168d..85d9f5d 100644 --- a/application/views/dashboard.php +++ b/application/views/dashboard.php @@ -1,30 +1,63 @@ load->view('header');?>
- -
-

+
+
+

+
+ + +
+

+

+ 0): + $i = 1; + foreach ($action_buttons as $button): + if($i == 1 && (count($action_buttons) == 1)) + $button['class'] = ''; + elseif($i == count($action_buttons)) + $button['class'] = 'right'; + elseif($i == 1) + $button['class'] = 'left'; + else + $button['class'] = 'middle'; +?>
+

+
+
+

+

+ 0): + $i = 1; + foreach ($recent_buttons as $button): + if($i == 1 && (count($recent_buttons) == 1)) + $button['class'] = ''; + elseif($i == count($recent_buttons)) + $button['class'] = 'right'; + elseif($i == 1) + $button['class'] = 'left'; + else + $button['class'] = 'middle'; +?>
+

+
+
+

+

+ +

+
- -
-

-

- -

-
-
-

-

- -

-
-
-

-

- -

-
-
load->view('footer');?> diff --git a/application/views/header.php b/application/views/header.php index 10142ee..fc8e3ca 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -175,16 +175,4 @@
-
-

-
- -
-
    -
  • 22.07.2011

  • -
  • 22.07.2011

  • -
  • 22.07.2011

  • -
-
- diff --git a/application/views/projects/detail.php b/application/views/projects/detail.php index ad82a62..6492026 100644 --- a/application/views/projects/detail.php +++ b/application/views/projects/detail.php @@ -88,8 +88,7 @@ - - + @@ -97,11 +96,20 @@ 0): foreach ($jobs as $job): + if($job['status'] == 'pending') { + $job['humanstatus'] = _('Pending'); + $job['cssclass'] = 'closed'; + } elseif($job['status'] == 'running') { + $job['humanstatus'] = _('Simulation running'); + $job['cssclass'] = 'pending'; + } elseif($job['status'] == 'complete') { + $job['humanstatus'] = _('Simulation complete'); + $job['cssclass'] = 'active'; + } ?> - - + | diff --git a/assets/css/style.css b/assets/css/style.css index 8d402dc..1f51c48 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -676,3 +676,11 @@ html ul.tabs li.active a:hover { .jtip { cursor: help; } + +#dashboard a.button { + text-align: center; +} + +#dashboard a.button strong { + font-size: 2.5em; +} diff --git a/assets/images/tango/document-new.png b/assets/images/tango/document-new.png new file mode 100644 index 0000000..e6d64bb Binary files /dev/null and b/assets/images/tango/document-new.png differ diff --git a/assets/images/tango/document-open.png b/assets/images/tango/document-open.png new file mode 100644 index 0000000..f35f258 Binary files /dev/null and b/assets/images/tango/document-open.png differ diff --git a/assets/images/tango/folder-new.png b/assets/images/tango/folder-new.png new file mode 100644 index 0000000..fcd15c0 Binary files /dev/null and b/assets/images/tango/folder-new.png differ diff --git a/assets/images/tango/folder-remote.png b/assets/images/tango/folder-remote.png new file mode 100644 index 0000000..3e0d9ad Binary files /dev/null and b/assets/images/tango/folder-remote.png differ