-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f590ac9
commit eab4b8e
Showing
12 changed files
with
197 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script lang="ts" setup> | ||
import { BccSelect } from "@bcc-code/design-library-vue"; | ||
defineProps<{ | ||
albums: readonly string[]; | ||
}>(); | ||
const value = defineModel<string>(); | ||
</script> | ||
|
||
<template> | ||
<BccSelect v-model="value" :label="$t('album')"> | ||
<option disabled value="">{{ $t("selectAnOption") }}</option> | ||
<option v-for="a in albums" :value="a"> | ||
{{ a }} | ||
</option> | ||
</BccSelect> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<script lang="tsx" setup> | ||
import { BccFormLabel } from "@bcc-code/design-library-vue"; | ||
const tracks = ref<Track[]>(); | ||
const props = defineProps<{ | ||
album: string; | ||
label: string; | ||
}>(); | ||
onMounted(async () => { | ||
tracks.value = await $fetch("/api/bmm/tracks/" + props.album, { | ||
method: "GET", | ||
}); | ||
}); | ||
const value = defineModel<number>(); | ||
const clicked = ref(false); | ||
const display = computed(() => { | ||
return tracks.value?.find((i) => i.id === value.value); | ||
}); | ||
const dateString = (date: Date) => { | ||
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`; | ||
}; | ||
const TrackView = (props: { track: Track }) => { | ||
const track = props.track; | ||
return ( | ||
<p class="flex cursor-pointer gap-2 rounded bg-slate-50 pl-2"> | ||
<span>{dateString(new Date(track.published_at))}</span> | ||
<span class="rounded-r bg-slate-200 px-2">{track.title}</span> | ||
</p> | ||
); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<BccFormLabel> | ||
{{ label }} | ||
</BccFormLabel> | ||
<div v-if="!clicked" class="flex"> | ||
<TrackView | ||
@click="clicked = true" | ||
v-if="display" | ||
:track="display" | ||
/> | ||
</div> | ||
<div v-else class="flex flex-col gap-2"> | ||
<div v-for="t in tracks" class="flex"> | ||
<TrackView | ||
:track="t" | ||
@click=" | ||
value = t.id; | ||
clicked = false; | ||
" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default defineEventHandler(async (event) => { | ||
return { | ||
languages: ["nb", "en"], | ||
albums: ["fra-kaare", "romans"], | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default defineEventHandler(async (event) => { | ||
const album = getRouterParam(event, "album"); | ||
|
||
switch (album) { | ||
case "fra-kaare": | ||
return await getFraKaareTracks(); | ||
} | ||
return []; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Track } from "~/utils/bmm"; | ||
|
||
export const getFraKaareTracks = async () => { | ||
const tracks = await $fetch( | ||
"https://bmm-api.brunstad.org/track?tags=fra-kaare&size=100", | ||
{ | ||
method: "GET", | ||
headers: { | ||
Authorization: "Bearer " + useRuntimeConfig().api.bmm.token, | ||
"Accept-Language": "nb", | ||
}, | ||
}, | ||
); | ||
|
||
return (tracks as Track[]).map( | ||
(i) => | ||
({ | ||
id: i.id, | ||
title: i.title, | ||
type: "track", | ||
published_at: i.published_at, | ||
}) as Track, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
export type Track = { | ||
title: string; | ||
id: number; | ||
type: "track"; | ||
published_at: string; | ||
}; | ||
|
||
export type TrackSubType = "audiobook"; | ||
|
||
export type BMMSingleForm = { | ||
originalTitle: string; | ||
title: string; | ||
albumId?: string; | ||
trackId?: string; | ||
trackId?: number; | ||
language?: (typeof bmmLanguages)[number]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
export default <T extends {}>(ref: Ref<T | undefined>, property: keyof T) => { | ||
export default function computedProperty<T, K extends keyof T>( | ||
mutable: Ref<T | undefined>, | ||
property: K, | ||
): globalThis.Ref<T[K] | undefined> { | ||
return computed({ | ||
get() { | ||
return ref.value?.[property]; | ||
return mutable.value?.[property]; | ||
}, | ||
set(v) { | ||
ref.value = ref.value | ||
? { | ||
...ref.value, | ||
[property]: v, | ||
} | ||
: undefined; | ||
mutable.value = { | ||
...(mutable.value ?? ({} as T)), | ||
[property]: v, | ||
}; | ||
}, | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export type Role = "fra-kaare-translator"; | ||
|
||
export const roleTags = (roles: Role[]) => {}; |