Skip to content
This repository
Browse code

Add quick worker-pool enable/disable feature and tweak entire site st…

…yle a bit
  • Loading branch information...
commit d88b46223be69aceb21ab85d18d23230deed52a4 1 parent 6fe463a
Chris Howie authored April 04, 2011
1  .gitignore
... ...
@@ -1,3 +1,4 @@
1 1
 *.swp
2 2
 
3 3
 config\.inc\.php
  4
+unused-icons
40  htdocs/admin/worker-pool.php
@@ -11,7 +11,7 @@ public function indexGetView()
11 11
         $id = (int)$_GET['id'];
12 12
 
13 13
         if ($id == 0) {
14  
-            return new RedirectView(make_url('/admin/workers.php'));
  14
+            return new RedirectView('/admin/workers.php');
15 15
         }
16 16
 
17 17
         $pdo = db_connect();
@@ -25,7 +25,7 @@ public function indexGetView()
25 25
         ', array(':worker_id' => $id));
26 26
 
27 27
         if (count($name) == 0) {
28  
-            return new RedirectView(make_url('/admin/workers.php'));
  28
+            return new RedirectView('/admin/workers.php');
29 29
         }
30 30
 
31 31
         $name = $name[0]['name'];
@@ -59,6 +59,42 @@ public function indexGetView()
59 59
 
60 60
         return new AdminWorkerPoolView($viewdata);
61 61
     }
  62
+
  63
+    public function setEnabledPostView()
  64
+    {
  65
+        $id = (int)$_POST['id'];
  66
+
  67
+        if ($id == 0) {
  68
+            return new RedirectView('/admin/workers.php');
  69
+        }
  70
+
  71
+        $enabled = (int)$_POST['enabled'];
  72
+        $pool = (int)$_POST['pool-id'];
  73
+
  74
+        $pdo = db_connect();
  75
+
  76
+        $q = $pdo->prepare('
  77
+            UPDATE worker_pool
  78
+
  79
+            SET enabled = :enabled
  80
+
  81
+            WHERE worker_id = :worker_id
  82
+              AND pool_id = :pool_id
  83
+        ');
  84
+
  85
+        $q->execute(array(
  86
+            ':enabled'      => $enabled,
  87
+            ':pool_id'      => $pool,
  88
+            ':worker_id'    => $id
  89
+        ));
  90
+
  91
+        if (!$q->rowCount()) {
  92
+            $_SESSION['tempdata']['errors'][] =
  93
+                sprintf('Pool not found or not affected.');
  94
+        }
  95
+
  96
+        return new RedirectView("/admin/worker-pool.php?id=$id");
  97
+    }
62 98
 }
63 99
 
64 100
 MvcEngine::run(new AdminWorkerPoolController());
BIN  htdocs/assets/icons/cog.png
BIN  htdocs/assets/icons/cog_add.png
BIN  htdocs/assets/icons/cog_delete.png
BIN  htdocs/assets/icons/flag_green.png
BIN  htdocs/assets/icons/flag_red.png
BIN  htdocs/assets/icons/page_error.png
BIN  htdocs/assets/icons/page_go.png
22  htdocs/assets/icons/readme.txt
... ...
@@ -0,0 +1,22 @@
  1
+Silk icon set 1.3
  2
+
  3
+_________________________________________
  4
+Mark James
  5
+http://www.famfamfam.com/lab/icons/silk/
  6
+_________________________________________
  7
+
  8
+This work is licensed under a
  9
+Creative Commons Attribution 2.5 License.
  10
+[ http://creativecommons.org/licenses/by/2.5/ ]
  11
+
  12
+This means you may use it for any purpose,
  13
+and make any changes you like.
  14
+All I ask is that you include a link back
  15
+to this page in your credits.
  16
+
  17
+Are you using this icon set? Send me an email
  18
+(including a link or picture if available) to
  19
+mjames@gmail.com
  20
+
  21
+Any other questions about this icon set please
  22
+contact mjames@gmail.com
BIN  htdocs/assets/icons/report.png
BIN  htdocs/assets/icons/server_go.png
57  htdocs/assets/style.css
@@ -45,19 +45,10 @@ table.data tr.disabled:hover {
45 45
 #recent-submissions,
46 46
 #recent-failed-submissions,
47 47
 #worker-status {
48  
-    width: 50%;
49  
-    margin: 0;
50  
-    padding: 0;
51  
-}
52  
-
53  
-#recent-submissions,
54  
-#worker-status {
55 48
     float: left;
56  
-    clear: both;
57  
-}
58  
-
59  
-#recent-failed-submissions {
60  
-    float: right;
  49
+    margin: 2em;
  50
+    margin-left: 0;
  51
+    padding: 0;
61 52
 }
62 53
 
63 54
 #navmenu {
@@ -81,11 +72,24 @@ table.data tr.disabled:hover {
81 72
     border: 1px solid transparent;
82 73
 }
83 74
 
84  
-#navmenu li a:hover {
85  
-    x-color: #222;
86  
-    x-background-color: #bbb;
  75
+#recent-submissions h2,
  76
+#recent-failed-submissions h2,
  77
+#worker-status h2 {
  78
+    padding-left: 22px;
  79
+    background-repeat: no-repeat;
  80
+    background-position: left center;
  81
+}
  82
+
  83
+#recent-submissions h2 {
  84
+    background-image: url('icons/page_go.png');
  85
+}
87 86
 
88  
-    border-color: #bbb;
  87
+#recent-failed-submissions h2 {
  88
+    background-image: url('icons/page_error.png');
  89
+}
  90
+
  91
+#worker-status h2 {
  92
+    background-image: url('icons/cog.png');
89 93
 }
90 94
 
91 95
 a:link, a:active, a:visited, a:hover {
@@ -111,7 +115,8 @@ table.entry tr.submit {
111 115
     text-align: center;
112 116
 }
113 117
 
114  
-input[type='submit'] {
  118
+input[type='submit'],
  119
+#navmenu li a:hover {
115 120
     color: #bbb;
116 121
     border: 1px outset #777;
117 122
     background-color: #333;
@@ -120,3 +125,21 @@ input[type='submit'] {
120 125
 form {
121 126
     display: inline;
122 127
 }
  128
+
  129
+img,
  130
+input[type='image'] {
  131
+    border: none;
  132
+    vertical-align: bottom;
  133
+}
  134
+
  135
+tr:hover .row-hover-hide {
  136
+    display: none;
  137
+}
  138
+
  139
+tr .row-hover-show {
  140
+    display: none;
  141
+}
  142
+
  143
+tr:hover .row-hover-show {
  144
+    display: inline;
  145
+}
21  htdocs/views/admin/worker-pool.view.php
@@ -25,8 +25,25 @@ protected function renderBody()
25 25
     <tr class="<?php if (!$row['enabled'] || !$row['pool-enabled']) { echo 'disabled'; } ?>">
26 26
         <td><?php echo_html($row['pool'])     ?></td>
27 27
         <td><?php echo_html($row['priority']) ?></td>
28  
-        <td><?php echo($row['enabled'] ? 'Yes' : 'No') ?></td>
29  
-        <td><?php echo($row['pool-enabled'] ? 'Yes' : 'No') ?></td>
  28
+        <td>
  29
+            <?php
  30
+                $indicator = $row['enabled'] ? 'flag_green.png' : 'flag_red.png';
  31
+                $newstatus = $row['enabled'] ? 0 : 1;
  32
+            ?>
  33
+            <form action="<?php echo_html(make_url('/admin/worker-pool.php')) ?>" method="POST">
  34
+                <input type="hidden" name="id" value="<?php echo_html($this->viewdata['worker-id']) ?>" />
  35
+                <input type="hidden" name="pool-id" value="<?php echo_html($row['pool-id']) ?>" />
  36
+                <input type="hidden" name="action" value="setEnabled" />
  37
+                <input type="hidden" name="enabled" value="<?php echo_html($newstatus) ?>" />
  38
+                <input type="image" src="<?php echo_html(make_url("/assets/icons/$indicator")) ?>" />
  39
+            </form>
  40
+        </td>
  41
+        <td>
  42
+            <?php
  43
+                $indicator = $row['pool-enabled'] ? 'flag_green.png' : 'flag_red.png';
  44
+            ?>
  45
+            <img src="<?php echo_html(make_url("/assets/icons/$indicator")) ?>" />
  46
+        </td>
30 47
         <td><?php echo_html($row['username']) ?></td>
31 48
         <td><?php echo_html($row['password']) ?></td>
32 49
     </tr>
9  htdocs/views/admin/workers.view.php
@@ -25,7 +25,8 @@ protected function renderBody()
25 25
         <td>
26 26
             <form action="<?php echo_html(make_url('/admin/worker-pool.php')) ?>">
27 27
                 <input type="hidden" name="id" value="<?php echo_html($row['id']) ?>" />
28  
-                <input type="submit" value="Manage pools" />
  28
+                <input type="image" title="Manage pools" alt="Manage pools"
  29
+                    src="<?php echo_html(make_url('/assets/icons/server_go.png')) ?>" />
29 30
             </form>
30 31
 
31 32
         <?php
@@ -34,7 +35,8 @@ protected function renderBody()
34 35
             <form action="<?php echo_html(make_url('/admin/workers.php')) ?>" method="POST">
35 36
                 <input type="hidden" name="action" value="delete" />
36 37
                 <input type="hidden" name="id" value="<?php echo_html($row['id']) ?>" />
37  
-                <input type="submit" value="Delete" />
  38
+                <input type="image" title="Delete worker" alt="Delete worker"
  39
+                    src="<?php echo_html(make_url('/assets/icons/cog_delete.png')) ?>" />
38 40
             </form>
39 41
 <?php
40 42
             }
@@ -46,7 +48,8 @@ protected function renderBody()
46 48
         <td>
47 49
             <form action="<?php echo_html(make_url('/admin/workers.php')) ?>">
48 50
                 <input type="hidden" name="action" value="new" />
49  
-                <input type="submit" value="New" />
  51
+                <input type="image" title="New worker" alt="New worker"
  52
+                    src="<?php echo_html(make_url('/assets/icons/cog_add.png')) ?>" />
50 53
             </form>
51 54
         </td>
52 55
     </tr>
4  htdocs/views/master.view.php
@@ -45,8 +45,8 @@ public function renderHtml()
45 45
         <h1><?php echo htmlspecialchars($this->viewdata['title']) ?></h1>
46 46
 
47 47
         <ul id="navmenu">
48  
-            <li><a href="<?php echo_html(make_url('/admin/')) ?>">Dashboard</a></li>
49  
-            <li><a href="<?php echo_html(make_url('/admin/workers.php')) ?>">Workers</a></li>
  48
+            <li><a href="<?php echo_html(make_url('/admin/')) ?>"><img src="<?php echo_html(make_url('/assets/icons/report.png')) ?>" /> Dashboard</a></li>
  49
+            <li><a href="<?php echo_html(make_url('/admin/workers.php')) ?>"><img src="<?php echo_html(make_url('/assets/icons/cog.png')) ?>" /> Workers</a></li>
50 50
         </ul>
51 51
 
52 52
 <?php

0 notes on commit d88b462

Please sign in to comment.
Something went wrong with that request. Please try again.