|
|
@ -1,10 +1,8 @@
|
|
|
|
import DataUtils from './utils/DataUtils';
|
|
|
|
import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_JSON } from './utils/DataUtils';
|
|
|
|
import Manager from './controllers/DashManager';
|
|
|
|
import * as DataEvent from './events/DataEvent';
|
|
|
|
import request from 'request-promise';
|
|
|
|
import DashManager from './controllers/DashManager';
|
|
|
|
import * as DataEvent from '../com/events/DataEvent';
|
|
|
|
|
|
|
|
//import DBUtils from '../../../../../brain/utils/tools/DBUtils';
|
|
|
|
const data = new DataUtils();
|
|
|
|
const utils = new DataUtils();
|
|
|
|
|
|
|
|
const settings = require('../../site/settings.json');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default class Base {
|
|
|
|
export default class Base {
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
@ -23,7 +21,7 @@ export default class Base {
|
|
|
|
.getElementById('login-btn')
|
|
|
|
.getElementById('login-btn')
|
|
|
|
.addEventListener('click', e => this.handleLogin(e));
|
|
|
|
.addEventListener('click', e => this.handleLogin(e));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let manager = new Manager();
|
|
|
|
//let dm = new DashManager();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
@ -32,23 +30,32 @@ export default class Base {
|
|
|
|
handleLogin(e) {
|
|
|
|
handleLogin(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
let authForm = utils.formDataToJSON(document.getElementById('login'));
|
|
|
|
let authForm = data.formDataToJSON(document.getElementById('login'));
|
|
|
|
|
|
|
|
data.request(
|
|
|
|
request({
|
|
|
|
'/api/v1/auth/login',
|
|
|
|
method: 'POST',
|
|
|
|
DataEvent.AUTH_STATUS,
|
|
|
|
uri: settings.base_url + '/api/v1/auth/login',
|
|
|
|
REQUEST_TYPE_POST,
|
|
|
|
body: authForm,
|
|
|
|
CONTENT_TYPE_JSON,
|
|
|
|
json: true
|
|
|
|
authForm
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.then(res => {
|
|
|
|
.then(r => {
|
|
|
|
if (res.type === DataEvent.REQUEST_LAME) {
|
|
|
|
let response = JSON.parse(r.request['response']);
|
|
|
|
e.target.innerHTML = res.message;
|
|
|
|
if (response.type === DataEvent.REQUEST_LAME) {
|
|
|
|
|
|
|
|
e.target.innerHTML = response.message;
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
|
|
e.target.innerHTML = 'TRY IT AGAIN, HOMIE';
|
|
|
|
|
|
|
|
}, 1500);
|
|
|
|
|
|
|
|
//console.log('NOPE', response.message);
|
|
|
|
|
|
|
|
//self.dashManager = new DashManager();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
e.target.innerHTML = response.message;
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
window.location = '/@/dashboard';
|
|
|
|
window.location = '/@/dashboard';
|
|
|
|
|
|
|
|
}, 500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
.catch(err => {
|
|
|
|
//console.log('ERROR', err);
|
|
|
|
//console.log(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|