I rightly do not know what this all is

This commit is contained in:
Michel 2024-10-30 19:40:26 +01:00
parent af6b2b752e
commit 287c1f67c5
78 changed files with 3484 additions and 3365 deletions

View file

@ -1,35 +1,35 @@
<?php
declare(strict_types=1);
use GamesShop\Entities\Account\User;
/** @var User|null $activeUser */
?>
<?php if ($activeUser !== null): ?>
<div class="d-flex avatar justify-content-center">
<div class="avatar-icon h-100 position-relative me-2 ratio-1">
<img src="<?= $activeUser->getProfilePictureUrl(); ?>" class="rounded-circle h-100" alt="User Profile Picture" />
<div class="position-absolute bottom-0 end-0 ratio-1 d-flex align-items-center z-1 avatar-login-method">
<i class="fa-brands <?= $activeUser->getLoginMethod()->getIconClass() ?>"></i>
<span class="position-absolute w-100 h-100 bottom-0 end-0 ratio-1 bg-body rounded-circle z-n1 avatar-login-method-icon"></span>
</div>
</div>
<div class="d-flex flex-column">
<span class="me-2 h-3">
<?= $activeUser->getName() ?>
</span>
<small class="text-muted">
<?= $activeUser->getPermission()->getHumanReadableName() ?>
</small>
</div>
<div class="h-100 d-flex align-items-center ms-2">
<a href="/logout">
<i class="fa-solid fa-arrow-right-to-bracket fa-xl text-danger"></i>
</a>
</div>
</div>
<?php endif ?>
<?php
declare(strict_types=1);
use GamesShop\Entities\Account\User;
/** @var User|null $activeUser */
?>
<?php if ($activeUser !== null): ?>
<div class="d-flex avatar justify-content-center">
<div class="avatar-icon h-100 position-relative me-2 ratio-1">
<img src="<?= $activeUser->getProfilePictureUrl(); ?>" class="rounded-circle h-100" alt="User Profile Picture" />
<div class="position-absolute bottom-0 end-0 ratio-1 d-flex align-items-center z-1 avatar-login-method">
<i class="fa-brands <?= $activeUser->getLoginMethod()->getIconClass() ?>"></i>
<span class="position-absolute w-100 h-100 bottom-0 end-0 ratio-1 bg-body rounded-circle z-n1 avatar-login-method-icon"></span>
</div>
</div>
<div class="d-flex flex-column">
<span class="me-2 h-3">
<?= $activeUser->getName() ?>
</span>
<small class="text-muted">
<?= $activeUser->getPermission()->getHumanReadableName() ?>
</small>
</div>
<div class="h-100 d-flex align-items-center ms-2">
<a href="/logout">
<i class="fa-solid fa-arrow-right-to-bracket fa-xl text-danger"></i>
</a>
</div>
</div>
<?php endif ?>

View file

@ -1,5 +1,5 @@
<?php
declare(strict_types=1);
?>
<?php
declare(strict_types=1);
?>

View file

@ -1,49 +1,49 @@
<?php
declare(strict_types=1);
use GamesShop\Templates\ResourceIndex;
use League\Plates\Template\Template;
assert($this instanceof Template);
/** @var ResourceIndex $resources */
assert($resources instanceof ResourceIndex);
if (!isset($resourceEntry)) {
throw new Exception("Resource entry not set");
}
/**
* @var string $resourceEntry
*/
$resource = $resources->getResource($resourceEntry);
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Game Shop</title>
<?php foreach ($resource->js as $js): ?>
<script src="/<?= $js ?>"></script>
<?php endforeach; ?>
<?php foreach ($resource->css as $css): ?>
<link rel="stylesheet" href="/<?= $css ?>">
<?php endforeach; ?>
</head>
<body class="vh-100 d-flex flex-column">
<?= $this->insert('layout/navbar') ?>
<main class="mt-2 position-relative flex-grow-1">
<?= $this->section('content'); ?>
</main>
<?= $this->section('modal') ?>
<div class="position-absolute bottom-0 start-50 opacity-25 text-center translate-middle-x">
<span class="h1">PROTOTYPE / POC</span>
</div>
</body>
</html>
<?php
declare(strict_types=1);
use GamesShop\Templates\ResourceIndex;
use League\Plates\Template\Template;
assert($this instanceof Template);
/** @var ResourceIndex $resources */
assert($resources instanceof ResourceIndex);
if (!isset($resourceEntry)) {
throw new Exception("Resource entry not set");
}
/**
* @var string $resourceEntry
*/
$resource = $resources->getResource($resourceEntry);
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Game Shop</title>
<?php foreach ($resource->js as $js): ?>
<script src="/<?= $js ?>"></script>
<?php endforeach; ?>
<?php foreach ($resource->css as $css): ?>
<link rel="stylesheet" href="/<?= $css ?>">
<?php endforeach; ?>
</head>
<body class="vh-100 d-flex flex-column">
<?= $this->insert('layout/navbar') ?>
<main class="mt-2 position-relative flex-grow-1">
<?= $this->section('content'); ?>
</main>
<?= $this->section('modal') ?>
<div class="position-absolute bottom-0 start-50 opacity-25 text-center translate-middle-x">
<span class="h1">PROTOTYPE / POC</span>
</div>
</body>
</html>

View file

@ -1,53 +1,53 @@
<?php
declare(strict_types=1);
use GamesShop\Entities\Account\User;
use GamesShop\Login\UserPermission;
use GamesShop\Templates\NavigationHeader;
$headers = [
new NavigationHeader('My Keys', '/keys', UserPermission::PROVIDER),
new NavigationHeader('Accounts', '/accounts', UserPermission::ADMIN)
];
/** @var User|null $activeUser */
$currentPermission = $activeUser === null ? UserPermission::NONE : $activeUser->getPermission();
?>
<nav class="navbar navbar-expand-lg bg-body-tertiary main-navigation">
<div class="container-fluid navigation-container">
<a class="navbar-brand" href="/">Game Shop</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar-content" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbar-content">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<?php foreach ($headers as $header):
if (!$currentPermission->hasLevel($header->minimumPermission)) {
continue;
}
?>
<li class="nav-link">
<a href="<?= $header->link ?>" class="nav-link"><?= $header->title ?></a>
</li>
<?php endforeach; ?>
</ul>
<?= $this->insert('layout/accountDisplay'); ?>
</div>
</div>
<div class="d-flex mode-switch me-3">
<button title="Use dark mode" id="dark" class="btn btn-sm btn-default text-secondary">
<i class="fa-regular fa-moon"></i>
</button>
<button title="Use light mode" id="light" class="btn btn-sm btn-default text-secondary">
<i class="fa-regular fa-sun"></i>
</button>
<button title="Use system preferred mode" id="system" class="btn btn-sm btn-default text-secondary">
<i class="fa-solid fa-display"></i>
</button>
</div>
<?php
declare(strict_types=1);
use GamesShop\Entities\Account\User;
use GamesShop\Login\UserPermission;
use GamesShop\Templates\NavigationHeader;
$headers = [
new NavigationHeader('My Keys', '/keys', UserPermission::PROVIDER),
new NavigationHeader('Accounts', '/accounts', UserPermission::ADMIN)
];
/** @var User|null $activeUser */
$currentPermission = $activeUser === null ? UserPermission::NONE : $activeUser->getPermission();
?>
<nav class="navbar navbar-expand-lg bg-body-tertiary main-navigation">
<div class="container-fluid navigation-container">
<a class="navbar-brand" href="/">Game Shop</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar-content" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbar-content">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<?php foreach ($headers as $header):
if (!$currentPermission->hasLevel($header->minimumPermission)) {
continue;
}
?>
<li class="nav-link">
<a href="<?= $header->link ?>" class="nav-link"><?= $header->title ?></a>
</li>
<?php endforeach; ?>
</ul>
<?= $this->insert('layout/accountDisplay'); ?>
</div>
</div>
<div class="d-flex mode-switch me-3">
<button title="Use dark mode" id="dark" class="btn btn-sm btn-default text-secondary">
<i class="fa-regular fa-moon"></i>
</button>
<button title="Use light mode" id="light" class="btn btn-sm btn-default text-secondary">
<i class="fa-regular fa-sun"></i>
</button>
<button title="Use system preferred mode" id="system" class="btn btn-sm btn-default text-secondary">
<i class="fa-solid fa-display"></i>
</button>
</div>
</nav>

View file

@ -1,57 +1,57 @@
<?php
declare(strict_types=1);
use GamesShop\Login\UserPermission;
$this->layout('layout/main', [ 'resourceEntry' => 'admin/accounts' ]);
?>
<h1>Users</h1>
<table id="user-table" class="table table-striped w-100">
<thead>
<tr>
<th width="2.4rem"></th>
<th>Name</th>
<th>Permission</th>
<th>Login-Method</th>
</tr>
</thead>
<tbody></tbody>
</table>
<?php $this->start('modal') ?>
<div class="modal" id="edit-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title h3">
Edit User
</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-2">
Name: <span class="name-input"></span>
</div>
<div class="mb-2">
Login Method: <span class="login-method"></span>
</div>
<div>
<label for="permissions">Permissions:</label>
<select name="" id="permissions" class="form-select permission-editor">
<?php foreach (UserPermission::cases() as $userPermission):?>
<option value="<?= $userPermission->value ?>"><?= $userPermission->getHumanReadableName() ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary js--save">Save changes</button>
</div>
</div>
</div>
</div>
<?php $this->end() ?>
<?php
declare(strict_types=1);
use GamesShop\Login\UserPermission;
$this->layout('layout/main', [ 'resourceEntry' => 'admin/accounts' ]);
?>
<h1>Users</h1>
<table id="user-table" class="table table-striped w-100">
<thead>
<tr>
<th width="2.4rem"></th>
<th>Name</th>
<th>Permission</th>
<th>Login-Method</th>
</tr>
</thead>
<tbody></tbody>
</table>
<?php $this->start('modal') ?>
<div class="modal" id="edit-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title h3">
Edit User
</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-2">
Name: <span class="name-input"></span>
</div>
<div class="mb-2">
Login Method: <span class="login-method"></span>
</div>
<div>
<label for="permissions">Permissions:</label>
<select name="" id="permissions" class="form-select permission-editor">
<?php foreach (UserPermission::cases() as $userPermission):?>
<option value="<?= $userPermission->value ?>"><?= $userPermission->getHumanReadableName() ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary js--save">Save changes</button>
</div>
</div>
</div>
</div>
<?php $this->end() ?>

View file

@ -1,11 +1,11 @@
<?php
declare(strict_types=1);
$this->layout('layout/main', [ 'resourceEntry' => 'index' ]);
/**
* @var int $errorCode
*/
?>
<img src="https://http.dog/<?= $errorCode ?>.jpg" alt="Error <?= $errorCode ?>" class="position-absolute top-50 start-50 translate-middle w-100" style="max-width: 800px" />
<?php
declare(strict_types=1);
$this->layout('layout/main', [ 'resourceEntry' => 'index' ]);
/**
* @var int $errorCode
*/
?>
<img src="https://http.dog/<?= $errorCode ?>.jpg" alt="Error <?= $errorCode ?>" class="position-absolute top-50 start-50 translate-middle w-100" style="max-width: 800px" />

View file

@ -1,9 +1,9 @@
<?php
declare(strict_types=1);
$this->layout('layout/main', [ 'resourceEntry' => 'index' ]);
?>
<h1>
Hello
<?php
declare(strict_types=1);
$this->layout('layout/main', [ 'resourceEntry' => 'index' ]);
?>
<h1>
Hello
</h1>

View file

@ -1,143 +1,153 @@
<?php
declare(strict_types=1);
use GamesShop\Entities\Games\KeyAttribute;
use GamesShop\Entities\GamesList;
use League\Plates\Template\Template;
assert($this instanceof Template);
/** @var GamesList[] $usersLists */
$this->layout('layout/main', [ 'resourceEntry' => 'keys' ]);
?>
<meta name="key-attributes" content="<?= htmlspecialchars(json_encode(KeyAttribute::casesAsAssociative())) ?>" />
<div class="row">
<div class="col-sm-6">
<h1>My Keys</h1>
</div>
<div class="col-sm-6 align-self-center">
<?php if (!empty($usersLists)): ?>
<select name="lists" id="list-select" class="form-select w-100">
<?php foreach ($usersLists as $list): ?>
<option value="<?= $list->getId() ?>"><?= $list->getName() ?></option>
<?php endforeach; ?>
<option value="_create">+ Create New</option>
</select>
<?php endif; ?>
</div>
</div>
<?php if (empty($usersLists)): ?>
<div class="text-center">
<p class="fs-4 mb-4">You don't have a key list. Create one here.</p>
<button class="btn btn-primary btn-lg js--create-list-button">
Create
</button>
</div>
<?php else: ?>
<ul id="key-tab" class="nav nav-tabs">
<li class="nav-item">
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#keys-tab-pane" role="tab">
Keys
</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#import-tab-pane" role="tab">
Import
</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#share-tab-pane" role="tab">
Share
</button>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade show active" id="keys-tab-pane" role="tabpanel">
<table class="table table-striped key-table">
<thead>
<tr>
<td></td>
<td>Game Name</td>
<td>Amount Keys</td>
<td>IGDB State</td>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="tab-pane fade" id="import-tab-pane" role="tabpanel">
<h2>Importer</h2>
<label for="formFile" class="form-label mt-3">Insert import file:</label>
<div class="mb-3 input-group">
<input class="form-control" type="file" id="import" accept="text/csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
<button class="btn btn-primary js--send-import">Send</button>
</div>
<div class="d-none" id="import-info-container">
<h3>Import Details:</h3>
<table class="table table-striped w-100" id="import-attribute-table">
<thead>
<tr>
<td>Column</td>
<td>Header</td>
<td>Attribute</td>
</tr>
</thead>
<tbody></tbody>
</table>
<button class="btn btn-primary js--do-import">
Import
</button>
</div>
</div>
<div class="tab-pane fade" id="share-tab-pane" role="tabpanel">
<h2>
Share your list
</h2>
<label for="share-user-search">Search for a user...</label>
<div class="input-group">
<input type="text" class="form-control" id="share-user-search" placeholder="">
<button class="btn btn-primary js--search-shared-user">Search</button>
</div>
</div>
</div>
<?php endif; ?>
<?php $this->start('modal') ?>
<div class="modal" id="create-list-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title h3">
Create list
</h1>
</div>
<div class="modal-body">
<div class="form-floating">
<input class="form-control" type="text" id="createListName" placeholder="">
<label for="createListName">Name</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary js--create-list">Create</button>
</div>
</div>
</div>
</div>
<?php $this->end() ?>
<?php
declare(strict_types=1);
use GamesShop\Entities\Games\KeyAttribute;
use GamesShop\Entities\GamesList;
use League\Plates\Template\Template;
assert($this instanceof Template);
/** @var GamesList[] $usersLists */
$this->layout('layout/main', [ 'resourceEntry' => 'keys' ]);
?>
<meta name="key-attributes" content="<?= htmlspecialchars(json_encode(KeyAttribute::casesAsAssociative())) ?>" />
<div class="row">
<div class="col-sm-6">
<h1>My Keys</h1>
</div>
<div class="col-sm-6 align-self-center">
<?php if (!empty($usersLists)): ?>
<select name="lists" id="list-select" class="form-select w-100">
<?php foreach ($usersLists as $list): ?>
<option value="<?= $list->getId() ?>"><?= $list->getName() ?></option>
<?php endforeach; ?>
<option value="_create">+ Create New</option>
</select>
<?php endif; ?>
</div>
</div>
<?php if (empty($usersLists)): ?>
<div class="text-center">
<p class="fs-4 mb-4">You don't have a key list. Create one here.</p>
<button class="btn btn-primary btn-lg js--create-list-button">
Create
</button>
</div>
<?php else: ?>
<ul id="key-tab" class="nav nav-tabs">
<li class="nav-item">
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#keys-tab-pane" role="tab">
Keys
</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#import-tab-pane" role="tab">
Import
</button>
</li>
<li class="nav-item">
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#share-tab-pane" role="tab">
Share
</button>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade show active" id="keys-tab-pane" role="tabpanel">
<table class="table table-striped key-table">
<thead>
<tr>
<th></th>
<th>Game Name</th>
<th>Amount Keys</th>
<th>IGDB State</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="tab-pane fade" id="import-tab-pane" role="tabpanel">
<h2>Importer</h2>
<label for="formFile" class="form-label mt-3">Insert import file:</label>
<div class="mb-3 input-group">
<input class="form-control" type="file" id="import" accept="text/csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
<button class="btn btn-primary js--send-import">Send</button>
</div>
<div class="d-none" id="import-info-container">
<h3>Import Details:</h3>
<table class="table table-striped w-100" id="import-attribute-table">
<thead>
<tr>
<th>Column</th>
<th>Header</th>
<th>Attribute</th>
</tr>
</thead>
<tbody></tbody>
</table>
<button class="btn btn-primary js--do-import">
Import
</button>
</div>
</div>
<div class="tab-pane fade" id="share-tab-pane" role="tabpanel">
<h2>
Share your list
</h2>
<label for="share-user-search">Search for a user...</label>
<div class="input-group mb-3">
<input type="text" class="form-control" id="share-user-search" placeholder="">
<button class="btn btn-primary js--search-shared-user">Search</button>
</div>
<h3>Users shared to</h3>
<table id="shared-users-table" class="table table-striped w-100">
<thead>
<tr>
<th width="2.4rem"></th>
<th>Name</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
<?php endif; ?>
<?php $this->start('modal') ?>
<div class="modal" id="create-list-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title h3">
Create list
</h1>
</div>
<div class="modal-body">
<div class="form-floating">
<input class="form-control" type="text" id="createListName" placeholder="">
<label for="createListName">Name</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary js--create-list">Create</button>
</div>
</div>
</div>
</div>
<?php $this->end() ?>

View file

@ -1,15 +1,15 @@
<?php
declare(strict_types=1);
$this->layout('layout/main', [ 'resourceEntry' => 'index' ]);
/** @var string $discordUrl */
?>
<a href="<?= $discordUrl ?>">
<button class="btn btn-primary position-absolute top-50 start-50 translate-middle">
<i class="fa-brands fa-discord"></i>
Login with Discord
</button>
<?php
declare(strict_types=1);
$this->layout('layout/main', [ 'resourceEntry' => 'index' ]);
/** @var string $discordUrl */
?>
<a href="<?= $discordUrl ?>">
<button class="btn btn-primary position-absolute top-50 start-50 translate-middle">
<i class="fa-brands fa-discord"></i>
Login with Discord
</button>
</a>