removed unnecessary api requests
parent
2b79a52275
commit
a699fd1926
@ -1,29 +1,30 @@
|
|||||||
import FipamoAdminAPI from '../../libraries/FipamoAdminAPI';
|
import FipamoAdminAPI from "../../libraries/FipamoAdminAPI";
|
||||||
import Notficaton from '../ui/Notifications';
|
import Notficaton from "../ui/Notifications";
|
||||||
const admin = new FipamoAdminAPI();
|
|
||||||
const notify = new Notficaton();
|
const notify = new Notficaton();
|
||||||
export default class Mailer {
|
export default class Mailer {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor() {}
|
constructor() {
|
||||||
//--------------------------
|
this.admin = new FipamoAdminAPI();
|
||||||
// methods
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
sendMail() {
|
// methods
|
||||||
let mailData = {
|
//--------------------------
|
||||||
content: 'This is a test email'
|
sendMail() {
|
||||||
};
|
let mailData = {
|
||||||
admin
|
content: "This is a test email",
|
||||||
.sendMail(mailData)
|
};
|
||||||
.then(result => {
|
this.admin
|
||||||
notify.alert(result.message, true);
|
.sendMail(mailData)
|
||||||
})
|
.then((result) => {
|
||||||
.catch(err => {
|
notify.alert(result.message, true);
|
||||||
notify.alert(err.message, false);
|
})
|
||||||
});
|
.catch((err) => {
|
||||||
}
|
notify.alert(err.message, false);
|
||||||
//--------------------------
|
});
|
||||||
// event handlers
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
// event handlers
|
||||||
|
//--------------------------
|
||||||
}
|
}
|
||||||
|
@ -1,64 +1,68 @@
|
|||||||
import FipamoAdminAPI from '../../libraries/FipamoAdminAPI';
|
import FipamoAdminAPI from "../../libraries/FipamoAdminAPI";
|
||||||
import NavActions from '../actions/NavActions';
|
import NavActions from "../actions/NavActions";
|
||||||
import * as DataEvent from '../events/DataEvent';
|
import * as DataEvent from "../events/DataEvent";
|
||||||
import Notifications from '../ui/Notifications';
|
import Notifications from "../ui/Notifications";
|
||||||
import Sortable from 'sortablejs';
|
import Sortable from "sortablejs";
|
||||||
const notify = new Notifications();
|
const notify = new Notifications();
|
||||||
const admin = new FipamoAdminAPI();
|
|
||||||
export default class NavIndex {
|
export default class NavIndex {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor() {
|
constructor() {
|
||||||
this.start();
|
this.admin = new FipamoAdminAPI();
|
||||||
}
|
this.start();
|
||||||
//--------------------------
|
}
|
||||||
// methods
|
//--------------------------
|
||||||
//--------------------------
|
// methods
|
||||||
start() {
|
//--------------------------
|
||||||
Sortable.create(document.getElementById('nav-pages'), {
|
start() {
|
||||||
onUpdate: () => {
|
let self = this;
|
||||||
new NavActions().syncMenu().then(data => {
|
Sortable.create(document.getElementById("nav-pages"), {
|
||||||
notify.alert('Updating Menu', null);
|
onUpdate: () => {
|
||||||
admin.syncNav(data).then(r => {
|
new NavActions().syncMenu().then((data) => {
|
||||||
if (r.type == DataEvent.MENU_UPDATED) {
|
notify.alert("Updating Menu", null);
|
||||||
notify.alert(r.message, true);
|
self.admin.syncNav(data).then((r) => {
|
||||||
} else {
|
if (r.type == DataEvent.MENU_UPDATED) {
|
||||||
notify.alert(r.message, true);
|
notify.alert(r.message, true);
|
||||||
}
|
} else {
|
||||||
});
|
notify.alert(r.message, true);
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
var nav = document.querySelectorAll('.nav-btn');
|
},
|
||||||
for (var i = 0, length = nav.length; i < length; i++) {
|
});
|
||||||
nav[i].addEventListener('click', e => this.handleNavButton(e), false);
|
var nav = document.querySelectorAll(".nav-btn");
|
||||||
}
|
for (var i = 0, length = nav.length; i < length; i++) {
|
||||||
}
|
nav[i].addEventListener("click", (e) => this.handleNavButton(e), false);
|
||||||
//--------------------------
|
}
|
||||||
// event handlers
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
handleNavButton(e) {
|
// event handlers
|
||||||
let id = '';
|
//--------------------------
|
||||||
switch (e.target.id) {
|
handleNavButton(e) {
|
||||||
case 'remove-item':
|
let id = "";
|
||||||
id = e.target.getAttribute('data-id');
|
let self = this;
|
||||||
new NavActions().removeItem(id);
|
switch (e.target.id) {
|
||||||
new NavActions().syncMenu().then(data => {
|
case "remove-item":
|
||||||
data.remove = e.target.getAttribute('data-uuid');
|
id = e.target.getAttribute("data-id");
|
||||||
notify.alert('Editing Menu', null);
|
new NavActions().removeItem(id);
|
||||||
admin.syncNav(data).then(r => {
|
new NavActions().syncMenu().then((data) => {
|
||||||
if (r.type == DataEvent.MENU_UPDATED) {
|
data.remove = e.target.getAttribute("data-uuid");
|
||||||
notify.alert(r.message, true);
|
notify.alert("Editing Menu", null);
|
||||||
} else {
|
self.admin.syncNav(data).then((r) => {
|
||||||
notify.alert(r.message, true);
|
if (r.type == DataEvent.MENU_UPDATED) {
|
||||||
}
|
notify.alert(r.message, true);
|
||||||
});
|
} else {
|
||||||
});
|
notify.alert(r.message, true);
|
||||||
break;
|
}
|
||||||
case 'edit-item':
|
});
|
||||||
window.location = '/@/dashboard/page/edit/' + e.target.getAttribute('data-id');
|
});
|
||||||
break;
|
break;
|
||||||
}
|
case "edit-item":
|
||||||
}
|
window.location =
|
||||||
|
"/@/dashboard/page/edit/" + e.target.getAttribute("data-id");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,221 +1,223 @@
|
|||||||
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
|
||||||
start() {
|
//--------------------------
|
||||||
let self = this;
|
start() {
|
||||||
//handle save button
|
let self = this;
|
||||||
document.getElementById('save-toggle').addEventListener('click', () =>
|
//handle save button
|
||||||
new SettingsActions()
|
document.getElementById("save-toggle").addEventListener("click", () =>
|
||||||
.getInfo()
|
new SettingsActions()
|
||||||
.then(data => {
|
.getInfo()
|
||||||
notify.alert('Saving Settings', null);
|
.then((data) => {
|
||||||
admin.syncSettings(data).then(r => {
|
notify.alert("Saving Settings", null);
|
||||||
if (r.type == DataEvent.SETTINGS_UPDATED) {
|
self.admin.syncSettings(data).then((r) => {
|
||||||
notify.alert(r.message, true);
|
if (r.type == DataEvent.SETTINGS_UPDATED) {
|
||||||
} else {
|
notify.alert(r.message, true);
|
||||||
notify.alert(r.message, true);
|
} else {
|
||||||
}
|
notify.alert(r.message, true);
|
||||||
});
|
}
|
||||||
})
|
});
|
||||||
.catch(() => {
|
})
|
||||||
//console.log(err);
|
.catch(() => {
|
||||||
})
|
//console.log(err);
|
||||||
);
|
})
|
||||||
//handle set up image uploads
|
);
|
||||||
document.getElementById('avatar').addEventListener('click', () => {
|
//handle set up image uploads
|
||||||
document.getElementById('avatar-upload').click();
|
document.getElementById("avatar").addEventListener("click", () => {
|
||||||
});
|
document.getElementById("avatar-upload").click();
|
||||||
document.getElementById('background').addEventListener('click', () => {
|
});
|
||||||
document.getElementById('background-upload').click();
|
document.getElementById("background").addEventListener("click", () => {
|
||||||
});
|
document.getElementById("background-upload").click();
|
||||||
document.getElementById('restore-backup').addEventListener('click', () => {
|
});
|
||||||
document.getElementById('backup-upload').click();
|
document.getElementById("restore-backup").addEventListener("click", () => {
|
||||||
});
|
document.getElementById("backup-upload").click();
|
||||||
document.getElementById('avatar-upload').addEventListener(
|
});
|
||||||
'change',
|
document.getElementById("avatar-upload").addEventListener(
|
||||||
e => {
|
"change",
|
||||||
self.handleImageUpload(e.target.id, e.target.files);
|
(e) => {
|
||||||
},
|
self.handleImageUpload(e.target.id, e.target.files);
|
||||||
false
|
},
|
||||||
);
|
false
|
||||||
document.getElementById('background-upload').addEventListener(
|
);
|
||||||
'change',
|
document.getElementById("background-upload").addEventListener(
|
||||||
e => {
|
"change",
|
||||||
self.handleImageUpload(e.target.id, e.target.files);
|
(e) => {
|
||||||
},
|
self.handleImageUpload(e.target.id, e.target.files);
|
||||||
false
|
},
|
||||||
);
|
false
|
||||||
document.getElementById('backup-upload').addEventListener(
|
);
|
||||||
'change',
|
document.getElementById("backup-upload").addEventListener(
|
||||||
e => {
|
"change",
|
||||||
self.handleBackup(e);
|
(e) => {
|
||||||
},
|
self.handleBackup(e);
|
||||||
false
|
},
|
||||||
);
|
false
|
||||||
//handle privacy toggle
|
);
|
||||||
//document
|
//handle privacy toggle
|
||||||
//.getElementById('privacy-toggle')
|
//document
|
||||||
//.addEventListener('click', e => this.togglePrivacy(e));
|
//.getElementById('privacy-toggle')
|
||||||
document
|
//.addEventListener('click', e => this.togglePrivacy(e));
|
||||||
.getElementById('render-toggle')
|
document
|
||||||
.addEventListener('click', e => this.toggleRender(e));
|
.getElementById("render-toggle")
|
||||||
document.getElementById('send-mail').addEventListener('click', e => this.handleMailer(e));
|
.addEventListener("click", (e) => this.toggleRender(e));
|
||||||
document
|
document
|
||||||
.getElementById('publish-pages')
|
.getElementById("send-mail")
|
||||||
.addEventListener('click', e => this.handlePublished(e));
|
.addEventListener("click", (e) => this.handleMailer(e));
|
||||||
//handle theme toggle
|
document
|
||||||
let themeBtns = document.querySelectorAll('.theme-select');
|
.getElementById("publish-pages")
|
||||||
for (var i = 0, length = themeBtns.length; i < length; i++) {
|
.addEventListener("click", (e) => this.handlePublished(e));
|
||||||
themeBtns[i].addEventListener('click', e => this.handleThemes(e));
|
//handle theme toggle
|
||||||
}
|
let themeBtns = document.querySelectorAll(".theme-select");
|
||||||
//handle mail options
|
for (var i = 0, length = themeBtns.length; i < length; i++) {
|
||||||
let mailBtn = document.querySelectorAll('.mail-option');
|
themeBtns[i].addEventListener("click", (e) => this.handleThemes(e));
|
||||||
for (i = 0, length = mailBtn.length; i < length; i++) {
|
}
|
||||||
mailBtn[i].addEventListener('click', e => this.handleMailOptions(e));
|
//handle mail options
|
||||||
}
|
let mailBtn = document.querySelectorAll(".mail-option");
|
||||||
//handle backup
|
for (i = 0, length = mailBtn.length; i < length; i++) {
|
||||||
document
|
mailBtn[i].addEventListener("click", (e) => this.handleMailOptions(e));
|
||||||
.getElementById('create-backup')
|
}
|
||||||
.addEventListener('click', e => this.handleBackup(e));
|
//handle backup
|
||||||
|
document
|
||||||
|
.getElementById("create-backup")
|
||||||
|
.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
|
||||||
//--------------------------
|
//--------------------------
|
||||||
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() {
|
||||||
mailer.sendMail();
|
let mailer = new Mailer();
|
||||||
}
|
mailer.sendMail();
|
||||||
handleThemes(e) {
|
}
|
||||||
e.stopPropagation();
|
handleThemes(e) {
|
||||||
e.preventDefault();
|
e.stopPropagation();
|
||||||
let themes = document.querySelectorAll('.theme-select');
|
e.preventDefault();
|
||||||
for (var i = 0, length = themes.length; i < length; i++) {
|
let themes = document.querySelectorAll(".theme-select");
|
||||||
e.target.id == themes[i].id
|
for (var i = 0, length = themes.length; i < length; i++) {
|
||||||
? themes[i].setAttribute('data-enabled', 'true')
|
e.target.id == themes[i].id
|
||||||
: themes[i].setAttribute('data-enabled', 'false');
|
? themes[i].setAttribute("data-enabled", "true")
|
||||||
}
|
: themes[i].setAttribute("data-enabled", "false");
|
||||||
}
|
}
|
||||||
handleMailOptions(e) {
|
}
|
||||||
e.preventDefault();
|
handleMailOptions(e) {
|
||||||
e.stopPropagation();
|
e.preventDefault();
|
||||||
let smtp = document.getElementById('mail-smtp');
|
e.stopPropagation();
|
||||||
let mailgun = document.getElementById('mail-mg');
|
let smtp = document.getElementById("mail-smtp");
|
||||||
let mail = document.querySelectorAll('.mail-option');
|
let mailgun = document.getElementById("mail-mg");
|
||||||
for (var i = 0, length = mail.length; i < length; i++) {
|
let mail = document.querySelectorAll(".mail-option");
|
||||||
if (e.target.id == mail[i].id) {
|
for (var i = 0, length = mail.length; i < length; i++) {
|
||||||
mail[i].setAttribute('data-enabled', 'true');
|
if (e.target.id == mail[i].id) {
|
||||||
if (e.target.id == 'option-smtp') {
|
mail[i].setAttribute("data-enabled", "true");
|
||||||
smtp.setAttribute('data-enabled', 'true');
|
if (e.target.id == "option-smtp") {
|
||||||
mailgun.setAttribute('data-enabled', 'false');
|
smtp.setAttribute("data-enabled", "true");
|
||||||
} else if (e.target.id == 'option-none') {
|
mailgun.setAttribute("data-enabled", "false");
|
||||||
smtp.setAttribute('data-enabled', 'false');
|
} else if (e.target.id == "option-none") {
|
||||||
mailgun.setAttribute('data-enabled', 'false');
|
smtp.setAttribute("data-enabled", "false");
|
||||||
} else {
|
mailgun.setAttribute("data-enabled", "false");
|
||||||
smtp.setAttribute('data-enabled', 'false');
|
} else {
|
||||||
mailgun.setAttribute('data-enabled', 'true');
|
smtp.setAttribute("data-enabled", "false");
|
||||||
}
|
mailgun.setAttribute("data-enabled", "true");
|
||||||
} else {
|
}
|
||||||
mail[i].setAttribute('data-enabled', 'false');
|
} else {
|
||||||
}
|
mail[i].setAttribute("data-enabled", "false");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleImageUpload(type, files) {
|
}
|
||||||
notify.alert('Uploading Image... ', null);
|
handleImageUpload(type, files) {
|
||||||
admin
|
notify.alert("Uploading Image... ", null);
|
||||||
.imageUpload(type, files)
|
this.admin
|
||||||
.then(r => {
|
.imageUpload(type, files)
|
||||||
if (r.type == DataEvent.AVATAR_UPLOADED) {
|
.then((r) => {
|
||||||
notify.alert(r.message, true);
|
if (r.type == DataEvent.AVATAR_UPLOADED) {
|
||||||
document.getElementById('avatar').src = r.url;
|
notify.alert(r.message, true);
|
||||||
} else {
|
document.getElementById("avatar").src = r.url;
|
||||||
notify.alert(r.message, true);
|
} else {
|
||||||
document.getElementById('background').src = r.url;
|
notify.alert(r.message, true);
|
||||||
}
|
document.getElementById("background").src = r.url;
|
||||||
})
|
}
|
||||||
.catch(() => {
|
})
|
||||||
//console.log(err)
|
.catch(() => {
|
||||||
});
|
//console.log(err)
|
||||||
}
|
});
|
||||||
handlePublished(e) {
|
}
|
||||||
e.preventDefault();
|
handlePublished(e) {
|
||||||
e.stopPropagation();
|
e.preventDefault();
|
||||||
let task = { task: 'publish all pages' };
|
e.stopPropagation();
|
||||||
notify.alert('Publishing site...', null);
|
let task = { task: "publish all pages" };
|
||||||
admin
|
notify.alert("Publishing site...", null);
|
||||||
.publishSite(task)
|
this.admin
|
||||||
.then(r => {
|
.publishSite(task)
|
||||||
notify.alert(r.message, true);
|
.then((r) => {
|
||||||
})
|
notify.alert(r.message, true);
|
||||||
.catch(err => {
|
})
|
||||||
notify.alert(err, false);
|
.catch((err) => {
|
||||||
});
|
notify.alert(err, false);
|
||||||
}
|
});
|
||||||
handleBackup(e) {
|
}
|
||||||
e.preventDefault();
|
handleBackup(e) {
|
||||||
e.stopPropagation();
|
e.preventDefault();
|
||||||
notify.alert('Creating backup', null);
|
e.stopPropagation();
|
||||||
admin
|
notify.alert("Creating backup", null);
|
||||||
.handleBackup(e.target.id, e.target.files)
|
this.admin
|
||||||
.then(r => {
|
.handleBackup(e.target.id, e.target.files)
|
||||||
notify.alert(r.message, true);
|
.then((r) => {
|
||||||
})
|
notify.alert(r.message, true);
|
||||||
.catch(err => {
|
})
|
||||||
notify.alert(err, false);
|
.catch((err) => {
|
||||||
});
|
notify.alert(err, false);
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue