add quick room.

This commit is contained in:
m1k1o
2021-03-12 22:56:13 +01:00
parent cae0ef4b40
commit b5df99176f
3 changed files with 79 additions and 1 deletions
+74
View File
@@ -0,0 +1,74 @@
<template>
<span>
<v-btn @click="Action" :loading="loading" color="info" dark>
+ Quick room
</v-btn>
<v-dialog v-model="dialog" max-width="920px">
<v-card>
<v-card-title class="headline">
Room information
</v-card-title>
<v-card-text>
<RoomInfo :roomId="roomId" />
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="grey" text @click="dialog = false">
Close
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</span>
</template>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator'
import RoomInfo from '@/components/RoomInfo.vue'
@Component({
components: {
RoomInfo,
}
})
export default class RoomActionBtn extends Vue {
private dialog = false
private loading = false
private roomId = ''
async Action() {
this.loading = true
try {
const entry = await this.$store.dispatch('ROOMS_CREATE', {
...this.$store.state.defaultRoomSettings,
// eslint-disable-next-line
user_pass: Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15),
// eslint-disable-next-line
admin_pass: Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15),
})
this.roomId = entry.id
this.dialog = true
} catch(e) {
if (e.response) {
this.$swal({
title: 'Server error',
text: e.response.data,
icon: 'error',
})
} else {
this.$swal({
title: 'Network error',
text: String(e),
icon: 'error',
})
}
} finally {
this.loading = false
}
}
}
</script>
+2 -1
View File
@@ -45,9 +45,10 @@ export default new Vuex.Store({
const res = await api.roomsList()
commit('ROOMS_SET', res.data);
},
async ROOMS_CREATE({ commit }: ActionContext<State, State>, roomSettings: RoomSettings) {
async ROOMS_CREATE({ commit }: ActionContext<State, State>, roomSettings: RoomSettings): Promise<RoomEntry> {
const res = await api.roomCreate(roomSettings)
commit('ROOMS_ADD', res.data);
return res.data
},
async ROOMS_GET(_: ActionContext<State, State>, roomId: string): Promise<RoomSettings> {
const res = await api.roomGet(roomId)
+3
View File
@@ -5,6 +5,7 @@
<v-btn @click="LoadRooms" class="mb-3" color="green" icon><v-icon>mdi-refresh</v-icon></v-btn>
</v-col>
<v-col class="text-right">
<RoomsQuick class="mr-3" />
<v-dialog
v-model="dialog"
persistent
@@ -33,11 +34,13 @@
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import RoomsList from '@/components/RoomsList.vue'
import RoomsQuick from '@/components/RoomsQuick.vue'
import RoomsCreate from '@/components/RoomsCreate.vue'
@Component({
components: {
RoomsList,
RoomsQuick,
RoomsCreate,
}
})