Incident Templates are now supported.

This commit is contained in:
James Brooks
2015-01-08 08:58:09 +00:00
parent 8248ac91fa
commit 1a4727bac2
12 changed files with 224 additions and 12 deletions

View File

@@ -3,8 +3,10 @@
namespace CachetHQ\Cachet\Http\Controllers;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\IncidentTemplate;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Routing\Controller;
class DashAPIController extends Controller
@@ -44,4 +46,17 @@ class DashAPIController extends Controller
return $componentData;
}
public function getIncidentTemplate()
{
$templateSlug = Binput::get('slug');
$template = IncidentTemplate::where('slug', $templateSlug)->first();
if ($template) {
return $template;
}
throw new ModelNotFoundException('Incident template for '.$templateSlug.' could not be found.');
}
}

View File

@@ -35,8 +35,22 @@ class DashIncidentController extends Controller
public function showAddIncident()
{
return View::make('dashboard.incidents.add')->with([
'pageTitle' => trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard'),
'components' => Component::all(),
'pageTitle' => trans('dashboard.incidents.add.title').' - '.trans('dashboard.dashboard'),
'components' => Component::all(),
'incidentTemplates' => IncidentTemplate::all(),
]);
}
/**
* Shows the incident templates.
*
* @return \Illuminate\View\View
*/
public function showTemplates()
{
return View::make('dashboard.incidents.templates.index')->with([
'pageTitle' => trans('dashboard.incidents.templates.title').' - '.trans('dashboard.dashboard'),
'incidentTemplates' => IncidentTemplate::all(),
]);
}
@@ -89,6 +103,35 @@ class DashIncidentController extends Controller
]);
}
/**
* Shows the edit incident template view.
*
* @param \CachetHQ\Cachet\Models\IncidentTemplate $template
*
* @return \Illuminate\View\View
*/
public function showEditTemplateAction(IncidentTemplate $template)
{
return View::make('dashboard.incidents.templates.edit')->with([
'pageTitle' => trans('dashboard.incidents.templates.edit.title').' - '.trans('dashboard.dashboard'),
'template' => $template,
]);
}
/**
* Deletes an incident template.
*
* @param \CachetHQ\Cachet\Models\IncidentTemplate $template
*
* @return \Illuminate\Http\RedirectResponse
*/
public function deleteTemplateAction(IncidentTemplate $template)
{
$template->delete();
return Redirect::back();
}
/**
* Creates a new incident template.
*
@@ -178,4 +221,18 @@ class DashIncidentController extends Controller
return Redirect::to('dashboard/incidents')->with('success', $successMsg);
}
/**
* Edit an incident template.
*
* @param \CachetHQ\Cachet\Models\IncidentTemplate $template
*
* @return \Illuminate\Http\RedirectResponse
*/
public function editTemplateAction(IncidentTemplate $template)
{
$template->update(Binput::get('template'));
return Redirect::back()->with('updatedTemplate', $template);
}
}