Debug frontend

master
adb-sh 2 years ago
parent 4a6255185a
commit f674f28921

@ -79,11 +79,11 @@ http {
location / { location / {
index index.html; #index index.html;
root /var/www/html; #root /var/www/html;
try_files $uri $uri/ /index.html; #try_files $uri $uri/ /index.html;
#proxy_set_header "Host" "127.0.0.1:8080"; proxy_set_header "Host" "127.0.0.1:8080";
#proxy_pass http://frontend:8080; proxy_pass http://frontend:8080;
} }
location /api/public { location /api/public {

@ -57,10 +57,10 @@ export class Api {
return (await this.axios.get(`/test`))?.data; return (await this.axios.get(`/test`))?.data;
} }
async getRole() { async getRole() {
return (await this.axios.get(`/user/role`))?.data; return (await this.axios.get(`/me/role`))?.data;
} }
async getCurrentlyPlaying() { async getCurrentlyPlaying() {
return (await this.axios.get(`/user/currentlyPlaying`))?.data; return (await this.axios.get(`/me/currentlyPlaying`))?.data;
} }
async getUserInfo(userId: string) { async getUserInfo(userId: string) {

@ -11,7 +11,10 @@
import { ref, watch } from 'vue'; import { ref, watch } from 'vue';
import { themeConfig } from '@/main'; import { themeConfig } from '@/main';
const sliderState = ref(themeConfig.getTheme() === 'dark'); let currentTheme;
currentTheme = themeConfig.getTheme() === 'dark'
const sliderState = ref(currentTheme);
watch(sliderState, (state) => { watch(sliderState, (state) => {
themeConfig.setTheme(state ? 'dark' : 'light'); themeConfig.setTheme(state ? 'dark' : 'light');

@ -8,18 +8,26 @@
:data="getter(data)" :data="getter(data)"
:update="update" :update="update"
/> />
<slot v-if="error" name="error"> <slot
v-if="error"
name="error"
:error="error"
:update="update"
>
<div class="alert alert-danger"> <div class="alert alert-danger">
{{ error.message || 'Oops! Something went wrong :/' }} {{ error.message || 'Oops! Something went wrong :/' }}
</div> </div>
</slot> </slot>
<slot v-else-if="loading && showThrobber" name="loading"> <transition name="fade">
<div class="overlay"> <slot v-if="loading && showThrobber" name="loading">
<div class="wrapper"> <div class="overlay">
<ThrobberLoading /> <div class="wrapper">
<div class="background bg-darkmode-dark bg-light" />
<ThrobberLoading class="position-relative" />
</div>
</div> </div>
</div> </slot>
</slot> </transition>
</div> </div>
</template> </template>
@ -57,6 +65,7 @@ const update = async (promise: Promise | unknown) => {
data.value = await (promise.isPromiseList data.value = await (promise.isPromiseList
? Promise.all(promise.promises) ? Promise.all(promise.promises)
: promise); : promise);
error.value = null;
} catch (e) { } catch (e) {
error.value = e; error.value = e;
} finally { } finally {
@ -83,8 +92,6 @@ watch(() => props.promise, (to) => {
width: 100%; width: 100%;
height: 100%; height: 100%;
min-height: 5rem; min-height: 5rem;
background-color: #fffd;
z-index: 9000;
.wrapper { .wrapper {
position: sticky; position: sticky;
display: flex; display: flex;
@ -93,6 +100,14 @@ watch(() => props.promise, (to) => {
top: 0; top: 0;
height: 100%; height: 100%;
max-height: 100vh; max-height: 100vh;
.background {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
opacity: 0.9;
}
} }
} }
} }

@ -30,13 +30,17 @@ onBeforeUnmount(() => {
class="progress-bar" class="progress-bar"
role="progressbar" role="progressbar"
:style="{ :style="{
width: `${ estimatedProgress / duration * 100 }%` width: `${ Math.min(estimatedProgress / duration, 1) * 100 }%`
}" }"
/> />
</div> </div>
<div class="row my-2"> <div class="row my-2">
<div class="col"> <div class="col">
<TimeFormatter :seconds="estimatedProgress / 1000"/> <TimeFormatter
:seconds="
Math.min(estimatedProgress, duration) / 1000
"
/>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<TimeFormatter :seconds="duration / 1000"/> <TimeFormatter :seconds="duration / 1000"/>

@ -11,3 +11,16 @@ html, body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.fade-enter-active, .fade-leave-active {
transition-property: opacity;
transition-duration: .25s;
}
.fade-enter-active {
transition-delay: .25s;
}
.fade-enter, .fade-leave-active {
opacity: 0
}

@ -23,7 +23,7 @@ const routes: Array<RouteRecordRaw> = [
component: () => component: () =>
import(/* webpackChunkName: "me" */ "../views/MePage.vue"), import(/* webpackChunkName: "me" */ "../views/MePage.vue"),
meta: { meta: {
requireAuth: false, requireAuth: true,
}, },
}, },
{ {

@ -1,37 +1,85 @@
<script setup lang="ts"></script> <script setup lang="ts">
import PromiseResolver from "@/components/PromiseResolver.vue";
import CurrentlyPlayingCompact from "@/components/CurrentlyPlayingCompact.vue";
import { onBeforeUnmount, ref } from "vue";
import { useApi } from "@/Api";
const api = useApi();
const userInfo = ref(api?.getCurrentlyPlaying());
let refreshUserInfo = setInterval(() => {
userInfo.value = api?.getCurrentlyPlaying();
}, 10000);
onBeforeUnmount(() => {
clearInterval(refreshUserInfo);
});
</script>
<template> <template>
<div> <div>
<h1>Me</h1> <h1>Me</h1>
<h2>Currently Listening to</h2>
<PromiseResolver
:promise="userInfo"
v-slot="{ data: { currentlyPlaying } }"
>
<CurrentlyPlayingCompact v-if="currentlyPlaying?.item" :currentlyPlaying="currentlyPlaying" />
<div v-else class="alert alert-info">
You are not listening to music.
</div>
</PromiseResolver>
<h2>Session</h2>
<PromiseResolver <PromiseResolver
:promise="$api.getSession()" :promise="$api.getSession()"
v-slot="slot"
> >
<div class="card"> <template #default="{ data: { session }, update }">
<div class="card-header"> <div class="card">
Your session <div class="card-header">
</div> Your session
<div class="card-body"> </div>
<p> <div class="card-body">
{{ slot }} <b>Host</b>
</p> <div>
<b>Clients</b> {{ session.host?.spotify.userId }}
</div>
<b>Clients</b>
<div>
<div v-for="client in session.clients" :key="client">
{{ client.displayName }}
</div>
</div>
</div>
<div class="card-footer">
<button
class="btn btn-danger mx-1"
@click="$api.leaveSession().then(() => update($api.getSession()))"
>
leave Session
</button>
<button
class="btn btn-danger mx-1"
@click="$api.deleteSession().then(() => update($api.getSession()))"
>
delete Session
</button>
</div>
</div> </div>
<div class="card-footer"> </template>
<button <template #error="{ error, update }">
class="btn btn-danger mx-1" <div v-if="error.response.status === 404">
@click="$api.leaveSession().then(() => update($api.getSession()))" <div class="alert alert-info">
> You are not part of a session.
leave Session </div>
</button>
<button <button
class="btn btn-danger mx-1" @click="$api.createSession().then(() => update($api.getSession()))"
@click="$api.deleteSession().then(() => update($api.getSession()))" class="btn btn-success"
> >
delete Session Create Session
</button> </button>
</div> </div>
</div> </template>
</PromiseResolver> </PromiseResolver>
</div> </div>
</template> </template>

Loading…
Cancel
Save