frequi_origin/src/components/BotEntry.vue

84 lines
2.2 KiB
Vue
Raw Normal View History

2021-08-29 18:17:34 +00:00
<template>
2021-08-30 05:12:46 +00:00
<div class="d-flex align-items-center justify-content-between w-100">
2021-08-29 18:17:34 +00:00
<span class="mr-2">{{ bot.botName || bot.botId }}</span>
2021-09-01 04:49:03 +00:00
<div class="align-items-center d-flex">
<span class="ml-2 mr-1 align-middle">{{
2022-04-21 18:18:28 +00:00
botStore.botStores[bot.botId].isBotOnline ? '&#128994;' : '&#128308;'
2021-08-29 18:17:34 +00:00
}}</span>
2021-08-31 18:45:35 +00:00
<b-form-checkbox
v-model="autoRefreshLoc"
class="ml-auto float-right mr-2 my-auto"
title="AutoRefresh"
variant="secondary"
@change="changeEvent"
>
R
</b-form-checkbox>
2021-08-29 18:17:34 +00:00
<div v-if="!noButtons" class="d-flex flex-align-cent">
2022-03-10 07:57:06 +00:00
<b-button class="ml-1" size="sm" title="Delete bot" @click="$emit('edit')">
<EditIcon :size="16" />
</b-button>
2021-08-29 18:17:34 +00:00
<b-button class="ml-1" size="sm" title="Delete bot" @click.prevent="clickRemoveBot(bot)">
<DeleteIcon :size="16" title="Delete Bot" />
</b-button>
</div>
</div>
</div>
</template>
<script lang="ts">
2022-03-10 07:57:06 +00:00
import EditIcon from 'vue-material-design-icons/Pencil.vue';
2021-08-29 18:17:34 +00:00
import DeleteIcon from 'vue-material-design-icons/Delete.vue';
2022-04-16 05:18:40 +00:00
import { BotDescriptor } from '@/types';
import { defineComponent, computed } from '@vue/composition-api';
2022-04-18 11:21:53 +00:00
import { useBotStore } from '@/stores/ftbotwrapper';
2021-08-29 18:17:34 +00:00
2022-04-16 05:18:40 +00:00
export default defineComponent({
name: 'BotEntry',
2022-03-10 07:57:06 +00:00
components: {
DeleteIcon,
EditIcon,
},
2022-04-16 05:18:40 +00:00
props: {
2022-04-26 20:00:21 +00:00
bot: { required: true, type: Object as () => BotDescriptor },
2022-04-16 05:18:40 +00:00
noButtons: { default: false, type: Boolean },
},
emits: ['edit'],
setup(props, { root }) {
2022-04-18 11:21:53 +00:00
const botStore = useBotStore();
2021-08-31 18:45:35 +00:00
2022-04-16 05:18:40 +00:00
const changeEvent = (v) => {
2022-04-18 11:21:53 +00:00
botStore.botStores[props.bot.botId].setAutoRefresh(v);
2022-04-16 05:18:40 +00:00
};
2021-08-31 18:45:35 +00:00
2022-04-16 05:18:40 +00:00
const clickRemoveBot = (bot: BotDescriptor) => {
//
root.$bvModal
.msgBoxConfirm(`Really remove (logout) from '${bot.botName}' (${bot.botId})?`)
.then((value: boolean) => {
if (value) {
2022-04-18 11:21:53 +00:00
botStore.removeBot(bot.botId);
2022-04-16 05:18:40 +00:00
}
});
};
const autoRefreshLoc = computed({
get() {
2022-04-18 11:21:53 +00:00
return botStore.botStores[props.bot.botId].autoRefresh;
2022-04-16 05:18:40 +00:00
},
set() {
2022-04-16 05:18:40 +00:00
// pass
},
});
2021-08-31 18:45:35 +00:00
2022-04-16 05:18:40 +00:00
return {
2022-04-18 11:21:53 +00:00
botStore,
2022-04-16 05:18:40 +00:00
changeEvent,
clickRemoveBot,
autoRefreshLoc,
};
},
});
2021-08-29 18:17:34 +00:00
</script>