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