Add admin backend to edit Service/Sites

This commit is contained in:
2011-12-21 01:11:56 +00:00
parent 7e029c3ad5
commit 59dd99cca2
5 changed files with 85 additions and 4 deletions

View File

@@ -8,6 +8,9 @@ if ( ! $auth->isAuthenticated() || ! $auth->hasPermission(StatusBoard_Permission
throw new StatusBoard_Exception_NotAuthorised(); throw new StatusBoard_Exception_NotAuthorised();
} }
$activity = null;
$success = true;
$service_id = $request->get('id', 'Sihnon_Exception_InvalidParameters'); $service_id = $request->get('id', 'Sihnon_Exception_InvalidParameters');
$service = null; $service = null;
try { try {
@@ -16,9 +19,43 @@ try {
throw new StatusBoard_Exception_FileNotFound(); 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(); $sites = $service->sites();
$this->smarty->assign('service', $service); $this->smarty->assign('service', $service);
$this->smarty->assign('sites', $sites); $this->smarty->assign('sites', $sites);
$this->smarty->assign('messages', $messages);
?> ?>

View File

@@ -21,10 +21,45 @@ try {
throw new StatusBoard_Exception_FileNotFound(); 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(); $open_incidents = $site->openIncidents();
$this->smarty->assign('service', $service); $this->smarty->assign('service', $service);
$this->smarty->assign('site', $site); $this->smarty->assign('site', $site);
$this->smarty->assign('open_incidents', $open_incidents); $this->smarty->assign('open_incidents', $open_incidents);
$this->smarty->assign('messages', $messages);
?> ?>

View File

@@ -8,7 +8,7 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="span16"> <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> <fieldset>
<legend>Edit Service</legend> <legend>Edit Service</legend>

View File

@@ -9,7 +9,7 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="span16"> <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> <fieldset>
<legend>Edit Site</legend> <legend>Edit Site</legend>
@@ -44,7 +44,7 @@
<dl> <dl>
{foreach from=$open_incidents item=incident} {foreach from=$open_incidents item=incident}
<dt> <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())}) ({StatusBoard_Status::name($incident->currentStatus())})
</dt> </dt>
<dd> <dd>

View File

@@ -42,7 +42,16 @@
{if $messages} {if $messages}
<div id="messages"> <div id="messages">
{foreach from=$messages item=message} {foreach from=$messages item=message}
{if is_array($message)}
{$severity=$message['severity']}
<div class="alert-message {$severity}">
{$message['content']}
</div>
{else}
<div class="alert-message info">
{$message} {$message}
</div>
{/if}
{/foreach} {/foreach}
</div><!-- /messages --> </div><!-- /messages -->
{/if} {/if}