diff --git a/controllers/ServerController.php b/controllers/ServerController.php index 7d381eb1..f6f0f254 100644 --- a/controllers/ServerController.php +++ b/controllers/ServerController.php @@ -11,6 +11,9 @@ public function listAction() return array("servers" => $servers); } + /** + * @todo An unstyled page might not be great + */ public function showAction(Server $server, Player $me, Request $request) { if ($server->staleInfo()) { @@ -38,4 +41,11 @@ public function editAction(Player $me, Server $server) { return $this->edit($server, $me, "server"); } + + + protected function redirectTo($model) + { + // Redirect to the server list after creating/editing a server + return $this->redirectToList($model); + } } diff --git a/src/Controller/CRUDController.php b/src/Controller/CRUDController.php index 2d43d749..09a53149 100644 --- a/src/Controller/CRUDController.php +++ b/src/Controller/CRUDController.php @@ -188,7 +188,7 @@ protected function canEdit($player, $model) * @param ModelInterface $model The model to redirect to * @return Response */ - private function redirectTo($model) + protected function redirectTo($model) { if ($model instanceof UrlModel) { return new RedirectResponse($model->getUrl()); diff --git a/views/Server/list.html.twig b/views/Server/list.html.twig index f440186f..a69f742d 100644 --- a/views/Server/list.html.twig +++ b/views/Server/list.html.twig @@ -30,34 +30,7 @@
-
- {% set status = (server.online) ? "online" : "offline" %} - - - {{ server.name }} - {{ server.country.flagLiteral | raw }} - - {% if me.canEdit(server) or me.canDelete(server) %} -
    - {% if me.canEdit(server) %} -
  • - - - -
  • -
  • {{ link_to(server, 'pencil', 'edit') }}
  • - {% endif %} - - {% if me.canDelete(server) %} -
  • {{ link_to(server, 'minus', 'delete') }}
  • - {% endif %} -
- {% endif %} -
- -

{{ server.address }}

-

Player count: {{ server.numPlayers }}

- Updated {{ server.lastUpdate | humanTime }} + {% include "Server/show.html.twig" %}
diff --git a/views/Server/show.html.twig b/views/Server/show.html.twig index 2e455ffd..5e057693 100644 --- a/views/Server/show.html.twig +++ b/views/Server/show.html.twig @@ -1,59 +1,28 @@ -{% import _self as serverlist %} +
+ {% set status = (server.online) ? "online" : "offline" %} -
- {% set status = "offline" %} - - {% if server.online %} - {% set status = "online" %} - {% endif %} - - - {{ server.name }} + + {{ server.name }} {{ server.country.flagLiteral | raw }} - -
- -

{{ server.address }}

-

Player count: {{ server.numPlayers }}

- -{% if server.players is not empty %} - -{% endif %} - -Updated {{ server.lastUpdate | humanTime }} - -{% macro team(player) %} - {% set team = player.team %} - - {% if team == 0 %} - (Rogue) - {% elseif team == 1 %} - (Red) - {% elseif team == 2 %} - (Green) - {% elseif team == 3 %} - (Blue) - {% elseif team == 4 %} - (Purple) - {% elseif team == 5 %} - (Observer) + {% if me.canEdit(server) or me.canDelete(server) %} + {% endif %} -{% endmacro %} +
+ +

{{ server.address }}

+

Player count: {{ server.numPlayers }}

+Updated {{ server.lastUpdate | humanTime }} \ No newline at end of file diff --git a/web/assets/js/min/utilities.js b/web/assets/js/min/utilities.js index 4ff1acfa..d35be850 100644 --- a/web/assets/js/min/utilities.js +++ b/web/assets/js/min/utilities.js @@ -1 +1 @@ -function formatCountry(a){if(!a.id||void 0===a.element)return a.text;var b=a.element.getAttribute("data-iso");return null===b?role.text:$('
'+a.text+"")}function formatRole(a){if(!a.id||void 0===a.element)return a.text;var b=a.element.getAttribute("data-icon");return null===b?a.text:$(' '+a.text+"")}$(document).ready(function(){$(".js-select__country").select2({templateResult:formatCountry,templateSelection:formatCountry})}),$(document).ready(function(){$(".js-select__role").select2({templateResult:formatRole,templateSelection:formatRole,width:"100%"})}),$(document).ready(function(){$(".js-select__timezone").select2()}); \ No newline at end of file +function formatCountry(a){if(!a.id||void 0===a.element)return a.text;var b=a.element.getAttribute("data-iso");return null===b?role.text:$('
'+a.text+"")}function formatRole(a){if(!a.id||void 0===a.element)return a.text;var b=a.element.getAttribute("data-icon");return null===b?a.text:$(' '+a.text+"")}$(document).ready(function(){$.fn.select2&&$(".js-select__country").select2({templateResult:formatCountry,templateSelection:formatCountry})}),$(document).ready(function(){$.fn.select2&&$(".js-select__role").select2({templateResult:formatRole,templateSelection:formatRole,width:"100%"})}),$(document).ready(function(){$.fn.select2&&$(".js-select__timezone").select2()}); \ No newline at end of file diff --git a/web/assets/js/partials/Select2-Country.js b/web/assets/js/partials/Select2-Country.js index c8d85df2..2ca80740 100644 --- a/web/assets/js/partials/Select2-Country.js +++ b/web/assets/js/partials/Select2-Country.js @@ -15,6 +15,10 @@ function formatCountry(country) { } $(document).ready(function() { + if (!$.fn.select2) { + return; + } + $(".js-select__country").select2({ templateResult: formatCountry, templateSelection: formatCountry diff --git a/web/assets/js/partials/Select2-Roles.js b/web/assets/js/partials/Select2-Roles.js index cbff1474..ee379d2a 100644 --- a/web/assets/js/partials/Select2-Roles.js +++ b/web/assets/js/partials/Select2-Roles.js @@ -15,6 +15,10 @@ function formatRole(role) { } $(document).ready(function() { + if (!$.fn.select2) { + return; + } + $(".js-select__role").select2({ templateResult: formatRole, templateSelection: formatRole, diff --git a/web/assets/js/partials/Select2-Timezones.js b/web/assets/js/partials/Select2-Timezones.js index 057701fe..c0cf23d6 100644 --- a/web/assets/js/partials/Select2-Timezones.js +++ b/web/assets/js/partials/Select2-Timezones.js @@ -1,3 +1,7 @@ $(document).ready(function() { + if (!$.fn.select2) { + return; + } + $(".js-select__timezone").select2(); }); \ No newline at end of file diff --git a/web/assets/js/profile.js b/web/assets/js/profile.js deleted file mode 100644 index cb1e26ff..00000000 --- a/web/assets/js/profile.js +++ /dev/null @@ -1,41 +0,0 @@ -function formatCountry(country) { - if (!country.id) { - return country.text; - } - - var $country = $( - '
' + country.text + '' - ); - return $country; -} - -function formatRole(role) { - if (!role.id || role.element === undefined) { - return role.text; - } - - var icon = role.element.getAttribute('data-icon'); - - if (icon === null) { - return role.text; - } - - return $( - ' ' + role.text + '' - ); -} - -$(document).ready(function() { - $("#form_country").select2({ - templateResult: formatCountry, - templateSelection: formatCountry, - }); - - $("#form_timezone").select2(); - - $(".role-select").select2({ - templateResult: formatRole, - templateSelection: formatRole, - width: '100%' - }); -}); diff --git a/web/assets/js/servers.js b/web/assets/js/servers.js index 6c759159..39aec4c2 100644 --- a/web/assets/js/servers.js +++ b/web/assets/js/servers.js @@ -8,7 +8,7 @@ function initPage() { // Add an invisible dimmer to elements that don't have one yet $(".dimmable").prepend(dimmer).prepend(spinner); - $(".server").each(function() { + $(".c-servers__server").each(function() { var url = baseURLNoHost + "/servers/" + $(this).attr("data-id"); $(this).updateServer(url); }); @@ -18,16 +18,16 @@ $(document).ready(function() { initPage(); }); -$(".servers").on("click", ".server-refresh", function(event) { +$(".c-servers").on("click", ".server-refresh", function(event) { event.preventDefault(); - $(this).parents(".server").updateServer($(this).attr("href")); + $(this).parents(".c-servers__server").updateServer($(this).attr("href")); }); $.fn.updateServer = function(url) { var server = $(this); - server.startSpinners().find(".server_info").load(url, function() { + server.startSpinners().find(".c-servers__server__info").load(url, function() { server.stopSpinners(); }); };