Fixed last broken link probably
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@
|
||||
</div>
|
||||
<div class="nav-group center">
|
||||
<div class="nav-item">
|
||||
<a href="..">Posti DM</a>
|
||||
<a href=".">Posti DM</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createRoomEventStream, Database, getLoggedUser } from '../index.js'
|
||||
import { BASE_URL, createRoomEventStream, Database, getLoggedUser } from '../index.js'
|
||||
import { addTooltipElementListener, resetTooltip, setTooltipText } from './tooltip.js'
|
||||
|
||||
async function renderWidget(elSeatMap, seats) {
|
||||
@@ -67,7 +67,7 @@ export async function createSeatWidget($roomGrid, roomId) {
|
||||
// Listener for takeing or leaving a seat
|
||||
$seat.addEventListener('click', async () => {
|
||||
if (!user) {
|
||||
location.href = '/login.html'
|
||||
location.href = `${BASE_URL}/`
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -1,24 +1,24 @@
|
||||
import './style.scss'
|
||||
|
||||
export const BASE_URL = import.meta.env.BASE_URL.replace(/\/$/, '')
|
||||
|
||||
let USER = false
|
||||
export async function getLoggedUser() {
|
||||
if (USER === false) {
|
||||
console.log('Caching user data...')
|
||||
USER = await (await fetch(`${import.meta.env.BASE_URL}api/user`)).json()
|
||||
USER = await (await fetch(`${BASE_URL}/api/user`)).json()
|
||||
}
|
||||
|
||||
return USER
|
||||
}
|
||||
|
||||
export function createRoomEventStream(roomId) {
|
||||
return new EventSource(`${import.meta.env.BASE_URL}api/room_events?id=${roomId}`)
|
||||
return new EventSource(`${BASE_URL}/api/room_events?id=${roomId}`)
|
||||
}
|
||||
|
||||
export const Database = {
|
||||
async getSeats(roomId) {
|
||||
const seatList = await (
|
||||
await fetch(`${import.meta.env.BASE_URL}api/room/seats?id=${roomId}`)
|
||||
).json()
|
||||
const seatList = await (await fetch(`${BASE_URL}/api/room/seats?id=${roomId}`)).json()
|
||||
const seats = {}
|
||||
|
||||
seatList.forEach(seat => {
|
||||
@@ -28,7 +28,7 @@ export const Database = {
|
||||
return seats
|
||||
},
|
||||
async occupySeat(seatId) {
|
||||
const response = await fetch(`${import.meta.env.BASE_URL}api/seat/occupy?id=${seatId}`, {
|
||||
const response = await fetch(`${BASE_URL}/api/seat/occupy?id=${seatId}`, {
|
||||
method: 'POST',
|
||||
})
|
||||
|
||||
@@ -39,7 +39,7 @@ export const Database = {
|
||||
await response.json()
|
||||
},
|
||||
async leaveSeat(seatId) {
|
||||
const response = await fetch(`${import.meta.env.BASE_URL}api/seat/leave?id=${seatId}`, {
|
||||
const response = await fetch(`${BASE_URL}/api/seat/leave?id=${seatId}`, {
|
||||
method: 'POST',
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createGridLineCanvas } from '../components/gridlines.js'
|
||||
import { getLoggedUser } from '../index.js'
|
||||
import { BASE_URL, getLoggedUser } from '../index.js'
|
||||
import { createSeatWidget } from '../components/seats-widget.js'
|
||||
import { createClock } from '../components/clock.js'
|
||||
import { attachTooltip } from '../components/tooltip.js'
|
||||
@@ -15,8 +15,8 @@ const elLogoutButton = document.querySelector('#logout-button')
|
||||
const elRoomGrid = document.querySelector('.room-grid')
|
||||
|
||||
async function logout() {
|
||||
await fetch(`${import.meta.env.BASE_URL}api/logout`, { method: 'POST' })
|
||||
location.href = `${import.meta.env.BASE_URL}`
|
||||
await fetch(`${BASE_URL}/api/logout`, { method: 'POST' })
|
||||
location.href = `${BASE_URL}`
|
||||
}
|
||||
|
||||
async function main() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getLoggedUser } from '../index.js'
|
||||
import { BASE_URL, getLoggedUser } from '../index.js'
|
||||
|
||||
//
|
||||
// Page Element
|
||||
@@ -33,7 +33,7 @@ function displayErrorString(e) {
|
||||
|
||||
async function login() {
|
||||
try {
|
||||
const response = await fetch(`${import.meta.env.BASE_URL}api/login`, {
|
||||
const response = await fetch(`${BASE_URL}/api/login`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json, text/plain, */*',
|
||||
@@ -50,7 +50,7 @@ async function login() {
|
||||
return
|
||||
}
|
||||
|
||||
location.href = `${import.meta.env.BASE_URL}`
|
||||
location.href = `${BASE_URL}/`
|
||||
} catch (e) {
|
||||
displayErrorString(e)
|
||||
}
|
||||
@@ -64,7 +64,7 @@ async function main() {
|
||||
const user = await getLoggedUser()
|
||||
console.log(user)
|
||||
if (user) {
|
||||
location.href = `${import.meta.env.BASE_URL}`
|
||||
location.href = `${BASE_URL}/`
|
||||
}
|
||||
|
||||
elLoginButton.addEventListener('click', () => login())
|
||||
|
||||
Reference in New Issue
Block a user