mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-10 02:11:57 +00:00
Improve code style
This commit is contained in:
parent
253e4964c9
commit
2a95ee1a66
15
.eslintrc.js
15
.eslintrc.js
|
@ -1,20 +1,19 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
node: true
|
||||
node: true,
|
||||
},
|
||||
'extends': [
|
||||
extends: [
|
||||
'plugin:vue/essential',
|
||||
// 'plugin:vue/recommended',
|
||||
'@vue/airbnb',
|
||||
"prettier"
|
||||
],
|
||||
'plugins': ["prettier"],
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint'
|
||||
parser: 'babel-eslint',
|
||||
},
|
||||
plugins: ['vue'],
|
||||
rules: {
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
|
@ -22,11 +22,6 @@ jobs:
|
|||
- name: npm install
|
||||
uses: bahmutov/npm-install@v1
|
||||
|
||||
- name: run lint
|
||||
- name: Run Lint
|
||||
run: |
|
||||
npm run lint
|
||||
|
||||
# - name: Prettify code
|
||||
# uses: creyD/prettier_action@v2.2
|
||||
# with:
|
||||
# dry: True
|
||||
npm run lint-ci
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"printWidth": 100,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5"
|
||||
"trailingComma": "es5",
|
||||
"files": "./src/**/*.{js,vue,json}"
|
||||
}
|
||||
|
|
|
@ -10,21 +10,25 @@ It will require Freqtrade to be running on the same host with the API enabled un
|
|||
|
||||
|
||||
## Project setup
|
||||
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
### Compiles and hot-reloads for development
|
||||
|
||||
```
|
||||
npm run serve
|
||||
```
|
||||
|
||||
### Compiles and minifies for production
|
||||
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
|
||||
```
|
||||
npm run lint
|
||||
```
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
module.exports = {
|
||||
"presets": [
|
||||
"@vue/cli-plugin-babel/preset"
|
||||
]
|
||||
}
|
||||
presets: ['@vue/cli-plugin-babel/preset'],
|
||||
};
|
||||
|
|
49
package-lock.json
generated
49
package-lock.json
generated
|
@ -1061,7 +1061,6 @@
|
|||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@nuxt/opencollective/-/opencollective-0.3.0.tgz",
|
||||
"integrity": "sha512-Vf09BxCdj1iT2IRqVwX5snaY2WCTkvM0O4cWWSO1ThCFuc4if0Q/nNwAgCxRU0FeYHJ7DdyMUNSdswCLKlVqeg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^2.4.2",
|
||||
"consola": "^2.10.1",
|
||||
|
@ -1635,6 +1634,13 @@
|
|||
"yallist": "^2.1.2"
|
||||
}
|
||||
},
|
||||
"prettier": {
|
||||
"version": "1.19.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
|
||||
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
|
@ -1973,7 +1979,6 @@
|
|||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
|
||||
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-convert": "^1.9.0"
|
||||
}
|
||||
|
@ -2490,14 +2495,12 @@
|
|||
"bootstrap": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.4.1.tgz",
|
||||
"integrity": "sha512-tbx5cHubwE6e2ZG7nqM3g/FZ5PQEDMWmMGNrCUBVRPHXTJaH7CBDdsLeu3eCh3B1tzAxTnAbtmrzvWEvT2NNEA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-tbx5cHubwE6e2ZG7nqM3g/FZ5PQEDMWmMGNrCUBVRPHXTJaH7CBDdsLeu3eCh3B1tzAxTnAbtmrzvWEvT2NNEA=="
|
||||
},
|
||||
"bootstrap-vue": {
|
||||
"version": "2.13.0",
|
||||
"resolved": "https://registry.npmjs.org/bootstrap-vue/-/bootstrap-vue-2.13.0.tgz",
|
||||
"integrity": "sha512-V/q2tgIY+tDxeBGOwqdPC4jk8CWmpwpSVY/1OVGxg4Jg1Jxcs6gQn7chhpI9KuBrO8diG/Nd6JRtnYwyE3b7Qw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@nuxt/opencollective": "^0.3.0",
|
||||
"bootstrap": ">=4.4.1 <5.0.0",
|
||||
|
@ -2901,7 +2904,6 @@
|
|||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
|
||||
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "^3.2.1",
|
||||
"escape-string-regexp": "^1.0.5",
|
||||
|
@ -3189,7 +3191,6 @@
|
|||
"version": "1.9.3",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
|
||||
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-name": "1.1.3"
|
||||
}
|
||||
|
@ -3197,8 +3198,7 @@
|
|||
"color-name": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
|
||||
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
|
||||
"dev": true
|
||||
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
|
||||
},
|
||||
"color-string": {
|
||||
"version": "1.5.3",
|
||||
|
@ -3317,8 +3317,7 @@
|
|||
"consola": {
|
||||
"version": "2.11.3",
|
||||
"resolved": "https://registry.npmjs.org/consola/-/consola-2.11.3.tgz",
|
||||
"integrity": "sha512-aoW0YIIAmeftGR8GSpw6CGQluNdkWMWh3yEFjH/hmynTYnMtibXszii3lxCXmk8YxJtI3FAK5aTiquA5VH68Gw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-aoW0YIIAmeftGR8GSpw6CGQluNdkWMWh3yEFjH/hmynTYnMtibXszii3lxCXmk8YxJtI3FAK5aTiquA5VH68Gw=="
|
||||
},
|
||||
"console-browserify": {
|
||||
"version": "1.2.0",
|
||||
|
@ -4450,8 +4449,7 @@
|
|||
"escape-string-regexp": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
|
||||
"dev": true
|
||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
|
||||
},
|
||||
"eslint": {
|
||||
"version": "6.8.0",
|
||||
|
@ -6223,8 +6221,7 @@
|
|||
"has-flag": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
||||
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
|
||||
"dev": true
|
||||
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
|
||||
},
|
||||
"has-symbols": {
|
||||
"version": "1.0.1",
|
||||
|
@ -8010,8 +8007,7 @@
|
|||
"node-fetch": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
|
||||
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
|
||||
},
|
||||
"node-forge": {
|
||||
"version": "0.9.0",
|
||||
|
@ -8711,14 +8707,12 @@
|
|||
"popper.js": {
|
||||
"version": "1.16.1",
|
||||
"resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz",
|
||||
"integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==",
|
||||
"dev": true
|
||||
"integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ=="
|
||||
},
|
||||
"portal-vue": {
|
||||
"version": "2.1.7",
|
||||
"resolved": "https://registry.npmjs.org/portal-vue/-/portal-vue-2.1.7.tgz",
|
||||
"integrity": "sha512-+yCno2oB3xA7irTt0EU5Ezw22L2J51uKAacE/6hMPMoO/mx3h4rXFkkBkT4GFsMDv/vEe8TNKC3ujJJ0PTwb6g==",
|
||||
"dev": true
|
||||
"integrity": "sha512-+yCno2oB3xA7irTt0EU5Ezw22L2J51uKAacE/6hMPMoO/mx3h4rXFkkBkT4GFsMDv/vEe8TNKC3ujJJ0PTwb6g=="
|
||||
},
|
||||
"portfinder": {
|
||||
"version": "1.0.26",
|
||||
|
@ -9345,11 +9339,10 @@
|
|||
"dev": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "1.19.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
|
||||
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz",
|
||||
"integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==",
|
||||
"dev": true
|
||||
},
|
||||
"prettier-linter-helpers": {
|
||||
"version": "1.0.0",
|
||||
|
@ -10891,7 +10884,6 @@
|
|||
"version": "5.5.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has-flag": "^3.0.0"
|
||||
}
|
||||
|
@ -11619,8 +11611,7 @@
|
|||
"vue-functional-data-merge": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/vue-functional-data-merge/-/vue-functional-data-merge-3.1.0.tgz",
|
||||
"integrity": "sha512-leT4kdJVQyeZNY1kmnS1xiUlQ9z1B/kdBFCILIjYYQDqZgLqCLa0UhjSSeRX6c3mUe6U5qYeM8LrEqkHJ1B4LA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-leT4kdJVQyeZNY1kmnS1xiUlQ9z1B/kdBFCILIjYYQDqZgLqCLa0UhjSSeRX6c3mUe6U5qYeM8LrEqkHJ1B4LA=="
|
||||
},
|
||||
"vue-hot-reload-api": {
|
||||
"version": "2.3.4",
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
"lint": "vue-cli-service lint",
|
||||
"lint-ci": "vue-cli-service lint --no-fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.19.2",
|
||||
|
@ -33,6 +34,7 @@
|
|||
"mutationobserver-shim": "^0.3.3",
|
||||
"popper.js": "^1.16.0",
|
||||
"portal-vue": "^2.1.6",
|
||||
"prettier": "^2.0.5",
|
||||
"sass": "^1.19.0",
|
||||
"sass-loader": "^8.0.0",
|
||||
"vue-cli-plugin-bootstrap-vue": "~0.6.0",
|
||||
|
|
|
@ -70,7 +70,7 @@ export default {
|
|||
forcesellHandler(item) {
|
||||
this.forcesell(item.trade_id)
|
||||
.then(() => console.log('asdf'))
|
||||
.catch(error => console.log(error.response));
|
||||
.catch((error) => console.log(error.response));
|
||||
},
|
||||
handleContextMenuEvent(item, index, event) {
|
||||
// stop browser context menu from appearing
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<template>
|
||||
<header>
|
||||
<NavBar/>
|
||||
<NavBar />
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import NavBar from "./NavBar.vue"
|
||||
import NavBar from './NavBar.vue';
|
||||
|
||||
export default {
|
||||
name: "Header",
|
||||
components: {NavBar},
|
||||
}
|
||||
name: 'Header',
|
||||
components: { NavBar },
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
18
src/main.js
18
src/main.js
|
@ -1,16 +1,16 @@
|
|||
import Vue from 'vue'
|
||||
import './plugins/bootstrap-vue'
|
||||
import App from './App.vue'
|
||||
import store from './store'
|
||||
import router from './router'
|
||||
import { apiStore } from './shared/apiService'
|
||||
import Vue from 'vue';
|
||||
import './plugins/bootstrap-vue';
|
||||
import App from './App.vue';
|
||||
import store from './store';
|
||||
import router from './router';
|
||||
import { apiStore } from './shared/apiService';
|
||||
|
||||
apiStore.store = store;
|
||||
|
||||
Vue.config.productionTip = false
|
||||
Vue.config.productionTip = false;
|
||||
|
||||
new Vue({
|
||||
store,
|
||||
router,
|
||||
render: h => h(App)
|
||||
}).$mount('#app')
|
||||
render: (h) => h(App),
|
||||
}).$mount('#app');
|
||||
|
|
10
src/plugins/bootstrap-vue.js
vendored
10
src/plugins/bootstrap-vue.js
vendored
|
@ -1,8 +1,8 @@
|
|||
import Vue from 'vue'
|
||||
import Vue from 'vue';
|
||||
|
||||
import BootstrapVue from 'bootstrap-vue'
|
||||
import BootstrapVue from 'bootstrap-vue';
|
||||
|
||||
import 'bootstrap/dist/css/bootstrap.min.css'
|
||||
import 'bootstrap-vue/dist/bootstrap-vue.css'
|
||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||
import 'bootstrap-vue/dist/bootstrap-vue.css';
|
||||
|
||||
Vue.use(BootstrapVue)
|
||||
Vue.use(BootstrapVue);
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
import Vue from 'vue'
|
||||
import VueRouter from 'vue-router'
|
||||
import Home from '@/views/Home.vue'
|
||||
import Vue from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import Home from '@/views/Home.vue';
|
||||
|
||||
Vue.use(VueRouter)
|
||||
Vue.use(VueRouter);
|
||||
|
||||
const routes = [
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Home',
|
||||
component: Home
|
||||
component: Home,
|
||||
},
|
||||
{
|
||||
path: '/trade',
|
||||
name: 'Freqtrade Trade',
|
||||
// route level code-splitting
|
||||
// this generates a separate chunk (about.[hash].js) for this route
|
||||
// which is lazy-loaded when the route is visited.
|
||||
component: () => import(/* webpackChunkName: "about" */ '@/views/Trade.vue'),
|
||||
},
|
||||
{
|
||||
path: '/trade',
|
||||
name: 'Freqtrade Trade',
|
||||
// route level code-splitting
|
||||
// this generates a separate chunk (about.[hash].js) for this route
|
||||
// which is lazy-loaded when the route is visited.
|
||||
component: () => import(/* webpackChunkName: "about" */ '@/views/Trade.vue')
|
||||
},
|
||||
{
|
||||
path: '/about',
|
||||
name: 'About',
|
||||
// route level code-splitting
|
||||
// this generates a separate chunk (about.[hash].js) for this route
|
||||
// which is lazy-loaded when the route is visited.
|
||||
component: () => import(/* webpackChunkName: "about" */ '@/views/About.vue')
|
||||
}
|
||||
]
|
||||
component: () => import(/* webpackChunkName: "about" */ '@/views/About.vue'),
|
||||
},
|
||||
];
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
base: process.env.BASE_URL,
|
||||
routes
|
||||
})
|
||||
routes,
|
||||
});
|
||||
|
||||
export default router
|
||||
export default router;
|
||||
|
|
|
@ -1,40 +1,39 @@
|
|||
import axios from 'axios';
|
||||
import { apiBase } from '../store/modules/config';
|
||||
|
||||
|
||||
export const apiStore = {store: null}
|
||||
export const apiStore = { store: null };
|
||||
|
||||
export const api = axios.create({
|
||||
baseURL: apiBase,
|
||||
timeout: 1000,
|
||||
withCredentials: true,
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
api.interceptors.request.use((config) => {
|
||||
const custconfig = config;
|
||||
// Merge custconfig dicts
|
||||
custconfig.headers = {...config.headers, ...apiStore.store.getters['user/apiAuth']};
|
||||
// Do something before request is sent
|
||||
// console.log(custconfig)
|
||||
return custconfig;
|
||||
}, (error) => Promise.reject(error)
|
||||
api.interceptors.request.use(
|
||||
(config) => {
|
||||
const custconfig = config;
|
||||
// Merge custconfig dicts
|
||||
custconfig.headers = { ...config.headers, ...apiStore.store.getters['user/apiAuth'] };
|
||||
// Do something before request is sent
|
||||
// console.log(custconfig)
|
||||
return custconfig;
|
||||
},
|
||||
(error) => Promise.reject(error),
|
||||
);
|
||||
|
||||
api.interceptors.response.use((response) => {
|
||||
return response;
|
||||
}
|
||||
,(err) => {
|
||||
// console.log(err.response.status);
|
||||
console.log(err);
|
||||
if (err.response && err.response.status === 401) {
|
||||
console.log("Dispatching refresh_token...")
|
||||
apiStore.store.dispatch('user/refresh_token')
|
||||
// maybe redirect to /login if needed !
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
reject(err);
|
||||
});
|
||||
// // return Promise.reject(err);
|
||||
}
|
||||
);
|
||||
api.interceptors.response.use(
|
||||
(response) => response,
|
||||
(err) => {
|
||||
// console.log(err.response.status);
|
||||
console.log(err);
|
||||
if (err.response && err.response.status === 401) {
|
||||
console.log('Dispatching refresh_token...');
|
||||
apiStore.store.dispatch('user/refresh_token');
|
||||
// maybe redirect to /login if needed !
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
reject(err);
|
||||
});
|
||||
// // return Promise.reject(err);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import Vue from 'vue';
|
||||
import Vuex from 'vuex';
|
||||
import axios from 'axios';
|
||||
|
||||
import ftbotModule from './modules/ftbot';
|
||||
|
@ -8,12 +8,10 @@ import alertsModule from './modules/alerts';
|
|||
|
||||
import { apiBase } from './modules/config';
|
||||
|
||||
Vue.use(Vuex)
|
||||
Vue.use(Vuex);
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
|
||||
},
|
||||
state: {},
|
||||
modules: {
|
||||
ftbot: ftbotModule,
|
||||
user: userModule,
|
||||
|
@ -23,28 +21,28 @@ export default new Vuex.Store({
|
|||
setPing(state, ping) {
|
||||
console.log(ping);
|
||||
const now = Date(Date.now());
|
||||
state.ping = `${ping.status} ${now.toString()}` ;
|
||||
}
|
||||
state.ping = `${ping.status} ${now.toString()}`;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
ping({ commit }) {
|
||||
axios.get(`${apiBase}/ping`)
|
||||
axios
|
||||
.get(`${apiBase}/ping`)
|
||||
.then((result) => commit('setPing', result.data))
|
||||
.catch(console.error);
|
||||
},
|
||||
refreshAll({dispatch}) {
|
||||
refreshAll({ dispatch }) {
|
||||
dispatch('refreshFrequent');
|
||||
dispatch('refreshSlow');
|
||||
dispatch('ftbot/getDaily');
|
||||
dispatch('ftbot/getBalance');
|
||||
|
||||
},
|
||||
refreshSlow({ dispatch }) {
|
||||
// dispatch('ftbot/getDaily');
|
||||
dispatch('ftbot/getPerformance');
|
||||
dispatch('ftbot/getProfit');
|
||||
},
|
||||
refreshFrequent({dispatch}) {
|
||||
refreshFrequent({ dispatch }) {
|
||||
// Refresh all data
|
||||
dispatch('ftbot/getOpentrades');
|
||||
dispatch('ftbot/getState');
|
||||
|
@ -52,5 +50,5 @@ export default new Vuex.Store({
|
|||
dispatch('ftbot/getWhitelist');
|
||||
dispatch('ftbot/getBlacklist');
|
||||
},
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
activeMessages: [],
|
||||
},
|
||||
mutations: {
|
||||
addAlert(state, message){
|
||||
console.log(`adding message '${message.message}' to message queue`)
|
||||
state.activeMessages.push(message)
|
||||
addAlert(state, message) {
|
||||
console.log(`adding message '${message.message}' to message queue`);
|
||||
state.activeMessages.push(message);
|
||||
},
|
||||
removeAlert(state) {
|
||||
state.activeMessages.shift()
|
||||
}
|
||||
state.activeMessages.shift();
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
addAlert({commit}, message) {
|
||||
commit('addAlert', message)
|
||||
}
|
||||
}
|
||||
}
|
||||
addAlert({ commit }, message) {
|
||||
commit('addAlert', message);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
const apiBase = '/api/v1';
|
||||
|
||||
|
||||
module.exports = {
|
||||
apiBase
|
||||
}
|
||||
apiBase,
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@ export default {
|
|||
},
|
||||
closedtrades(state) {
|
||||
return state.trades.filter((item) => !item.is_open);
|
||||
}
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
updateTrades(state, trades) {
|
||||
|
@ -55,87 +55,99 @@ export default {
|
|||
},
|
||||
actions: {
|
||||
getTrades({ commit }) {
|
||||
console.log("fetching trades")
|
||||
return api.get('/trades')
|
||||
console.log('fetching trades');
|
||||
return api
|
||||
.get('/trades')
|
||||
.then((result) => commit('updateTrades', result.data))
|
||||
.catch(console.error);
|
||||
},
|
||||
},
|
||||
getOpentrades({ commit }) {
|
||||
return api.get(`/status`)
|
||||
return api
|
||||
.get('/status')
|
||||
.then((result) => commit('updateOpenTrades', result.data))
|
||||
.catch(console.error);
|
||||
},
|
||||
},
|
||||
getPerformance({ commit }) {
|
||||
return api.get(`/performance`)
|
||||
return api
|
||||
.get('/performance')
|
||||
.then((result) => commit('updatePerformance', result.data))
|
||||
.catch(console.error);
|
||||
},
|
||||
getWhitelist({ commit }) {
|
||||
return api.get(`/whitelist`)
|
||||
return api
|
||||
.get('/whitelist')
|
||||
.then((result) => commit('updateWhitelist', result.data))
|
||||
.catch(console.error);
|
||||
},
|
||||
getBlacklist({ commit }) {
|
||||
return api.get(`/blacklist`)
|
||||
return api
|
||||
.get('/blacklist')
|
||||
.then((result) => commit('updateBlacklist', result.data))
|
||||
.catch(console.error);
|
||||
},
|
||||
},
|
||||
getProfit({ commit }) {
|
||||
return api.get(`/profit`)
|
||||
return api
|
||||
.get('/profit')
|
||||
.then((result) => commit('updateProfit', result.data))
|
||||
.catch(console.error);
|
||||
},
|
||||
getBalance({ commit }) {
|
||||
return api.get(`/balance`)
|
||||
return api
|
||||
.get('/balance')
|
||||
.then((result) => commit('updateBalance', result.data))
|
||||
.catch(console.error);
|
||||
},
|
||||
getDaily({ commit }) {
|
||||
return api.get(`/daily`)
|
||||
return api
|
||||
.get('/daily')
|
||||
.then((result) => commit('updateDaily', result.data))
|
||||
.catch(console.error);
|
||||
},
|
||||
getState({ commit }) {
|
||||
return api.get(`/show_config`)
|
||||
return api
|
||||
.get('/show_config')
|
||||
.then((result) => commit('updateState', result.data))
|
||||
.catch(console.error);
|
||||
},
|
||||
},
|
||||
// Post methods
|
||||
// TODO: Migrate calls to API to a seperate module unrelated to vuex?
|
||||
startBot() {
|
||||
return api.post(`/start`, {})
|
||||
.catch(console.error);
|
||||
},
|
||||
return api.post('/start', {}).catch(console.error);
|
||||
},
|
||||
stopBot() {
|
||||
return api.post(`/stop`, {})
|
||||
.catch(console.error);
|
||||
|
||||
return api.post('/stop', {}).catch(console.error);
|
||||
},
|
||||
stopBuy() {
|
||||
return api.post(`/stopbuy`, {})
|
||||
.catch(console.error);
|
||||
|
||||
return api.post('/stopbuy', {}).catch(console.error);
|
||||
},
|
||||
reloadConfig() {
|
||||
return api.post(`/reload_conf`, {})
|
||||
.catch(console.error);
|
||||
|
||||
return api.post('/reload_conf', {}).catch(console.error);
|
||||
},
|
||||
forcesell({ dispatch }, tradeid) {
|
||||
console.log(tradeid);
|
||||
if (tradeid) {
|
||||
const payload = { tradeid };
|
||||
console.log(payload);
|
||||
return api.post(`/forcesell`, payload).then(() => {
|
||||
dispatch('alerts/addAlert', { message: `Sell order for ${tradeid} created` }, { root: true })
|
||||
}).catch((error) => {
|
||||
console.error(error.response)
|
||||
dispatch('alerts/addAlert', { message: `Failed to create sell order for ${tradeid}`, severity: 'danger' }, { root: true })
|
||||
|
||||
})
|
||||
return api
|
||||
.post('/forcesell', payload)
|
||||
.then(() => {
|
||||
dispatch(
|
||||
'alerts/addAlert',
|
||||
{ message: `Sell order for ${tradeid} created` },
|
||||
{ root: true },
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error.response);
|
||||
dispatch(
|
||||
'alerts/addAlert',
|
||||
{ message: `Failed to create sell order for ${tradeid}`, severity: 'danger' },
|
||||
{ root: true },
|
||||
);
|
||||
});
|
||||
}
|
||||
// Error branchs
|
||||
const error = "Tradeid is empty";
|
||||
const error = 'Tradeid is empty';
|
||||
console.error(error);
|
||||
return new Promise((resolve, reject) => {
|
||||
reject(error);
|
||||
|
@ -144,22 +156,33 @@ export default {
|
|||
forcebuy({ dispatch }, payload) {
|
||||
console.log(payload);
|
||||
if (payload && payload.pair) {
|
||||
|
||||
return api.post(`/forcebuy`, payload).then(() => {
|
||||
dispatch('alerts/addAlert', { message: `Buy order for ${payload.pair} created.` }, { root: true })
|
||||
}).catch((error) => {
|
||||
console.error(error.response)
|
||||
dispatch('alerts/addAlert', { message: `Error occured buying: '${error.response.data.error}'`, severity: 'danger' }, { root: true })
|
||||
|
||||
})
|
||||
return api
|
||||
.post('/forcebuy', payload)
|
||||
.then(() => {
|
||||
dispatch(
|
||||
'alerts/addAlert',
|
||||
{ message: `Buy order for ${payload.pair} created.` },
|
||||
{ root: true },
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error.response);
|
||||
dispatch(
|
||||
'alerts/addAlert',
|
||||
{
|
||||
message: `Error occured buying: '${error.response.data.error}'`,
|
||||
severity: 'danger',
|
||||
},
|
||||
{ root: true },
|
||||
);
|
||||
});
|
||||
}
|
||||
// Error branchs
|
||||
const error = "Pair is empty";
|
||||
const error = 'Pair is empty';
|
||||
console.error(error);
|
||||
return new Promise((resolve, reject) => {
|
||||
reject(error);
|
||||
});
|
||||
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -16,14 +16,13 @@ export default {
|
|||
getters: {
|
||||
apiAuth(state) {
|
||||
// const token = JSON.parse(localStorage.getItem('auth'));
|
||||
let result = {}
|
||||
let result = {};
|
||||
if (state.accessToken) {
|
||||
result = {
|
||||
Authorization: `Bearer ${state.accessToken}`,
|
||||
Authorization: `Bearer ${state.accessToken}`,
|
||||
};
|
||||
}
|
||||
else {
|
||||
console.log("user not logged in");
|
||||
} else {
|
||||
console.log('user not logged in');
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
@ -43,21 +42,26 @@ export default {
|
|||
state.loggedIn = true;
|
||||
},
|
||||
logout(state) {
|
||||
console.log("Logging out");
|
||||
console.log('Logging out');
|
||||
localStorage.removeItem(AUTH_REF_TOKEN);
|
||||
localStorage.removeItem(AUTH_ACCESS_TOKEN);
|
||||
|
||||
state.auth = null;
|
||||
state.loggedIn = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
login({ commit }, auth) {
|
||||
// Login using username / password
|
||||
console.log(auth);
|
||||
axios.post(`${apiBase}/token/login`, {}, {
|
||||
auth: { ...auth }
|
||||
})
|
||||
axios
|
||||
.post(
|
||||
`${apiBase}/token/login`,
|
||||
{},
|
||||
{
|
||||
auth: { ...auth },
|
||||
},
|
||||
)
|
||||
.then((result) => {
|
||||
console.log(result.data);
|
||||
|
||||
|
@ -66,21 +70,25 @@ export default {
|
|||
// commit('setLogin');
|
||||
// }
|
||||
if (result.data.access_token) {
|
||||
commit('setAccessTokens', result.data.access_token)
|
||||
commit('setAccessTokens', result.data.access_token);
|
||||
}
|
||||
if (result.data.refresh_token) {
|
||||
commit('setRefreshTokens', result.data.refresh_token)
|
||||
commit('setRefreshTokens', result.data.refresh_token);
|
||||
}
|
||||
})
|
||||
.catch(console.error);
|
||||
},
|
||||
refresh_token({ commit, dispatch }) {
|
||||
console.log("Refreshing token...")
|
||||
console.log('Refreshing token...');
|
||||
const token = JSON.parse(localStorage.getItem(AUTH_REF_TOKEN));
|
||||
axios.post(`${apiBase}/token/refresh`, {}, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
|
||||
})
|
||||
axios
|
||||
.post(
|
||||
`${apiBase}/token/refresh`,
|
||||
{},
|
||||
{
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
},
|
||||
)
|
||||
.then((result) => {
|
||||
if (result.data.access_token) {
|
||||
commit('setAccessTokens', result.data.access_token);
|
||||
|
@ -95,10 +103,8 @@ export default {
|
|||
|
||||
logout({ commit, state }) {
|
||||
if (state.loggedIn) {
|
||||
|
||||
commit('logout');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
console.log('Not logged in');
|
||||
}
|
||||
},
|
||||
|
|
|
@ -62,7 +62,14 @@ import DailyStats from '@/components/ftbot/DailyStats.vue';
|
|||
|
||||
export default {
|
||||
name: 'Trade',
|
||||
components: { TradeList, Performance, BotControls, BotStatus, Balance, DailyStats },
|
||||
components: {
|
||||
TradeList,
|
||||
Performance,
|
||||
BotControls,
|
||||
BotStatus,
|
||||
Balance,
|
||||
DailyStats,
|
||||
},
|
||||
created() {
|
||||
this.refreshAll();
|
||||
},
|
||||
|
@ -81,7 +88,7 @@ export default {
|
|||
...mapActions(['refreshSlow', 'refreshFrequent', 'refreshAll']),
|
||||
// ...mapActions('ftbot', ['getTrades', 'getProfit', 'getState']),
|
||||
startRefresh() {
|
||||
console.log(`Starting automatic refresh.`);
|
||||
console.log('Starting automatic refresh.');
|
||||
this.refreshFrequent();
|
||||
this.refresh_interval = setInterval(() => {
|
||||
this.refreshFrequent();
|
||||
|
@ -92,7 +99,7 @@ export default {
|
|||
}, 60000);
|
||||
},
|
||||
stopRefresh() {
|
||||
console.log(`Stopping automatic refresh.`);
|
||||
console.log('Stopping automatic refresh.');
|
||||
clearInterval(this.refresh_interval);
|
||||
clearInterval(this.refresh_interval_slow);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user