Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Invictus Bier Systeem is _het_ websysteem voor O.D.D. Invictus.

## Ontwikkelen

IBS3 gebruikt node 22.4.0
IBS3 gebruikt node 22.11.0

Om te beginnen met ontwikkelen moet je eerst de repository clonen met

Expand Down
32 changes: 32 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ model User {
File File[]
AccessToken AccessToken[]
Activity Activity[]

FrontPageItem FrontPageItem[]
}

model Account {
Expand Down Expand Up @@ -915,6 +917,8 @@ model File {
Photo Photo[]
Journal Journal? @relation(fields: [journalId], references: [id])
journalId Int?

FrontPageImage FrontPageItem[]
}

//
Expand All @@ -933,3 +937,31 @@ model Job {
completedAt DateTime?
result String?
}

//
// Dit moet natuurlijk in de database
//
model FrontPageItem {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

// HTML ID waar deze foto komt
key String
// Titel (staat bij een foto)
// bijv. Lichting 1
title String
// Bijbehordende beschrijving
description String
visible Boolean @default(false)

// verwijst dit item naar een andere pagina?
link String?

changedBy User? @relation(fields: [userId], references: [id], onDelete: NoAction)
userId Int?

// Photo
file File @relation(fields: [fileId], references: [id], onDelete: Cascade)
fileId String
}
4 changes: 2 additions & 2 deletions src/lib/server/auth/authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ const handleAuthorization = (async ({ event, resolve }) => {
if (event.route.id?.includes('(public)')) {
// Resolve normally
return await resolve(event)
} else if (!url.startsWith('/auth')) {
} else if (!url.startsWith('/home') || !url.startsWith('/auth')) {
// If the path is something other than /auth, check if the user is logged in

if (!user) {
return redirect(303, '/auth')
return redirect(303, '/home')
}

if (user.accessDisabled) {
Expand Down
7 changes: 2 additions & 5 deletions src/lib/server/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ const {
},
callbacks: {
async redirect({ url, baseUrl }) {
if (url.startsWith('/auth')) {
throw redirect(303, '/')
}

return baseUrl
// Redirect to / after signin
return '/'
},
},
})
Expand Down
1 change: 1 addition & 0 deletions src/lib/server/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export enum Setting {
DEFAULT_SALE_FOOD_LEDGER = 'DEFAULT_SALE_FOOD_LEDGER',
DEFAULT_SALE_OTHER_LEDGER = 'DEFAULT_SALE_OTHER_LEDGER',
STRAFBAKKEN_VERDUBBELAAR_ENABLED = 'STRAFBAKKEN_VERDUBBELAAR_ENABLED',
DESCRIPTION_INVICTUS = 'DESCRIPTION_INVICTUS',
}

export const settings = {
Expand Down
17 changes: 0 additions & 17 deletions src/routes/(app)/activiteit/nieuw/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,6 @@ export const actions = {
if (image.size > 0) {
const filename = await uploadPhoto(image, event.locals.user, false)

// const buf = Buffer.from(await image.arrayBuffer())

// const photo = await uploadPhoto(
// {
// creator,
// uploader: event.locals.user,
// runProcessingJob: false,
// additionalName: 'Activiteit',
// invisible: true,
// upload: {
// buf,
// filename: image.name,
// },
// },
// tx,
// )

await tx.activity.update({
where: {
id: activity.id,
Expand Down
11 changes: 11 additions & 0 deletions src/routes/(app)/admin/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import TablerFiles from '~icons/tabler/files'
import TablerAdjustmentsCog from '~icons/tabler/adjustments-cog'
import TablerListNumbers from '~icons/tabler/list-numbers'
import TablerHome from '~icons/tabler/home'
import TablerBeer from '~icons/tabler/beer'
import TablerBackhoe from '~icons/tabler/backhoe'
import { toast } from '$lib/notification'
Expand Down Expand Up @@ -53,6 +54,16 @@
</a>
</td>
</tr>
<tr>
<td>
<a href="/admin/home">
<span class="icon">
<TablerHome />
</span>
Verander publieke homepage
</a>
</td>
</tr>
<tr>
<td>
<a href="/admin/shortlinks">
Expand Down
10 changes: 10 additions & 0 deletions src/routes/(app)/admin/home/+page.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { PageServerLoad } from './$types'
import db from '$lib/server/db'
import { Setting, settings } from '$lib/server/settings'

export const load = (async () => {
const photos = await db.frontPageItem.findMany()
const description = settings.get(Setting.DESCRIPTION_INVICTUS)

return { photos, description }
}) satisfies PageServerLoad
24 changes: 24 additions & 0 deletions src/routes/(app)/admin/home/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script lang="ts">
import Title from '$lib/components/title.svelte'
import type { PageData } from './$types'

export let data: PageData
</script>

<Title title="Verander homepage" underTitle="Alle plaatjes op /home kunnen aangepast worden, doe dat vooral senaat" />

<h2>Groepsfoto</h2>

<hr />

<h2>Tijdelijke foto</h2>

<hr />

<h2>Omschrijving Invictus</h2>

<hr />

<h2>Lichtingen</h2>

<hr />
5 changes: 5 additions & 0 deletions src/routes/(app)/admin/home/+server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { RequestHandler } from './$types'

export const GET: RequestHandler = async () => {
return new Response()
}
23 changes: 23 additions & 0 deletions src/routes/(public)/home/+page.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import db from '$lib/server/db'
import type { PageServerLoad } from './$types'

export const load = (async ({ locals }) => {
const name = locals.user?.firstName ?? null

const photos = await db.frontPageItem.findMany({
where: {
visible: true,
},
})

const temp = photos.find(p => p.key === 'temp')
const group = photos.find(p => p.key === 'group')
const lichtingen = photos.find(p => p.key.includes('lichting'))

return {
name,
group,
lichtingen,
temp,
}
}) satisfies PageServerLoad
Loading