ignore button clicks when processing requests

pull/84/head
Ro 4 years ago
parent 08d034a8d1
commit 7002ba8014

File diff suppressed because one or more lines are too long

@ -12,6 +12,7 @@ export default class Base {
// constructor
//--------------------------
constructor() {
this.processing = false;
this.start();
}
@ -47,14 +48,18 @@ export default class Base {
// event handlers
//--------------------------
handleLogin(e) {
if (this.processing) return;
let self = this;
e.stopPropagation();
e.preventDefault();
let authForm = data.formDataToJSON(document.getElementById("login"));
notify.alert("Looking, hold up", null);
let api = new FipamoApi();
this.processing = true;
api
.login(authForm)
.then((response) => {
self.processing = false;
if (response.type === DataEvent.REQUEST_LAME) {
notify.alert(response.message, false);
} else {
@ -66,21 +71,27 @@ export default class Base {
}
})
.catch((err) => {
self.processing = false;
notify.alert(err, false);
});
}
handleSetup(e) {
if (this.processing) return;
let self = this;
e.stopPropagation();
e.preventDefault();
let setUpForm = data.formDataToJSON(document.getElementById("init-form"));
let api = new FipamoApi();
this.processing = true;
api
.init(setUpForm)
.then((response) => {
if (response.type === DataEvent.API_INIT_LAME) {
self.processing = false;
notify.alert(response.message, false);
} else {
self.processing = false;
notify.alert(response.message, true);
setTimeout(() => {
window.location = "/dashboard";
@ -88,21 +99,27 @@ export default class Base {
}
})
.catch((err) => {
self.processing = false;
notify.alert(err, false);
});
}
handleRestore(e) {
if (this.processing) return;
let self = this;
e.stopPropagation();
e.preventDefault();
let api = new FipamoApi();
var form = document.getElementById("init-restore");
this.processing = true;
api
.handleInitRestore(form)
.then((response) => {
if (response.type === DataEvent.REQUEST_LAME) {
self.processing = false;
notify.alert(response.message, false);
} else {
self.processing = false;
notify.alert(response.message, true);
setTimeout(() => {
window.location = "/dashboard";
@ -110,6 +127,7 @@ export default class Base {
}
})
.catch((err) => {
self.processing = false;
notify.alert(err, false);
});
}

@ -10,6 +10,7 @@ export default class NavIndex {
// constructor
//--------------------------
constructor() {
this.processing = false;
this.admin = new FipamoAdminAPI();
this.start();
}
@ -41,6 +42,7 @@ export default class NavIndex {
// event handlers
//--------------------------
handleNavButton(e) {
if (this.processing) return;
let id = "";
let self = this;
switch (e.target.id) {
@ -50,7 +52,9 @@ export default class NavIndex {
new NavActions().syncMenu().then((data) => {
data.remove = e.target.getAttribute("data-uuid");
notify.alert("Editing Menu", null);
self.processing = true;
self.admin.syncNav(data).then((r) => {
self.processing = false;
if (r.type == DataEvent.MENU_UPDATED) {
notify.alert(r.message, true);
} else {
@ -60,6 +64,7 @@ export default class NavIndex {
});
break;
case "edit-item":
self.processing = false;
window.location =
"/dashboard/page/edit/" + e.target.getAttribute("data-id");
break;

@ -16,6 +16,7 @@ export default class PostEditor {
// constructor
//--------------------------
constructor() {
this.processing = false;
let self = this;
this.admin = new FipamoAdminAPI();
this.urlPieces = document.URL.split("/");
@ -136,6 +137,7 @@ export default class PostEditor {
: currentOption.setAttribute("data-active", "false");
}
handleEditorOptions(e) {
if (this.processing) return;
let self = this;
switch (e) {
case EditorEvent.EDITOR_SAVE:
@ -149,10 +151,12 @@ export default class PostEditor {
document.getElementById("featured-image-upload").files[0]
)
.then((page) => {
self.processing = true;
notify.alert("Writing down changes", null);
self.admin
.pageActions(task, page)
.then((r) => {
self.processing = false;
if (
r.type === DataEvent.PAGE_ERROR ||
r.type === DataEvent.API_REQUEST_LAME
@ -168,6 +172,7 @@ export default class PostEditor {
}
})
.catch((err) => {
self.processing = false;
notify.alert(err, false);
});
});
@ -179,12 +184,15 @@ export default class PostEditor {
}
if (confirm("AYE! You know you're deleting this post, right?")) {
let id = { id: this.postUUID };
self.processing = true;
this.admin
.pageActions(TASK_PAGE_DELETE, id)
.then(() => {
self.processing = false;
window.location = "/dashboard/pages";
})
.catch((err) => {
self.processing = false;
notify.alert(err, false);
});
} else {

@ -9,6 +9,7 @@ export default class SettingsIndex {
// constructor
//--------------------------
constructor() {
this.processing = false;
this.start();
this.admin = new FipamoAdminAPI();
}
@ -171,44 +172,59 @@ export default class SettingsIndex {
});
}
handlePublished(e) {
if (this.processing) return;
e.preventDefault();
e.stopPropagation();
let self = this;
let task = { task: "publish all pages" };
this.processing = true;
notify.alert("Publishing site...", null);
this.admin
.publishSite(task)
.then((r) => {
self.processing = false;
notify.alert(r.message, true);
})
.catch((err) => {
self.processing = false;
notify.alert(err, false);
});
}
handleBackup(e) {
if (this.processing) return;
let self = this;
e.preventDefault();
e.stopPropagation();
notify.alert("Creating backup", null);
this.processing = true;
this.admin
.handleBackup(e.target.id, e.target.files)
.then((r) => {
self.processing = false;
notify.alert(r.message, true);
})
.catch((err) => {
self.processing = false;
notify.alert(err, false);
});
}
handleReindex(e) {
if (this.processing) return;
let self = this;
e.preventDefault();
e.stopPropagation();
let task = { task: "cleanup pages indexes" };
this.processing = true;
notify.alert("Cleaning up page indexes", null);
this.admin
.handleReindex(task)
.then((r) => {
self.processing = false;
notify.alert(r.message, true);
})
.catch((err) => {
self.processing = false;
notify.alert(err, false);
});
}

Loading…
Cancel
Save