mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-23 11:35:14 +00:00
Use enum for alerts
This commit is contained in:
parent
1fd9291cdb
commit
1355d8e8a6
|
@ -1,6 +1,8 @@
|
||||||
import { api } from '@/shared/apiService';
|
import { api } from '@/shared/apiService';
|
||||||
import { BotState, BlacklistPayload, ForcebuyPayload, Logs, DailyPayload, Trade } from '@/types';
|
import { BotState, BlacklistPayload, ForcebuyPayload, Logs, DailyPayload, Trade } from '@/types';
|
||||||
|
|
||||||
|
import { AlertActions } from './alerts';
|
||||||
|
|
||||||
export enum UserStoreGetters {
|
export enum UserStoreGetters {
|
||||||
openTrades = 'openTrades',
|
openTrades = 'openTrades',
|
||||||
tradeDetail = 'tradeDetail',
|
tradeDetail = 'tradeDetail',
|
||||||
|
@ -175,10 +177,12 @@ export default {
|
||||||
try {
|
try {
|
||||||
const res = await api.post('/reload_config', {});
|
const res = await api.post('/reload_config', {});
|
||||||
console.log(res.data);
|
console.log(res.data);
|
||||||
dispatch('alerts/addAlert', { message: res.data.status }, { root: true });
|
dispatch(AlertActions.addAlert, { message: res.data.status }, { root: true });
|
||||||
return Promise.resolve(res);
|
return Promise.resolve(res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.resposne);
|
console.error(error.resposne);
|
||||||
|
dispatch(AlertActions.addAlert, { message: 'Error reloading ' }, { root: true });
|
||||||
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -186,7 +190,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
const res = await api.delete(`/trades/${tradeid}`);
|
const res = await api.delete(`/trades/${tradeid}`);
|
||||||
dispatch(
|
dispatch(
|
||||||
'alerts/addAlert',
|
AlertActions.addAlert,
|
||||||
{ message: res.data.result_msg ? res.data.result_msg : `Deleted Trade ${tradeid}` },
|
{ message: res.data.result_msg ? res.data.result_msg : `Deleted Trade ${tradeid}` },
|
||||||
{ root: true },
|
{ root: true },
|
||||||
);
|
);
|
||||||
|
@ -194,7 +198,7 @@ export default {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.response);
|
console.error(error.response);
|
||||||
dispatch(
|
dispatch(
|
||||||
'alerts/addAlert',
|
AlertActions.addAlert,
|
||||||
{ message: `Failed to delete trade ${tradeid}`, severity: 'danger' },
|
{ message: `Failed to delete trade ${tradeid}`, severity: 'danger' },
|
||||||
{ root: true },
|
{ root: true },
|
||||||
);
|
);
|
||||||
|
@ -207,7 +211,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
const res = await api.post('/forcesell', payload);
|
const res = await api.post('/forcesell', payload);
|
||||||
dispatch(
|
dispatch(
|
||||||
'alerts/addAlert',
|
AlertActions.addAlert,
|
||||||
{ message: `Sell order for ${tradeid} created` },
|
{ message: `Sell order for ${tradeid} created` },
|
||||||
{ root: true },
|
{ root: true },
|
||||||
);
|
);
|
||||||
|
@ -215,7 +219,7 @@ export default {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.response);
|
console.error(error.response);
|
||||||
dispatch(
|
dispatch(
|
||||||
'alerts/addAlert',
|
AlertActions.addAlert,
|
||||||
{ message: `Failed to create sell order for ${tradeid}`, severity: 'danger' },
|
{ message: `Failed to create sell order for ${tradeid}`, severity: 'danger' },
|
||||||
{ root: true },
|
{ root: true },
|
||||||
);
|
);
|
||||||
|
@ -232,7 +236,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
const res = await api.post('/forcebuy', payload);
|
const res = await api.post('/forcebuy', payload);
|
||||||
dispatch(
|
dispatch(
|
||||||
'alerts/addAlert',
|
AlertActions.addAlert,
|
||||||
{ message: `Buy order for ${payload.pair} created.` },
|
{ message: `Buy order for ${payload.pair} created.` },
|
||||||
{ root: true },
|
{ root: true },
|
||||||
);
|
);
|
||||||
|
@ -240,7 +244,7 @@ export default {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.response);
|
console.error(error.response);
|
||||||
dispatch(
|
dispatch(
|
||||||
'alerts/addAlert',
|
AlertActions.addAlert,
|
||||||
{
|
{
|
||||||
message: `Error occured buying: '${error.response.data.error}'`,
|
message: `Error occured buying: '${error.response.data.error}'`,
|
||||||
severity: 'danger',
|
severity: 'danger',
|
||||||
|
@ -265,7 +269,7 @@ export default {
|
||||||
const { errors } = result.data;
|
const { errors } = result.data;
|
||||||
Object.keys(errors).forEach((pair) => {
|
Object.keys(errors).forEach((pair) => {
|
||||||
dispatch(
|
dispatch(
|
||||||
'alerts/addAlert',
|
AlertActions.addAlert,
|
||||||
{
|
{
|
||||||
message: `Error while adding pair ${pair} to Blacklist: ${errors[pair].error_msg}`,
|
message: `Error while adding pair ${pair} to Blacklist: ${errors[pair].error_msg}`,
|
||||||
},
|
},
|
||||||
|
@ -274,7 +278,7 @@ export default {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
dispatch(
|
dispatch(
|
||||||
'alerts/addAlert',
|
AlertActions.addAlert,
|
||||||
{ message: `Pair ${payload.blacklist} added.` },
|
{ message: `Pair ${payload.blacklist} added.` },
|
||||||
{ root: true },
|
{ root: true },
|
||||||
);
|
);
|
||||||
|
@ -283,7 +287,7 @@ export default {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.response);
|
console.error(error.response);
|
||||||
dispatch(
|
dispatch(
|
||||||
'alerts/addAlert',
|
AlertActions.addAlert,
|
||||||
{
|
{
|
||||||
message: `Error occured while adding pairs to Blacklist: '${error.response.data.error}'`,
|
message: `Error occured while adding pairs to Blacklist: '${error.response.data.error}'`,
|
||||||
severity: 'danger',
|
severity: 'danger',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user