diff --git a/src/CreateTable.vue b/src/CreateTable.vue
index 45217e5..513c4e0 100644
--- a/src/CreateTable.vue
+++ b/src/CreateTable.vue
@@ -1,11 +1,13 @@
diff --git a/src/TableManager.vue b/src/TableManager.vue
index d11615e..d07caa1 100644
--- a/src/TableManager.vue
+++ b/src/TableManager.vue
@@ -11,46 +11,37 @@ import SplitButton from 'primevue/splitbutton'
import ConfirmDialog from 'primevue/confirmdialog'
import { useConfirm } from 'primevue/useconfirm'
-const route = useRouter()
+const router = useRouter()
const allTables = ref()
const activeTables = ref()
const confirm = useConfirm()
onMounted(() => {
- activeTables.value = [
- {
- tableName: 'Table-One',
- link: 'vtt.cyberpunkrush.co/table-one',
- },
- ]
-
- axios.get('http://localhost/api/tables/all').then((resp) => (allTables.value = resp.data))
- axios.get('http://localhost/api/tables/active').then((resp) => (activeTables.value = resp.data))
+ activeTables.value = []
+ loadTables()
})
+async function loadTables(): Promise {
+ return axios.get('http://localhost/api/tables/all')
+ .then((resp) => (allTables.value = resp.data))
+ .then(() => axios.get('http://localhost/api/tables/active'))
+ .then((resp) => (activeTables.value = resp.data))
+}
+
function startTable(tableId: number) {
axios.post(`http://localhost/api/tables/${tableId}:start`)
- .then((resp) => axios.get('http://localhost/api/tables/all'))
- .then((resp) => (allTables.value = resp.data))
- .then((resp) => axios.get('http://localhost/api/tables/active'))
- .then((resp) => (activeTables.value = resp.data))
+ .then(() => loadTables())
}
function stopTable(tableId: number) {
axios.post(`http://localhost/api/tables/${tableId}:stop`)
- .then((resp) => axios.get('http://localhost/api/tables/all'))
- .then((resp) => (allTables.value = resp.data))
- .then((resp) => axios.get('http://localhost/api/tables/active'))
- .then((resp) => (activeTables.value = resp.data))
+ .then(() => loadTables())
}
function deleteTable(tableId: number) {
axios
.delete(`http://localhost/api/tables/${tableId}`)
- .then((resp) => axios.get('http://localhost/api/tables/active'))
- .then((resp) => (activeTables.value = resp.data))
- .then((resp) => axios.get('http://localhost/api/tables/all'))
- .then((resp) => (allTables.value = resp.data))
+ .then(() => loadTables())
}
function buildButtonModel(table: any) {
@@ -58,11 +49,10 @@ function buildButtonModel(table: any) {
{
label: 'Edit',
command: () => {
- route.push({ name: 'edit', params: { id: table.id } })
+ router.push({ name: 'edit', params: { id: table.id } })
},
},
{ label: 'Restart' },
- { label: 'Force Stop' },
{ separator: true },
{
label: 'Delete',
@@ -77,12 +67,11 @@ function buildButtonModel(table: any) {
]
}
-function createTable() {
- axios.post('http://localhost/api/tables', { table_name: 'table name', table_link: 'table link' })
-}