Add admin UI/Backend for adding sites
This commit is contained in:
@@ -19,6 +19,10 @@ class StatusBoard_Service extends StatusBoard_DatabaseObject {
|
|||||||
|
|
||||||
return $new_service;
|
return $new_service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function newSite($name, $description) {
|
||||||
|
return StatusBoard_Site::newSiteForService($this, $name, $description);
|
||||||
|
}
|
||||||
|
|
||||||
public function sites($ignore_cache = false) {
|
public function sites($ignore_cache = false) {
|
||||||
if ($this->sites === null || $ignore_cache) {
|
if ($this->sites === null || $ignore_cache) {
|
||||||
|
|||||||
@@ -16,6 +16,17 @@ class StatusBoard_Site extends StatusBoard_DatabaseObject {
|
|||||||
return static::all_for('service', $service->id);
|
return static::all_for('service', $service->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function newSiteForService(StatusBoard_Service $service, $name, $description) {
|
||||||
|
$new_service = new self();
|
||||||
|
$new_service->service = $service->id;
|
||||||
|
$new_service->name = $name;
|
||||||
|
$new_service->description = $description;
|
||||||
|
|
||||||
|
$new_service->create();
|
||||||
|
|
||||||
|
return $new_service;
|
||||||
|
}
|
||||||
|
|
||||||
public function openIncidents($ignore_cache = false) {
|
public function openIncidents($ignore_cache = false) {
|
||||||
if ($this->incidents_open === null || $ignore_cache) {
|
if ($this->incidents_open === null || $ignore_cache) {
|
||||||
$this->incidents_open = StatusBoard_Incident::open_for_site($this);
|
$this->incidents_open = StatusBoard_Incident::open_for_site($this);
|
||||||
|
|||||||
@@ -43,10 +43,26 @@ if ($request->exists('do')) {
|
|||||||
$messages[] = 'No changes were necessary.';
|
$messages[] = 'No changes were necessary.';
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default: {
|
case 'add-site': {
|
||||||
|
$name = StatusBoard_Main::issetelse($_POST['name'], 'Sihnon_Exception_InvalidParameters');
|
||||||
|
$description = StatusBoard_Main::issetelse($_POST['description'], 'Sihnon_Exception_InvalidParameters');
|
||||||
|
|
||||||
|
$site = $service->newSite($name, $description);
|
||||||
|
|
||||||
|
$messages[] = array(
|
||||||
|
'severity' => 'success',
|
||||||
|
'content' => 'The site was created succesfully.',
|
||||||
|
);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
|
||||||
|
default: {
|
||||||
|
$messages[] = array(
|
||||||
|
'severity' => 'warning',
|
||||||
|
'content' => "The activity '{$activity}' is not supported.",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,28 @@
|
|||||||
You haven't created any sites for this service yet. Create some with the button below.
|
You haven't created any sites for this service yet. Create some with the button below.
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<form id="admin_addsite" method="post" action="{$base_uri}admin/add-site/service/{$service->id}/">
|
<form id="admin_addsite" method="post" action="{$base_uri}admin/service/id/{$service->id}/do/add-site/">
|
||||||
<input type="button" class="btn success" name="addsite" value="Add Site" />
|
<fieldset>
|
||||||
</form>
|
<legend>Add Site</legend>
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
<label for="admin_site_add_name">Name</label>
|
||||||
|
<div class="text">
|
||||||
|
<input class="xlarge span5" id="admin_site_add_name" name="name" type="text" value="" />
|
||||||
|
</div>
|
||||||
|
</div><!-- /clearfix -->
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
<label for="admin_site_add_description">Description</label>
|
||||||
|
<div class="text">
|
||||||
|
<textarea class="span12" id="admin_site_add_description" name="description"></textarea>
|
||||||
|
</div>
|
||||||
|
</div><!-- /clearfix -->
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
<div class="input">
|
||||||
|
<input type="submit" class="btn success" name="addsite" value="Add Site" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user