|
|
@ -8,205 +8,205 @@ const data = new DataUitls();
|
|
|
|
const notify = new Notfications();
|
|
|
|
const notify = new Notfications();
|
|
|
|
|
|
|
|
|
|
|
|
export default class Base {
|
|
|
|
export default class Base {
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
// constructor
|
|
|
|
// constructor
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
constructor() {
|
|
|
|
constructor() {
|
|
|
|
this.processing = false;
|
|
|
|
this.processing = false;
|
|
|
|
this.start();
|
|
|
|
this.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
// methods
|
|
|
|
// methods
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
start() {
|
|
|
|
start() {
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
document.getElementById('dash-form') ||
|
|
|
|
document.getElementById('dash-form') ||
|
|
|
|
document.getElementById('dash-init')
|
|
|
|
document.getElementById('dash-init')
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
var options = document.getElementsByClassName('init-option');
|
|
|
|
var options = document.getElementsByClassName('init-option');
|
|
|
|
for (let index = 0; index < options.length; index++) {
|
|
|
|
for (let index = 0; index < options.length; index++) {
|
|
|
|
options[index].addEventListener('click', e => this.handleOptions(e));
|
|
|
|
options[index].addEventListener('click', e => this.handleOptions(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (document.getElementById('dash-form')) {
|
|
|
|
if (document.getElementById('dash-form')) {
|
|
|
|
document
|
|
|
|
document
|
|
|
|
.getElementById('login-btn')
|
|
|
|
.getElementById('login-btn')
|
|
|
|
.addEventListener('click', e => this.handleLogin(e));
|
|
|
|
.addEventListener('click', e => this.handleLogin(e));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
document
|
|
|
|
document
|
|
|
|
.getElementById('init-blog')
|
|
|
|
.getElementById('init-blog')
|
|
|
|
.addEventListener('click', e => this.handleSetup(e));
|
|
|
|
.addEventListener('click', e => this.handleSetup(e));
|
|
|
|
document
|
|
|
|
document
|
|
|
|
.getElementById('blog-restore')
|
|
|
|
.getElementById('blog-restore')
|
|
|
|
.addEventListener('click', e => this.handleRestore(e));
|
|
|
|
.addEventListener('click', e => this.handleRestore(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (document.getElementById('dash-reset')) {
|
|
|
|
} else if (document.getElementById('dash-reset')) {
|
|
|
|
document
|
|
|
|
document
|
|
|
|
.getElementById('get-secret-btn')
|
|
|
|
.getElementById('get-secret-btn')
|
|
|
|
.addEventListener('click', e => this.handleReset(e));
|
|
|
|
.addEventListener('click', e => this.handleReset(e));
|
|
|
|
|
|
|
|
|
|
|
|
document
|
|
|
|
document
|
|
|
|
.getElementById('reset-btn')
|
|
|
|
.getElementById('reset-btn')
|
|
|
|
.addEventListener('click', e => this.handleReset(e));
|
|
|
|
.addEventListener('click', e => this.handleReset(e));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
new DashManager();
|
|
|
|
new DashManager();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
// event handlers
|
|
|
|
// event handlers
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
|
handleLogin(e) {
|
|
|
|
handleLogin(e) {
|
|
|
|
if (this.processing) return;
|
|
|
|
if (this.processing) return;
|
|
|
|
let self = this;
|
|
|
|
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 FipamoAdminAPI();
|
|
|
|
let api = new FipamoAdminAPI();
|
|
|
|
this.processing = true;
|
|
|
|
this.processing = true;
|
|
|
|
api.login(authForm)
|
|
|
|
api.login(authForm)
|
|
|
|
.then(response => {
|
|
|
|
.then(response => {
|
|
|
|
self.processing = false;
|
|
|
|
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 {
|
|
|
|
notify.alert(response.message, true);
|
|
|
|
notify.alert(response.message, true);
|
|
|
|
e.target.innerHTML = response.message;
|
|
|
|
e.target.innerHTML = response.message;
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
window.location = '/dashboard';
|
|
|
|
window.location = '/dashboard';
|
|
|
|
}, 500);
|
|
|
|
}, 500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
.catch(err => {
|
|
|
|
self.processing = false;
|
|
|
|
self.processing = false;
|
|
|
|
notify.alert(err, false);
|
|
|
|
notify.alert(err, false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handleSetup(e) {
|
|
|
|
handleSetup(e) {
|
|
|
|
if (this.processing) return;
|
|
|
|
if (this.processing) return;
|
|
|
|
let self = this;
|
|
|
|
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 mm = new Maintenance();
|
|
|
|
let mm = new Maintenance();
|
|
|
|
this.processing = true;
|
|
|
|
this.processing = true;
|
|
|
|
mm.create(setUpForm)
|
|
|
|
mm.create(setUpForm)
|
|
|
|
.then(response => {
|
|
|
|
.then(response => {
|
|
|
|
if (response.type === DataEvent.API_INIT_LAME) {
|
|
|
|
if (response.type === DataEvent.API_INIT_LAME) {
|
|
|
|
self.processing = false;
|
|
|
|
self.processing = false;
|
|
|
|
notify.alert(response.message, false);
|
|
|
|
notify.alert(response.message, false);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
self.processing = false;
|
|
|
|
self.processing = false;
|
|
|
|
notify.alert(response.message, true);
|
|
|
|
notify.alert(response.message, true);
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
window.location = '/dashboard';
|
|
|
|
window.location = '/dashboard';
|
|
|
|
}, 700);
|
|
|
|
}, 700);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
.catch(err => {
|
|
|
|
self.processing = false;
|
|
|
|
self.processing = false;
|
|
|
|
notify.alert(err, false);
|
|
|
|
notify.alert(err, false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handleRestore(e) {
|
|
|
|
handleRestore(e) {
|
|
|
|
if (this.processing) return;
|
|
|
|
if (this.processing) return;
|
|
|
|
let self = this;
|
|
|
|
let self = this;
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
let mm = new Maintenance();
|
|
|
|
let mm = new Maintenance();
|
|
|
|
var form = document.getElementById('init-restore');
|
|
|
|
var form = document.getElementById('init-restore');
|
|
|
|
this.processing = true;
|
|
|
|
this.processing = true;
|
|
|
|
mm.restore(form)
|
|
|
|
mm.restore(form)
|
|
|
|
.then(response => {
|
|
|
|
.then(response => {
|
|
|
|
if (response.type === DataEvent.REQUEST_LAME) {
|
|
|
|
if (response.type === DataEvent.REQUEST_LAME) {
|
|
|
|
self.processing = false;
|
|
|
|
self.processing = false;
|
|
|
|
notify.alert(response.message, false);
|
|
|
|
notify.alert(response.message, false);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
self.processing = false;
|
|
|
|
self.processing = false;
|
|
|
|
notify.alert(response.message, true);
|
|
|
|
notify.alert(response.message, true);
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
window.location = '/dashboard';
|
|
|
|
window.location = '/dashboard';
|
|
|
|
}, 1500);
|
|
|
|
}, 1500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
.catch(err => {
|
|
|
|
self.processing = false;
|
|
|
|
self.processing = false;
|
|
|
|
notify.alert(err, false);
|
|
|
|
notify.alert(err, false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handleReset(e) {
|
|
|
|
handleReset(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
let self = this;
|
|
|
|
let self = this;
|
|
|
|
let mm = new Maintenance();
|
|
|
|
let mm = new Maintenance();
|
|
|
|
if (e.target.id == 'get-secret-btn') {
|
|
|
|
if (e.target.id == 'get-secret-btn') {
|
|
|
|
let data = {
|
|
|
|
let data = {
|
|
|
|
email: document.getElementById('email').value,
|
|
|
|
email: document.getElementById('email').value,
|
|
|
|
task: 'retrieveSecret'
|
|
|
|
task: 'retrieveSecret'
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.processing = true;
|
|
|
|
this.processing = true;
|
|
|
|
mm.secret(data)
|
|
|
|
mm.secret(data)
|
|
|
|
.then(response => {
|
|
|
|
.then(response => {
|
|
|
|
self.processing = false;
|
|
|
|
self.processing = false;
|
|
|
|
if (response.secret) {
|
|
|
|
if (response.secret) {
|
|
|
|
document.getElementById('secret').value = response.secret;
|
|
|
|
document.getElementById('secret').value = response.secret;
|
|
|
|
notify.alert(response.message, true);
|
|
|
|
notify.alert(response.message, true);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (response.type == 'mailSent') {
|
|
|
|
if (response.type == 'mailSent') {
|
|
|
|
notify.alert(response.message, true);
|
|
|
|
notify.alert(response.message, true);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
notify.alert(response.message, false);
|
|
|
|
notify.alert(response.message, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
.catch(err => {
|
|
|
|
self.processing = false;
|
|
|
|
self.processing = false;
|
|
|
|
notify.alert(err, false);
|
|
|
|
notify.alert(err, false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let data = {
|
|
|
|
let data = {
|
|
|
|
newPass: document.getElementById('new_password').value,
|
|
|
|
newPass: document.getElementById('new_password').value,
|
|
|
|
newPassConfirm: document.getElementById('new_password2').value,
|
|
|
|
newPassConfirm: document.getElementById('new_password2').value,
|
|
|
|
secret: document.getElementById('secret').value
|
|
|
|
secret: document.getElementById('secret').value
|
|
|
|
};
|
|
|
|
};
|
|
|
|
mm.newPass(data)
|
|
|
|
mm.newPass(data)
|
|
|
|
.then(response => {
|
|
|
|
.then(response => {
|
|
|
|
self.processing = false;
|
|
|
|
self.processing = false;
|
|
|
|
if (response.type == 'passNotCreated') {
|
|
|
|
if (response.type == 'passNotCreated') {
|
|
|
|
notify.alert(response.message, false);
|
|
|
|
notify.alert(response.message, false);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
notify.alert(response.message, true);
|
|
|
|
notify.alert(response.message, true);
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
window.location = '/dashboard';
|
|
|
|
window.location = '/dashboard';
|
|
|
|
}, 1000);
|
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
.catch(err => {
|
|
|
|
self.processing = false;
|
|
|
|
self.processing = false;
|
|
|
|
notify.alert(err, false);
|
|
|
|
notify.alert(err, false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handleOptions(e) {
|
|
|
|
handleOptions(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
let init = document.getElementById('dash-init');
|
|
|
|
let init = document.getElementById('dash-init');
|
|
|
|
let restore = document.getElementById('dash-restore');
|
|
|
|
let restore = document.getElementById('dash-restore');
|
|
|
|
if (e.target.id === 'init-switch-restore') {
|
|
|
|
if (e.target.id === 'init-switch-restore') {
|
|
|
|
init.style.display = 'none';
|
|
|
|
init.style.display = 'none';
|
|
|
|
init.style.visibility = 'hidden';
|
|
|
|
init.style.visibility = 'hidden';
|
|
|
|
|
|
|
|
|
|
|
|
restore.style.display = 'flex';
|
|
|
|
restore.style.display = 'flex';
|
|
|
|
restore.style.visibility = 'visible';
|
|
|
|
restore.style.visibility = 'visible';
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
init.style.display = 'flex';
|
|
|
|
init.style.display = 'flex';
|
|
|
|
init.style.visibility = 'visible';
|
|
|
|
init.style.visibility = 'visible';
|
|
|
|
|
|
|
|
|
|
|
|
restore.style.display = 'none';
|
|
|
|
restore.style.display = 'none';
|
|
|
|
restore.style.visibility = 'hidden';
|
|
|
|
restore.style.visibility = 'hidden';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|