From f69f56597afca97f3fb3d19153bec491d9d8774a Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Fri, 9 Sep 2011 21:08:10 +0200 Subject: [PATCH 01/11] Add two date helpers - time_diff() to count the seconds between two datetimes - secondsToString() to make a pretty string from seconds --- application/helpers/MY_date_helper.php | 65 +++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) 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 */ From f98d21a40dc0ab8f61925c3cbabd5f0c7ef5eb49 Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Fri, 9 Sep 2011 21:10:01 +0200 Subject: [PATCH 02/11] Add additional info to the server model --- application/models/server.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/application/models/server.php b/application/models/server.php index 3f62a2e..1f42bed 100644 --- a/application/models/server.php +++ b/application/models/server.php @@ -97,7 +97,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; } } From 136b81534cc0180bf592d8c8e6a6ad8ec9612f82 Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Fri, 9 Sep 2011 21:11:13 +0200 Subject: [PATCH 03/11] Add uptime, workload and hardware-specs to the XML-RPC API --- application/controllers/xmlrpc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); From e36b0b0ab194ecae7b9646847c720833c7dafc17 Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Fri, 9 Sep 2011 21:11:39 +0200 Subject: [PATCH 04/11] Show additional info when displaying server details --- application/views/admin/server/detail.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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

From beb934888641bf452a88f56b73d3d6182890a2d2 Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Fri, 9 Sep 2011 23:41:59 +0200 Subject: [PATCH 05/11] Adjust limit for a server's workload --- application/views/admin/server/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 { From 0d07fe802cbc01b593afb2c038817c3dbd0e82ba Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Fri, 9 Sep 2011 23:42:23 +0200 Subject: [PATCH 06/11] Dynamically set availability for a server based on last heartbeat --- application/models/server.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/application/models/server.php b/application/models/server.php index 1f42bed..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); } /** From 6ea70a504b9a5d3941123cd2fc6d022498eccaf4 Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Sat, 10 Sep 2011 00:09:08 +0200 Subject: [PATCH 07/11] Add status-field to job model --- application/models/job.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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); } /** From 33056409f526ceb4476148f625ecf543cb6046d8 Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Sat, 10 Sep 2011 00:09:55 +0200 Subject: [PATCH 08/11] Show a job's status on project detail page --- application/views/projects/detail.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/application/views/projects/detail.php b/application/views/projects/detail.php index 3019cc8..498a08a 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'; + } ?> - - + | From 72c55e48ef0705b50124901a1dffb407d2b5504b Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Sat, 10 Sep 2011 01:06:53 +0200 Subject: [PATCH 09/11] Remove "recent events" from sidebar It just takes up space --- application/views/header.php | 12 ------------ 1 file changed, 12 deletions(-) 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

  • -
-
- From a5576287db088bd335d90c0070bf0183cb60f1e1 Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Sat, 10 Sep 2011 01:07:22 +0200 Subject: [PATCH 10/11] Add CSS class for buttons on the dashboard --- assets/css/style.css | 8 ++++++++ 1 file changed, 8 insertions(+) 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; +} From 853ec411c3f6d8cfb47df330738ee80c03024721 Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Sat, 10 Sep 2011 01:13:13 +0200 Subject: [PATCH 11/11] Make dashboard dynamic --- application/controllers/dashboard.php | 43 +++++++++++++- application/views/dashboard.php | 79 ++++++++++++++++++-------- assets/images/tango/document-new.png | Bin 0 -> 1008 bytes assets/images/tango/document-open.png | Bin 0 -> 1550 bytes assets/images/tango/folder-new.png | Bin 0 -> 1399 bytes assets/images/tango/folder-remote.png | Bin 0 -> 1446 bytes 6 files changed, 97 insertions(+), 25 deletions(-) create mode 100644 assets/images/tango/document-new.png create mode 100644 assets/images/tango/document-open.png create mode 100644 assets/images/tango/folder-new.png create mode 100644 assets/images/tango/folder-remote.png 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/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/assets/images/tango/document-new.png b/assets/images/tango/document-new.png new file mode 100644 index 0000000000000000000000000000000000000000..e6d64bb90b32dfec83232de6478afc1a6b335b8f GIT binary patch literal 1008 zcmV9&7>1-t%; zZoBM??ke>U^dD4er7kL=hDJeZLn7jm5(v08gqI)OnbXC!k+JW?xKusTXl69mbH4MM z@xcEq@?UJK$`~hw1@dkN7mNd7!v<|zXR5g`LOT&)eSQ72TrT&mh?I;m7-R6>>yxk%nY!jFra=|`UYN$jJFw$o6!Q~hf9-+XQxm0cZ zJOI$ON<^+(?>q^>$`OG*B(MkM>^|0nAkF)!0Ktc~6Mw%ewATx-0 z2=>Fy#)6oaAmto-RYqh2Z%eTNabbvae=k5%Xre;9nY`Cxo3Q|K&2t~+0bbw5`9+*Bg4+i7q|>%JJZgfrw$XMK(PuKxMWP1) zmY0{W>pwdb1w8NJv=RMSizu_;qj``kQ{8>c()+Ea(0)p>xdkyNp>qyZjjXz5Nh%eb zJ_06CKaG(SAOf&5#fzQa`ScU_6UFA1NR%C^9_W{0asp;?Orsp*IYRUtB#$=>{POGf z$mGS7-aUt|f-L1XOD{mFpjwHh3d#hRje(RK4xrbrCP4qK*Ol9z4QaP$ zB0w01u}ZUm;sE+(Xb;3G&N>H11xP%I05&!@FlI1uh6OanWah@e?qL{S$7*F|CG}!T zQk>+WI7tmb|J9u4iTE=iTT(+XjMA*NEST6TNGiioz`DnJl8oemyOdkq1z9qR=SBkP zt&A)XRZRu!2Phk3PF1yBE|(FB-UUGr{Oh~`$mjECz&vmawE6)`KxJ=l@5|NI)h|Rk zFN(X9=I-w9SHJ>bfdjzz`fv=G1MUG+ow>a$ literal 0 HcmV?d00001 diff --git a/assets/images/tango/document-open.png b/assets/images/tango/document-open.png new file mode 100644 index 0000000000000000000000000000000000000000..f35f2583540678b7a544d9175245096082f302af GIT binary patch literal 1550 zcmV+p2J!icP)x2@7Ze~uNfga3vbZE9GEM?G2QWwx$l|aG!6EBtvokxp zvoq5l)m6n|XM1OQW{kx~$|IHPv)|{b_kF9YL=;7Qme9AeD9aOny9T9{E~r#qPhztg z1VQi60-DXH_~GhP{O0)=sMqT=*LlCEvE6RV7hihev3LLe?mJnMeJ2Ql_)r2aUc4x- z|MMTLudh!Kdhc=0;hZDSbBr;>am=?)-y@FSdHfr{d*ijY=4x z#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pWd9DGQ&**AE z`Wm$zAV3Bj0Rx`dcCmTpnQ#qAUNe9La!&rm{vV&0_z$|iO8zfMYH0uf002ovPDHLk FV1m5tllTAt literal 0 HcmV?d00001 diff --git a/assets/images/tango/folder-remote.png b/assets/images/tango/folder-remote.png new file mode 100644 index 0000000000000000000000000000000000000000..3e0d9add38a8481e639dd3e266daf866d25ef537 GIT binary patch literal 1446 zcmV;X1zGxuP)> z+_>nnw76&~73o6grY*;t&%O7|B@w~@DHj0Fojd1ht$(!EzP`}_B1)L~uAp2lcL3VYc93+S(b3VqLZN_Su?Qjp z5di>{Ql0lkqk)?@Z;k_4A7ICh9Z{`Ta|Q=XFvhF_=(ZGX1wjA+9f-6AK>%xQzE|)L z!1(yMK6UDps#dF=3;^f~(#}R&?HQ+oE2Y{1{)PYmV6Ek1v0p_|j9W8|pQl#`*=)UN z!z_;}L1bkAs~>)6(tR94flf6Q(l|xvmSx^H4+gYv80P2B;wl;Hn_n*}@0L&Z!1a|X?6GkI2&}QR(uvsZZSg40kqyiZq?>Jty z2f{E!Bed8(;vwfb@Uq)egn;EE9Yq>SQ9b=Vy#yfu7-TSzbI_OB-rKT>pcaN8=EXGt zL_~)VAGVD^V{u9FaG?%W*cB=l}q48jZ#ezs}G{dI0Vp(_6mm zu95%@0BoZB^LMU&oo=JlZMW$4_wUMkrD1_6MXKi!C>C-fqx<%Jw`*j?E9CQ-o}O;a zKdF2&zfk+_*}jRjR>x63Axe_wLKVQAh;&W?t=x2JVq$`>T)E;te*D-^lEiggH%U9{ z@9$S*V`HBKcozV9o@WmoI+V56;@-V`QLEL;BuT=|Jbw4?-7nK)wbq{R`%$S>(tG#r zwMUK|;faX}5fLE~!Leh=97~z!VYvJ~=u04~Yn>)oTCH(9kQ)d{9Kjx($5z@L~Ss$&)8WM@No`(J7MO5F?UU+twaoq*o%6aWAK07*qoM6N<$f_V;% A=Kufz literal 0 HcmV?d00001