frequi_origin/src/components/BotList.vue

76 lines
2.0 KiB
Vue
Raw Normal View History

2021-08-29 08:29:53 +00:00
<template>
2021-09-26 09:06:07 +00:00
<div v-if="botCount > 0">
2021-08-29 18:17:34 +00:00
<h3 v-if="!small">Available bots</h3>
2021-08-29 09:07:41 +00:00
<b-list-group>
<b-list-group-item
v-for="bot in allAvailableBots"
:key="bot.botId"
:active="bot.botId === selectedBot"
button
2021-08-29 11:59:39 +00:00
:title="`${bot.botId} - ${bot.botName} - ${bot.botUrl}`"
@click="selectBot(bot.botId)"
2021-08-29 09:07:41 +00:00
>
2022-03-10 07:57:06 +00:00
<bot-rename
v-if="editingBots.includes(bot.botId)"
:bot="bot"
@saved="stopEditBot(bot.botId)"
@cancelled="stopEditBot(bot.botId)"
/>
<bot-entry v-else :bot="bot" :no-buttons="small" @edit="editBot(bot.botId)" />
2021-08-29 09:07:41 +00:00
</b-list-group-item>
</b-list-group>
2021-08-29 18:17:34 +00:00
<LoginModal v-if="!small" class="mt-2" login-text="Add new bot" />
2021-08-29 08:29:53 +00:00
</div>
</template>
<script lang="ts">
2021-08-29 18:17:34 +00:00
import { Component, Prop, Vue } from 'vue-property-decorator';
2021-08-29 08:29:53 +00:00
import { namespace } from 'vuex-class';
import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper';
import LoginModal from '@/views/LoginModal.vue';
2021-08-29 18:17:34 +00:00
import BotEntry from '@/components/BotEntry.vue';
2022-03-10 07:57:06 +00:00
import BotRename from '@/components/BotRename.vue';
2021-08-29 18:17:34 +00:00
import { BotDescriptors } from '@/types';
import StoreModules from '@/store/storeSubModules';
2021-08-29 08:29:53 +00:00
const ftbot = namespace(StoreModules.ftbot);
2021-08-29 08:29:53 +00:00
2022-03-10 07:57:06 +00:00
@Component({
components: {
LoginModal,
BotEntry,
BotRename,
},
})
2021-08-29 08:29:53 +00:00
export default class BotList extends Vue {
2021-08-29 18:17:34 +00:00
@Prop({ default: false, type: Boolean }) small!: boolean;
2021-09-26 09:06:07 +00:00
@ftbot.Getter [MultiBotStoreGetters.botCount]: number;
2021-08-29 09:07:41 +00:00
@ftbot.Getter [MultiBotStoreGetters.selectedBot]: string;
2021-09-04 08:35:00 +00:00
@ftbot.Getter [MultiBotStoreGetters.allIsBotOnline]: Record<string, boolean>;
2021-08-29 12:08:32 +00:00
@ftbot.Getter [MultiBotStoreGetters.allAvailableBots]: BotDescriptors;
2021-08-29 08:29:53 +00:00
2021-08-29 09:07:41 +00:00
@ftbot.Action selectBot;
2022-03-10 07:57:06 +00:00
editingBots: string[] = [];
editBot(botId: string) {
if (!this.editingBots.includes(botId)) {
this.editingBots.push(botId);
}
}
stopEditBot(botId: string) {
if (!this.editingBots.includes(botId)) {
return;
}
this.editingBots.splice(this.editingBots.indexOf(botId), 1);
}
2021-08-29 08:29:53 +00:00
}
</script>