Support deleting locks

This commit is contained in:
Matthias 2021-03-01 19:50:26 +01:00
parent 29355a06b4
commit 46c806427a
3 changed files with 48 additions and 3 deletions

View File

@ -5,7 +5,18 @@
<b-button class="float-right" size="sm" @click="getLocks">&#x21bb;</b-button>
</div>
<div>
<b-table class="table-sm" :items="currentLocks" :fields="tableFields"> </b-table>
<b-table class="table-sm" :items="currentLocks" :fields="tableFields">
<template #cell(actions)="row">
<b-button
class="btn-xs ml-1"
size="sm"
title="Delete trade"
@click="removePairLock(row.item)"
>
<DeleteIcon :size="16" />
</b-button>
</template>
</b-table>
</div>
</div>
</template>
@ -16,14 +27,25 @@ import { BotStoreGetters } from '@/store/modules/ftbot';
import { Lock } from '@/types';
import { Component, Vue } from 'vue-property-decorator';
import { namespace } from 'vuex-class';
import DeleteIcon from 'vue-material-design-icons/Delete.vue';
import { AlertActions } from '@/store/modules/alerts';
const ftbot = namespace('ftbot');
const alerts = namespace('alerts');
@Component({})
@Component({
components: { DeleteIcon },
})
export default class PairLockList extends Vue {
@ftbot.Action getLocks;
@ftbot.Getter [BotStoreGetters.currentLocks]!: Lock;
@ftbot.Getter [BotStoreGetters.currentLocks]!: Lock[];
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@ftbot.Action deleteLock!: (lockid: string) => Promise<string>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@alerts.Action [AlertActions.addAlert];
timestampms = timestampms;
@ -32,8 +54,18 @@ export default class PairLockList extends Vue {
{ key: 'pair', label: 'Pair' },
{ key: 'lock_end_timestamp', label: 'Until', formatter: 'timestampms' },
{ key: 'reason', label: 'Reason' },
{ key: 'actions' },
];
}
removePairLock(item: Lock) {
console.log(item);
if (item.id !== undefined) {
this.deleteLock(item.id);
} else {
this.addAlert({ message: 'This Freqtrade version does not support deleting locks.' });
}
}
}
</script>

View File

@ -206,6 +206,18 @@ export default {
.then((result) => commit('updateLocks', result.data))
.catch(console.error);
},
async deleteLock({ dispatch, commit }, lockid: string) {
try {
const res = await api.delete(`/locks/${lockid}`);
showAlert(dispatch, res.data.result_msg ? res.data.result_msg : `Deleted Lock ${lockid}.`);
commit('updateLocks', res.data);
return Promise.resolve(res);
} catch (error) {
console.error(error.response);
showAlert(dispatch, `Failed to delete lock ${lockid}`, 'danger');
return Promise.reject(error);
}
},
getOpenTrades({ commit, state }) {
return api
.get('/status')

View File

@ -1,4 +1,5 @@
export interface Lock {
id: string;
pair: string;
/** Lock insertion time in the format Y-M-d HH:mm:ss */
lock_time: string;