|
|
@ -1,17 +1,16 @@
|
|
|
|
import SettingsActions from '../actions/SettingsActions';
|
|
|
|
import SettingsActions from "../actions/SettingsActions";
|
|
|
|
import FipamoAdminAPI from '../../libraries/FipamoAdminAPI';
|
|
|
|
import FipamoAdminAPI from "../../libraries/FipamoAdminAPI";
|
|
|
|
import * as DataEvent from '../../../src/com/events/DataEvent';
|
|
|
|
import * as DataEvent from "../../../src/com/events/DataEvent";
|
|
|
|
import Mailer from '../actions/Mailer';
|
|
|
|
import Mailer from "../actions/Mailer";
|
|
|
|
import Notifications from '../ui/Notifications';
|
|
|
|
import Notifications from "../ui/Notifications";
|
|
|
|
const admin = new FipamoAdminAPI();
|
|
|
|
|
|
|
|
const notify = new Notifications();
|
|
|
|
const notify = new Notifications();
|
|
|
|
const mailer = new Mailer();
|
|
|
|
|
|
|
|
export default class SettingsIndex {
|
|
|
|
export default class SettingsIndex {
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
// constructor
|
|
|
|
// constructor
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
constructor() {
|
|
|
|
constructor() {
|
|
|
|
this.start();
|
|
|
|
this.start();
|
|
|
|
|
|
|
|
this.admin = new FipamoAdminAPI();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
// methods
|
|
|
|
// methods
|
|
|
@ -19,12 +18,12 @@ export default class SettingsIndex {
|
|
|
|
start() {
|
|
|
|
start() {
|
|
|
|
let self = this;
|
|
|
|
let self = this;
|
|
|
|
//handle save button
|
|
|
|
//handle save button
|
|
|
|
document.getElementById('save-toggle').addEventListener('click', () =>
|
|
|
|
document.getElementById("save-toggle").addEventListener("click", () =>
|
|
|
|
new SettingsActions()
|
|
|
|
new SettingsActions()
|
|
|
|
.getInfo()
|
|
|
|
.getInfo()
|
|
|
|
.then(data => {
|
|
|
|
.then((data) => {
|
|
|
|
notify.alert('Saving Settings', null);
|
|
|
|
notify.alert("Saving Settings", null);
|
|
|
|
admin.syncSettings(data).then(r => {
|
|
|
|
self.admin.syncSettings(data).then((r) => {
|
|
|
|
if (r.type == DataEvent.SETTINGS_UPDATED) {
|
|
|
|
if (r.type == DataEvent.SETTINGS_UPDATED) {
|
|
|
|
notify.alert(r.message, true);
|
|
|
|
notify.alert(r.message, true);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -37,32 +36,32 @@ export default class SettingsIndex {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
);
|
|
|
|
);
|
|
|
|
//handle set up image uploads
|
|
|
|
//handle set up image uploads
|
|
|
|
document.getElementById('avatar').addEventListener('click', () => {
|
|
|
|
document.getElementById("avatar").addEventListener("click", () => {
|
|
|
|
document.getElementById('avatar-upload').click();
|
|
|
|
document.getElementById("avatar-upload").click();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
document.getElementById('background').addEventListener('click', () => {
|
|
|
|
document.getElementById("background").addEventListener("click", () => {
|
|
|
|
document.getElementById('background-upload').click();
|
|
|
|
document.getElementById("background-upload").click();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
document.getElementById('restore-backup').addEventListener('click', () => {
|
|
|
|
document.getElementById("restore-backup").addEventListener("click", () => {
|
|
|
|
document.getElementById('backup-upload').click();
|
|
|
|
document.getElementById("backup-upload").click();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
document.getElementById('avatar-upload').addEventListener(
|
|
|
|
document.getElementById("avatar-upload").addEventListener(
|
|
|
|
'change',
|
|
|
|
"change",
|
|
|
|
e => {
|
|
|
|
(e) => {
|
|
|
|
self.handleImageUpload(e.target.id, e.target.files);
|
|
|
|
self.handleImageUpload(e.target.id, e.target.files);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
false
|
|
|
|
false
|
|
|
|
);
|
|
|
|
);
|
|
|
|
document.getElementById('background-upload').addEventListener(
|
|
|
|
document.getElementById("background-upload").addEventListener(
|
|
|
|
'change',
|
|
|
|
"change",
|
|
|
|
e => {
|
|
|
|
(e) => {
|
|
|
|
self.handleImageUpload(e.target.id, e.target.files);
|
|
|
|
self.handleImageUpload(e.target.id, e.target.files);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
false
|
|
|
|
false
|
|
|
|
);
|
|
|
|
);
|
|
|
|
document.getElementById('backup-upload').addEventListener(
|
|
|
|
document.getElementById("backup-upload").addEventListener(
|
|
|
|
'change',
|
|
|
|
"change",
|
|
|
|
e => {
|
|
|
|
(e) => {
|
|
|
|
self.handleBackup(e);
|
|
|
|
self.handleBackup(e);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
false
|
|
|
|
false
|
|
|
@ -72,30 +71,32 @@ export default class SettingsIndex {
|
|
|
|
//.getElementById('privacy-toggle')
|
|
|
|
//.getElementById('privacy-toggle')
|
|
|
|
//.addEventListener('click', e => this.togglePrivacy(e));
|
|
|
|
//.addEventListener('click', e => this.togglePrivacy(e));
|
|
|
|
document
|
|
|
|
document
|
|
|
|
.getElementById('render-toggle')
|
|
|
|
.getElementById("render-toggle")
|
|
|
|
.addEventListener('click', e => this.toggleRender(e));
|
|
|
|
.addEventListener("click", (e) => this.toggleRender(e));
|
|
|
|
document.getElementById('send-mail').addEventListener('click', e => this.handleMailer(e));
|
|
|
|
|
|
|
|
document
|
|
|
|
document
|
|
|
|
.getElementById('publish-pages')
|
|
|
|
.getElementById("send-mail")
|
|
|
|
.addEventListener('click', e => this.handlePublished(e));
|
|
|
|
.addEventListener("click", (e) => this.handleMailer(e));
|
|
|
|
|
|
|
|
document
|
|
|
|
|
|
|
|
.getElementById("publish-pages")
|
|
|
|
|
|
|
|
.addEventListener("click", (e) => this.handlePublished(e));
|
|
|
|
//handle theme toggle
|
|
|
|
//handle theme toggle
|
|
|
|
let themeBtns = document.querySelectorAll('.theme-select');
|
|
|
|
let themeBtns = document.querySelectorAll(".theme-select");
|
|
|
|
for (var i = 0, length = themeBtns.length; i < length; i++) {
|
|
|
|
for (var i = 0, length = themeBtns.length; i < length; i++) {
|
|
|
|
themeBtns[i].addEventListener('click', e => this.handleThemes(e));
|
|
|
|
themeBtns[i].addEventListener("click", (e) => this.handleThemes(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//handle mail options
|
|
|
|
//handle mail options
|
|
|
|
let mailBtn = document.querySelectorAll('.mail-option');
|
|
|
|
let mailBtn = document.querySelectorAll(".mail-option");
|
|
|
|
for (i = 0, length = mailBtn.length; i < length; i++) {
|
|
|
|
for (i = 0, length = mailBtn.length; i < length; i++) {
|
|
|
|
mailBtn[i].addEventListener('click', e => this.handleMailOptions(e));
|
|
|
|
mailBtn[i].addEventListener("click", (e) => this.handleMailOptions(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//handle backup
|
|
|
|
//handle backup
|
|
|
|
document
|
|
|
|
document
|
|
|
|
.getElementById('create-backup')
|
|
|
|
.getElementById("create-backup")
|
|
|
|
.addEventListener('click', e => this.handleBackup(e));
|
|
|
|
.addEventListener("click", (e) => this.handleBackup(e));
|
|
|
|
|
|
|
|
|
|
|
|
document
|
|
|
|
document
|
|
|
|
.getElementById('reindex-pages')
|
|
|
|
.getElementById("reindex-pages")
|
|
|
|
.addEventListener('click', e => this.handleReindex(e));
|
|
|
|
.addEventListener("click", (e) => this.handleReindex(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
// event handlers
|
|
|
|
// event handlers
|
|
|
@ -103,73 +104,74 @@ export default class SettingsIndex {
|
|
|
|
togglePrivacy(e) {
|
|
|
|
togglePrivacy(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
if (e.target.getAttribute('data-private') == 'false') {
|
|
|
|
if (e.target.getAttribute("data-private") == "false") {
|
|
|
|
e.target.setAttribute('data-private', 'true');
|
|
|
|
e.target.setAttribute("data-private", "true");
|
|
|
|
e.target.innerHTML = 'SITE IS PUBLIC';
|
|
|
|
e.target.innerHTML = "SITE IS PUBLIC";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
e.target.setAttribute('data-private', 'false');
|
|
|
|
e.target.setAttribute("data-private", "false");
|
|
|
|
e.target.innerHTML = 'SITE IS PRIVATE';
|
|
|
|
e.target.innerHTML = "SITE IS PRIVATE";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
toggleRender(e) {
|
|
|
|
toggleRender(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
if (e.target.getAttribute('data-render') == 'false') {
|
|
|
|
if (e.target.getAttribute("data-render") == "false") {
|
|
|
|
e.target.setAttribute('data-render', 'true');
|
|
|
|
e.target.setAttribute("data-render", "true");
|
|
|
|
//e.target.innerHTML = 'RENDER PAGES ON SAVE';
|
|
|
|
//e.target.innerHTML = 'RENDER PAGES ON SAVE';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
e.target.setAttribute('data-render', 'false');
|
|
|
|
e.target.setAttribute("data-render", "false");
|
|
|
|
//e.target.innerHTML = "DON'T RENDER PAGES ON SAVE";
|
|
|
|
//e.target.innerHTML = "DON'T RENDER PAGES ON SAVE";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handleMailer() {
|
|
|
|
handleMailer() {
|
|
|
|
|
|
|
|
let mailer = new Mailer();
|
|
|
|
mailer.sendMail();
|
|
|
|
mailer.sendMail();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handleThemes(e) {
|
|
|
|
handleThemes(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
let themes = document.querySelectorAll('.theme-select');
|
|
|
|
let themes = document.querySelectorAll(".theme-select");
|
|
|
|
for (var i = 0, length = themes.length; i < length; i++) {
|
|
|
|
for (var i = 0, length = themes.length; i < length; i++) {
|
|
|
|
e.target.id == themes[i].id
|
|
|
|
e.target.id == themes[i].id
|
|
|
|
? themes[i].setAttribute('data-enabled', 'true')
|
|
|
|
? themes[i].setAttribute("data-enabled", "true")
|
|
|
|
: themes[i].setAttribute('data-enabled', 'false');
|
|
|
|
: themes[i].setAttribute("data-enabled", "false");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handleMailOptions(e) {
|
|
|
|
handleMailOptions(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
let smtp = document.getElementById('mail-smtp');
|
|
|
|
let smtp = document.getElementById("mail-smtp");
|
|
|
|
let mailgun = document.getElementById('mail-mg');
|
|
|
|
let mailgun = document.getElementById("mail-mg");
|
|
|
|
let mail = document.querySelectorAll('.mail-option');
|
|
|
|
let mail = document.querySelectorAll(".mail-option");
|
|
|
|
for (var i = 0, length = mail.length; i < length; i++) {
|
|
|
|
for (var i = 0, length = mail.length; i < length; i++) {
|
|
|
|
if (e.target.id == mail[i].id) {
|
|
|
|
if (e.target.id == mail[i].id) {
|
|
|
|
mail[i].setAttribute('data-enabled', 'true');
|
|
|
|
mail[i].setAttribute("data-enabled", "true");
|
|
|
|
if (e.target.id == 'option-smtp') {
|
|
|
|
if (e.target.id == "option-smtp") {
|
|
|
|
smtp.setAttribute('data-enabled', 'true');
|
|
|
|
smtp.setAttribute("data-enabled", "true");
|
|
|
|
mailgun.setAttribute('data-enabled', 'false');
|
|
|
|
mailgun.setAttribute("data-enabled", "false");
|
|
|
|
} else if (e.target.id == 'option-none') {
|
|
|
|
} else if (e.target.id == "option-none") {
|
|
|
|
smtp.setAttribute('data-enabled', 'false');
|
|
|
|
smtp.setAttribute("data-enabled", "false");
|
|
|
|
mailgun.setAttribute('data-enabled', 'false');
|
|
|
|
mailgun.setAttribute("data-enabled", "false");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
smtp.setAttribute('data-enabled', 'false');
|
|
|
|
smtp.setAttribute("data-enabled", "false");
|
|
|
|
mailgun.setAttribute('data-enabled', 'true');
|
|
|
|
mailgun.setAttribute("data-enabled", "true");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
mail[i].setAttribute('data-enabled', 'false');
|
|
|
|
mail[i].setAttribute("data-enabled", "false");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handleImageUpload(type, files) {
|
|
|
|
handleImageUpload(type, files) {
|
|
|
|
notify.alert('Uploading Image... ', null);
|
|
|
|
notify.alert("Uploading Image... ", null);
|
|
|
|
admin
|
|
|
|
this.admin
|
|
|
|
.imageUpload(type, files)
|
|
|
|
.imageUpload(type, files)
|
|
|
|
.then(r => {
|
|
|
|
.then((r) => {
|
|
|
|
if (r.type == DataEvent.AVATAR_UPLOADED) {
|
|
|
|
if (r.type == DataEvent.AVATAR_UPLOADED) {
|
|
|
|
notify.alert(r.message, true);
|
|
|
|
notify.alert(r.message, true);
|
|
|
|
document.getElementById('avatar').src = r.url;
|
|
|
|
document.getElementById("avatar").src = r.url;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
notify.alert(r.message, true);
|
|
|
|
notify.alert(r.message, true);
|
|
|
|
document.getElementById('background').src = r.url;
|
|
|
|
document.getElementById("background").src = r.url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
.catch(() => {
|
|
|
@ -179,27 +181,27 @@ export default class SettingsIndex {
|
|
|
|
handlePublished(e) {
|
|
|
|
handlePublished(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
let task = { task: 'publish all pages' };
|
|
|
|
let task = { task: "publish all pages" };
|
|
|
|
notify.alert('Publishing site...', null);
|
|
|
|
notify.alert("Publishing site...", null);
|
|
|
|
admin
|
|
|
|
this.admin
|
|
|
|
.publishSite(task)
|
|
|
|
.publishSite(task)
|
|
|
|
.then(r => {
|
|
|
|
.then((r) => {
|
|
|
|
notify.alert(r.message, true);
|
|
|
|
notify.alert(r.message, true);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
.catch((err) => {
|
|
|
|
notify.alert(err, false);
|
|
|
|
notify.alert(err, false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handleBackup(e) {
|
|
|
|
handleBackup(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
notify.alert('Creating backup', null);
|
|
|
|
notify.alert("Creating backup", null);
|
|
|
|
admin
|
|
|
|
this.admin
|
|
|
|
.handleBackup(e.target.id, e.target.files)
|
|
|
|
.handleBackup(e.target.id, e.target.files)
|
|
|
|
.then(r => {
|
|
|
|
.then((r) => {
|
|
|
|
notify.alert(r.message, true);
|
|
|
|
notify.alert(r.message, true);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
.catch((err) => {
|
|
|
|
notify.alert(err, false);
|
|
|
|
notify.alert(err, false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -207,14 +209,14 @@ export default class SettingsIndex {
|
|
|
|
handleReindex(e) {
|
|
|
|
handleReindex(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
let task = { task: 'cleanup pages indexes' };
|
|
|
|
let task = { task: "cleanup pages indexes" };
|
|
|
|
notify.alert('Cleaning up page indexes', null);
|
|
|
|
notify.alert("Cleaning up page indexes", null);
|
|
|
|
admin
|
|
|
|
this.admin
|
|
|
|
.handleReindex(task)
|
|
|
|
.handleReindex(task)
|
|
|
|
.then(r => {
|
|
|
|
.then((r) => {
|
|
|
|
notify.alert(r.message, true);
|
|
|
|
notify.alert(r.message, true);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
.catch((err) => {
|
|
|
|
notify.alert(err, false);
|
|
|
|
notify.alert(err, false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|