|
|
|
@ -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);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|