Settings can now be updated

This commit is contained in:
James Brooks
2014-12-20 17:50:47 +00:00
parent 39441245b3
commit 77913b59db
4 changed files with 43 additions and 16 deletions

View File

@@ -116,4 +116,27 @@ class DashboardController extends Controller {
'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;
}
$setting = Setting::firstOrCreate([
'name' => $settingName,
])->update([
'value' => $settingValue
]);
}
return Redirect::back();
}
}

View File

@@ -1,6 +1,8 @@
<?php
class Setting extends Eloquent {
protected $fillable = ['name', 'value'];
/**
* Returns a setting from the database.
* @param string $settingName

View File

@@ -17,4 +17,5 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function() {
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');
});

View File

@@ -6,16 +6,16 @@
</div>
<div class="row">
<div class="col-sm-12">
<form>
<h3>Cachet Settings <i>Not working yet.</i></h3>
<form name='SettingsForm' class='form-vertical' role='form' action='/dashboard/settings' method='POST'>
<h3>Cachet Settings</h3>
<fieldset>
<div class='form-group'>
<label>Site Name</label>
<input type='text' class='form-control' value='{{ Setting::get("app_name") }}' required />
<input type='text' class='form-control' name='app_name' value='{{ Setting::get("app_name") }}' required />
</div>
<div class='form-group'>
<label>Site URL</label>
<input type='text' class='form-control' value='{{ Setting::get("app_domain") }}' required />
<input type='text' class='form-control' name='app_domain' value='{{ Setting::get("app_domain") }}' required />
</div>
</fieldset>
@@ -28,11 +28,11 @@
<fieldset>
<div class='form-group'>
<label>Allowed Domains <em>Comma Seperated</em></label>
<textarea class='form-control' name='settings[security][allowed_domains]' rows='5' placeholder='http://cachet.io, http://cachet.herokuapp.com'>{{ Setting::get('allowed_domains') }}</textarea>
<textarea class='form-control' name='allowed_domains' rows='5' placeholder='http://cachet.io, http://cachet.herokuapp.com'>{{ Setting::get('allowed_domains') }}</textarea>
</div>
<div class='form-group'>
<label>Disallowed Domains <em>Comma Seperated</em></label>
<textarea class='form-control' name='settings[security][disallowed_domains]' rows='5' placeholder='http://cachetfake.io, http://cachetfake.herokuapp.com'>{{ Setting::get('disallowed_domains') }}</textarea>
<textarea class='form-control' name='disallowed_domains' rows='5' placeholder='http://cachetfake.io, http://cachetfake.herokuapp.com'>{{ Setting::get('disallowed_domains') }}</textarea>
</div>
</fieldset>
@@ -44,26 +44,27 @@
<h3>Theme</h3>
<fieldset>
<div class='form-group'>
<label>Background Colour</label>
<input type='text' class='form-control' />
<label>Background Color</label>
<input type='text' class='form-control' name='style.background_color' value='{{ Setting::get("style_background_color") }}' />
</div>
<div class='form-group'>
<label>Text Colour</label>
<input type='text' class='form-control' />
<label>Text Color</label>
<input type='text' class='form-control' name='style.text_color' value='{{ Setting::get("style_text_color") }}' />
</div>
<div class='form-group'>
<label>Success Warning Colour</label>
<input type='text' class='form-control' />
<label>Success Warning Color</label>
<input type='text' class='form-control' name='style.success_warning_color' value='{{ Setting::get("style_success_warning_color") }}' />
</div>
<div class='form-group'>
<label>Error Warning Colour</label>
<input type='text' class='form-control' />
<label>Error Warning Color</label>
<input type='text' class='form-control' name='style.error_warning_color' value='{{ Setting::get("style_error_warning_color") }}' />
</div>
<div class='form-group'>
<label>Info Warning Colour</label>
<input type='text' class='form-control' />
<label>Info Warning Color</label>
<input type='text' class='form-control' name='style.info_warning_color' value='{{ Setting::get("style_info_warning_color") }}' />
</div>
</fieldset>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>