From: Michael Tremer Date: Tue, 4 Dec 2012 12:50:42 +0000 (+0100) Subject: Redesign mirror management. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=25afb794dc991f55c1662c3d764c205626f70a1e;p=people%2Fjschlag%2Fpbs.git Redesign mirror management. --- diff --git a/data/templates/mirrors-delete.html b/data/templates/mirrors-delete.html index a92ae03..c1c1ef3 100644 --- a/data/templates/mirrors-delete.html +++ b/data/templates/mirrors-delete.html @@ -22,23 +22,19 @@ -
-
-

- {{ _("You are going to delete the mirror %s.") % mirror.hostname }} -

+

+ {{ _("You are going to delete the mirror %s.") % mirror.hostname }} +

- -
+ + +
{% end block %} diff --git a/data/templates/mirrors-detail.html b/data/templates/mirrors-detail.html index b1e0a36..6804b98 100644 --- a/data/templates/mirrors-detail.html +++ b/data/templates/mirrors-detail.html @@ -17,16 +17,40 @@ + {% if current_user and current_user.has_perm("manage_mirrors") %} + + {% end %} +
-
- +
+
@@ -48,8 +72,8 @@
{{ _("Hostname") }}
-

{{ _("Status information") }}

- +

{{ _("Status information") }}

+
@@ -68,43 +92,11 @@
{{ _("Status") }}
- - {% if current_user and current_user.has_perm("manage_mirrors") %} - - {% end %}
-
-

{{ _("Map") }}

- +
{% if mirror.longitude and mirror.latitude %} -

- {{ _("The location of the mirror server is estimated by the IP address.") }} -

-

@@ -112,9 +104,19 @@ - © OpenStreetMap contributors, CC-BY-SA

+

+ {{ _("The location of the mirror server is estimated by the IP address.") }} +

{% else %} - {{ _("The location of the mirror server could not be estimated.") }} +

+ {{ _("The location of the mirror server could not be estimated.") }} +

{% end %}
+ + {% if log %} +

{{ _("Log") }}

+ {% module Log(log) %} + {% end %} {% end block %} diff --git a/data/templates/mirrors-edit.html b/data/templates/mirrors-edit.html index e319b5d..ab6c7f4 100644 --- a/data/templates/mirrors-edit.html +++ b/data/templates/mirrors-edit.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block title %}{{ _("Edit mirror %s") % mirror.hostname }}{% end block %} +{% block title %}{{ _("Manage mirror %s") % mirror.hostname }}{% end block %} {% block body %} -
-
-
- {% raw xsrf_form_html() %} -
-
- -
- + + {% raw xsrf_form_html() %} +
+
+ +
+ -

- {{ _("The canonical hostname.") }} -

-
-
+

+ {{ _("The canonical hostname.") }} +

+
+
-
- -
- -
-
-
+
+ +
+ +
+
+ -
- {{ _("Contact information") }} +
+ {{ _("Contact information") }} -
- -
- +
+ +
+ -

- {{ _("The owner of the mirror server.") }} -

-
-
+

+ {{ _("The owner of the mirror server.") }} +

+
+
-
- -
- +
+ +
+ -

- {{ _("An email address to contact an administrator of the mirror.") }} -
- {{ _("This won't be made public.") }} -

-
-
+

+ {{ _("An email address to contact an administrator of the mirror.") }} +
+ {{ _("This won't be made public.") }} +

+
+
-
- - {{ _("Cancel") }} -
-
- -
-
+
+ + {{ _("Cancel") }} +
+ + {% end block %} diff --git a/data/templates/mirrors-list.html b/data/templates/mirrors-list.html index 2c6121a..4f67e10 100644 --- a/data/templates/mirrors-list.html +++ b/data/templates/mirrors-list.html @@ -13,82 +13,86 @@ + {% if current_user and current_user.has_perm("manage_mirrors") %} + + {% end %} + -
-
-

- {{ _("On this page, you will see a list of all mirror servers.") }} -

+

+ {{ _("On this page, you will see a list of all mirror servers.") }} +

- {% if mirrors %} - - - - - - - - - - - - {% for mirror in mirrors %} - - - - - - - - {% end %} - -
 {{ _("Hostname") }}{{ _("Owner") }}{{ _("Status") }}{{ _("Last check") }}
- [{{ mirror.country_code }}] - - - {{ mirror.hostname }} - - - {{ mirror.owner or _("N/A") }} - - {{ mirror.check_status }} - - {% if mirror.last_check %} - {{ format_date(mirror.last_check, relative=True) }} - {% else %} - {{ _("Unknown") }} - {% end %} -
- {% else %} -
-

{{ _("No mirrors") }}

- {{ _("There are no mirrors configured, yet.") }} -
- {% end %} -
-
+ {% if mirrors %} + + + + + + + + + + {% for mirror in mirrors %} + + + + + + + {% end %} + +
{{ _("Hostname") }} / {{ _("Owner") }}{{ _("Last check") }}
+ + {{ mirror.hostname }} + +

+ {{ mirror.owner or _("N/A") }} +

+
+ [{{ mirror.country_code }}] - - {% if current_user and current_user.has_perm("manage_mirrors") %} - + {% if mirror.check_status == "UP" %} + + {{ _("Up") }} + + {% elif mirror.check_status == "DOWN" %} + + {{ _("Down") }} + + {% else %} + + {{ _("Unknown") }} + + {% end %} + + {% if mirror.last_check %} + {{ format_date(mirror.last_check, relative=True) }} + {% else %} + {{ _("N/A") }} + {% end %} +
+ {% else %} +

+ {{ _("There are no mirrors configured, yet.") }} +

{% end %} -
-
-

{{ _("Log") }}

- {% module Log(log) %} -
-
+ {% if log %} +

{{ _("Log") }}

+ {% module Log(log) %} + {% end %} {% end block %} diff --git a/data/templates/mirrors-new.html b/data/templates/mirrors-new.html index 8222f60..67ee96b 100644 --- a/data/templates/mirrors-new.html +++ b/data/templates/mirrors-new.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block title %}{{ _("Create new mirror") }}{% end block %} +{% block title %}{{ _("Add new mirror") }}{% end block %} {% block body %} -
-
-
- {% raw xsrf_form_html() %} -
-
- -
- - -

- {{ _("Enter the canonical hostname of the mirror.") }} -

-
-
- -
- -
- - -

- {{ _("The path to the files on the server.") }} -

-
-
- -
- -
-
-
-
-
+
+ {% raw xsrf_form_html() %} +
+
+ +
+ + +

+ {{ _("Enter the canonical hostname of the mirror.") }} +

+
+
+ +
+ +
+ + +

+ {{ _("The path to the files on the server.") }} +

+
+
+ +
+ +
+
+
{% end block %} diff --git a/web/handlers_mirrors.py b/web/handlers_mirrors.py index 5a81da1..c022f2f 100644 --- a/web/handlers_mirrors.py +++ b/web/handlers_mirrors.py @@ -25,7 +25,7 @@ class MirrorListHandler(BaseHandler): } # Get recent log messages. - kwargs["log"] = self.pakfire.mirrors.get_history(limit=10) + kwargs["log"] = self.pakfire.mirrors.get_history(limit=5) self.render("mirrors-list.html", **kwargs) @@ -36,7 +36,9 @@ class MirrorDetailHandler(BaseHandler): if not mirror: raise tornado.web.HTTPError(404, "Could not find mirror: %s" % hostname) - self.render("mirrors-detail.html", mirror=mirror) + log = self.pakfire.mirrors.get_history(mirror=mirror, limit=10) + + self.render("mirrors-detail.html", mirror=mirror, log=log) class MirrorActionHandler(BaseHandler): @@ -75,8 +77,6 @@ class MirrorNewHandler(MirrorActionHandler): }) return self.get(**errors) - print hostname, path - mirror = backend.mirrors.Mirror.create(self.pakfire, hostname, path, user=self.current_user) assert mirror @@ -106,9 +106,9 @@ class MirrorEditHandler(MirrorActionHandler): enabled = self.get_argument("enabled", None) if enabled: - mirror.set_status("enabled") + mirror.set_status("enabled", user=self.current_user) else: - mirror.set_status("disabled") + mirror.set_status("disabled", user=self.current_user) mirror.hostname = hostname mirror.path = path