Create incidents from the dashboard index
This commit is contained in:
@@ -9,6 +9,15 @@ class DashboardController extends Controller {
|
||||
return View::make('dashboard.index');
|
||||
}
|
||||
|
||||
public function createIncidentAction() {
|
||||
$_incident = Input::get('incident');
|
||||
$_incident['user_id'] = Auth::user()->id;
|
||||
|
||||
$incident = Incident::create($_incident);
|
||||
|
||||
return Redirect::back()->with('incident', $incident);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the components view.
|
||||
* @return \Illuminate\View\View
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AlterTableIncidentsRemoveDefaultComponent extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('incidents', function(Blueprint $table)
|
||||
{
|
||||
DB::statement("ALTER TABLE `incidents` CHANGE `component_id` `component_id` TINYINT(4) NOT NULL DEFAULT '0';");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('incidents', function(Blueprint $table)
|
||||
{
|
||||
DB::statement("ALTER TABLE `incidents` CHANGE `component_id` `component_id` TINYINT(4) NOT NULL DEFAULT '1';");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,13 +9,13 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
|
||||
|
||||
protected $rules = [
|
||||
'user_id' => 'required|integer',
|
||||
'component_id' => 'required|integer',
|
||||
'component_id' => 'integer',
|
||||
'name' => 'required',
|
||||
'status' => 'required|integer',
|
||||
'message' => 'required',
|
||||
];
|
||||
|
||||
protected $fillable = ['component_id', 'name', 'status', 'message'];
|
||||
protected $fillable = ['user_id', 'component_id', 'name', 'status', 'message'];
|
||||
|
||||
protected $appends = ['humanStatus'];
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function() {
|
||||
Route::get('/', ['as' => 'dashboard', 'uses' => 'DashboardController@showDashboard']);
|
||||
Route::post('/', 'DashboardController@createIncidentAction');
|
||||
|
||||
Route::get('components', ['as' => 'dashboard.components', 'uses' => 'DashboardController@showComponents']);
|
||||
Route::get('incidents', ['as' => 'dashboard.incidents', 'uses' => 'DashboardController@showIncidents']);
|
||||
Route::get('metrics', ['as' => 'dashboard.metrics', 'uses' => 'DashboardController@showMetrics']);
|
||||
|
||||
@@ -9,14 +9,59 @@
|
||||
<div class="col-sm-12">
|
||||
<div role='tabpanel'>
|
||||
<ul class="nav nav-tabs" role='tablist'>
|
||||
<li role='presentation' class='active'><a data-toggle='tab' role='tab' href="#tab-1">Tab 1</a></li>
|
||||
<li role='presentation'><a data-toggle='tab' role='tab' href="#tab-2">Tab 2</a></li>
|
||||
<li role='presentation'><a data-toggle='tab' role='tab' href="#tab-3">Tab 3</a></li>
|
||||
<li role='presentation' class='active'><a data-toggle='tab' role='tab' href="#create-incident">Create an Incident</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div role='tabpanel' class='tab-pane active' id="tab-1">Foo</div>
|
||||
<div role='tabpanel' class='tab-pane' id="tab-2">Bar</div>
|
||||
<div role='tabpanel' class='tab-pane' id="tab-3">Baz</div>
|
||||
<div role='tabpanel' class='tab-pane active' id="create-incident">
|
||||
<div class='row'>
|
||||
<div class='col-md-12'>
|
||||
<h3>Create an Incident</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='row'>
|
||||
<div class='col-md-12'>
|
||||
@if($incident = Session::get('incident'))
|
||||
<div class='alert alert-{{ $incident->isValid() ? "success" : "error" }}'>
|
||||
@if($incident->isValid())
|
||||
<strong>Awesome.</strong> Incident added.
|
||||
@else
|
||||
<strong>Whoops.</strong> Something went wrong with the incident.
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{ Form::open(['name' => 'IncidentForm', 'class' => 'form-vertical', 'role' => 'form']) }}
|
||||
<fieldset>
|
||||
<div class='form-group'>
|
||||
<label for='incident-name'>Incident Name</label>
|
||||
<input type='text' class='form-control' name='incident[name]' id='incident-name' required />
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='incident-name'>Incident Status</label><br />
|
||||
<label class='radio-inline'>
|
||||
<input type='radio' name='incident[status]' value='1' /> {{ Lang::get('cachet.incident.status')[1] }}
|
||||
</label>
|
||||
<label class='radio-inline'>
|
||||
<input type='radio' name='incident[status]' value='2' /> {{ Lang::get('cachet.incident.status')[2] }}
|
||||
</label>
|
||||
<label class='radio-inline'>
|
||||
<input type='radio' name='incident[status]' value='3' /> {{ Lang::get('cachet.incident.status')[3] }}
|
||||
</label>
|
||||
<label class='radio-inline'>
|
||||
<input type='radio' name='incident[status]' value='4' /> {{ Lang::get('cachet.incident.status')[4] }}
|
||||
</label>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label>Message</label>
|
||||
<textarea name='incident[message]' class='form-control' rows='5'></textarea>
|
||||
</div>
|
||||
</fieldset>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user