Skip to content

Commit

Permalink
Navbar, acl, extra packages
Browse files Browse the repository at this point in the history
  • Loading branch information
rdurica committed Aug 14, 2023
1 parent c948704 commit 12e74b1
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 1,542 deletions.
18 changes: 18 additions & 0 deletions src/app/Model/Constant/Resource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace App\Model\Constant;

/**
* Resources.
*
* @package App\Model\Constant
* @author Robert Durica <[email protected]>
* @copyright Copyright (c) 2023, Robert Durica
*/
final class Resource
{
/** Edit game rules. */
public const RULES = 'rules';
}
37 changes: 37 additions & 0 deletions src/app/Model/Manager/RulesManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace App\Model\Manager;

use Nette\Database\Table\ActiveRow;
use Rdurica\Core\Model\Manager\Manager;

/**
* RulesManager.
*
* @package App\Model\Manager
* @author Robert Durica <[email protected]>
* @copyright Copyright (c) 2023, Robert Durica
*/
final class RulesManager extends Manager
{
/** @var string Table name. */
private const TABLE = 'rules';

/** @inheritDoc */
protected function getTableName(): string
{
return self::TABLE;
}

/**
* Get rules.
*
* @return ActiveRow|null
*/
public function findRules(): ?ActiveRow
{
return $this->find()->fetch();
}
}
30 changes: 29 additions & 1 deletion src/app/Presenter/HomePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,41 @@

namespace App\Presenter;

use App\Model\Constant\Resource;
use App\Model\Manager\RulesManager;
use Nepada\SecurityAnnotations\Annotations\Allowed;
use Nepada\SecurityAnnotations\SecurityAnnotations;
use Nette\DI\Attributes\Inject;
use Rdurica\Core\Constant\Privileges;
use Rdurica\Core\Presenter\Presenter;
use Rdurica\Core\Presenter\RequireLoggedUser;
use Rdurica\Core\Presenter\SetMdbTemplateLayout;


/**
* HomePresenter.
*
* @package App\Presenter
* @author Robert Durica <[email protected]>
* @copyright Copyright (c) 2023, Robert Durica
*/
final class HomePresenter extends Presenter
{
use SetMdbTemplateLayout;
use RequireLoggedUser;
use SecurityAnnotations;

#[Inject]
public RulesManager $rulesManager;

/**
* Rules page.
*
* @return void
*/
#[Allowed(resource: Resource::RULES, privilege: Privileges::VIEW)]
public function renderRules(): void
{
$data = $this->rulesManager->findRules();
$this->getTemplate()->data = $data;
}
}
4 changes: 1 addition & 3 deletions src/app/Presenter/SignPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,4 @@ public function createComponentLoginForm(): LoginForm
{
return $this->loginForm->create();
}


}
}
63 changes: 57 additions & 6 deletions src/app/Presenter/templates/Home/default.latte
Original file line number Diff line number Diff line change
@@ -1,11 +1,62 @@
{block navbar}{include './../navbar.latte'}{/block}
{block content}
<div class="align-items-center text-white bg-primary border-0" role="alert" aria-live="assertive" aria-atomic="true">
<div class="d-flex">
<div class="toast-body">
Hello, world! This is a toast message.
<div class="row">
<div class="col-md-5 offset-md-2">
Actual Challenges
<div class="card text-center mt-2">
<div class="card-header">Featured</div>
<div class="card-body">
<h5 class="card-title">Special title treatment</h5>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
<a href="#" class="btn btn-primary ">Go somewhere</a>
</div>
<div class="card-footer text-muted">2 days ago</div>
</div>

<div class="card text-center mt-2">
<div class="card-header">Featured</div>
<div class="card-body">
<h5 class="card-title">Special title treatment</h5>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
<div class="card-footer text-muted">2 days ago</div>
</div>

<div class="card text-center mt-2">
<div class="card-header">Featured</div>
<div class="card-body">
<h5 class="card-title">Special title treatment</h5>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
<div class="card-footer text-muted">2 days ago</div>
</div>
</div>
<div class="col-md-3 offset-md-2">
Completed
<div class="card border border-success shadow-0 mt-2" style="max-width: 18rem;">
<div class="card-body text-success">
<h5 class="card-title">Success card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
</div>
</div>

<div class="card border border-success shadow-0 mt-2" style="max-width: 18rem;">
<div class="card-body text-success">
<h5 class="card-title">Success card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
</div>
</div>

<div class="card border border-success shadow-0 mt-2" style="max-width: 18rem;">
<div class="card-body text-success">
<h5 class="card-title">Success card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
{/block}
</div>
14 changes: 14 additions & 0 deletions src/app/Presenter/templates/Home/rules.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{block navbar}{include './../navbar.latte'}{/block}
{block content}
<div class="row">
<div class="col-md-10 offset-md-1">
<div class="card mt-2">
<div class="card-body">
{$data->message|noescape}
<br>
<a n:if="$user->isAllowed(App\Model\Constant\Resource::RULES, Rdurica\Core\Constant\Privileges::EDIT)"
href="#" class="btn btn-primary">Upravit</a>
</div>
</div>
</div>
</div>
16 changes: 14 additions & 2 deletions src/app/Presenter/templates/navbar.latte
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<!-- Navbar -->
{block css}
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-datepicker.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/assets/datagrid.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/assets/datagrid-spinners.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-select.css">
{/block}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<!-- Container wrapper -->
<div class="container-fluid">
Expand All @@ -24,14 +30,20 @@
/> B-day challenge
</a>
<!-- Left links -->
{* <ul class="navbar-nav me-auto mb-2 mb-lg-0">*}
{* <ul class="navbar-nav me-auto mb-2 mb-lg-0">*}
{* <li class="nav-item">*}
{* <a class="nav-link" href="#">Pridat ukol</a>*}
{* </li>*}
{* </ul>*}
</div>
<!-- Right elements -->
<div class="d-flex align-items-center">
<a n:if="$user->isAllowed(App\Model\Constant\Resource::RULES, Rdurica\Core\Constant\Privileges::VIEW)"
n:href=":rules"
class="link-secondary me-3 ">
<i class="fas fa-circle-info"></i>
</a>

<!-- Avatar -->
<div class="dropdown">
<a class="dropdown-toggle d-flex align-items-center hidden-arrow"
Expand Down
8 changes: 5 additions & 3 deletions src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
"type": "project",
"license": ["MIT"],
"require": {
"php": ">= 8.0",
"rdurica/core": "~0.2.0",
"tracy/tracy": "^2.9"
"php": ">= 8.2",
"rdurica/core": "dev-main",
"tracy/tracy": "^2.9",
"ublaboo/datagrid": "dev-master",
"nepada/security-annotations": "^5.0"
},
"require-dev": {
"nette/tester": "^2.4"
Expand Down
Loading

0 comments on commit 12e74b1

Please sign in to comment.