potato
This commit is contained in:
25
package-lock.json
generated
25
package-lock.json
generated
@@ -11,6 +11,7 @@
|
|||||||
"@primeuix/themes": "^2.0.3",
|
"@primeuix/themes": "^2.0.3",
|
||||||
"@primevue/forms": "^4.5.5",
|
"@primevue/forms": "^4.5.5",
|
||||||
"axios": "^1.13.6",
|
"axios": "^1.13.6",
|
||||||
|
"axios-retry": "^4.5.0",
|
||||||
"primeflex": "^4.0.0",
|
"primeflex": "^4.0.0",
|
||||||
"primeicons": "^7.0.0",
|
"primeicons": "^7.0.0",
|
||||||
"primevue": "^4.5.4",
|
"primevue": "^4.5.4",
|
||||||
@@ -2771,6 +2772,18 @@
|
|||||||
"proxy-from-env": "^2.1.0"
|
"proxy-from-env": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/axios-retry": {
|
||||||
|
"version": "4.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-4.5.0.tgz",
|
||||||
|
"integrity": "sha512-aR99oXhpEDGo0UuAlYcn2iGRds30k366Zfa05XWScR9QaQD4JYiP3/1Qt1u7YlefUOK+cn0CcwoL1oefavQUlQ==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"is-retry-allowed": "^2.2.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"axios": "0.x || 1.x"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/balanced-match": {
|
"node_modules/balanced-match": {
|
||||||
"version": "4.0.4",
|
"version": "4.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
||||||
@@ -3876,6 +3889,18 @@
|
|||||||
"node": ">=0.12.0"
|
"node": ">=0.12.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/is-retry-allowed": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-XVm7LOeLpTW4jV19QSH38vkswxoLud8sQ57YwJVTPWdiaI9I8keEhGFpBlslyVsgdQy4Opg8QOLb8YRgsyZiQg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/is-wsl": {
|
"node_modules/is-wsl": {
|
||||||
"version": "3.1.1",
|
"version": "3.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.1.tgz",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
"@primeuix/themes": "^2.0.3",
|
"@primeuix/themes": "^2.0.3",
|
||||||
"@primevue/forms": "^4.5.5",
|
"@primevue/forms": "^4.5.5",
|
||||||
"axios": "^1.13.6",
|
"axios": "^1.13.6",
|
||||||
|
"axios-retry": "^4.5.0",
|
||||||
"primeflex": "^4.0.0",
|
"primeflex": "^4.0.0",
|
||||||
"primeicons": "^7.0.0",
|
"primeicons": "^7.0.0",
|
||||||
"primevue": "^4.5.4",
|
"primevue": "^4.5.4",
|
||||||
|
|||||||
@@ -40,12 +40,12 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function tableLink() {
|
function tableLink() {
|
||||||
if (selectedTableRef.value.table_link == "None") {
|
if (!selectedTableRef.value) {
|
||||||
linkVisible.value = false
|
linkVisible.value = false
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
linkVisible.value = true
|
linkVisible.value = true
|
||||||
return 'http://' + selectedTableRef.value.table_link + '.' + hostname.value
|
return 'http://' + hostname.value + "/" + selectedTableRef.value.table_link
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayUsername(): string {
|
function displayUsername(): string {
|
||||||
|
|||||||
@@ -21,17 +21,17 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div>
|
<div>
|
||||||
<Button class="button-box" label="Start" @click="startTable(activeTable)" />
|
<Button class="button-box" label="Start" @click="startTable(activeTable!)" />
|
||||||
<Button class="button-box" label="Stop" @click="stopTable(activeTable)" />
|
<Button class="button-box" label="Stop" @click="stopTable(activeTable!)" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button class="button-box" label="Hard Start" @click="hardStartTable(activeTable)" />
|
<Button class="button-box" label="Hard Start" @click="hardStartTable(activeTable!)" />
|
||||||
<Button class="button-box" label="Delete" @click="protectedDelete()" />
|
<Button class="button-box" label="Delete" @click="protectedDelete()" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Form :key="forceReset" ref="edit-form" :initialValues="activeTable" @submit="save">
|
<Form :key="forceReset" ref="edit-form" :initialValues="activeTable!" @submit="save">
|
||||||
<Card class="detailCard flex">
|
<Card class="detailCard flex">
|
||||||
<template #title> Edit Details </template>
|
<template #title> Edit Details </template>
|
||||||
<template #content>
|
<template #content>
|
||||||
@@ -123,7 +123,7 @@ const table = reactive({
|
|||||||
version: 0,
|
version: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
const activeTable: Ref<GameTable> = useSelectedTable()
|
const activeTable: Ref<GameTable | null> = useSelectedTable()
|
||||||
const forceReset = ref(0)
|
const forceReset = ref(0)
|
||||||
|
|
||||||
const foundryStatus = reactive({
|
const foundryStatus = reactive({
|
||||||
@@ -171,7 +171,7 @@ function readTable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function readFoundryStatus() {
|
function readFoundryStatus() {
|
||||||
if (table.active) {
|
if (activeTable.value) {
|
||||||
axios.get(`http://${activeTable.value.table_link}.${hostname.value}/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
|
||||||
@@ -192,14 +192,16 @@ watch(activeTable, () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function protectedDelete() {
|
function protectedDelete() {
|
||||||
|
if (activeTable.value) {
|
||||||
confirm.require({
|
confirm.require({
|
||||||
header: `Delete ${table.table_name}?`,
|
header: `Delete ${table.table_name}?`,
|
||||||
message: "This will delete the table and all of it's data",
|
message: "This will delete the table and all of it's data",
|
||||||
accept: () => {
|
accept: () => {
|
||||||
deleteTable(activeTable.value)
|
deleteTable(activeTable.value!)
|
||||||
router.push('/')
|
router.push('/')
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadTable() {
|
function loadTable() {
|
||||||
@@ -219,7 +221,7 @@ function loadTable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function save(form: any) {
|
function save(form: any) {
|
||||||
console.log(form)
|
if (activeTable.value) {
|
||||||
updateTable(activeTable.value.id, {
|
updateTable(activeTable.value.id, {
|
||||||
id: activeTable.value.id,
|
id: activeTable.value.id,
|
||||||
table_name: form.values.table_name,
|
table_name: form.values.table_name,
|
||||||
@@ -228,6 +230,7 @@ function save(form: any) {
|
|||||||
version: form.values.version,
|
version: form.values.version,
|
||||||
user_id: activeTable.value.user_id
|
user_id: activeTable.value.user_id
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isTableLoading() {
|
function isTableLoading() {
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
|
|
||||||
<Column field="table_link" header="Table Link">
|
<Column field="table_link" header="Table Link">
|
||||||
<template #body="slotProps">
|
<template #body="slotProps">
|
||||||
<a v-if="slotProps.data.active" :href="'http://' + slotProps.data.table_link + '.' + hostname">
|
<a v-if="slotProps.data.active" :href="'http://' + hostname + '/' + slotProps.data.table_link"">
|
||||||
http://{{ slotProps.data.table_link }}.{{ hostname }}/
|
http://{{ hostname }}/{{ slotProps.data.table_link }}
|
||||||
</a>
|
</a>
|
||||||
<div v-if="!slotProps.data.active">
|
<div v-if="!slotProps.data.active">
|
||||||
http://{{ slotProps.data.table_link }}.{{ hostname }}/
|
http://{{ hostname }}/{{ slotProps.data.table_link }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export interface GameTable {
|
|||||||
user_id: number
|
user_id: number
|
||||||
}
|
}
|
||||||
|
|
||||||
let $selectedTable: Ref<GameTable> | undefined
|
let $selectedTable: Ref<GameTable | null> | undefined
|
||||||
let $activeTables: Ref<Array<GameTable>> | undefined
|
let $activeTables: Ref<Array<GameTable>> | undefined
|
||||||
let $allTables: Ref<Array<GameTable>> | undefined
|
let $allTables: Ref<Array<GameTable>> | undefined
|
||||||
|
|
||||||
@@ -27,16 +27,9 @@ export function useAllTables(): Ref<Array<GameTable>> {
|
|||||||
return $allTables
|
return $allTables
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useSelectedTable(): Ref<GameTable> {
|
export function useSelectedTable(): Ref<GameTable | null> {
|
||||||
if (!$selectedTable)
|
if (!$selectedTable)
|
||||||
$selectedTable = ref({
|
$selectedTable = ref(null)
|
||||||
id: 0,
|
|
||||||
table_name: 'None',
|
|
||||||
table_link: 'None',
|
|
||||||
active: false,
|
|
||||||
version: 0,
|
|
||||||
user_id: 0,
|
|
||||||
})
|
|
||||||
return $selectedTable
|
return $selectedTable
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +43,7 @@ export function loadAllTables(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function loadSelectedTable(tableId: number = 0): void {
|
export function loadSelectedTable(tableId: number = 0): void {
|
||||||
if ($selectedTable) {
|
if ($selectedTable && $selectedTable.value) {
|
||||||
let id = tableId || $selectedTable.value.id
|
let id = tableId || $selectedTable.value.id
|
||||||
axios.get(`/api/tables/${id}`).then((resp) => ($selectedTable!.value = resp.data))
|
axios.get(`/api/tables/${id}`).then((resp) => ($selectedTable!.value = resp.data))
|
||||||
}
|
}
|
||||||
@@ -69,12 +62,23 @@ export function clearSelectedTable(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function startTable(gameTable: GameTable): void {
|
export async function startTable(gameTable: GameTable): Promise<void> {
|
||||||
axios
|
await axios
|
||||||
.post(`/api/tables/${gameTable.id}:start`, { hard: 'False' })
|
.post(`/api/tables/${gameTable.id}:start`, { hard: 'False' })
|
||||||
.then(() => loadAllTables())
|
.then(() => loadAllTables())
|
||||||
.then(() => loadActiveTables())
|
.then(() => loadActiveTables())
|
||||||
.then(() => loadSelectedTable())
|
.then(() => loadSelectedTable())
|
||||||
|
|
||||||
|
for (let retries = 0; retries < 10; retries++) {
|
||||||
|
try {
|
||||||
|
await axios.get(`http://${location.hostname}/${gameTable.table_link}`)
|
||||||
|
console.log('loaded')
|
||||||
|
return
|
||||||
|
} catch {
|
||||||
|
await new Promise(f => setTimeout(f, 1000))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hardStartTable(gameTable: GameTable): void {
|
export function hardStartTable(gameTable: GameTable): void {
|
||||||
@@ -93,7 +97,7 @@ export function stopTable(gameTable: GameTable): void {
|
|||||||
.then(() => loadSelectedTable())
|
.then(() => loadSelectedTable())
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTable(): Promise<number> {
|
export async function createTable(): Promise<number> {
|
||||||
return axios.post(`/api/tables`, {}).then((resp) => resp.data.id)
|
return axios.post(`/api/tables`, {}).then((resp) => resp.data.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user