2020-05-04 04:31:12 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import Vuex from 'vuex'
|
2020-05-04 18:34:59 +00:00
|
|
|
import axios from 'axios';
|
2020-05-04 04:31:12 +00:00
|
|
|
|
2020-05-04 18:58:41 +00:00
|
|
|
import ftbotModule from './modules/ftbot';
|
2020-05-06 19:24:12 +00:00
|
|
|
import userModule from './modules/user';
|
2020-05-11 18:22:23 +00:00
|
|
|
import alertsModule from './modules/alerts';
|
2020-05-04 18:34:59 +00:00
|
|
|
|
|
|
|
import { apiBase } from './modules/config';
|
|
|
|
|
2020-05-04 04:31:12 +00:00
|
|
|
Vue.use(Vuex)
|
|
|
|
|
|
|
|
export default new Vuex.Store({
|
|
|
|
state: {
|
2020-05-06 19:24:12 +00:00
|
|
|
|
2020-05-04 04:31:12 +00:00
|
|
|
},
|
2020-05-04 05:28:53 +00:00
|
|
|
modules: {
|
2020-05-06 19:24:12 +00:00
|
|
|
ftbot: ftbotModule,
|
|
|
|
user: userModule,
|
2020-05-11 18:22:23 +00:00
|
|
|
alerts: alertsModule,
|
2020-05-04 05:28:53 +00:00
|
|
|
},
|
2020-05-04 04:31:12 +00:00
|
|
|
mutations: {
|
2020-05-04 18:34:59 +00:00
|
|
|
setPing(state, ping) {
|
|
|
|
console.log(ping);
|
|
|
|
const now = Date(Date.now());
|
|
|
|
state.ping = `${ping.status} ${now.toString()}` ;
|
|
|
|
}
|
2020-05-04 04:31:12 +00:00
|
|
|
},
|
|
|
|
actions: {
|
2020-05-04 18:34:59 +00:00
|
|
|
ping({ commit }) {
|
|
|
|
axios.get(`${apiBase}/ping`)
|
|
|
|
.then((result) => commit('setPing', result.data))
|
|
|
|
.catch(console.error);
|
2020-05-04 18:56:11 +00:00
|
|
|
},
|
|
|
|
refresh_all({dispatch}) {
|
|
|
|
// Refresh all data
|
2020-05-06 17:38:52 +00:00
|
|
|
dispatch('ftbot/getState');
|
|
|
|
dispatch('ftbot/getOpentrades');
|
2020-05-04 18:58:41 +00:00
|
|
|
dispatch('ftbot/getTrades');
|
2020-05-06 04:38:57 +00:00
|
|
|
dispatch('ftbot/getPerformance');
|
|
|
|
dispatch('ftbot/getProfit');
|
2020-05-04 18:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-04 04:31:12 +00:00
|
|
|
})
|