settings syncing active
turned on the abiity to save settings to config file via the settings page the current member session needs to updated by the data coming in but that will be handled by a specific member service that hasn't been built yet, so just commenting it out for now also fixed a minor bug that was stopping the save on render toggle from working correctly, so now it's saving and updating the status properly now
This commit is contained in:
parent
eda377aba3
commit
252059df19
7 changed files with 53 additions and 13 deletions
|
@ -20,8 +20,14 @@ class SettingsAPIController extends Controller
|
|||
|
||||
public function publish(Request $request)
|
||||
{
|
||||
$body = json_decode($request->getContent());
|
||||
$result = $this->render->publishAll();
|
||||
return response()->json($result)->header('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
public function sync(Request $request)
|
||||
{
|
||||
$body = json_decode($request->getContent());
|
||||
$result = $this->settings->sync($body);
|
||||
return response()->json($result)->header('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,13 +54,26 @@ class DocService
|
|||
public static function writeSettings($fileContents)
|
||||
{
|
||||
$fileLocation = env('SETTINGS_PATH');
|
||||
if (!is_file($fileLocation)) {
|
||||
file_put_contents($fileLocation, json_encode($fileContents));
|
||||
} else {
|
||||
($new = fopen($fileLocation, 'w')) or die('Unable to open file!');
|
||||
fwrite($new, json_encode($fileContents));
|
||||
fclose($new);
|
||||
$message = [];
|
||||
try {
|
||||
if (!is_file($fileLocation)) {
|
||||
file_put_contents($fileLocation, json_encode($fileContents));
|
||||
} else {
|
||||
($new = fopen($fileLocation, 'w')) or die('Unable to open file!');
|
||||
fwrite($new, json_encode($fileContents));
|
||||
fclose($new);
|
||||
}$message = [
|
||||
'message' => "Settings Synced. You're doing great!",
|
||||
'type' => 'settingsUpdated',
|
||||
];
|
||||
} catch (Error $error) {
|
||||
$message = [
|
||||
'message' => "Settings Not Synced. We'll figure it out",
|
||||
'type' => 'settingsUpdated',
|
||||
];
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
public static function writeHTML($location, $html, $path = null)
|
||||
|
|
|
@ -67,4 +67,28 @@ class SettingsService
|
|||
$this->settings['global'][$key] = $data;
|
||||
$this->docs->writeSettings($this->settings);
|
||||
}
|
||||
|
||||
public function sync($data)
|
||||
{
|
||||
//dd($data->global->renderOnSave);
|
||||
$settings = $this->getSettings();
|
||||
$settings['global']['base_url'] = $data->global->base_url;
|
||||
$settings['global']['title'] = $data->global->title;
|
||||
$settings['global']['descriptions'] = $data->global->descriptions;
|
||||
$settings['global']['private'] = $data->global->private;
|
||||
$settings['global']['renderOnSave'] = $data->global->renderOnSave;
|
||||
$settings['global']['theme'] = $data->global->theme;
|
||||
$settings['global']['externalAPI'] = $data->global->externalAPI;
|
||||
$settings['global']['dynamicRender'] = $data->global->dynamicRender;
|
||||
|
||||
//TODO: This is for to be created MemberServices
|
||||
//Member::updateData('handle', $data['member']['handle']);
|
||||
//Member::updateData('email', $data['member']['email']);
|
||||
|
||||
$settings['email']['active'] = $data->email->active;
|
||||
$settings['email']['smtp'] = $data->email->smtp;
|
||||
$settings['email']['mailgun'] = $data->email->mailgun;
|
||||
|
||||
return $this->docs->writeSettings($settings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ export default class SettingsActions {
|
|||
//let privacy = document.getElementById('privacy-toggle').getAttribute('data-private');
|
||||
let render = document.getElementById('render-toggle').getAttribute('data-render');
|
||||
let background = document
|
||||
.querySelector('[role="background"]')
|
||||
.querySelector('.background')
|
||||
.style.backgroundImage.slice(4, -1)
|
||||
.replace(/"/g, '');
|
||||
let selected = '';
|
||||
|
|
|
@ -154,7 +154,7 @@ class FipamoAdminAPI {
|
|||
this._request(
|
||||
this.baseURL ? this.baseURL + url : url,
|
||||
TASK_SETTINGS_WRITE,
|
||||
REQUEST_TYPE_POST,
|
||||
REQUEST_TYPE_PUT,
|
||||
CONTENT_TYPE_JSON,
|
||||
data
|
||||
)
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
@php
|
||||
$renderOnSave = false;
|
||||
@endphp
|
||||
|
||||
<div class="submenu">
|
||||
<button id="save-toggle" title="save settings">
|
||||
<i class="ti ti-device-floppy"></i>
|
||||
|
|
|
@ -26,3 +26,4 @@ Route::post("/v1/page/create", [PageAPIController::class, 'create']);
|
|||
Route::post("/v1/files", [FileUploadAPIController::class, 'upload']);
|
||||
//settings
|
||||
Route::put("/v1/settings/publish", [SettingsAPIController::class, 'publish']);
|
||||
Route::put("/v1/settings/sync", [SettingsAPIController::class, 'sync']);
|
||||
|
|
Loading…
Reference in a new issue