frequi_origin/src/store/index.js

55 lines
1.2 KiB
JavaScript
Raw Normal View History

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
},
refreshAll({dispatch}) {
dispatch('refreshFrequent');
dispatch('refreshSlow');
},
refreshSlow({ dispatch }) {
dispatch('ftbot/getBalance');
dispatch('ftbot/getPerformance');
dispatch('ftbot/getProfit');
},
refreshFrequent({dispatch}) {
2020-05-04 18:56:11 +00:00
// Refresh all data
dispatch('ftbot/getState');
dispatch('ftbot/getOpentrades');
2020-05-04 18:58:41 +00:00
dispatch('ftbot/getTrades');
2020-05-12 05:07:53 +00:00
dispatch('ftbot/getWhitelist');
dispatch('ftbot/getBlacklist');
},
2020-05-04 18:34:59 +00:00
}
2020-05-04 04:31:12 +00:00
})