2020-05-22 12:43:32 +00:00
|
|
|
<template>
|
|
|
|
<!-- TODO We could move the list into a component since we are reusing the same code for both lists. -->
|
|
|
|
<div>
|
2020-05-23 08:23:01 +00:00
|
|
|
<div>
|
|
|
|
<h3>Whitelist Methods</h3>
|
|
|
|
|
|
|
|
<div v-if="pairlistMethods.length" class="list">
|
|
|
|
<b-list-group v-for="(method, key) in pairlistMethods" :key="key">
|
|
|
|
<b-list-group-item href="#" class="pair white">{{ method }}</b-list-group-item>
|
|
|
|
</b-list-group>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-05-22 12:43:32 +00:00
|
|
|
<!-- Show Whitelist -->
|
|
|
|
<h3>Whitelist</h3>
|
|
|
|
<div v-if="whitelist.length" class="list">
|
|
|
|
<b-list-group v-for="(pair, key) in whitelist" :key="key">
|
2021-12-11 16:21:19 +00:00
|
|
|
<b-list-group-item class="pair white">{{ pair }}</b-list-group-item>
|
2020-05-22 12:43:32 +00:00
|
|
|
</b-list-group>
|
|
|
|
</div>
|
|
|
|
<p v-else>List Unavailable. Please Login and make sure server is running.</p>
|
|
|
|
<hr />
|
|
|
|
|
|
|
|
<!-- Blacklsit -->
|
2020-05-27 19:13:48 +00:00
|
|
|
<div>
|
2021-12-11 16:21:19 +00:00
|
|
|
<label
|
|
|
|
class="mr-auto h3"
|
|
|
|
title="Blacklist - Select (followed by a click on '-') to remove pairs"
|
|
|
|
>Blacklist</label
|
|
|
|
>
|
|
|
|
<div class="float-right d-flex d-flex-columns pr-1">
|
|
|
|
<b-button id="blacklist-add-btn" class="col-6 mr-1" size="sm">+</b-button>
|
|
|
|
<b-button
|
|
|
|
size="sm"
|
|
|
|
class="col-6"
|
|
|
|
title="Select pairs to delete pairs from your blacklist."
|
|
|
|
:disabled="blacklistSelect.length === 0"
|
|
|
|
@click="deletePairs"
|
|
|
|
>
|
|
|
|
<DeleteIcon :size="16" title="Delete Bot" />
|
|
|
|
</b-button>
|
|
|
|
</div>
|
2021-11-24 19:36:42 +00:00
|
|
|
<b-popover
|
|
|
|
title="Add to blacklist"
|
|
|
|
target="blacklist-add-btn"
|
2021-12-11 16:21:19 +00:00
|
|
|
triggers="click blur"
|
2021-11-24 19:36:42 +00:00
|
|
|
:show.sync="blackListShow"
|
|
|
|
>
|
2020-05-28 04:36:08 +00:00
|
|
|
<form ref="form" @submit.prevent>
|
2020-05-27 19:13:48 +00:00
|
|
|
<div>
|
|
|
|
<b-form-group label-cols="2" label="Pair" label-for="pair-input">
|
|
|
|
<b-form-input
|
|
|
|
id="pair-input"
|
|
|
|
v-model="newblacklistpair"
|
|
|
|
required
|
|
|
|
autofocus
|
|
|
|
></b-form-input>
|
|
|
|
</b-form-group>
|
|
|
|
<b-button
|
|
|
|
id="blacklist-submit"
|
2020-08-31 15:43:44 +00:00
|
|
|
class="float-right mb-2"
|
2020-05-27 19:13:48 +00:00
|
|
|
size="sm"
|
2020-05-28 04:36:08 +00:00
|
|
|
type="submit"
|
2020-05-27 19:13:48 +00:00
|
|
|
@click="addBlacklistPair"
|
|
|
|
>Add</b-button
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</b-popover>
|
|
|
|
</div>
|
2020-05-22 12:43:32 +00:00
|
|
|
<div v-if="blacklist.length" class="list">
|
|
|
|
<b-list-group v-for="(pair, key) in blacklist" :key="key">
|
2021-12-11 16:21:19 +00:00
|
|
|
<b-list-group-item
|
|
|
|
class="pair black"
|
|
|
|
:active="blacklistSelect.indexOf(key) > -1"
|
|
|
|
@click="blacklistSelectClick(key)"
|
|
|
|
>{{ pair }}</b-list-group-item
|
|
|
|
>
|
2020-05-22 12:43:32 +00:00
|
|
|
</b-list-group>
|
|
|
|
</div>
|
|
|
|
<p v-else>BlackList Unavailable. Please Login and make sure server is running.</p>
|
|
|
|
<!-- Pagination -->
|
|
|
|
<!-- TODO Add pagination support -->
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2020-08-04 06:06:30 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
|
|
|
import { namespace } from 'vuex-class';
|
2020-08-29 09:23:39 +00:00
|
|
|
import { BlacklistPayload, BlacklistResponse } from '@/types';
|
2021-08-28 09:39:03 +00:00
|
|
|
import { BotStoreGetters } from '@/store/modules/ftbot';
|
2021-12-11 16:21:19 +00:00
|
|
|
import DeleteIcon from 'vue-material-design-icons/Delete.vue';
|
2020-08-04 06:06:30 +00:00
|
|
|
|
|
|
|
const ftbot = namespace('ftbot');
|
|
|
|
|
2021-12-11 16:21:19 +00:00
|
|
|
@Component({ components: { DeleteIcon } })
|
2020-08-04 06:06:30 +00:00
|
|
|
export default class FTBotAPIPairList extends Vue {
|
|
|
|
newblacklistpair = '';
|
|
|
|
|
|
|
|
blackListShow = false;
|
|
|
|
|
2021-12-11 16:21:19 +00:00
|
|
|
blacklistSelect: number[] = [];
|
|
|
|
|
2020-08-04 06:06:30 +00:00
|
|
|
@ftbot.Action getWhitelist;
|
|
|
|
|
|
|
|
@ftbot.Action getBlacklist;
|
|
|
|
|
2020-09-08 13:45:01 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2020-08-17 05:17:10 +00:00
|
|
|
@ftbot.Action addBlacklist!: (payload: BlacklistPayload) => Promise<BlacklistResponse>;
|
2020-08-04 06:06:30 +00:00
|
|
|
|
2021-12-11 16:21:19 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
@ftbot.Action deleteBlacklist!: (payload: string[]) => Promise<BlacklistResponse>;
|
|
|
|
|
2021-08-28 09:39:03 +00:00
|
|
|
@ftbot.Getter [BotStoreGetters.whitelist]!: string[];
|
2020-08-04 06:06:30 +00:00
|
|
|
|
2021-08-28 09:39:03 +00:00
|
|
|
@ftbot.Getter [BotStoreGetters.blacklist]!: string[];
|
2020-08-04 06:06:30 +00:00
|
|
|
|
2021-08-28 09:39:03 +00:00
|
|
|
@ftbot.Getter [BotStoreGetters.pairlistMethods]!: string[];
|
2020-08-04 06:06:30 +00:00
|
|
|
|
2020-05-22 12:43:32 +00:00
|
|
|
created() {
|
2020-08-04 06:06:30 +00:00
|
|
|
this.initBlacklist();
|
|
|
|
}
|
|
|
|
|
|
|
|
initBlacklist() {
|
|
|
|
if (this.whitelist.length === 0) {
|
|
|
|
this.getWhitelist();
|
|
|
|
}
|
|
|
|
if (this.blacklist.length === 0) {
|
|
|
|
this.getBlacklist();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addBlacklistPair() {
|
|
|
|
if (this.newblacklistpair) {
|
|
|
|
this.blackListShow = false;
|
|
|
|
|
|
|
|
this.addBlacklist({ blacklist: [this.newblacklistpair] });
|
|
|
|
this.newblacklistpair = '';
|
|
|
|
}
|
|
|
|
}
|
2021-12-11 16:21:19 +00:00
|
|
|
|
|
|
|
blacklistSelectClick(key) {
|
|
|
|
console.log(key);
|
|
|
|
const index = this.blacklistSelect.indexOf(key);
|
|
|
|
if (index > -1) {
|
|
|
|
this.blacklistSelect.splice(index, 1);
|
|
|
|
} else {
|
|
|
|
this.blacklistSelect.push(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
deletePairs() {
|
|
|
|
if (this.blacklistSelect.length === 0) {
|
|
|
|
console.log('nothing to delete');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// const pairlist = this.blacklistSelect;
|
|
|
|
const pairlist = this.blacklist.filter(
|
|
|
|
(value, index) => this.blacklistSelect.indexOf(index) > -1,
|
|
|
|
);
|
|
|
|
console.log('Deleting pairs: ', pairlist);
|
|
|
|
this.deleteBlacklist(pairlist);
|
|
|
|
this.blacklistSelect = [];
|
|
|
|
}
|
2020-08-04 06:06:30 +00:00
|
|
|
}
|
2020-05-22 12:43:32 +00:00
|
|
|
</script>
|
|
|
|
|
2021-12-11 16:21:19 +00:00
|
|
|
<style scoped lang="scss">
|
|
|
|
.list-group-item.active {
|
|
|
|
background: #41b883;
|
|
|
|
}
|
2020-05-22 12:43:32 +00:00
|
|
|
.list {
|
|
|
|
display: grid;
|
2020-05-23 08:23:01 +00:00
|
|
|
grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
|
2020-05-22 12:43:32 +00:00
|
|
|
grid-gap: 0.5rem;
|
|
|
|
padding-bottom: 1rem;
|
|
|
|
}
|
|
|
|
.pair {
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
background: #41b883;
|
|
|
|
padding: 0.5rem;
|
|
|
|
border-radius: 5px;
|
|
|
|
text-align: center;
|
|
|
|
position: relative;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
.white {
|
|
|
|
background: white;
|
|
|
|
color: black;
|
|
|
|
}
|
|
|
|
|
|
|
|
.black {
|
|
|
|
background: black;
|
|
|
|
color: white;
|
|
|
|
}
|
|
|
|
</style>
|