privacy and theme toggles up and running

sql-version-freeze
Ro 6 years ago
parent 2f439d11ff
commit e3d5146881

@ -85,7 +85,7 @@ router.post("/sync", (req, res, next) =>
obj.description = payload.descriptions;
obj.private = payload.private;
obj.theme = payload.theme;
obj.background = payload.background;
obj.background = payload.background; //TODO: make this url relative
fs.writeJson('site-settings.json', obj).then(() =>
{
res.json(
@ -195,11 +195,11 @@ router.post('/add-feature-background', function(req, res, next)
}
else
{
var postImage = req.files[0].path;
var bgImage = req.files[0].path;
return res.json(
{
message: DataEvent.SITE_BACKGROUND_UPLOADED,
url: postImage.substr(7, postImage.length)
url: bgImage.substr(7, bgImage.length)
});
}
});

@ -8368,7 +8368,7 @@ function () {
};
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);
//console.log("RESPONSE", response)
resolve(response);
}).catch(function (err) {
reject(err);
@ -8427,14 +8427,18 @@ function () {
_createClass(SettingsIndex, [{
key: "start",
value: function start() {
var self = this;
var _this = this;
var self = this; //handle save button
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);
});
});
}); //handle set up image uploads
document.getElementById('avatar').addEventListener('click', function (e) {
document.getElementById('avatar-upload').click();
});
@ -8446,11 +8450,48 @@ function () {
}, false);
document.getElementById('background-upload').addEventListener('change', function (e) {
self.handleImageUpload(e.target.id, e.target.files);
}, false);
}, false); //handle privacy toggle
document.getElementById("privacy-toggle").addEventListener("click", function (e) {
return _this.togglePrivacy(e);
}); //handle theme toggle
var themeBtns = document.querySelectorAll('.theme-select');
for (var i = 0, length = themeBtns.length; i < length; i++) {
themeBtns[i].addEventListener('click', function (e) {
return _this.handleThemes(e);
});
}
} //--------------------------
// event handlers
//--------------------------
}, {
key: "togglePrivacy",
value: function togglePrivacy(e) {
e.stopPropagation();
e.preventDefault();
if (e.target.getAttribute('data-private') == "false") {
e.target.setAttribute('data-private', 'true');
e.target.innerHTML = "SITE IS PUBLIC";
} else {
e.target.setAttribute('data-private', 'false');
e.target.innerHTML = "SITE IS PRIVATE";
}
}
}, {
key: "handleThemes",
value: function handleThemes(e) {
e.stopPropagation();
e.preventDefault();
var themes = document.querySelectorAll('.theme-select');
for (var i = 0, length = themes.length; i < length; i++) {
e.target.id == themes[i].id ? themes[i].setAttribute('data-enabled', 'true') : themes[i].setAttribute('data-enabled', 'false');
}
}
}, {
key: "handleImageUpload",
value: function handleImageUpload(type, files) {

File diff suppressed because one or more lines are too long

@ -12,7 +12,7 @@ block main-content
input(type='text', name='handle' id='settings-handle', placeholder='handle', value=member.handle, autofocus)
input(type='text', name='email' id='settings-email', placeholder='email', value=member.email, autofocus)
#site-settings
label OPTIONS
label SITE INFO
br
#site-background
img#background(src=settings.background, alt="image for site background", for="background-upload")
@ -21,7 +21,11 @@ block main-content
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)
=settings.description
button#privacy-toggle(data-private=settings.private) SITE IS PUBLIC
button#privacy-toggle(data-private=settings.private)
-if (settings.private == 'false')
| SITE IS PRIVATE
-else
| SITE IS PUBLIC
#theme-settings
label THEMES
br
@ -30,7 +34,7 @@ block main-content
-if(themes[index].current == "true")
a.theme-select(href="#" id=themes[index].theme.name, data-enabled="true")
= themes[index].theme["display-name"]
svg(viewBox="0 0 20 20" class="icons")
//svg(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-check')
-else
a.theme-select(href="#" id=themes[index].theme.name, data-enabled="false")

@ -54,7 +54,7 @@ export default class SettingsActions
{
self.dataUtils.request('/api/settings/sync', DataEvent.SETTINGS_UPDATED, REQUEST_TYPE_POST, CONTENT_TYPE_JSON, settingsData).then((response) =>
{
console.log("RESPONSE", response)
//console.log("RESPONSE", response)
resolve(response)
}).catch((err) =>
{

@ -26,6 +26,7 @@ export default class SettingsIndex
start()
{
let self = this;
//handle save button
document.getElementById('save-toggle').addEventListener('click', f => new SettingsActions().save().then(response =>
{
console.log(response);
@ -33,6 +34,7 @@ export default class SettingsIndex
{
console.log(err);
}));
//handle set up image uploads
document.getElementById('avatar').addEventListener('click', e =>
{
document.getElementById('avatar-upload').click();
@ -49,10 +51,42 @@ export default class SettingsIndex
{
self.handleImageUpload(e.target.id, e.target.files);
}, false);
//handle privacy toggle
document.getElementById("privacy-toggle").addEventListener("click", e=>this.togglePrivacy(e));
//handle theme toggle
let themeBtns = document.querySelectorAll('.theme-select');
for (var i = 0, length = themeBtns.length; i < length; i++)
{
themeBtns[i].addEventListener('click', e=>this.handleThemes(e));
}
}
//--------------------------
// event handlers
//--------------------------
togglePrivacy(e)
{
e.stopPropagation();
e.preventDefault();
if(e.target.getAttribute('data-private') == "false")
{
e.target.setAttribute('data-private', 'true');
e.target.innerHTML = "SITE IS PUBLIC"
}else{
e.target.setAttribute('data-private', 'false');
e.target.innerHTML = "SITE IS PRIVATE"
}
}
handleThemes(e){
e.stopPropagation();
e.preventDefault();
let themes = document.querySelectorAll('.theme-select');
for (var i = 0, length = themes.length; i < length; i++)
{
(e.target.id == themes[i].id) ? themes[i].setAttribute('data-enabled', 'true') : themes[i].setAttribute('data-enabled', 'false')
}
}
handleImageUpload(type, files)
{
let url = ""

Loading…
Cancel
Save