Update dropdown to select. Add in float labels. Further cleaning editor.
This commit is contained in:
@@ -5,12 +5,13 @@ import { useRouter } from 'vue-router'
|
|||||||
import InputText from 'primevue/inputtext'
|
import InputText from 'primevue/inputtext'
|
||||||
import Button from 'primevue/button'
|
import Button from 'primevue/button'
|
||||||
import Card from 'primevue/card'
|
import Card from 'primevue/card'
|
||||||
import Dropdown from 'primevue/dropdown'
|
import Select from 'primevue/select'
|
||||||
|
import FloatLabel from 'primevue/floatlabel';
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const table_name = ref('Default Table Name')
|
const table_name = ref()
|
||||||
const table_link = ref('default_table_link')
|
const table_link = ref()
|
||||||
const version = ref(12)
|
const version = ref()
|
||||||
|
|
||||||
const availableVersion = ref([11, 12])
|
const availableVersion = ref([11, 12])
|
||||||
|
|
||||||
@@ -23,6 +24,12 @@ function saveTable() {
|
|||||||
})
|
})
|
||||||
.then(() => router.push({ name: 'home' }))
|
.then(() => router.push({ name: 'home' }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clear() {
|
||||||
|
table_name.value = null
|
||||||
|
table_link.value = null
|
||||||
|
version.value = null
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -42,14 +49,25 @@ function saveTable() {
|
|||||||
<template #title> New Table Details </template>
|
<template #title> New Table Details </template>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="flex flex-column">
|
<div class="flex flex-column">
|
||||||
<InputText class="button-box" type="text" placeholder="Table Name" v-model="table_name" />
|
<FloatLabel variant="on">
|
||||||
<InputText class="button-box" type="text" placeholder="Table Link" v-model="table_link" />
|
<InputText id="table_name" class="button-box w-full" type="text" v-model="table_name" />
|
||||||
<Dropdown class="button-box" v-model="version" :options="availableVersion"></Dropdown>
|
<label for="table_name">Table Name</label>
|
||||||
|
</FloatLabel>
|
||||||
|
|
||||||
|
<FloatLabel variant="on">
|
||||||
|
<InputText id="table_link" class="button-box w-full" type="text" v-model="table_link" />
|
||||||
|
<label for="table_link">Table Link</label>
|
||||||
|
</FloatLabel>
|
||||||
|
|
||||||
|
<FloatLabel variant="on">
|
||||||
|
<Select id="table_version" class="button-box w-full" v-model="version" :options="availableVersion"></Select>
|
||||||
|
<label for="table_version">Foundry Version</label>
|
||||||
|
</FloatLabel>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<Button class="button-box" label="Save" @click="saveTable()" />
|
<Button class="button-box" label="Save" @click="saveTable()" />
|
||||||
<Button class="button-box" label="Clear" />
|
<Button class="button-box" label="Clear" @click="clear()" />
|
||||||
</template>
|
</template>
|
||||||
</Card>
|
</Card>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
<template #start>
|
<template #start>
|
||||||
<Button label="Home" as="a" href="/" />
|
<Button asChild v-slot="slotProps">
|
||||||
|
<RouterLink to="/" :class="slotProps.class">Home</RouterLink>
|
||||||
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
<template #center>
|
<template #center>
|
||||||
<a :href="tableLink()"> {{ tableLink() }} </a>
|
<a :href="tableLink()"> {{ tableLink() }} </a>
|
||||||
@@ -21,6 +23,7 @@ import Toolbar from 'primevue/toolbar'
|
|||||||
import Button from 'primevue/button'
|
import Button from 'primevue/button'
|
||||||
import Dialog from 'primevue/dialog'
|
import Dialog from 'primevue/dialog'
|
||||||
import Login from './Login.vue'
|
import Login from './Login.vue'
|
||||||
|
import { RouterLink } from 'vue-router'
|
||||||
|
|
||||||
import { useUserData } from './user'
|
import { useUserData } from './user'
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<ConfirmDialog></ConfirmDialog>
|
||||||
|
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<Card class="detailCard flex">
|
<Card class="detailCard flex">
|
||||||
<template #title>
|
<template #title>
|
||||||
@@ -18,9 +20,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<Button class="button-box" label="Start" @click="startTable()" />
|
<div>
|
||||||
<Button class="button-box" label="Stop" @click="stopTable()" />
|
<Button class="button-box" label="Start" @click="startTable(activeTable)" />
|
||||||
<Button class="button-box" label="Delete" @click="deleteTable()" />
|
<Button class="button-box" label="Stop" @click="stopTable(activeTable)" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Button class="button-box" label="Hard Start" @click="hardStartTable(activeTable)" />
|
||||||
|
<Button class="button-box" label="Delete" @click="protectedDelete()" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
@@ -31,7 +38,7 @@
|
|||||||
<div class="flex flex-column">
|
<div class="flex flex-column">
|
||||||
<InputText class="button-box" name="table_name" type="text" placeholder="Table Name" />
|
<InputText class="button-box" name="table_name" type="text" placeholder="Table Name" />
|
||||||
<InputText class="button-box" name="table_link" type="text" placeholder="Table Link" />
|
<InputText class="button-box" name="table_link" type="text" placeholder="Table Link" />
|
||||||
<Dropdown class="button-box" name="version" :options="availableVersion"></Dropdown>
|
<Select class="button-box" name="version" :options="availableVersion"></Select>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@@ -69,23 +76,26 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { reactive, ref, useTemplateRef, onMounted, watch, onUnmounted } from 'vue'
|
import { reactive, ref, onMounted, watch, onUnmounted } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import { useConfirm } from 'primevue/useconfirm'
|
||||||
import { Form } from '@primevue/forms'
|
import { Form } from '@primevue/forms'
|
||||||
import InputText from 'primevue/inputtext'
|
import InputText from 'primevue/inputtext'
|
||||||
import Button from 'primevue/button'
|
import Button from 'primevue/button'
|
||||||
import Card from 'primevue/card'
|
import Card from 'primevue/card'
|
||||||
import Chip from 'primevue/chip'
|
import Chip from 'primevue/chip'
|
||||||
import Dropdown from 'primevue/dropdown'
|
import Select from 'primevue/select'
|
||||||
|
import ConfirmDialog from 'primevue/confirmdialog'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
useSelectedTable,
|
useSelectedTable,
|
||||||
loadSelectedTable,
|
loadSelectedTable,
|
||||||
// startTable,
|
clearSelectedTable,
|
||||||
|
startTable,
|
||||||
hardStartTable,
|
hardStartTable,
|
||||||
// stopTable,
|
stopTable,
|
||||||
updateTable,
|
updateTable,
|
||||||
// deleteTable,
|
deleteTable,
|
||||||
} from './game_tables'
|
} from './game_tables'
|
||||||
|
|
||||||
import type { GameTable } from './game_tables'
|
import type { GameTable } from './game_tables'
|
||||||
@@ -93,7 +103,8 @@ import type { Ref } from 'vue'
|
|||||||
|
|
||||||
const hostname = ref()
|
const hostname = ref()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const editForm = useTemplateRef('edit-form')
|
const router = useRouter()
|
||||||
|
const confirm = useConfirm()
|
||||||
|
|
||||||
const table = reactive({
|
const table = reactive({
|
||||||
table_name: 'default',
|
table_name: 'default',
|
||||||
@@ -137,8 +148,8 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
console.log('unmounted')
|
|
||||||
clearInterval(interval)
|
clearInterval(interval)
|
||||||
|
clearSelectedTable()
|
||||||
})
|
})
|
||||||
|
|
||||||
function readTable() {
|
function readTable() {
|
||||||
@@ -151,7 +162,7 @@ function readTable() {
|
|||||||
|
|
||||||
function readFoundryStatus() {
|
function readFoundryStatus() {
|
||||||
if (table.active) {
|
if (table.active) {
|
||||||
axios.get(`/${table.table_link}/api/status`).then((resp) => {
|
axios.get(`http://${activeTable.value.table_link}.${hostname.value}/api/status`).then((resp) => {
|
||||||
if (resp.status == 200) {
|
if (resp.status == 200) {
|
||||||
foundryStatus.running = resp.data.version
|
foundryStatus.running = resp.data.version
|
||||||
foundryStatus.active = resp.data.active
|
foundryStatus.active = resp.data.active
|
||||||
@@ -170,6 +181,17 @@ watch(activeTable, () => {
|
|||||||
forceReset.value++
|
forceReset.value++
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function protectedDelete() {
|
||||||
|
confirm.require({
|
||||||
|
header: `Delete ${table.table_name}?`,
|
||||||
|
message: "This will delete the table and all of it's data",
|
||||||
|
accept: () => {
|
||||||
|
deleteTable(activeTable.value)
|
||||||
|
router.push('/')
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function loadTable() {
|
function loadTable() {
|
||||||
axios
|
axios
|
||||||
.get(`/api/tables/${route.params.id}`)
|
.get(`/api/tables/${route.params.id}`)
|
||||||
@@ -198,21 +220,6 @@ function save(form: any) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function startTable() {
|
|
||||||
axios.post(`/api/tables/${route.params.id}:start`, { hard: 'false' })
|
|
||||||
}
|
|
||||||
|
|
||||||
function stopTable() {
|
|
||||||
axios.post(`/api/tables/${route.params.id}:stop`).then(() => {
|
|
||||||
foundryStatus.running = false
|
|
||||||
foundryStatus.active = false
|
|
||||||
foundryStatus.world = 'Not Loaded'
|
|
||||||
foundryStatus.users = 0
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteTable() { }
|
|
||||||
|
|
||||||
function isTableLoading() {
|
function isTableLoading() {
|
||||||
return table.active && !foundryStatus.running
|
return table.active && !foundryStatus.running
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,19 @@ export function loadSelectedTable(tableId: number = 0): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function clearSelectedTable(): void {
|
||||||
|
if ($selectedTable) {
|
||||||
|
$selectedTable.value = {
|
||||||
|
id: 0,
|
||||||
|
table_name: 'None',
|
||||||
|
table_link: 'None',
|
||||||
|
active: false,
|
||||||
|
version: 0,
|
||||||
|
user_id: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function startTable(gameTable: GameTable): void {
|
export function startTable(gameTable: GameTable): void {
|
||||||
axios
|
axios
|
||||||
.post(`/api/tables/${gameTable.id}:start`, { hard: 'False' })
|
.post(`/api/tables/${gameTable.id}:start`, { hard: 'False' })
|
||||||
|
|||||||
Reference in New Issue
Block a user