2021-08-29 18:17:34 +00:00
|
|
|
<template>
|
2022-11-19 08:15:34 +00:00
|
|
|
<div v-if="bot" class="d-flex align-items-center justify-content-between w-100">
|
2022-11-18 18:48:15 +00:00
|
|
|
<span class="me-2">{{ bot.botName || bot.botId }}</span>
|
2021-08-29 18:17:34 +00:00
|
|
|
|
2021-09-01 04:49:03 +00:00
|
|
|
<div class="align-items-center d-flex">
|
2021-08-31 18:45:35 +00:00
|
|
|
<b-form-checkbox
|
|
|
|
v-model="autoRefreshLoc"
|
2022-11-20 10:12:07 +00:00
|
|
|
class="ms-auto float-end me-2 my-auto mt-1"
|
2021-08-31 18:45:35 +00:00
|
|
|
title="AutoRefresh"
|
|
|
|
variant="secondary"
|
2022-11-20 10:12:07 +00:00
|
|
|
switch
|
2021-08-31 18:45:35 +00:00
|
|
|
@change="changeEvent"
|
|
|
|
>
|
2022-11-20 10:12:07 +00:00
|
|
|
<span class="ms-2 me-1 align-middle">{{
|
|
|
|
botStore.botStores[bot.botId].isBotOnline ? '🟢' : '🔴'
|
|
|
|
}}</span>
|
2021-08-31 18:45:35 +00:00
|
|
|
</b-form-checkbox>
|
2022-11-20 10:12:07 +00:00
|
|
|
<div v-if="!noButtons" class="float-end d-flex flex-align-center">
|
2022-11-18 18:48:15 +00:00
|
|
|
<b-button class="ms-1" size="sm" title="Delete bot" @click="$emit('edit')">
|
2022-03-10 07:57:06 +00:00
|
|
|
<EditIcon :size="16" />
|
|
|
|
</b-button>
|
|
|
|
|
2022-11-19 08:15:34 +00:00
|
|
|
<b-button class="ms-1" size="sm" title="Delete bot" @click="botRemoveModalVisible = true">
|
2021-08-29 18:17:34 +00:00
|
|
|
<DeleteIcon :size="16" title="Delete Bot" />
|
|
|
|
</b-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-11-20 07:36:46 +00:00
|
|
|
<b-modal
|
|
|
|
v-if="!noButtons"
|
|
|
|
id="removeBotModal"
|
|
|
|
v-model="botRemoveModalVisible"
|
|
|
|
title="Logout confirmation"
|
|
|
|
@ok="confirmRemoveBot"
|
|
|
|
>
|
2022-11-19 08:15:34 +00:00
|
|
|
Really remove (logout) from {{ bot.botName }} ({{ bot.botId }})?
|
|
|
|
</b-modal>
|
2021-08-29 18:17:34 +00:00
|
|
|
</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';
|
2022-11-19 08:15:34 +00:00
|
|
|
import { defineComponent, computed, ref } from 'vue';
|
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'],
|
2022-07-07 18:44:19 +00:00
|
|
|
setup(props) {
|
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
|
|
|
};
|
2022-11-19 08:15:34 +00:00
|
|
|
const botRemoveModalVisible = ref(false);
|
2021-08-31 18:45:35 +00:00
|
|
|
|
2022-11-19 08:15:34 +00:00
|
|
|
const confirmRemoveBot = () => {
|
|
|
|
botRemoveModalVisible.value = false;
|
|
|
|
botStore.removeBot(props.bot.botId);
|
|
|
|
console.log('removing bot.');
|
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
|
|
|
},
|
2022-04-21 04:37:57 +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,
|
|
|
|
autoRefreshLoc,
|
2022-11-19 08:15:34 +00:00
|
|
|
confirmRemoveBot,
|
|
|
|
botRemoveModalVisible,
|
2022-04-16 05:18:40 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
2021-08-29 18:17:34 +00:00
|
|
|
</script>
|
2022-11-20 10:12:07 +00:00
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.form-switch {
|
|
|
|
padding-left: 0;
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: nowrap;
|
|
|
|
}
|
|
|
|
</style>
|