Skip to content

Commit

Permalink
POC: Navigate while staying in meeting
Browse files Browse the repository at this point in the history
  • Loading branch information
Bettelstab committed Sep 18, 2024
1 parent 9b44f89 commit f56de04
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 4 deletions.
5 changes: 4 additions & 1 deletion frontend/renderer/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Vue3Toasity from 'vue3-toastify'
// eslint-disable-next-line import/no-unassigned-import
import 'vue3-toastify/dist/index.css'

import AppWrapper from '#components/embedded-table/AppWrapper.vue'
import PageShell from '#components/PageShell.vue'
import { setPageContext } from '#context/usePageContext'
import { createApolloClient } from '#plugins/apollo'
Expand Down Expand Up @@ -47,7 +48,9 @@ function createApp(pageContext: PageContext, isClient = true) {
{},
{
default: () => {
return h(this.Page, this.pageProps)
return h(AppWrapper, null, {
default: () => h(this.Page, this.pageProps),
})
},
},
)
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/components/embedded-table/AppWrapper.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<FloatingTable />
<slot></slot>
</template>

<script lang="ts" setup>
import FloatingTable from '#components/embedded-table/FloatingTable.vue'
</script>
32 changes: 32 additions & 0 deletions frontend/src/components/embedded-table/FloatingTable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<template>
<div v-show="isActive" class="container">
<EmbeddedTable v-if="errorMessage === null" :url="tableUrl" @table-closed="onTableClosed" />
<div v-else class="test-not-found">
{{ $t('table.notFound') }}
</div>
</div>
</template>

<script setup lang="ts">
import EmbeddedTable from '#components/embedded-table/EmbeddedTable.vue'
import { useTable } from './useTable'
const { errorMessage, tableUrl, isActive, leaveTable } = useTable()
const onTableClosed = () => {
leaveTable()
}
</script>

<style scoped lang="scss">
@use 'sass:map';
@import 'vuetify/lib/styles/settings/_variables';
.container {
width: 400px;
height: 400px;
display: flex;
z-index: 1000;
}
</style>
65 changes: 65 additions & 0 deletions frontend/src/components/embedded-table/useTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { useLazyQuery } from '@vue/apollo-composable'
import { ref, watch, computed } from 'vue'

import GlobalErrorHandler from '#plugins/globalErrorHandler'
import { joinTableQuery } from '#queries/joinTableQuery'

const tableUrl = ref<string | null>(null)

const tableId = ref<number | null>(null)

const errorMessage = ref<string | null>(null)

export const useTable = () => {
const getTableId = computed(() => tableId.value)

const {
load,
result: joinTableQueryResult,
error: joinTableQueryError,
} = useLazyQuery(
joinTableQuery,
() => ({
tableId: tableId.value,
}),
{
prefetch: false,
fetchPolicy: 'no-cache',
},
)

watch(joinTableQueryResult, (data: { joinTable: string }) => {
if (!data.joinTable) return
tableUrl.value = data.joinTable
errorMessage.value = null
})

// eslint-disable-next-line promise/prefer-await-to-callbacks
watch(joinTableQueryError, (error) => {
if (!error) return
GlobalErrorHandler.error('Error opening table', error)
errorMessage.value = error.message
tableUrl.value = null
})

const setTableId = async (id: number) => {
tableId.value = id
await load()
}

const isActive = computed(() => tableId.value !== null)

const leaveTable = () => {
tableId.value = null
}

return {
loadTable: load,
getTableId,
setTableId,
tableUrl,
isActive,
leaveTable,
errorMessage,
}
}
8 changes: 5 additions & 3 deletions frontend/src/components/tablesDrawer/TableList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</template>

<script lang="ts" setup>
import { navigate } from 'vike/client/router'
import { useTable } from '#components/embedded-table/useTable'
import type { OpenTable } from '#stores/tablesStore'
Expand All @@ -25,9 +25,11 @@ defineProps<{
const emit = defineEmits(['openTable'])
const openTable = (id: number) => {
const { setTableId } = useTable()
const openTable = async (id: number) => {
emit('openTable')
navigate(`/table/${id}`)
await setTableId(id)
}
</script>

Expand Down

0 comments on commit f56de04

Please sign in to comment.