From c05b1e8d06313b22149a4f4469a1bf34cbea04a3 Mon Sep 17 00:00:00 2001 From: Varakh Date: Thu, 5 Apr 2018 16:26:12 +0200 Subject: [PATCH] add deselect server --- config/ACL.php | 1 + config/env.example | 1 - config/routes.php | 5 +++++ src/Control/Actions/IndexAction.php | 2 +- src/Control/Actions/ServerDeselectAction.php | 17 +++++++++++++++++ src/Util/BootstrapHelper.php | 1 - src/View/material/layout.twig | 2 +- src/View/material/layout/breadcrumbs.twig | 2 +- src/View/material/layout/menu.twig | 2 +- 9 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 src/Control/Actions/ServerDeselectAction.php diff --git a/config/ACL.php b/config/ACL.php index 122821e..0877017 100644 --- a/config/ACL.php +++ b/config/ACL.php @@ -34,6 +34,7 @@ class ACL extends \Zend\Permissions\Acl\Acl '/servers/create', '/servers/{sid}', '/servers/select/{sid}', + '/servers/deselect', '/servers/delete/{sid}', '/servers/start/{sid}', '/servers/stop/{sid}', diff --git a/config/env.example b/config/env.example index 64b8b56..66f7946 100644 --- a/config/env.example +++ b/config/env.example @@ -1,7 +1,6 @@ # site site_title="Teamspeak 3 Web" site_url="http://localhost:8080" -site_index="/servers" # values: "/", "..." site_language="en" # values: each yml you specified in data/locale/ site_date_format="d.m.Y H:i:s" # values: all possible for Date::class diff --git a/config/routes.php b/config/routes.php index 5062c5d..76b7ee4 100644 --- a/config/routes.php +++ b/config/routes.php @@ -85,6 +85,11 @@ $container[ServerSelectAction::class] = function ($container) { }; $app->get('/servers/select/{sid}', ServerSelectAction::class); +$container[ServerDeselectAction::class] = function ($container) { + return new ServerDeselectAction($container); +}; +$app->get('/servers/deselect', ServerDeselectAction::class); + $container[ServerDeleteAction::class] = function ($container) { return new ServerDeleteAction($container); }; diff --git a/src/Control/Actions/IndexAction.php b/src/Control/Actions/IndexAction.php index ba5b2b9..c451834 100644 --- a/src/Control/Actions/IndexAction.php +++ b/src/Control/Actions/IndexAction.php @@ -7,6 +7,6 @@ final class IndexAction extends AbstractAction { public function __invoke(Request $request, Response $response, $args) { - return $response->withRedirect(getenv('site_index')); + return $response->withRedirect('/servers'); } } \ No newline at end of file diff --git a/src/Control/Actions/ServerDeselectAction.php b/src/Control/Actions/ServerDeselectAction.php new file mode 100644 index 0000000..2fe87bb --- /dev/null +++ b/src/Control/Actions/ServerDeselectAction.php @@ -0,0 +1,17 @@ +session->delete('sid'); + $this->session->delete('name'); + + $this->flash->addMessage('success', $this->translator->trans('done')); + return $response->withRedirect('/servers'); + } +} \ No newline at end of file diff --git a/src/Util/BootstrapHelper.php b/src/Util/BootstrapHelper.php index 08e7afa..e3a971c 100644 --- a/src/Util/BootstrapHelper.php +++ b/src/Util/BootstrapHelper.php @@ -30,7 +30,6 @@ class BootstrapHelper $env->required([ 'site_title', 'site_url', - 'site_index', 'site_language', 'site_date_format', 'theme', diff --git a/src/View/material/layout.twig b/src/View/material/layout.twig index c475267..746166b 100644 --- a/src/View/material/layout.twig +++ b/src/View/material/layout.twig @@ -11,7 +11,7 @@
-

{{ getenv('site_title') }}

+

{{ getenv('site_title') }}

{% if currentUser is not empty %}

{% trans with {'%username%': currentUser.user|upper} %} diff --git a/src/View/material/layout/breadcrumbs.twig b/src/View/material/layout/breadcrumbs.twig index dd21ac9..8b67d7b 100644 --- a/src/View/material/layout/breadcrumbs.twig +++ b/src/View/material/layout/breadcrumbs.twig @@ -1,4 +1,4 @@ \ No newline at end of file diff --git a/src/View/material/layout/menu.twig b/src/View/material/layout/menu.twig index d570de3..a2b0cbd 100644 --- a/src/View/material/layout/menu.twig +++ b/src/View/material/layout/menu.twig @@ -14,7 +14,7 @@ {% if session_exists('sid') %}
{% if session_exists('sname') %} -

{{ session_get('sname') }}
+
close {{ session_get('sname') }}
{% endif %}
  • {% trans %}menu.servers.info{% endtrans %}