got piping for updating settings working. still kinda crunchy.
This commit is contained in:
parent
37b75e1740
commit
e0ba70d475
13 changed files with 307 additions and 86 deletions
|
@ -12,7 +12,8 @@ import RightsManager,
|
||||||
OBJECT_PROJECT_CLIENT,
|
OBJECT_PROJECT_CLIENT,
|
||||||
OBJECT_PROJECT_FOLIO,
|
OBJECT_PROJECT_FOLIO,
|
||||||
OBJECT_BOOKMARK,
|
OBJECT_BOOKMARK,
|
||||||
OBJECT_POST
|
OBJECT_POST,
|
||||||
|
OBJECT_SETTINGS
|
||||||
}
|
}
|
||||||
from '../../tools/utilities/RightsManager';
|
from '../../tools/utilities/RightsManager';
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
@ -57,69 +58,49 @@ router.post("/sync", (req, res, next) =>
|
||||||
let payload = req.body;
|
let payload = req.body;
|
||||||
Models.User.findById(req.session.user.id).then((user) =>
|
Models.User.findById(req.session.user.id).then((user) =>
|
||||||
{
|
{
|
||||||
if (rightsManager.check(user.role, OBJECT_POST, TASK_UPDATE))
|
if (rightsManager.check(user.role, OBJECT_SETTINGS, TASK_UPDATE))
|
||||||
{
|
{
|
||||||
for (let index = 0; index < payload.length; index++)
|
fs.readJson('site-settings.json').then(obj =>
|
||||||
{
|
{
|
||||||
const item = payload[index];
|
if (user.hande != payload.handle || user.email != payload.email)
|
||||||
Models.FreshPost.findOne(
|
|
||||||
{
|
{
|
||||||
where:
|
user.update(
|
||||||
{
|
{
|
||||||
"post":
|
handle: payload.handle,
|
||||||
{
|
email: payload.email
|
||||||
[Op.contains]:
|
}).then(updated =>
|
||||||
{
|
|
||||||
uuid: item.post.uuid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).then(found =>
|
|
||||||
{
|
|
||||||
let buffed = sanitize(item.post.plaintext,
|
|
||||||
{
|
{
|
||||||
allowedTags: ['del', 'a', 'iframe', 'img', ],
|
console.log("UPDATED")
|
||||||
allowedAttributes:
|
}).catch(err =>
|
||||||
{
|
{
|
||||||
a: ['href', 'name', 'target'],
|
console.log("ERR", err);
|
||||||
img: ['src'],
|
|
||||||
iframe: ['height', 'width', 'src', 'frameborder', 'allow', 'allowfullscreen']
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
buffed = new StringUtils().decodeHTML(buffed);
|
}
|
||||||
item.post.plaintext = buffed;
|
else
|
||||||
item.post.html = md.render(buffed,
|
{
|
||||||
|
console.log("USER NOT UPDATED")
|
||||||
|
}
|
||||||
|
obj.url = payload.url;
|
||||||
|
obj.title = payload.title;
|
||||||
|
obj.description = payload.descriptions;
|
||||||
|
obj.private = payload.private;
|
||||||
|
obj.theme = payload.theme;
|
||||||
|
fs.writeJson('site-settings.json', obj).then(() =>
|
||||||
|
{
|
||||||
|
res.json(
|
||||||
{
|
{
|
||||||
html: true,
|
message: DataEvent.SETTINGS_UPDATED
|
||||||
xhtmlOut: true,
|
|
||||||
});
|
});
|
||||||
if (!_.isEqual(item.post, found.post))
|
|
||||||
{
|
|
||||||
found.update(item).then(updated =>
|
|
||||||
{
|
|
||||||
console.log("UPDATED", updated);
|
|
||||||
}).catch(err =>
|
|
||||||
{
|
|
||||||
//console.log("***ERROR***", err);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//chilld
|
|
||||||
}
|
|
||||||
}).catch(err =>
|
}).catch(err =>
|
||||||
{
|
{
|
||||||
//console.log("***ERRRORZ****", err);
|
console.error(err)
|
||||||
Models.FreshPost.create(item).then(fresh =>
|
|
||||||
{
|
|
||||||
//console.log(fresh)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
//console.log("PAYLOAD", payload);
|
||||||
res.json(
|
//console.log("SETTINGS", obj);
|
||||||
|
}).catch(err =>
|
||||||
{
|
{
|
||||||
message: "postsSynced"
|
console.error(err)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -130,7 +111,6 @@ router.post("/sync", (req, res, next) =>
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
/***
|
/***
|
||||||
UPLOAD AVATAR
|
UPLOAD AVATAR
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -47,10 +47,12 @@ var postDashboard = require('./routes/back/dash_posts');
|
||||||
var settingsDashboard = require('./routes/back/dash_settings');
|
var settingsDashboard = require('./routes/back/dash_settings');
|
||||||
//api
|
//api
|
||||||
var postLibrary = require('./api/content/posts');
|
var postLibrary = require('./api/content/posts');
|
||||||
|
var settings = require('./api/content/settings');
|
||||||
var mailer = require('./api/content/mailer');
|
var mailer = require('./api/content/mailer');
|
||||||
// API PATHS
|
// API PATHS
|
||||||
|
|
||||||
app.use('/api/post', postLibrary);
|
app.use('/api/post', postLibrary);
|
||||||
|
app.use('/api/settings', settings);
|
||||||
// PAGES
|
// PAGES
|
||||||
app.use('/', front);
|
app.use('/', front);
|
||||||
app.use('/@/dashboard', back);
|
app.use('/@/dashboard', back);
|
||||||
|
|
|
@ -27,11 +27,11 @@ router.get('/', function(req, res)
|
||||||
(theme.name == settings.theme) ? themes.push(
|
(theme.name == settings.theme) ? themes.push(
|
||||||
{
|
{
|
||||||
theme: theme,
|
theme: theme,
|
||||||
current: true
|
current: "true"
|
||||||
}): themes.push(
|
}): themes.push(
|
||||||
{
|
{
|
||||||
theme: theme,
|
theme: theme,
|
||||||
current: false
|
current: "false"
|
||||||
})
|
})
|
||||||
}).catch(err =>
|
}).catch(err =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@ export const POST_UPDATED = 'postUpdated';
|
||||||
export const POST_DELETED = 'postImageAdded';
|
export const POST_DELETED = 'postImageAdded';
|
||||||
export const POSTS_SYNCED = 'postsSynced';
|
export const POSTS_SYNCED = 'postsSynced';
|
||||||
export const LOCAL_DB_READY = 'localDBReady';
|
export const LOCAL_DB_READY = 'localDBReady';
|
||||||
|
export const SETTINGS_UPDATED = 'settingsUpdated';
|
||||||
class DataEvent
|
class DataEvent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,13 @@ export const roles = {
|
||||||
"delete": true
|
"delete": true
|
||||||
},
|
},
|
||||||
"post":
|
"post":
|
||||||
|
{
|
||||||
|
"create": true,
|
||||||
|
"read": true,
|
||||||
|
"update": true,
|
||||||
|
"delete": true
|
||||||
|
},
|
||||||
|
"settings":
|
||||||
{
|
{
|
||||||
"create": true,
|
"create": true,
|
||||||
"read": true,
|
"read": true,
|
||||||
|
@ -131,6 +138,7 @@ export const OBJECT_PROJECT_CLIENT = 'client_project'
|
||||||
export const OBJECT_PROJECT_FOLIO = 'folio_project'
|
export const OBJECT_PROJECT_FOLIO = 'folio_project'
|
||||||
export const OBJECT_BOOKMARK = 'bookmark'
|
export const OBJECT_BOOKMARK = 'bookmark'
|
||||||
export const OBJECT_POST = 'post'
|
export const OBJECT_POST = 'post'
|
||||||
|
export const OBJECT_SETTINGS = 'settings'
|
||||||
export default class RightsManager
|
export default class RightsManager
|
||||||
{
|
{
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
|
|
@ -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": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
153
themes/dash/assets/js/dash.min.js
vendored
153
themes/dash/assets/js/dash.min.js
vendored
|
@ -197,7 +197,7 @@ exports.default = _default;
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(exports, "__esModule", {
|
||||||
value: true
|
value: true
|
||||||
});
|
});
|
||||||
exports.default = exports.LOCAL_DB_READY = exports.POSTS_SYNCED = exports.POST_DELETED = exports.POST_UPDATED = exports.POST_ADDED = exports.POST_ERROR = exports.FEATURE_IMAGE_ADDED = exports.POST_IMAGE_ADDED = exports.PROJECTS_SORTED = exports.PROJECT_ADDED = exports.PROJECT_UPDATED = exports.ARCHIVES_ENTRY_LOADED = exports.ARCHIVES_PAGE_LOADED = exports.ARCHIVES_JSON_LOADED = exports.HTML_LOADED = exports.SETTINGS_LOADED = exports.IMG_REQUEST_LAME = exports.IMG_REQUEST_GOOD = exports.REQUEST_LAME = exports.REQUEST_GOOD = void 0;
|
exports.default = exports.SETTINGS_UPDATED = exports.LOCAL_DB_READY = exports.POSTS_SYNCED = exports.POST_DELETED = exports.POST_UPDATED = exports.POST_ADDED = exports.POST_ERROR = exports.FEATURE_IMAGE_ADDED = exports.POST_IMAGE_ADDED = exports.PROJECTS_SORTED = exports.PROJECT_ADDED = exports.PROJECT_UPDATED = exports.ARCHIVES_ENTRY_LOADED = exports.ARCHIVES_PAGE_LOADED = exports.ARCHIVES_JSON_LOADED = exports.HTML_LOADED = exports.SETTINGS_LOADED = exports.IMG_REQUEST_LAME = exports.IMG_REQUEST_GOOD = exports.REQUEST_LAME = exports.REQUEST_GOOD = void 0;
|
||||||
|
|
||||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
@ -241,6 +241,8 @@ var POSTS_SYNCED = 'postsSynced';
|
||||||
exports.POSTS_SYNCED = POSTS_SYNCED;
|
exports.POSTS_SYNCED = POSTS_SYNCED;
|
||||||
var LOCAL_DB_READY = 'localDBReady';
|
var LOCAL_DB_READY = 'localDBReady';
|
||||||
exports.LOCAL_DB_READY = LOCAL_DB_READY;
|
exports.LOCAL_DB_READY = LOCAL_DB_READY;
|
||||||
|
var SETTINGS_UPDATED = 'settingsUpdated';
|
||||||
|
exports.SETTINGS_UPDATED = SETTINGS_UPDATED;
|
||||||
|
|
||||||
var DataEvent = function DataEvent() {
|
var DataEvent = function DataEvent() {
|
||||||
_classCallCheck(this, DataEvent);
|
_classCallCheck(this, DataEvent);
|
||||||
|
@ -8290,7 +8292,146 @@ function () {
|
||||||
}();
|
}();
|
||||||
|
|
||||||
exports.default = PostIndex;
|
exports.default = PostIndex;
|
||||||
},{"./PostEditor":"controllers/PostEditor.js"}],"controllers/DashManager.js":[function(require,module,exports) {
|
},{"./PostEditor":"controllers/PostEditor.js"}],"actions/SettingsActions.js":[function(require,module,exports) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.default = void 0;
|
||||||
|
|
||||||
|
var _DataUtils = _interopRequireWildcard(require("../../../../../brain//tools/utilities/DataUtils"));
|
||||||
|
|
||||||
|
var _StringUtils = _interopRequireDefault(require("../../../../../brain//tools/utilities/StringUtils"));
|
||||||
|
|
||||||
|
var _DateUtils = _interopRequireDefault(require("../../../../../brain/tools/utilities/DateUtils"));
|
||||||
|
|
||||||
|
var DataEvent = _interopRequireWildcard(require("../../../../../brain/tools/events/DataEvent"));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||||
|
|
||||||
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||||
|
|
||||||
|
var SettingsActions =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function () {
|
||||||
|
//--------------------------
|
||||||
|
// constructor
|
||||||
|
//--------------------------
|
||||||
|
function SettingsActions() {
|
||||||
|
_classCallCheck(this, SettingsActions);
|
||||||
|
|
||||||
|
this.dataUtils = new _DataUtils.default();
|
||||||
|
this.dateUtils = new _DateUtils.default();
|
||||||
|
} //--------------------------
|
||||||
|
// methods
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
|
||||||
|
_createClass(SettingsActions, [{
|
||||||
|
key: "save",
|
||||||
|
value: function save() {
|
||||||
|
var self = this;
|
||||||
|
var handle = document.getElementById('settings-handle').value;
|
||||||
|
var email = document.getElementById('settings-email').value;
|
||||||
|
var url = document.getElementById('settings-url').value;
|
||||||
|
var title = document.getElementById('settings-title').value;
|
||||||
|
var desc = document.getElementById('settings-desc').innerHTML;
|
||||||
|
var privacy = document.getElementById('privacy-toggle').getAttribute('data-private');
|
||||||
|
var selected = "";
|
||||||
|
var 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
var 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, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_JSON, settingsData).then(function (response) {
|
||||||
|
console.log("RESPONSE", response);
|
||||||
|
resolve(response);
|
||||||
|
}).catch(function (err) {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} //--------------------------
|
||||||
|
// event handlers
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return SettingsActions;
|
||||||
|
}();
|
||||||
|
|
||||||
|
exports.default = SettingsActions;
|
||||||
|
},{"../../../../../brain//tools/utilities/DataUtils":"../../../../brain/tools/utilities/DataUtils.js","../../../../../brain//tools/utilities/StringUtils":"../../../../brain/tools/utilities/StringUtils.js","../../../../../brain/tools/utilities/DateUtils":"../../../../brain/tools/utilities/DateUtils.js","../../../../../brain/tools/events/DataEvent":"../../../../brain/tools/events/DataEvent.js"}],"controllers/SettingsIndex.js":[function(require,module,exports) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
exports.default = void 0;
|
||||||
|
|
||||||
|
var _SettingsActions = _interopRequireDefault(require("../actions/SettingsActions"));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||||
|
|
||||||
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||||
|
|
||||||
|
var SettingsIndex =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function () {
|
||||||
|
//--------------------------
|
||||||
|
// constructor
|
||||||
|
//--------------------------
|
||||||
|
function SettingsIndex() {
|
||||||
|
_classCallCheck(this, SettingsIndex);
|
||||||
|
|
||||||
|
this.start();
|
||||||
|
} //--------------------------
|
||||||
|
// methods
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
|
||||||
|
_createClass(SettingsIndex, [{
|
||||||
|
key: "start",
|
||||||
|
value: function start() {
|
||||||
|
document.getElementById('save-toggle').addEventListener('click', function (f) {
|
||||||
|
return new _SettingsActions.default().save().then(function (response) {
|
||||||
|
console.log(response);
|
||||||
|
}).catch(function (err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} //--------------------------
|
||||||
|
// event handlers
|
||||||
|
//--------------------------
|
||||||
|
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return SettingsIndex;
|
||||||
|
}();
|
||||||
|
|
||||||
|
exports.default = SettingsIndex;
|
||||||
|
},{"../actions/SettingsActions":"actions/SettingsActions.js"}],"controllers/DashManager.js":[function(require,module,exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
@ -8300,6 +8441,8 @@ exports.default = void 0;
|
||||||
|
|
||||||
var _PostIndex = _interopRequireDefault(require("./PostIndex"));
|
var _PostIndex = _interopRequireDefault(require("./PostIndex"));
|
||||||
|
|
||||||
|
var _SettingsIndex = _interopRequireDefault(require("./SettingsIndex"));
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
@ -8340,6 +8483,10 @@ function () {
|
||||||
this.currentDisplay = new _PostIndex.default(page);
|
this.currentDisplay = new _PostIndex.default(page);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'settings':
|
||||||
|
this.currentDisplay = new _SettingsIndex.default();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// just chill
|
// just chill
|
||||||
break;
|
break;
|
||||||
|
@ -8356,7 +8503,7 @@ function () {
|
||||||
}();
|
}();
|
||||||
|
|
||||||
exports.default = DashManager;
|
exports.default = DashManager;
|
||||||
},{"./PostIndex":"controllers/PostIndex.js"}],"Base.js":[function(require,module,exports) {
|
},{"./PostIndex":"controllers/PostIndex.js","./SettingsIndex":"controllers/SettingsIndex.js"}],"Base.js":[function(require,module,exports) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", {
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -6,22 +6,26 @@ block main-content
|
||||||
img(src=member.avi)
|
img(src=member.avi)
|
||||||
input(id="avatar-upload" type="file" name="avatar-image-upload")
|
input(id="avatar-upload" type="file" name="avatar-image-upload")
|
||||||
#member-settings
|
#member-settings
|
||||||
input(type='text', name='handle' class='settings-handle', placeholder='handle', value=member.handle, autofocus)
|
input(type='text', name='handle' id='settings-handle', placeholder='handle', value=member.handle, autofocus)
|
||||||
input(type='text', name='email' class='settings-email', placeholder='email', value=member.email, autofocus)
|
input(type='text', name='email' id='settings-email', placeholder='email', value=member.email, autofocus)
|
||||||
#site-settings
|
#site-settings
|
||||||
label OPTIONS
|
label OPTIONS
|
||||||
br
|
br
|
||||||
input(type='text', name='base-url' class='settings-url', placeholder='url', value=settings.url, autofocus)
|
input(type='text', name='base-url' id='settings-url', placeholder='url', value=settings.url, autofocus)
|
||||||
input(type='text', name='base-title' class='settings-title', placeholder='site title', value=settings.title, autofocus)
|
input(type='text', name='base-title' id='settings-title', placeholder='site title', value=settings.title, autofocus)
|
||||||
textarea(id="settings_desc" type='text', name='settings_desc' class='settings-dec', placeholder='description stuff', autofocus)
|
textarea(id="settings-desc" type='text', name='settings_desc' class='settings-dec', placeholder='description stuff', autofocus)
|
||||||
=settings.description
|
=settings.description
|
||||||
button#privacy-toggle SITE IS PUBLIC
|
button#privacy-toggle(data-private=settings.private) SITE IS PUBLIC
|
||||||
#theme-settings
|
#theme-settings
|
||||||
label THEMES
|
label THEMES
|
||||||
br
|
br
|
||||||
- var index = 0;
|
- var index = 0;
|
||||||
- for ( index; index < themes.length; index++)
|
- for ( index; index < themes.length; index++)
|
||||||
a.theme-select(href="#" id=themes[index].theme.name)
|
-if(themes[index].current == "true")
|
||||||
|
a.theme-select(href="#" id=themes[index].theme.name, data-enabled="true")
|
||||||
|
= themes[index].theme["display-name"]
|
||||||
|
-else
|
||||||
|
a.theme-select(href="#" id=themes[index].theme.name, data-enabled="false")
|
||||||
= themes[index].theme["display-name"]
|
= themes[index].theme["display-name"]
|
||||||
button#save-toggle SAVE SETTINGS
|
button#save-toggle SAVE SETTINGS
|
||||||
|
|
||||||
|
|
66
themes/dash/src/com/actions/SettingsActions.js
Normal file
66
themes/dash/src/com/actions/SettingsActions.js
Normal file
|
@ -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
|
||||||
|
//--------------------------
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
import PostIndex from './PostIndex';
|
import PostIndex from './PostIndex';
|
||||||
|
import SettingsIndex from './SettingsIndex';
|
||||||
|
|
||||||
export default class DashManager {
|
export default class DashManager {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
@ -23,6 +24,9 @@ export default class DashManager {
|
||||||
case 'posts':
|
case 'posts':
|
||||||
this.currentDisplay = new PostIndex(page);
|
this.currentDisplay = new PostIndex(page);
|
||||||
break;
|
break;
|
||||||
|
case 'settings':
|
||||||
|
this.currentDisplay = new SettingsIndex();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// just chill
|
// just chill
|
||||||
|
|
27
themes/dash/src/com/controllers/SettingsIndex.js
Normal file
27
themes/dash/src/com/controllers/SettingsIndex.js
Normal file
|
@ -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 a new issue