From 5a450c46db4fca11e103721468a8836cffacfa2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Wed, 10 Jun 2020 00:30:29 +0200 Subject: [PATCH] MAPG-117 remove admin/maps and place a button to the maps page if admin is logged in --- public/index.php | 1 - public/static/css/mapguesser.css | 8 ++++++++ public/static/css/maps.css | 2 +- src/Controller/MapAdminController.php | 7 ------- src/Controller/MapsController.php | 12 +++++++++++- views/admin/map_editor.php | 2 +- views/admin/maps.php | 7 ------- views/maps.php | 1 + 8 files changed, 22 insertions(+), 18 deletions(-) delete mode 100644 views/admin/maps.php diff --git a/public/index.php b/public/index.php index d1677c7..8c3d2bd 100644 --- a/public/index.php +++ b/public/index.php @@ -23,7 +23,6 @@ Container::$routeCollection->group('game', function (MapGuesser\Routing\RouteCol $routeCollection->post('guess-json', '{mapId}/guess.json', [MapGuesser\Controller\GameFlowController::class, 'evaluateGuess']); }); Container::$routeCollection->group('admin', function (MapGuesser\Routing\RouteCollection $routeCollection) { - $routeCollection->get('admin.maps', 'maps', [MapGuesser\Controller\MapAdminController::class, 'getMaps']); $routeCollection->get('admin.mapEditor', 'mapEditor/{mapId}', [MapGuesser\Controller\MapAdminController::class, 'getMapEditor']); $routeCollection->get('admin.place', 'place.json/{placeId}', [MapGuesser\Controller\MapAdminController::class, 'getPlace']); $routeCollection->post('admin.saveMap', 'saveMap/{mapId}/json', [MapGuesser\Controller\MapAdminController::class, 'saveMap']); diff --git a/public/static/css/mapguesser.css b/public/static/css/mapguesser.css index 6be0b44..7bedd39 100644 --- a/public/static/css/mapguesser.css +++ b/public/static/css/mapguesser.css @@ -162,6 +162,14 @@ button.red:hover, button.red:focus, a.button.red:hover, a.button.red:focus { background-color: #7f2929; } +button.yellow, a.button.yellow { + background-color: #e8a349; +} + +button.yellow:hover, button.yellow:focus, a.button.yellow:hover, a.button.yellow:focus { + background-color: #c37713; +} + input, select, textarea { background-color: #f9fafb; border: solid #c8d2e1 1px; diff --git a/public/static/css/maps.css b/public/static/css/maps.css index 69da1db..323d772 100644 --- a/public/static/css/maps.css +++ b/public/static/css/maps.css @@ -27,7 +27,7 @@ div.mapItem>img { } div.mapItem>div.inner { - padding: 8px; + padding: 10px 8px; } div.mapItem>div.inner>div.info { diff --git a/src/Controller/MapAdminController.php b/src/Controller/MapAdminController.php index f4809c8..0019469 100644 --- a/src/Controller/MapAdminController.php +++ b/src/Controller/MapAdminController.php @@ -37,13 +37,6 @@ class MapAdminController implements ISecured return $user !== null && $user->hasPermission(IUser::PERMISSION_ADMIN); } - public function getMaps(): IContent - { - //TODO - - return new HtmlContent('admin/maps'); - } - public function getMapEditor(): IContent { $mapId = (int) $this->request->query('mapId'); diff --git a/src/Controller/MapsController.php b/src/Controller/MapsController.php index 46aa8b3..d56dd59 100644 --- a/src/Controller/MapsController.php +++ b/src/Controller/MapsController.php @@ -2,13 +2,22 @@ use MapGuesser\Database\Query\Select; use MapGuesser\Database\RawExpression; +use MapGuesser\Interfaces\Authentication\IUser; use MapGuesser\Interfaces\Database\IResultSet; +use MapGuesser\Interfaces\Request\IRequest; use MapGuesser\Interfaces\Response\IContent; use MapGuesser\Util\Geo\Bounds; use MapGuesser\Response\HtmlContent; class MapsController { + private IRequest $request; + + public function __construct(IRequest $request) + { + $this->request = $request; + } + public function getMaps(): IContent { $select = new Select(\Container::$dbConnection, 'maps'); @@ -36,7 +45,8 @@ class MapsController $maps[] = $map; } - $data = ['maps' => $maps]; + $user = $this->request->user(); + $data = ['maps' => $maps, 'isAdmin' => $user !== null && $user->hasPermission(IUser::PERMISSION_ADMIN)]; return new HtmlContent('maps', $data); } diff --git a/views/admin/map_editor.php b/views/admin/map_editor.php index cea6b25..4358017 100644 --- a/views/admin/map_editor.php +++ b/views/admin/map_editor.php @@ -3,7 +3,7 @@

- + MapGuesser diff --git a/views/admin/maps.php b/views/admin/maps.php deleted file mode 100644 index bc6ad73..0000000 --- a/views/admin/maps.php +++ /dev/null @@ -1,7 +0,0 @@ - - -
-

Maps

-

TODO

-
- \ No newline at end of file diff --git a/views/maps.php b/views/maps.php index 8ca8bce..6f959fa 100644 --- a/views/maps.php +++ b/views/maps.php @@ -31,6 +31,7 @@

Play this map + Edit this map