Add admin backend to edit Service/Sites
This commit is contained in:
@@ -8,6 +8,9 @@ if ( ! $auth->isAuthenticated() || ! $auth->hasPermission(StatusBoard_Permission
|
||||
throw new StatusBoard_Exception_NotAuthorised();
|
||||
}
|
||||
|
||||
$activity = null;
|
||||
$success = true;
|
||||
|
||||
$service_id = $request->get('id', 'Sihnon_Exception_InvalidParameters');
|
||||
$service = null;
|
||||
try {
|
||||
@@ -16,9 +19,43 @@ try {
|
||||
throw new StatusBoard_Exception_FileNotFound();
|
||||
}
|
||||
|
||||
if ($request->exists('do')) {
|
||||
$activity = $request->get('do');
|
||||
switch ($activity) {
|
||||
|
||||
case 'edit': {
|
||||
$name = StatusBoard_Main::issetelse($_POST['name'], 'Sihnon_Exception_InvalidParameters');
|
||||
$description = StatusBoard_Main::issetelse($_POST['description'], 'Sihnon_Exception_InvalidParameters');
|
||||
|
||||
if ($name) {
|
||||
$service->name = $name;
|
||||
}
|
||||
if ($description) {
|
||||
$service->description = $description;
|
||||
}
|
||||
if ($name || $description) {
|
||||
$service->save();
|
||||
$messages[] = array(
|
||||
'severity' => 'success',
|
||||
'content' => 'The service was updated succesfully.',
|
||||
);
|
||||
} else {
|
||||
$messages[] = 'No changes were necessary.';
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
default: {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sites = $service->sites();
|
||||
|
||||
$this->smarty->assign('service', $service);
|
||||
$this->smarty->assign('sites', $sites);
|
||||
$this->smarty->assign('messages', $messages);
|
||||
|
||||
?>
|
||||
@@ -21,10 +21,45 @@ try {
|
||||
throw new StatusBoard_Exception_FileNotFound();
|
||||
}
|
||||
|
||||
if ($request->exists('do')) {
|
||||
$activity = $request->get('do');
|
||||
switch ($activity) {
|
||||
|
||||
case 'edit': {
|
||||
$name = StatusBoard_Main::issetelse($_POST['name'], 'Sihnon_Exception_InvalidParameters');
|
||||
$description = StatusBoard_Main::issetelse($_POST['description'], 'Sihnon_Exception_InvalidParameters');
|
||||
|
||||
if ($name) {
|
||||
$site->name = $name;
|
||||
}
|
||||
if ($description) {
|
||||
$site->description = $description;
|
||||
}
|
||||
if ($name || $description) {
|
||||
$site->save();
|
||||
$messages[] = array(
|
||||
'severity' => 'success',
|
||||
'content' => 'The site was updated succesfully.',
|
||||
);
|
||||
} else {
|
||||
$messages[] = 'No changes were necessary.';
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
default: {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$open_incidents = $site->openIncidents();
|
||||
|
||||
$this->smarty->assign('service', $service);
|
||||
$this->smarty->assign('site', $site);
|
||||
$this->smarty->assign('open_incidents', $open_incidents);
|
||||
$this->smarty->assign('messages', $messages);
|
||||
|
||||
?>
|
||||
@@ -8,7 +8,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="span16">
|
||||
<form id="admin_service_edit" method="post" action="{$base_uri}admin/services/id/{$service->id}/do/edit/">
|
||||
<form id="admin_service_edit" method="post" action="{$base_uri}admin/service/id/{$service->id}/do/edit/">
|
||||
<fieldset>
|
||||
<legend>Edit Service</legend>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="span16">
|
||||
<form id="admin_site_edit" method="post" action="{$base_uri}admin/site/id/{$site->id}/do/edit/">
|
||||
<form id="admin_site_edit" method="post" action="{$base_uri}admin/site/service/{$service->id}/id/{$site->id}/do/edit/">
|
||||
<fieldset>
|
||||
<legend>Edit Site</legend>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<dl>
|
||||
{foreach from=$open_incidents item=incident}
|
||||
<dt>
|
||||
<a href="{$base_uri}admin/incident/service/{$service->id}/site/{$site->id}/id/{$incident->id}" title="Edit Incident {$incident->reference|escape:html}">{$incident->reference|escape:html}</a>
|
||||
<a href="{$base_uri}admin/incident/service/{$service->id}/site/{$site->id}/id/{$incident->id}/" title="Edit Incident {$incident->reference|escape:html}">{$incident->reference|escape:html}</a>
|
||||
({StatusBoard_Status::name($incident->currentStatus())})
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
@@ -42,7 +42,16 @@
|
||||
{if $messages}
|
||||
<div id="messages">
|
||||
{foreach from=$messages item=message}
|
||||
{$message}
|
||||
{if is_array($message)}
|
||||
{$severity=$message['severity']}
|
||||
<div class="alert-message {$severity}">
|
||||
{$message['content']}
|
||||
</div>
|
||||
{else}
|
||||
<div class="alert-message info">
|
||||
{$message}
|
||||
</div>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</div><!-- /messages -->
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user