Skip to content

Commit

Permalink
models, types & persistent storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayo Horkovic committed Oct 29, 2023
1 parent c66d58e commit 0e6c858
Show file tree
Hide file tree
Showing 53 changed files with 554 additions and 216 deletions.
33 changes: 29 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"laravel-vue-i18n": "^2.7.1",
"openseadragon": "^4.1.0",
"pinia": "^2.1.6",
"pinia-plugin-persistedstate": "^3.2.0",
"vue": "^3.3.7",
"vue-router": "^4.2.5",
"vue3-carousel": "^0.3.1"
Expand Down
13 changes: 8 additions & 5 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import './bootstrap'
import './css/style.css'

import App from './App.vue'
import '@/bootstrap'
import '@/css/style.css'

import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router/auto'
import { i18nVue } from 'laravel-vue-i18n'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import * as Sentry from '@sentry/vue'

import App from '@/App.vue'
import { useLocaleStore } from '@/stores/LocaleStore'
import { useHistoryStore } from '@/stores/HistoryStore'

Expand All @@ -29,7 +29,10 @@ const app = createApp(App)
Sentry.init({ app, dsn: import.meta.env.VITE_SENTRY_DSN })

app.use(router)
app.use(createPinia())

const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
app.use(pinia)

const localeStore = useLocaleStore()
app.use(i18nVue, {
Expand Down
4 changes: 3 additions & 1 deletion src/components/author/AuthorDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
</template>

<script setup lang="ts">
import Item from '@/models/Item'
defineProps<{
item: any //TODO: add model
item: Item
}>()
</script>
4 changes: 3 additions & 1 deletion src/components/author/AuthorSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
</template>

<script setup lang="ts">
import Item from '@/models/Item'
defineProps<{
item: any // TODO: add model
item: Item
}>()
</script>
10 changes: 6 additions & 4 deletions src/components/author/AuthorityDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ import axios from 'axios'
import ItemPreview from '@/components/general/ItemPreview.vue'
import ItemImage from '@/components/general/ItemImage.vue'
import Authority from '@/models/Authority'
import Item from '@/models/Item'
const props = defineProps<{
authority: any // TODO: add model
authority: Authority
}>()
const relatedItems = ref<any[]>([]) // TODO: add model
const previewItem = ref<any | null>(null) // TODO: add model
const relatedItems = ref<Item[]>([])
const previewItem = ref<Item | null>(null)
const isLoading = ref(true)
onMounted(async () => {
Expand All @@ -56,7 +58,7 @@ onMounted(async () => {
const response = await axios.get(
`/api/related_items/${props.authority.related_items.join(',')}`
)
relatedItems.value = response.data.data
relatedItems.value = response.data.data.map((item: any) => new Item(item))
} catch (error) {
console.error(error)
} finally {
Expand Down
4 changes: 3 additions & 1 deletion src/components/author/AuthoritySummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
</template>

<script setup lang="ts">
import Authority from '@/models/Authority'
defineProps<{
authority: any // TODO: add model
authority: Authority
}>()
</script>
13 changes: 7 additions & 6 deletions src/components/bucketlist/Bucketlist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
unlocked
? $t('All artworks found')
: $t(':found of :all artworks found', {
found: found.length,
all: bucketlist.items.length,
found: String(found?.length ?? 0),
all: String(bucketlist.items.length ?? 0),
})
}}
</p>
Expand Down Expand Up @@ -58,7 +58,7 @@
</Thumbnail>
</router-link>
</div>
<div v-if="found.length">
<div v-if="found?.length">
<h3 class="text-1.5xl font-medium leading-6">{{ $t('Found') }}</h3>
<div class="mt-4 flex flex-col gap-y-4">
<router-link v-for="item in found" :key="item.id" :to="`/item/${item.id}`">
Expand All @@ -82,13 +82,14 @@ import ItemThumbnail from '@/components/general/ItemThumbnail.vue'
import LockedItemThumbnail from '@/components/bucketlist/LockedItemThumbnail.vue'
import ResponsiveImageWithSizes from '@/components/general/ResponsiveImageWithSizes.vue'
import Thumbnail from '@/components/general/Thumbnail.vue'
import Bucketlist from '@/models/Bucketlist'
const props = defineProps<{
id: string
}>()
const bucketlistStore = useBucketlistStore()
const interactionStore = useInteractionStore()
const bucketlist = ref<any | null>(null) // TODO: add model
const bucketlist = ref<Bucketlist | null>(null)
const found = computed(() => {
return bucketlist.value?.items.filter((item) => interactionStore.isItemViewed(item.id))
Expand All @@ -98,10 +99,10 @@ const notFound = computed(() => {
return bucketlist.value?.items.filter((item) => !interactionStore.isItemViewed(item.id))
})
const unlocked = computed(() => !notFound.value.length)
const unlocked = computed(() => !notFound.value?.length)
onMounted(async () => {
bucketlist.value = bucketlistStore.get(props.id)
bucketlist.value = bucketlistStore.get(props.id)!
bucketlist.value = await bucketlistStore.load(props.id)
})
</script>
3 changes: 2 additions & 1 deletion src/components/bucketlist/LockedItemThumbnail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
<script setup lang="ts">
import ResponsiveImageWithSizes from '@/components/general/ResponsiveImageWithSizes.vue'
import Thumbnail from '@/components/general/Thumbnail.vue'
import Item from '@/models/Item'
defineProps<{
item: any // TODO: add model
item: Item
}>()
</script>
10 changes: 6 additions & 4 deletions src/components/general/ImageLightbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</button>
</div>
<div
v-if="visible"
v-if="visible && images"
class="fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4"
@click="visible = false"
>
Expand All @@ -42,16 +42,18 @@
</template>

<script setup lang="ts">
import type { IImage } from '@/models/_Interfaces'
import ZoomViewer from '@/components/misc/ZoomViewer.vue'
import ItemImage from '@/components/general/ItemImage.vue'
defineProps<{
alt: string
offsetTop: number
src: string
srcset: string
images: string[]
imageAspectRatio: number
offsetTop?: number
images?: IImage[]
imageAspectRatio?: number
imgClass?: string
}>()
Expand Down
2 changes: 1 addition & 1 deletion src/components/general/ItemImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<script setup lang="ts">
defineProps<{
alt: string
offsetTop: number
offsetTop?: number
src: string
srcset: string
}>()
Expand Down
4 changes: 3 additions & 1 deletion src/components/general/ItemLoader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
</template>

<script setup lang="ts">
import Item from '@/models/Item'
const props = defineProps<{
id: string
}>()
const item = ref<any | null>(null) // TODO: add model
const item = ref<Item | null>(null)
onMounted(async () => {
const itemStore = useItemStore()
Expand Down
3 changes: 2 additions & 1 deletion src/components/general/ItemPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@
<script setup lang="ts">
import WebumeniaButton from '@/components/forms/WebumeniaButton.vue'
import ConfirmButton from '@/components/forms/ConfirmButton.vue'
import Item from '@/models/Item'
defineProps<{
item: any //TODO: add model
item: Item
}>()
const emit = defineEmits<{
Expand Down
3 changes: 2 additions & 1 deletion src/components/general/ItemThumbnail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
<script setup lang="ts">
import Thumbnail from '@/components/general/Thumbnail.vue'
import ResponsiveImageWithSizes from '@/components/general/ResponsiveImageWithSizes.vue'
import Item from '@/models/Item'
defineProps<{
item: any //TODO: add model
item: Item
}>()
</script>
4 changes: 3 additions & 1 deletion src/components/general/ResponsiveImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
</template>

<script setup lang="ts">
import type { IImage } from '@/models/_Interfaces'
defineProps<{
image: any //TODO: add model
image: IImage
}>()
</script>
4 changes: 3 additions & 1 deletion src/components/general/ResponsiveImageWithSizes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
</template>

<script setup lang="ts">
import type { IImage } from '@/models/_Interfaces'
defineProps<{
image: any //TODO: add model
image: IImage
}>()
const img = ref<any | null>(null)
Expand Down
4 changes: 2 additions & 2 deletions src/components/general/ResponsiveVideoEmbed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<script setup lang="ts">
defineProps<{
src: string
width: number
height: number
width?: number
height?: number
}>()
</script>
4 changes: 3 additions & 1 deletion src/components/general/VideoSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
</template>

<script setup lang="ts">
import type { IImage } from '@/models/_Interfaces'
import ResponsiveImage from '@/components/general/ResponsiveImage.vue'
defineProps<{
thumbnail: any //TODO: add model
thumbnail: IImage
title?: string
subtitle?: string
}>()
Expand Down
8 changes: 6 additions & 2 deletions src/components/interactions/InteractionItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
</template>

<script setup lang="ts">
import type { Component } from 'vue'
import Item from '@/models/Item'
defineProps<{
item: any //TODO: add model
item: Item
label: string
icon: any //TODO: add model
icon: Component
iconClass?: string
}>()
</script>
4 changes: 2 additions & 2 deletions src/components/interactions/InteractionItemFavourited.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
icon-class="fill-current"
:label="$t('Saved')"
v-bind="props"
item=""
/>
</template>

<script setup lang="ts">
import SvgHeartSmall from '@/components/svg/SvgHeartSmall.vue'
import InteractionItem from '@/components/interactions/InteractionItem.vue'
import Item from '@/models/Item'
const props = defineProps<{
item: any //TODO: add model
item: Item
}>()
</script>
Loading

0 comments on commit 0e6c858

Please sign in to comment.