got piping for updating settings working. still kinda crunchy.
parent
37b75e1740
commit
e0ba70d475
@ -1,18 +1 @@
|
|||||||
{
|
{"url":"http://fipamo.local","title":"This is Fipamo, bro","description":"The most chill blog framework ever.","theme":"default","private":"false","email":{"smtp":{"domain":"","email":"","password":""},"mailgun":{"domain":"","api-key":""}}}
|
||||||
"url": "http://fipamo.local/",
|
|
||||||
"title": "this is the title",
|
|
||||||
"description":"The most chill blog framework ever.",
|
|
||||||
"theme": "default",
|
|
||||||
"private": false,
|
|
||||||
"email": {
|
|
||||||
"smtp": {
|
|
||||||
"domain":"",
|
|
||||||
"email": "",
|
|
||||||
"password": ""
|
|
||||||
},
|
|
||||||
"mailgun": {
|
|
||||||
"domain": "",
|
|
||||||
"api-key": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,66 @@
|
|||||||
|
import DataUtils,
|
||||||
|
{
|
||||||
|
REQUEST_TYPE_GET,
|
||||||
|
REQUEST_TYPE_PUT,
|
||||||
|
REQUEST_TYPE_POST,
|
||||||
|
REQUEST_TYPE_DELETE,
|
||||||
|
CONTENT_TYPE_JSON,
|
||||||
|
CONTENT_TYPE_FORM
|
||||||
|
}
|
||||||
|
from '../../../../../brain//tools/utilities/DataUtils';
|
||||||
|
import StringUtils from '../../../../../brain//tools/utilities/StringUtils';
|
||||||
|
import DateUtils from '../../../../../brain/tools/utilities/DateUtils';
|
||||||
|
import * as DataEvent from '../../../../../brain/tools/events/DataEvent';
|
||||||
|
export default class SettingsActions
|
||||||
|
{
|
||||||
|
//--------------------------
|
||||||
|
// constructor
|
||||||
|
//--------------------------
|
||||||
|
constructor()
|
||||||
|
{
|
||||||
|
this.dataUtils = new DataUtils();
|
||||||
|
this.dateUtils = new DateUtils();
|
||||||
|
}
|
||||||
|
//--------------------------
|
||||||
|
// methods
|
||||||
|
//--------------------------
|
||||||
|
save()
|
||||||
|
{
|
||||||
|
let self = this;
|
||||||
|
let handle = document.getElementById('settings-handle').value;
|
||||||
|
let email = document.getElementById('settings-email').value;
|
||||||
|
let url = document.getElementById('settings-url').value;
|
||||||
|
let title = document.getElementById('settings-title').value;
|
||||||
|
let desc = document.getElementById('settings-desc').innerHTML;
|
||||||
|
let privacy = document.getElementById('privacy-toggle').getAttribute('data-private');
|
||||||
|
let selected = "";
|
||||||
|
let selects = document.querySelectorAll('.theme-select');
|
||||||
|
for (var i = 0, length = selects.length; i < length; i++)
|
||||||
|
{
|
||||||
|
if (selects[i].getAttribute('data-enabled') == "true") selected = selects[i].id;
|
||||||
|
}
|
||||||
|
let settingsData = {
|
||||||
|
handle: handle,
|
||||||
|
email: email,
|
||||||
|
url: url,
|
||||||
|
title: title,
|
||||||
|
descriptions: desc,
|
||||||
|
private: privacy,
|
||||||
|
theme: selected
|
||||||
|
}
|
||||||
|
return new Promise(function(resolve, reject)
|
||||||
|
{
|
||||||
|
self.dataUtils.request('/api/settings/sync', DataEvent.SETTINGS_UPDATED, REQUEST_TYPE_POST, CONTENT_TYPE_JSON, settingsData).then((response) =>
|
||||||
|
{
|
||||||
|
console.log("RESPONSE", response)
|
||||||
|
resolve(response)
|
||||||
|
}).catch((err) =>
|
||||||
|
{
|
||||||
|
reject(err);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//--------------------------
|
||||||
|
// event handlers
|
||||||
|
//--------------------------
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
import SettingsActions from "../actions/SettingsActions";
|
||||||
|
export default class SettingsIndex
|
||||||
|
{
|
||||||
|
//--------------------------
|
||||||
|
// constructor
|
||||||
|
//--------------------------
|
||||||
|
constructor()
|
||||||
|
{
|
||||||
|
this.start();
|
||||||
|
}
|
||||||
|
//--------------------------
|
||||||
|
// methods
|
||||||
|
//--------------------------
|
||||||
|
start()
|
||||||
|
{
|
||||||
|
document.getElementById('save-toggle').addEventListener('click', f => new SettingsActions().save().then(response =>
|
||||||
|
{
|
||||||
|
console.log(response);
|
||||||
|
}).catch(err =>
|
||||||
|
{
|
||||||
|
console.log(err);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
//--------------------------
|
||||||
|
// event handlers
|
||||||
|
//--------------------------
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "default",
|
"name": "default",
|
||||||
"display-name":"Fipama Oh Won",
|
"display-name":"Fipamo Oh Won",
|
||||||
"author": "Are0h",
|
"author": "Are0h",
|
||||||
"description": "The most dangerous default theme in the known universe.",
|
"description": "The most dangerous default theme in the known universe.",
|
||||||
"version": "1.0.0"
|
"version": "1.0.0"
|
||||||
|
Loading…
Reference in New Issue