1
0
Fork 0
forked from TWS/kalkutago

Frontend was merged prematurely, this fixes that #3

Merged
scott merged 5 commits from frontend/feature/login-view into feature/user-auth 2023-08-26 06:18:07 -04:00
2 changed files with 11 additions and 0 deletions
Showing only changes of commit 290218eefe - Show all commits

View file

@ -2,6 +2,7 @@ import { reactive } from "vue"
import { Track } from "./track"
import { Tick } from './ticks'
import { error } from "./error"
import { getCookie } from "./util";
enum State {
Unfetched,
@ -31,6 +32,8 @@ class AppState {
constructor() {
this.tracks = new Array<Track>
this.state = State.Unfetched
const name = getCookie("name")
if (name) this.user = { name }
}
streamUpdatesFromServer() {
const source = new EventSource("/api/v1/updates")

8
client/src/util.ts Normal file
View file

@ -0,0 +1,8 @@
export function getCookie(key: string): string | null {
const start = document.cookie.indexOf(key + '=')
if(start === -1) return null
let end: number | undefined = document.cookie.indexOf(';', start)
if(end === -1)
end = undefined
return document.cookie.substring(start + key.length + 1, end)
}