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"
|
|
|
|
>
|
2023-05-08 19:19:05 +00:00
|
|
|
<div
|
2022-12-08 18:54:43 +00:00
|
|
|
v-if="botStore.botStores[bot.botId].isBotLoggedIn"
|
2022-12-08 17:22:34 +00:00
|
|
|
:title="botStore.botStores[bot.botId].isBotOnline ? 'Online' : 'Offline'"
|
2023-05-08 19:19:05 +00:00
|
|
|
>
|
2023-05-09 16:25:28 +00:00
|
|
|
<i-mdi-circle
|
2023-05-08 19:19:05 +00:00
|
|
|
class="ms-2 me-1 align-middle"
|
|
|
|
:class="botStore.botStores[bot.botId].isBotOnline ? 'online' : 'offline'"
|
2023-05-09 16:25:28 +00:00
|
|
|
/>
|
2023-05-08 19:19:05 +00:00
|
|
|
</div>
|
|
|
|
<div v-else title="Login info expired, please login again.">
|
2023-05-09 16:25:28 +00:00
|
|
|
<i-mdi-cancel class="offline" />
|
2023-05-08 19:19:05 +00:00
|
|
|
</div>
|
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-12-10 11:51:28 +00:00
|
|
|
<b-button
|
|
|
|
v-if="botStore.botStores[bot.botId].isBotLoggedIn"
|
|
|
|
class="ms-1"
|
|
|
|
size="sm"
|
|
|
|
title="Edit bot"
|
|
|
|
@click="$emit('edit')"
|
|
|
|
>
|
2023-05-13 06:56:54 +00:00
|
|
|
<i-mdi-pencil />
|
2022-03-10 07:57:06 +00:00
|
|
|
</b-button>
|
2022-12-10 11:51:28 +00:00
|
|
|
<b-button v-else class="ms-1" size="sm" title="Login again" @click="$emit('editLogin')">
|
2023-05-09 16:25:28 +00:00
|
|
|
<i-mdi-login />
|
2022-12-10 11:51:28 +00:00
|
|
|
</b-button>
|
2022-11-19 08:15:34 +00:00
|
|
|
<b-button class="ms-1" size="sm" title="Delete bot" @click="botRemoveModalVisible = true">
|
2023-05-09 16:25:28 +00:00
|
|
|
<i-mdi-delete />
|
2021-08-29 18:17:34 +00:00
|
|
|
</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>
|
|
|
|
|
2023-05-06 13:33:29 +00:00
|
|
|
<script setup lang="ts">
|
2023-05-09 04:49:13 +00:00
|
|
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
2022-04-16 05:18:40 +00:00
|
|
|
import { BotDescriptor } from '@/types';
|
2023-05-06 13:33:29 +00:00
|
|
|
import { computed, ref } from 'vue';
|
2021-08-29 18:17:34 +00:00
|
|
|
|
2023-05-06 13:33:29 +00:00
|
|
|
const props = defineProps({
|
|
|
|
bot: { required: true, type: Object as () => BotDescriptor },
|
|
|
|
noButtons: { default: false, type: Boolean },
|
|
|
|
});
|
|
|
|
defineEmits(['edit', 'editLogin']);
|
|
|
|
const botStore = useBotStore();
|
2021-08-31 18:45:35 +00:00
|
|
|
|
2023-05-06 13:33:29 +00:00
|
|
|
const changeEvent = (v) => {
|
|
|
|
botStore.botStores[props.bot.botId].setAutoRefresh(v);
|
|
|
|
};
|
|
|
|
const botRemoveModalVisible = ref(false);
|
2021-08-31 18:45:35 +00:00
|
|
|
|
2023-05-06 13:33:29 +00:00
|
|
|
const confirmRemoveBot = () => {
|
|
|
|
botRemoveModalVisible.value = false;
|
|
|
|
botStore.removeBot(props.bot.botId);
|
|
|
|
console.log('removing bot.');
|
|
|
|
};
|
|
|
|
const autoRefreshLoc = computed({
|
|
|
|
get() {
|
|
|
|
return botStore.botStores[props.bot.botId].autoRefresh;
|
|
|
|
},
|
|
|
|
set() {
|
|
|
|
// pass
|
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;
|
|
|
|
}
|
2022-12-08 17:22:34 +00:00
|
|
|
.online {
|
|
|
|
color: #1aa903;
|
|
|
|
}
|
|
|
|
.offline {
|
|
|
|
color: #e01515;
|
|
|
|
}
|
2022-11-20 10:12:07 +00:00
|
|
|
</style>
|