diff --git a/src/CreateTable.vue b/src/CreateTable.vue
new file mode 100644
index 0000000..f2fa535
--- /dev/null
+++ b/src/CreateTable.vue
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+ New Table Details
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/TableEditor.vue b/src/TableEditor.vue
index d2bf610..19f17e9 100644
--- a/src/TableEditor.vue
+++ b/src/TableEditor.vue
@@ -6,10 +6,7 @@
Status:
-
+
@@ -22,20 +19,8 @@
Edit Details
-
-
+
+
@@ -81,19 +66,24 @@ const table = reactive({
table_name: 'default',
table_link: 'default',
active: 0,
+ version: 0,
})
const tableName = ref()
const tableLink = ref()
onMounted(() => {
- axios.get(`http://localhost/api/tables/${route.params.id}`).then((resp) => {
- table.table_name = resp.data.table_name
- table.table_link = resp.data.table_link
- table.active = resp.data.active
- tableName.value = resp.data.table_name
- tableLink.value = resp.data.table_link
- })
+
+ if (route.params.id == 0) {
+ } else {
+ axios.get(`http://localhost/api/tables/${route.params.id}`).then((resp) => {
+ table.table_name = resp.data.table_name
+ table.table_link = resp.data.table_link
+ table.active = resp.data.active
+ tableName.value = resp.data.table_name
+ tableLink.value = resp.data.table_link
+ })
+ }
})
watch(
diff --git a/src/TableManager.vue b/src/TableManager.vue
index 62c427f..9768fac 100644
--- a/src/TableManager.vue
+++ b/src/TableManager.vue
@@ -8,10 +8,13 @@ import DataTable from 'primevue/datatable'
import Column from 'primevue/column'
import Card from 'primevue/card'
import SplitButton from 'primevue/splitbutton'
+import ConfirmDialog from 'primevue/confirmdialog'
+import { useConfirm } from 'primevue/useconfirm'
const route = useRouter()
const allTables = ref()
const activeTables = ref()
+const confirm = useConfirm()
onMounted(() => {
activeTables.value = [
@@ -26,37 +29,51 @@ onMounted(() => {
})
function startTable(tableId: number) {
- const start = axios.post(`http://localhost/api/tables/${tableId}:start`)
- start
+ axios.post(`http://localhost/api/tables/${tableId}:start`)
.then((resp) => axios.get('http://localhost/api/tables/all'))
.then((resp) => (allTables.value = resp.data))
- start
.then((resp) => axios.get('http://localhost/api/tables/active'))
.then((resp) => (activeTables.value = resp.data))
}
function stopTable(tableId: number) {
- const stop = axios.post(`http://localhost/api/tables/${tableId}:stop`)
- stop
+ axios.post(`http://localhost/api/tables/${tableId}:stop`)
.then((resp) => axios.get('http://localhost/api/tables/all'))
.then((resp) => (allTables.value = resp.data))
- stop
.then((resp) => axios.get('http://localhost/api/tables/active'))
.then((resp) => (activeTables.value = resp.data))
}
-function buildButtonModel(id: number) {
+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))
+}
+
+function buildButtonModel(table) {
return [
{
label: 'Edit',
command: () => {
- route.push({ name: 'edit', params: { id: id } })
+ route.push({ name: 'edit', params: { id: table.id } })
},
},
{ label: 'Restart' },
{ label: 'Force Stop' },
{ separator: true },
- { label: 'Delete' },
+ {
+ label: 'Delete',
+ command: () => {
+ confirm.require({
+ header: `Delete ${table.table_name}?`,
+ message: "This will delete the table and all of it's data",
+ accept: () => { deleteTable(table.id) },
+ })
+ },
+ },
]
}
@@ -97,6 +114,8 @@ function createTable() {
+
+
Active Tables
@@ -141,16 +160,15 @@ function createTable() {
-
+
-
+
+
+
diff --git a/src/main.ts b/src/main.ts
index fe999a0..d422d1c 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -5,11 +5,14 @@ import Aura from '@primeuix/themes/aura'
import Router from './Router.vue'
import TableManager from './TableManager.vue'
import TableEditor from './TableEditor.vue'
+import CreateTable from './CreateTable.vue'
import 'primeflex/primeflex.css'
+import ConfirmationService from 'primevue/confirmationservice'
const routes = [
{ name: 'home', path: '/', component: TableManager },
{ name: 'edit', path: '/edit/:id', component: TableEditor },
+ { name: 'new', path: '/new', component: CreateTable }
]
const router = createRouter({
@@ -19,6 +22,7 @@ const router = createRouter({
const app = createApp(Router)
app.use(router)
+app.use(ConfirmationService)
app.use(PrimeVue, {
theme: {
preset: Aura,