Incident templates can now be created.
This commit is contained in:
@@ -24,6 +24,27 @@ class DashIncidentController extends Controller {
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the add incident template view.
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function showAddIncidentTemplate() {
|
||||
return View::make('dashboard.incident-template')->with([
|
||||
'pageTitle' => 'Add Incident Template - Dashboard',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new incident template.
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function createIncidentTemplateAction() {
|
||||
$_template = Input::get('template');
|
||||
$template = IncidentTemplate::create($_template);
|
||||
|
||||
return Redirect::back()->with('template', $template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new incident.
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
|
||||
@@ -7,8 +7,12 @@ class IncidentTemplate extends Eloquent {
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'alpha|required',
|
||||
'slug' => 'alpha_dash|required',
|
||||
'template' => 'required'
|
||||
'template' => 'required',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'template',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -18,7 +22,7 @@ class IncidentTemplate extends Eloquent {
|
||||
public static function boot() {
|
||||
parent::boot();
|
||||
|
||||
self::on('saving', function($template) {
|
||||
self::saving(function($template) {
|
||||
$template->slug = Str::slug($template->name);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function() {
|
||||
Route::get('incidents', ['as' => 'dashboard.incidents', 'uses' => 'DashIncidentController@showIncidents']);
|
||||
Route::get('incidents/add', ['as' => 'dashboard.incidents.add', 'uses' => 'DashIncidentController@showAddIncident']);
|
||||
Route::post('incidents/add', 'DashIncidentController@createIncidentAction');
|
||||
Route::get('incidents/template', ['as' => 'dashboard.incident-template', 'uses' => 'DashIncidentController@showAddIncidentTemplate']);
|
||||
Route::post('incidents/template', 'DashIncidentController@createIncidentTemplateAction');
|
||||
|
||||
// Metrics
|
||||
Route::get('metrics', ['as' => 'dashboard.metrics', 'uses' => 'DashboardController@showMetrics']);
|
||||
|
||||
37
app/views/dashboard/incident-template.blade.php
Normal file
37
app/views/dashboard/incident-template.blade.php
Normal file
@@ -0,0 +1,37 @@
|
||||
@extends('layout.dashboard')
|
||||
|
||||
@section('content')
|
||||
<div class="header">
|
||||
<i class="fa fa-dashboard"></i> {{ Lang::get('cachet.dashboard.incident-add') }}
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h3>Create an Incident Template</h3>
|
||||
|
||||
@if($template = Session::get('template'))
|
||||
<div class='alert alert-{{ $template->isValid() ? "success" : "danger" }}'>
|
||||
@if($template->isValid())
|
||||
<strong>Awesome.</strong> Template added.
|
||||
@else
|
||||
<strong>Whoops.</strong> Something went wrong with the template.
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{ Form::open(['name' => 'IncidentTemplateForm', 'class' => 'form-vertical', 'role' => 'form']) }}
|
||||
<fieldset>
|
||||
<div class='form-group'>
|
||||
<label for='template-name'>Template Name</label>
|
||||
<input type='text' class='form-control' name='template[name]' id='template-name' required />
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label>Template</label>
|
||||
<textarea name='template[template]' class='form-control' rows='5' required></textarea>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Create</button>
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
||||
Reference in New Issue
Block a user