diff --git a/app/controllers/DashComponentController.php b/app/controllers/DashComponentController.php new file mode 100644 index 00000000..2175dd89 --- /dev/null +++ b/app/controllers/DashComponentController.php @@ -0,0 +1,47 @@ +with([ + 'pageTitle' => 'Components - Dashboard', + 'components' => $components + ]); + } + + /** + * Shows the add component view. + * @return \Illuminate\View\View + */ + public function showAddComponent() { + return View::make('dashboard.component-add')->with([ + 'pageTitle' => 'Add Component - Dashboard', + ]); + } + + /** + * Creates a new component. + * @return \Illuminate\Http\RedirectResponse + */ + public function createComponentAction() { + $_component = Input::get('component'); + $component = Component::create($_component); + + return Redirect::back()->with('component', $component); + } + + /** + * Deletes a given component. + * @param Component $component + * @return \Illuminate\Http\RedirectResponse + */ + public function deleteComponentAction(Component $component) { + $component->delete(); + return Redirect::back(); + } +} diff --git a/app/controllers/DashIncidentController.php b/app/controllers/DashIncidentController.php new file mode 100644 index 00000000..04ce212f --- /dev/null +++ b/app/controllers/DashIncidentController.php @@ -0,0 +1,37 @@ +with([ + 'pageTitle' => 'Incidents - Dashboard', + 'incidents' => $incidents + ]); + } + + /** + * Shows the add incident view. + * @return \Illuminate\View\View + */ + public function showAddIncident() { + return View::make('dashboard.incident-add')->with([ + 'pageTitle' => 'Add Incident - Dashboard', + ]); + } + + /** + * Creates a new incident. + * @return \Illuminate\Http\RedirectResponse + */ + public function createIncidentAction() { + $_incident = Input::get('incident'); + $incident = Incident::create($_incident); + + return Redirect::back()->with('incident', $incident); + } +} diff --git a/app/controllers/DashSettingsController.php b/app/controllers/DashSettingsController.php new file mode 100644 index 00000000..b71c9049 --- /dev/null +++ b/app/controllers/DashSettingsController.php @@ -0,0 +1,40 @@ +with([ + 'pageTitle' => 'Settings - Dashboard' + ]); + } + + /** + * Updates the statsu page settings. + * @return \Illuminate\View\View + */ + public function postSettings() { + $settings = Input::all(); + + foreach ($settings as $settingName => $settingValue) { + // Don't save empty settings. Kinda useless... + if (!$settingValue) { + continue; + } + + if (strstr($settingName, 'style_')) { + $settingValue = str_replace('#', '', $settingValue); + } + + $setting = Setting::firstOrCreate([ + 'name' => $settingName, + ])->update([ + 'value' => $settingValue + ]); + } + + return Redirect::back(); + } +} diff --git a/app/controllers/DashboardController.php b/app/controllers/DashboardController.php index b6972bfc..5a192a24 100644 --- a/app/controllers/DashboardController.php +++ b/app/controllers/DashboardController.php @@ -9,84 +9,6 @@ class DashboardController extends Controller { return View::make('dashboard.index'); } - /** - * Shows the components view. - * @return \Illuminate\View\View - */ - public function showComponents() { - $components = Component::all(); - - return View::make('dashboard.components')->with([ - 'pageTitle' => 'Components - Dashboard', - 'components' => $components - ]); - } - - /** - * Shows the add component view. - * @return \Illuminate\View\View - */ - public function showAddComponent() { - return View::make('dashboard.component-add')->with([ - 'pageTitle' => 'Add Component - Dashboard', - ]); - } - - /** - * Creates a new component. - * @return \Illuminate\Http\RedirectResponse - */ - public function createComponentAction() { - $_component = Input::get('component'); - $component = Component::create($_component); - - return Redirect::back()->with('component', $component); - } - - /** - * Deletes a given component. - * @param Component $component - * @return \Illuminate\Http\RedirectResponse - */ - public function deleteComponentAction(Component $component) { - $component->delete(); - return Redirect::back(); - } - - /** - * Shows the incidents view. - * @return \Illuminate\View\View - */ - public function showIncidents() { - $incidents = Incident::all(); - - return View::make('dashboard.incidents')->with([ - 'pageTitle' => 'Incidents - Dashboard', - 'incidents' => $incidents - ]); - } - - /** - * Shows the add incident view. - * @return \Illuminate\View\View - */ - public function showAddIncident() { - return View::make('dashboard.incident-add')->with([ - 'pageTitle' => 'Add Incident - Dashboard', - ]); - } - - /** - * Creates a new incident. - * @return \Illuminate\Http\RedirectResponse - */ - public function createIncidentAction() { - $_incident = Input::get('incident'); - $incident = Incident::create($_incident); - - return Redirect::back()->with('incident', $incident); - } - /** * Shows the metrics view. * @return \Illuminate\View\View @@ -106,41 +28,4 @@ class DashboardController extends Controller { 'pageTitle' => 'Notifications - Dashboard' ]); } - - /** - * Shows the settings view. - * @return \Illuminate\View\View - */ - public function showSettings() { - return View::make('dashboard.settings')->with([ - 'pageTitle' => 'Settings - Dashboard' - ]); - } - - /** - * Updates the statsu page settings. - * @return \Illuminate\View\View - */ - public function postSettings() { - $settings = Input::all(); - - foreach ($settings as $settingName => $settingValue) { - // Don't save empty settings. Kinda useless... - if (!$settingValue) { - continue; - } - - if (strstr($settingName, 'style_')) { - $settingValue = str_replace('#', '', $settingValue); - } - - $setting = Setting::firstOrCreate([ - 'name' => $settingName, - ])->update([ - 'value' => $settingValue - ]); - } - - return Redirect::back(); - } } diff --git a/app/routes/dashboard.php b/app/routes/dashboard.php index 7a06f770..aa42face 100644 --- a/app/routes/dashboard.php +++ b/app/routes/dashboard.php @@ -4,18 +4,18 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function() { Route::get('/', ['as' => 'dashboard', 'uses' => 'DashboardController@showDashboard']); // TODO: Switch for Route::controller? - Route::get('components', ['as' => 'dashboard.components', 'uses' => 'DashboardController@showComponents']); - Route::get('components/add', ['as' => 'dashboard.components.add', 'uses' => 'DashboardController@showAddComponent']); - Route::post('components/add', 'DashboardController@createComponentAction'); - Route::get('components/{component}/delete', 'DashboardController@deleteComponentAction'); + Route::get('components', ['as' => 'dashboard.components', 'uses' => 'DashComponentController@showComponents']); + Route::get('components/add', ['as' => 'dashboard.components.add', 'uses' => 'DashComponentController@showAddComponent']); + Route::post('components/add', 'DashComponentController@createComponentAction'); + Route::get('components/{component}/delete', 'DashComponentController@deleteComponentAction'); - Route::get('incidents', ['as' => 'dashboard.incidents', 'uses' => 'DashboardController@showIncidents']); - Route::get('incidents/add', ['as' => 'dashboard.incidents.add', 'uses' => 'DashboardController@showAddIncident']); - Route::post('incidents/add', 'DashboardController@createIncidentAction'); + 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('metrics', ['as' => 'dashboard.metrics', 'uses' => 'DashboardController@showMetrics']); Route::get('notifications', ['as' => 'dashboard.notifications', 'uses' => 'DashboardController@showNotifications']); Route::get('status-page', ['as' => 'dashboard.status-page', 'uses' => 'DashboardController@showStatusPage']); - Route::get('settings', ['as' => 'dashboard.settings', 'uses' => 'DashboardController@showSettings']); - Route::post('settings', 'DashboardController@postSettings'); + Route::get('settings', ['as' => 'dashboard.settings', 'uses' => 'DashSettingsController@showSettings']); + Route::post('settings', 'DashSettingsController@postSettings'); });