From fd0b0e1a2677a424b27a0ad3c69f73e17c8c4549 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Wed, 21 Dec 2011 02:16:37 +0000 Subject: [PATCH] Add admin UI/backend for adding a new Service --- public/scripts/main.js | 8 +++++++ source/lib/StatusBoard/Service.class.php | 10 ++++++++ source/webui/pages/admin.php | 30 ++++++++++++++++++++++++ source/webui/templates/admin.tpl | 26 ++++++++++++++++++-- 4 files changed, 72 insertions(+), 2 deletions(-) diff --git a/public/scripts/main.js b/public/scripts/main.js index f5abd24..c0dc14e 100644 --- a/public/scripts/main.js +++ b/public/scripts/main.js @@ -20,6 +20,14 @@ var sb = { html: true, }); }, + + admin: { + + init: function() { + + } + + }, usercp: { diff --git a/source/lib/StatusBoard/Service.class.php b/source/lib/StatusBoard/Service.class.php index 64c1589..1af47db 100644 --- a/source/lib/StatusBoard/Service.class.php +++ b/source/lib/StatusBoard/Service.class.php @@ -9,6 +9,16 @@ class StatusBoard_Service extends StatusBoard_DatabaseObject { protected $_db_description; protected $sites = null; + + public static function newService($name, $description) { + $new_service = new self(); + $new_service->name = $name; + $new_service->description = $description; + + $new_service->create(); + + return $new_service; + } public function sites($ignore_cache = false) { if ($this->sites === null || $ignore_cache) { diff --git a/source/webui/pages/admin.php b/source/webui/pages/admin.php index 0b4bed8..844a844 100644 --- a/source/webui/pages/admin.php +++ b/source/webui/pages/admin.php @@ -9,6 +9,35 @@ if ( ! $auth->isAuthenticated() || ! $auth->hasPermission(StatusBoard_Permission throw new StatusBoard_Exception_NotAuthorised(); } +$activity = null; +$success = true; + +if ($request->exists('do')) { + $activity = $request->get('do'); + switch ($activity) { + + case 'add-service': { + $name = StatusBoard_Main::issetelse($_POST['name'], 'Sihnon_Exception_InvalidParameters'); + $description = StatusBoard_Main::issetelse($_POST['description'], 'Sihnon_Exception_InvalidParameters'); + + $service = StatusBoard_Service::newService($name, $description); + + $messages[] = array( + 'severity' => 'success', + 'content' => 'The service was created succesfully.', + ); + + } break; + + default: { + $messages[] = array( + 'severity' => 'warning', + 'content' => "The activity '{$activity}' is not supported.", + ); + } + } +} + $this->smarty->assign('tab', $request->get('tab', 'admin')); $services = StatusBoard_Service::all(); @@ -21,5 +50,6 @@ $this->smarty->assign('users', $users); $this->smarty->assign('debug_displayexceptions', $config->get('debug.display_exceptions')); $this->smarty->assign('cache_basedir', $config->get('cache.base_dir')); $this->smarty->assign('templates_tmppath', $config->get('templates.tmp_path')); +$this->smarty->assign('messages', $messages); ?> \ No newline at end of file diff --git a/source/webui/templates/admin.tpl b/source/webui/templates/admin.tpl index f3d01f4..3693d1e 100644 --- a/source/webui/templates/admin.tpl +++ b/source/webui/templates/admin.tpl @@ -28,8 +28,30 @@ You haven't created any services yet. Create some with the button below. {/if} -
- + +
+ Add Service + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+