frequi_origin/src/components/BotEntry.vue

127 lines
3.5 KiB
Vue
Raw Normal View History

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">
<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-12-08 17:22:34 +00:00
<OnlineIcon
2022-12-08 18:54:43 +00:00
v-if="botStore.botStores[bot.botId].isBotLoggedIn"
2022-12-08 17:22:34 +00:00
:size="18"
class="ms-2 me-1 align-middle"
:class="botStore.botStores[bot.botId].isBotOnline ? 'online' : 'offline'"
:title="botStore.botStores[bot.botId].isBotOnline ? 'Online' : 'Offline'"
></OnlineIcon>
2022-12-08 18:54:43 +00:00
<LoggedOutIcon
v-else
class="offline"
title="Login info expired, please login again."
2022-12-08 18:54:43 +00:00
></LoggedOutIcon>
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">
<b-button
v-if="botStore.botStores[bot.botId].isBotLoggedIn"
class="ms-1"
size="sm"
title="Edit bot"
@click="$emit('edit')"
>
2022-03-10 07:57:06 +00:00
<EditIcon :size="16" />
</b-button>
<b-button v-else class="ms-1" size="sm" title="Login again" @click="$emit('editLogin')">
<LoginIcon :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';
import LoginIcon from 'vue-material-design-icons/Login.vue';
2021-08-29 18:17:34 +00:00
import DeleteIcon from 'vue-material-design-icons/Delete.vue';
2022-12-08 17:22:34 +00:00
import OnlineIcon from 'vue-material-design-icons/Circle.vue';
2022-12-08 18:54:43 +00:00
import LoggedOutIcon from 'vue-material-design-icons/Cancel.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,
LoginIcon,
2022-12-08 17:22:34 +00:00
OnlineIcon,
2022-12-08 18:54:43 +00:00
LoggedOutIcon,
2022-03-10 07:57:06 +00:00
},
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', 'editLogin'],
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
},
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;
}
2022-12-08 17:22:34 +00:00
.online {
color: #1aa903;
}
.offline {
color: #e01515;
}
2022-11-20 10:12:07 +00:00
</style>