new table shizz
This commit is contained in:
54
src/CreateTable.vue
Normal file
54
src/CreateTable.vue
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<script setup>
|
||||||
|
import axios from 'axios'
|
||||||
|
import { reactive, ref, watch, onMounted } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import { Form } from '@primevue/forms'
|
||||||
|
import InputText from 'primevue/inputtext'
|
||||||
|
import Button from 'primevue/button'
|
||||||
|
import Card from 'primevue/card'
|
||||||
|
import Chip from 'primevue/chip'
|
||||||
|
import Dropdown from 'primevue/dropdown';
|
||||||
|
|
||||||
|
const table_name = ref("Default Table Name")
|
||||||
|
const table_link = ref("default_table_link")
|
||||||
|
const version = ref(12)
|
||||||
|
|
||||||
|
const availableVersion = ref([
|
||||||
|
11, 12
|
||||||
|
]);
|
||||||
|
|
||||||
|
function saveTable() {
|
||||||
|
axios.post('http://localhost/api/tables', { "table_name": table_name.value, "table_link": table_link.value, })
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@import 'primeicons/primeicons.css';
|
||||||
|
|
||||||
|
.detailCard {
|
||||||
|
margin: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-box {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Card class="detailCard flex">
|
||||||
|
<template #title> New Table Details </template>
|
||||||
|
<template #content>
|
||||||
|
<div class="flex flex-column">
|
||||||
|
<InputText class="button-box" type="text" placeholder="Table Name" v-model="table_name" />
|
||||||
|
<InputText class="button-box" type="text" placeholder="Table Link" v-model="table_link" />
|
||||||
|
<Dropdown class="button-box" v-model="version" :options="availableVersion"></Dropdown>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #footer>
|
||||||
|
<Button class="button-box" label="Save" @click="saveTable()" />
|
||||||
|
<Button class="button-box" label="Clear" />
|
||||||
|
</template>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
</template>
|
||||||
@@ -6,10 +6,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #subtitle>
|
<template #subtitle>
|
||||||
Status:
|
Status:
|
||||||
<Chip
|
<Chip :class="table.active ? 'active' : 'inactive'" :label="table.active ? 'active' : 'inactive'" />
|
||||||
:class="table.active ? 'active' : 'inactive'"
|
|
||||||
:label="table.active ? 'active' : 'inactive'"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<Button class="button-box" label="Start" />
|
<Button class="button-box" label="Start" />
|
||||||
@@ -22,20 +19,8 @@
|
|||||||
<template #title> Edit Details </template>
|
<template #title> Edit Details </template>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="flex flex-column">
|
<div class="flex flex-column">
|
||||||
<InputText
|
<InputText class="button-box" name="tableName" type="text" placeholder="Table Name" v-model="tableName" />
|
||||||
class="button-box"
|
<InputText class="button-box" name="tableLink" type="text" placeholder="Table Link" v-model="tableLink" />
|
||||||
name="tableName"
|
|
||||||
type="text"
|
|
||||||
placeholder="Table Name"
|
|
||||||
v-model="tableName"
|
|
||||||
/>
|
|
||||||
<InputText
|
|
||||||
class="button-box"
|
|
||||||
name="tableLink"
|
|
||||||
type="text"
|
|
||||||
placeholder="Table Link"
|
|
||||||
v-model="tableLink"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@@ -81,19 +66,24 @@ const table = reactive({
|
|||||||
table_name: 'default',
|
table_name: 'default',
|
||||||
table_link: 'default',
|
table_link: 'default',
|
||||||
active: 0,
|
active: 0,
|
||||||
|
version: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
const tableName = ref()
|
const tableName = ref()
|
||||||
const tableLink = ref()
|
const tableLink = ref()
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
axios.get(`http://localhost/api/tables/${route.params.id}`).then((resp) => {
|
|
||||||
table.table_name = resp.data.table_name
|
if (route.params.id == 0) {
|
||||||
table.table_link = resp.data.table_link
|
} else {
|
||||||
table.active = resp.data.active
|
axios.get(`http://localhost/api/tables/${route.params.id}`).then((resp) => {
|
||||||
tableName.value = resp.data.table_name
|
table.table_name = resp.data.table_name
|
||||||
tableLink.value = resp.data.table_link
|
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(
|
watch(
|
||||||
|
|||||||
@@ -8,10 +8,13 @@ import DataTable from 'primevue/datatable'
|
|||||||
import Column from 'primevue/column'
|
import Column from 'primevue/column'
|
||||||
import Card from 'primevue/card'
|
import Card from 'primevue/card'
|
||||||
import SplitButton from 'primevue/splitbutton'
|
import SplitButton from 'primevue/splitbutton'
|
||||||
|
import ConfirmDialog from 'primevue/confirmdialog'
|
||||||
|
import { useConfirm } from 'primevue/useconfirm'
|
||||||
|
|
||||||
const route = useRouter()
|
const route = useRouter()
|
||||||
const allTables = ref()
|
const allTables = ref()
|
||||||
const activeTables = ref()
|
const activeTables = ref()
|
||||||
|
const confirm = useConfirm()
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
activeTables.value = [
|
activeTables.value = [
|
||||||
@@ -26,37 +29,51 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function startTable(tableId: number) {
|
function startTable(tableId: number) {
|
||||||
const start = axios.post(`http://localhost/api/tables/${tableId}:start`)
|
axios.post(`http://localhost/api/tables/${tableId}:start`)
|
||||||
start
|
|
||||||
.then((resp) => axios.get('http://localhost/api/tables/all'))
|
.then((resp) => axios.get('http://localhost/api/tables/all'))
|
||||||
.then((resp) => (allTables.value = resp.data))
|
.then((resp) => (allTables.value = resp.data))
|
||||||
start
|
|
||||||
.then((resp) => axios.get('http://localhost/api/tables/active'))
|
.then((resp) => axios.get('http://localhost/api/tables/active'))
|
||||||
.then((resp) => (activeTables.value = resp.data))
|
.then((resp) => (activeTables.value = resp.data))
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopTable(tableId: number) {
|
function stopTable(tableId: number) {
|
||||||
const stop = axios.post(`http://localhost/api/tables/${tableId}:stop`)
|
axios.post(`http://localhost/api/tables/${tableId}:stop`)
|
||||||
stop
|
|
||||||
.then((resp) => axios.get('http://localhost/api/tables/all'))
|
.then((resp) => axios.get('http://localhost/api/tables/all'))
|
||||||
.then((resp) => (allTables.value = resp.data))
|
.then((resp) => (allTables.value = resp.data))
|
||||||
stop
|
|
||||||
.then((resp) => axios.get('http://localhost/api/tables/active'))
|
.then((resp) => axios.get('http://localhost/api/tables/active'))
|
||||||
.then((resp) => (activeTables.value = resp.data))
|
.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 [
|
return [
|
||||||
{
|
{
|
||||||
label: 'Edit',
|
label: 'Edit',
|
||||||
command: () => {
|
command: () => {
|
||||||
route.push({ name: 'edit', params: { id: id } })
|
route.push({ name: 'edit', params: { id: table.id } })
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ label: 'Restart' },
|
{ label: 'Restart' },
|
||||||
{ label: 'Force Stop' },
|
{ label: 'Force Stop' },
|
||||||
{ separator: true },
|
{ 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() {
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<ConfirmDialog></ConfirmDialog>
|
||||||
|
|
||||||
<Card class="ActiveTables">
|
<Card class="ActiveTables">
|
||||||
<template #title>
|
<template #title>
|
||||||
<h2>Active Tables</h2>
|
<h2>Active Tables</h2>
|
||||||
@@ -141,16 +160,15 @@ function createTable() {
|
|||||||
</Column>
|
</Column>
|
||||||
<Column header="Close">
|
<Column header="Close">
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
<SplitButton
|
<SplitButton label="Start" @click="startTable(slotProps.data.id)"
|
||||||
label="Start"
|
:model="buildButtonModel(slotProps.data)" />
|
||||||
@click="startTable(slotProps.data.id)"
|
|
||||||
:model="buildButtonModel(slotProps.data.id)"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
<div class="button-box flex justify-content-end">
|
<div class="button-box flex justify-content-end">
|
||||||
<Button label="New Table" @click="createTable()" />
|
<router-link to="/new">
|
||||||
|
<Button label="New Table"" />
|
||||||
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -5,11 +5,14 @@ import Aura from '@primeuix/themes/aura'
|
|||||||
import Router from './Router.vue'
|
import Router from './Router.vue'
|
||||||
import TableManager from './TableManager.vue'
|
import TableManager from './TableManager.vue'
|
||||||
import TableEditor from './TableEditor.vue'
|
import TableEditor from './TableEditor.vue'
|
||||||
|
import CreateTable from './CreateTable.vue'
|
||||||
import 'primeflex/primeflex.css'
|
import 'primeflex/primeflex.css'
|
||||||
|
import ConfirmationService from 'primevue/confirmationservice'
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{ name: 'home', path: '/', component: TableManager },
|
{ name: 'home', path: '/', component: TableManager },
|
||||||
{ name: 'edit', path: '/edit/:id', component: TableEditor },
|
{ name: 'edit', path: '/edit/:id', component: TableEditor },
|
||||||
|
{ name: 'new', path: '/new', component: CreateTable }
|
||||||
]
|
]
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
@@ -19,6 +22,7 @@ const router = createRouter({
|
|||||||
|
|
||||||
const app = createApp(Router)
|
const app = createApp(Router)
|
||||||
app.use(router)
|
app.use(router)
|
||||||
|
app.use(ConfirmationService)
|
||||||
app.use(PrimeVue, {
|
app.use(PrimeVue, {
|
||||||
theme: {
|
theme: {
|
||||||
preset: Aura,
|
preset: Aura,
|
||||||
|
|||||||
Reference in New Issue
Block a user