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 05:28:53 +00:00
|
|
|
import tradesModule from './modules/trades';
|
|
|
|
|
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-04 18:34:59 +00:00
|
|
|
ping: 'ddd',
|
2020-05-04 04:31:12 +00:00
|
|
|
},
|
2020-05-04 05:28:53 +00:00
|
|
|
modules: {
|
|
|
|
trades: tradesModule
|
|
|
|
},
|
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
|
|
|
|
dispatch('trades/getTrades');
|
2020-05-04 18:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-04 04:31:12 +00:00
|
|
|
})
|