Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…yle a bit
  • Loading branch information...
commit d88b46223be69aceb21ab85d18d23230deed52a4 1 parent 6fe463a
@cdhowie authored
View
1  .gitignore
@@ -1,3 +1,4 @@
*.swp
config\.inc\.php
+unused-icons
View
40 htdocs/admin/worker-pool.php
@@ -11,7 +11,7 @@ public function indexGetView()
$id = (int)$_GET['id'];
if ($id == 0) {
- return new RedirectView(make_url('/admin/workers.php'));
+ return new RedirectView('/admin/workers.php');
}
$pdo = db_connect();
@@ -25,7 +25,7 @@ public function indexGetView()
', array(':worker_id' => $id));
if (count($name) == 0) {
- return new RedirectView(make_url('/admin/workers.php'));
+ return new RedirectView('/admin/workers.php');
}
$name = $name[0]['name'];
@@ -59,6 +59,42 @@ public function indexGetView()
return new AdminWorkerPoolView($viewdata);
}
+
+ public function setEnabledPostView()
+ {
+ $id = (int)$_POST['id'];
+
+ if ($id == 0) {
+ return new RedirectView('/admin/workers.php');
+ }
+
+ $enabled = (int)$_POST['enabled'];
+ $pool = (int)$_POST['pool-id'];
+
+ $pdo = db_connect();
+
+ $q = $pdo->prepare('
+ UPDATE worker_pool
+
+ SET enabled = :enabled
+
+ WHERE worker_id = :worker_id
+ AND pool_id = :pool_id
+ ');
+
+ $q->execute(array(
+ ':enabled' => $enabled,
+ ':pool_id' => $pool,
+ ':worker_id' => $id
+ ));
+
+ if (!$q->rowCount()) {
+ $_SESSION['tempdata']['errors'][] =
+ sprintf('Pool not found or not affected.');
+ }
+
+ return new RedirectView("/admin/worker-pool.php?id=$id");
+ }
}
MvcEngine::run(new AdminWorkerPoolController());
View
BIN  htdocs/assets/icons/cog.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  htdocs/assets/icons/cog_add.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  htdocs/assets/icons/cog_delete.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  htdocs/assets/icons/flag_green.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  htdocs/assets/icons/flag_red.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  htdocs/assets/icons/page_error.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  htdocs/assets/icons/page_go.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
22 htdocs/assets/icons/readme.txt
@@ -0,0 +1,22 @@
+Silk icon set 1.3
+
+_________________________________________
+Mark James
+http://www.famfamfam.com/lab/icons/silk/
+_________________________________________
+
+This work is licensed under a
+Creative Commons Attribution 2.5 License.
+[ http://creativecommons.org/licenses/by/2.5/ ]
+
+This means you may use it for any purpose,
+and make any changes you like.
+All I ask is that you include a link back
+to this page in your credits.
+
+Are you using this icon set? Send me an email
+(including a link or picture if available) to
+mjames@gmail.com
+
+Any other questions about this icon set please
+contact mjames@gmail.com
View
BIN  htdocs/assets/icons/report.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  htdocs/assets/icons/server_go.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
57 htdocs/assets/style.css
@@ -45,19 +45,10 @@ table.data tr.disabled:hover {
#recent-submissions,
#recent-failed-submissions,
#worker-status {
- width: 50%;
- margin: 0;
- padding: 0;
-}
-
-#recent-submissions,
-#worker-status {
float: left;
- clear: both;
-}
-
-#recent-failed-submissions {
- float: right;
+ margin: 2em;
+ margin-left: 0;
+ padding: 0;
}
#navmenu {
@@ -81,11 +72,24 @@ table.data tr.disabled:hover {
border: 1px solid transparent;
}
-#navmenu li a:hover {
- x-color: #222;
- x-background-color: #bbb;
+#recent-submissions h2,
+#recent-failed-submissions h2,
+#worker-status h2 {
+ padding-left: 22px;
+ background-repeat: no-repeat;
+ background-position: left center;
+}
+
+#recent-submissions h2 {
+ background-image: url('icons/page_go.png');
+}
- border-color: #bbb;
+#recent-failed-submissions h2 {
+ background-image: url('icons/page_error.png');
+}
+
+#worker-status h2 {
+ background-image: url('icons/cog.png');
}
a:link, a:active, a:visited, a:hover {
@@ -111,7 +115,8 @@ table.entry tr.submit {
text-align: center;
}
-input[type='submit'] {
+input[type='submit'],
+#navmenu li a:hover {
color: #bbb;
border: 1px outset #777;
background-color: #333;
@@ -120,3 +125,21 @@ input[type='submit'] {
form {
display: inline;
}
+
+img,
+input[type='image'] {
+ border: none;
+ vertical-align: bottom;
+}
+
+tr:hover .row-hover-hide {
+ display: none;
+}
+
+tr .row-hover-show {
+ display: none;
+}
+
+tr:hover .row-hover-show {
+ display: inline;
+}
View
21 htdocs/views/admin/worker-pool.view.php
@@ -25,8 +25,25 @@ protected function renderBody()
<tr class="<?php if (!$row['enabled'] || !$row['pool-enabled']) { echo 'disabled'; } ?>">
<td><?php echo_html($row['pool']) ?></td>
<td><?php echo_html($row['priority']) ?></td>
- <td><?php echo($row['enabled'] ? 'Yes' : 'No') ?></td>
- <td><?php echo($row['pool-enabled'] ? 'Yes' : 'No') ?></td>
+ <td>
+ <?php
+ $indicator = $row['enabled'] ? 'flag_green.png' : 'flag_red.png';
+ $newstatus = $row['enabled'] ? 0 : 1;
+ ?>
+ <form action="<?php echo_html(make_url('/admin/worker-pool.php')) ?>" method="POST">
+ <input type="hidden" name="id" value="<?php echo_html($this->viewdata['worker-id']) ?>" />
+ <input type="hidden" name="pool-id" value="<?php echo_html($row['pool-id']) ?>" />
+ <input type="hidden" name="action" value="setEnabled" />
+ <input type="hidden" name="enabled" value="<?php echo_html($newstatus) ?>" />
+ <input type="image" src="<?php echo_html(make_url("/assets/icons/$indicator")) ?>" />
+ </form>
+ </td>
+ <td>
+ <?php
+ $indicator = $row['pool-enabled'] ? 'flag_green.png' : 'flag_red.png';
+ ?>
+ <img src="<?php echo_html(make_url("/assets/icons/$indicator")) ?>" />
+ </td>
<td><?php echo_html($row['username']) ?></td>
<td><?php echo_html($row['password']) ?></td>
</tr>
View
9 htdocs/views/admin/workers.view.php
@@ -25,7 +25,8 @@ protected function renderBody()
<td>
<form action="<?php echo_html(make_url('/admin/worker-pool.php')) ?>">
<input type="hidden" name="id" value="<?php echo_html($row['id']) ?>" />
- <input type="submit" value="Manage pools" />
+ <input type="image" title="Manage pools" alt="Manage pools"
+ src="<?php echo_html(make_url('/assets/icons/server_go.png')) ?>" />
</form>
<?php
@@ -34,7 +35,8 @@ protected function renderBody()
<form action="<?php echo_html(make_url('/admin/workers.php')) ?>" method="POST">
<input type="hidden" name="action" value="delete" />
<input type="hidden" name="id" value="<?php echo_html($row['id']) ?>" />
- <input type="submit" value="Delete" />
+ <input type="image" title="Delete worker" alt="Delete worker"
+ src="<?php echo_html(make_url('/assets/icons/cog_delete.png')) ?>" />
</form>
<?php
}
@@ -46,7 +48,8 @@ protected function renderBody()
<td>
<form action="<?php echo_html(make_url('/admin/workers.php')) ?>">
<input type="hidden" name="action" value="new" />
- <input type="submit" value="New" />
+ <input type="image" title="New worker" alt="New worker"
+ src="<?php echo_html(make_url('/assets/icons/cog_add.png')) ?>" />
</form>
</td>
</tr>
View
4 htdocs/views/master.view.php
@@ -45,8 +45,8 @@ public function renderHtml()
<h1><?php echo htmlspecialchars($this->viewdata['title']) ?></h1>
<ul id="navmenu">
- <li><a href="<?php echo_html(make_url('/admin/')) ?>">Dashboard</a></li>
- <li><a href="<?php echo_html(make_url('/admin/workers.php')) ?>">Workers</a></li>
+ <li><a href="<?php echo_html(make_url('/admin/')) ?>"><img src="<?php echo_html(make_url('/assets/icons/report.png')) ?>" /> Dashboard</a></li>
+ <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>
</ul>
<?php
Please sign in to comment.
Something went wrong with that request. Please try again.