Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add score system #534

Merged
merged 24 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
33a24b0
Init Commit
PhilPinsdorf Oct 23, 2023
aab92ef
Pair programming
TitusKirch Oct 23, 2023
739780e
Added Random Generator Frontend
PhilPinsdorf Oct 28, 2023
8f03535
Removed Scaleup Animation because it is not used
PhilPinsdorf Oct 28, 2023
ef8e5e6
Fix darkmode
TitusKirch Oct 29, 2023
47816a2
lint code
TitusKirch Oct 29, 2023
013b6f0
Merge remote-tracking branch 'origin/feat/phil-frontend' into feat/ad…
TitusKirch Oct 29, 2023
66c20cb
Merge branch 'fix/darkmode' into feat/add-score-system
TitusKirch Oct 29, 2023
1f5975d
Fixed Font
PhilPinsdorf Oct 29, 2023
6ae16d1
Add scoresystem
TitusKirch Oct 29, 2023
d394c86
Fixed AvatarCard
PhilPinsdorf Oct 29, 2023
9b8699d
Merge remote-tracking branch 'origin/dev' into feat/add-score-system
TitusKirch Oct 29, 2023
e4a6364
Fixed Transition Component
PhilPinsdorf Oct 29, 2023
550b33d
Fixed single-file component element order
PhilPinsdorf Oct 29, 2023
bdb4cc5
Added Name for Display Route
PhilPinsdorf Oct 29, 2023
1557917
Set new Location for AvatarCard
PhilPinsdorf Oct 29, 2023
0316ba4
Fixed isFetchingRandomGenerator
PhilPinsdorf Oct 29, 2023
48d1fe4
Fixed Naming
PhilPinsdorf Oct 29, 2023
e87f5a9
Fixed Transiotin, Audio and added Riser
PhilPinsdorf Oct 29, 2023
73f6ffe
Merge remote-tracking branch 'origin/feat/phil-frontend' into feat/ad…
TitusKirch Oct 29, 2023
6a5432c
Adjust display of name
TitusKirch Oct 29, 2023
7ba0dad
Regenerate components file
TitusKirch Oct 29, 2023
6a369ac
Merge branch 'dev' into feat/add-score-system
TitusKirch Oct 29, 2023
245501d
Lint code and fix typo
TitusKirch Oct 29, 2023
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
25 changes: 25 additions & 0 deletions app/Http/Controllers/Api/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,31 @@ public function randomGeneratorState(): JsonResponse
return response()->json(json_decode($state->value));
}

/**
* Return the current state of the score system.
* The state is structured like this:
* {
* "teams": {
* "name": string;
* "score": string;
* }[];
* }
*/
public function scoreSystemState(): JsonResponse
{
// get state with key scoreSystem
$state = State::where('key', 'scoreSystem')->first();

// if state does not exist, return setup
if (! $state) {
return response()->json([
'teams' => [],
]);
}

return response()->json(json_decode($state->value));
}

/**
* Fresh users data
*/
Expand Down
69 changes: 69 additions & 0 deletions app/Http/Controllers/DashboardAdminScoreSystemController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace App\Http\Controllers;

use App\Models\State;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Request;
use Inertia\Inertia;
use Inertia\Response;

class DashboardAdminScoreSystemController extends Controller
{
/**
* Display the dashboard admin score system page
*/
public function index(): Response
{
// check if a state exists or we need to create a new one
$state = State::where('key', 'scoreSystem')->first();
if (! $state) {
$state = new State();
$state->key = 'scoreSystem';
}

return Inertia::render('Dashboard/Admin/ScoreSystem/Index', [
'state' => json_decode($state->value),
]);
}

/**
* Execute the dashboard admin score system submit action
*/
public function indexExecuteSubmit(): JsonResponse
{
// validate the request
$request = Request::validate([
'teams.*.name' => ['required', 'string'],
'teams.*.score' => ['required', 'string'],
]);

// check if a state exists or we need to create a new one
$state = State::where('key', 'scoreSystem')->first();
if (! $state) {
$state = new State();
$state->key = 'scoreSystem';
}

// update the state
$state->value = json_encode([
'teams' => $request['teams'],
]);

// save the state
$state->save();

// return success
return response()->json([
'success' => true,
]);
}

/*
* Display the dashboard admin score system display page
*/
public function display(): Response
{
return Inertia::render('Dashboard/Admin/ScoreSystem/Display');
}
}
4 changes: 4 additions & 0 deletions database/seeders/ModuleDemoSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public function run(): void
'key' => 'randomGenerator',
'active' => true,
],
[
'key' => 'scoreSystem',
'active' => true,
],
];

foreach ($modules as $module) {
Expand Down
4 changes: 4 additions & 0 deletions database/seeders/ModuleGerolsteinSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public function run(): void
'key' => 'randomGenerator',
'active' => true,
],
[
'key' => 'scoreSystem',
'active' => true,
],
];

foreach ($modules as $module) {
Expand Down
4 changes: 4 additions & 0 deletions database/seeders/ModuleSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public function run(): void
'key' => 'randomGenerator',
'active' => false,
],
[
'key' => 'scoreSystem',
'active' => false,
],
];

foreach ($modules as $module) {
Expand Down
4 changes: 4 additions & 0 deletions database/seeders/RoleSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function run(): void
'manage events',
'manage users',
'manage random generator',
'manage score system',
] as $permission) {
if (! Permission::where('name', $permission)->exists()) {
Permission::create(['name' => $permission]);
Expand All @@ -40,6 +41,7 @@ public function run(): void
}
$stageTutorRole = Role::where('name', 'stage tutor')->first();
$stageTutorRole->givePermissionTo($permissions['manage random generator']);
$stageTutorRole->givePermissionTo($permissions['manage score system']);

// create esa role if it doesn't exist
if (! Role::where('name', 'esa')->exists()) {
Expand All @@ -58,6 +60,7 @@ public function run(): void
$adminRole->givePermissionTo($permissions['view hidden event details']);
$adminRole->givePermissionTo($permissions['manage events']);
$adminRole->givePermissionTo($permissions['manage random generator']);
$adminRole->givePermissionTo($permissions['manage score system']);
$adminRole->givePermissionTo($permissions['manage users']);

// create super admin role if it doesn't exist
Expand All @@ -69,6 +72,7 @@ public function run(): void
$superAdminRole->givePermissionTo($permissions['view hidden event details']);
$superAdminRole->givePermissionTo($permissions['manage events']);
$superAdminRole->givePermissionTo($permissions['manage random generator']);
$superAdminRole->givePermissionTo($permissions['manage score system']);
$superAdminRole->givePermissionTo($permissions['manage users']);

// create special role if it doesn't exist
Expand Down
33 changes: 33 additions & 0 deletions resources/js/components/app/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@
>
Zufallsgenerator
</InertiaLink>
<InertiaLink
v-if="
modules['scoreSystem']?.active &&
user.permissionsArray.includes('manage score system')
"
href="/dashboard/admin/score-system"
:class="{
'border-red-500 text-red-900':
$page.url == '/dashboard/admin/score-system',
'border-transparent text-red-500 hover:border-red-300 hover:text-red-700':
$page.url != '/dashboard/admin/score-system',
}"
class="inline-flex items-center border-b-[3px] px-1 pt-1 text-sm font-medium"
>
Punktesystem
</InertiaLink>
<InertiaLink
v-if="user.permissionsArray.includes('manage users')"
href="/dashboard/admin/users"
Expand Down Expand Up @@ -177,6 +193,23 @@
>
Zufallsgenerator
</DisclosureButton>
<DisclosureButton
v-if="
modules['scoreSystem']?.active &&
user.permissionsArray.includes('manage score system')
"
:as="InertiaLink"
href="/dashboard/admin/score-system"
:class="{
'border-red-500 bg-red-100 text-red-900 dark:bg-black dark:text-red-500':
$page.url == '/dashboard/admin/score-system',
'border-transparent text-red-600 hover:border-red-300 hover:bg-red-50 hover:text-red-800 dark:text-red-400 dark:hover:bg-gray-900 dark:hover:text-red-100':
$page.url != '/dashboard/admin/score-system',
}"
class="block border-l-4 py-2 pl-3 pr-4 text-base font-medium"
>
Punktesystem
</DisclosureButton>
<DisclosureButton
v-if="user.permissionsArray.includes('manage users')"
:as="InertiaLink"
Expand Down
5 changes: 3 additions & 2 deletions resources/js/components/random/generator/user/AvatarCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<img v-if="props.src" :src="props.src" class="h-fit" />
<div
v-else
class="flex h-[30rem] transform items-center justify-center text-center font-eighty-miles text-8xl text-white"
class="flex h-[30rem] transform flex-col items-center justify-center text-center font-eighty-miles text-8xl text-white"
>
<span>{{ props.firstname }} {{ props.lastname }}</span>
<span>{{ props.firstname }}</span>
<span>{{ props.lastname }}</span>
</div>
</div>
</template>
Expand Down
9 changes: 9 additions & 0 deletions resources/js/layouts/DisplayLayout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<div
class="flex h-screen flex-col overflow-hidden bg-slate-950 bg-[url('/images/random-generator/background/comic-yellow.jpg')] bg-cover"
>
<div class="flex-grow">
<slot />
</div>
</div>
</template>
7 changes: 0 additions & 7 deletions resources/js/layouts/RandomGeneratorLayout.vue

This file was deleted.

Loading
Loading