diff --git a/src/Router.vue b/src/Router.vue index 3518d2b..c6295ab 100644 --- a/src/Router.vue +++ b/src/Router.vue @@ -32,6 +32,6 @@ function displayUsername(): string { } function loginCallback(): void { - visible.value = false; + visible.value = false } diff --git a/src/TableList.vue b/src/TableList.vue new file mode 100644 index 0000000..dc630b0 --- /dev/null +++ b/src/TableList.vue @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + http://{{ hostname }}/{{ slotProps.data.table_link }} + + + http://{{ hostname }}/{{ slotProps.data.table_link }} + + + + + + + + + + + + + + + + + + + + diff --git a/src/TableManager.vue b/src/TableManager.vue index 37842ff..7c5b947 100644 --- a/src/TableManager.vue +++ b/src/TableManager.vue @@ -1,78 +1,18 @@ - @@ -117,22 +56,7 @@ function buildButtonModel(table: any) { - - - - - - http://{{ hostname }}/{{ slotProps.data.table_link }} - - - - - - - - - - + @@ -142,31 +66,7 @@ function buildButtonModel(table: any) { - - - - - - http://{{ hostname }}/{{ slotProps.data.table_link }} - - - http://{{ hostname }}/{{ slotProps.data.table_link }} - - - - - - - - - - - - + diff --git a/src/game_tables.ts b/src/game_tables.ts new file mode 100644 index 0000000..c7829a8 --- /dev/null +++ b/src/game_tables.ts @@ -0,0 +1,59 @@ +import axios from 'axios' +import { ref, computed, onMounted } from 'vue' +import type { Ref } from 'vue' + +export interface GameTable { + id: number + table_name: string + table_link: string + active: boolean +} + +const $activeTables: Ref> = ref([]) +const $allTables: Ref> = ref([]) + +export function useActiveTables(): Ref> { + loadActiveTables() + return $activeTables +} + +export function useAllTables(): Ref> { + loadAllTables() + return $allTables +} + +export function loadActiveTables(): void { + axios.get('/api/tables/active').then((resp) => ($activeTables.value = resp.data)) +} + +export function loadAllTables(): void { + axios.get('/api/tables/all').then((resp) => ($allTables.value = resp.data)) +} + +export function startTable(gameTable: GameTable) { + axios + .post(`/api/tables/${gameTable.id}:start`, { hard: 'False' }) + .then(() => loadAllTables()) + .then(() => loadActiveTables()) +} + +export function hardStartTable(gameTable: GameTable): void { + axios + .post(`/api/tables/${gameTable.id}:start`, { hard: 'True' }) + .then(() => loadAllTables()) + .then(() => loadActiveTables()) +} + +export function stopTable(gameTable: GameTable) { + axios + .post(`/api/tables/${gameTable.id}:stop`) + .then(() => loadAllTables()) + .then(() => loadActiveTables()) +} + +export function deleteTable(gameTable: GameTable) { + axios + .delete(`/api/tables/${gameTable.id}`) + .then(() => loadAllTables()) + .then(() => loadActiveTables()) +} diff --git a/src/user.ts b/src/user.ts index 15d02f0..78cad41 100644 --- a/src/user.ts +++ b/src/user.ts @@ -10,7 +10,7 @@ export interface User { const $current_user = ref({ id: 0, username: 'username', is_admin: false, authenticated: false }) export const current_user = computed((): User => { - return $current_user.value + return computed($current_user) }) function loadCurrentUser(): void {