]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
Redesign mirror management.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 4 Dec 2012 12:50:42 +0000 (13:50 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 4 Dec 2012 12:50:42 +0000 (13:50 +0100)
data/templates/mirrors-delete.html
data/templates/mirrors-detail.html
data/templates/mirrors-edit.html
data/templates/mirrors-list.html
data/templates/mirrors-new.html
web/handlers_mirrors.py

index a92ae0353fd47eb7302373a8e9ef5033bc87e945..c1c1ef31728b0cdaa32e3c20b28eab04fe28a7ce 100644 (file)
        </ul>
 
        <div class="page-header">
-               <h1>{{ _("Mirror") }}: {{ mirror.hostname }}</h1>
+               <h2>{{ _("Delete mirror: %s") % mirror.hostname }}</h2>
        </div>
 
-       <div class="row">
-               <div class="span6 offset3">
-                       <p>
-                               {{ _("You are going to delete the mirror <strong>%s</strong>.") % mirror.hostname }}
-                       </p>
+       <p>
+               {{ _("You are going to delete the mirror %s.") % mirror.hostname }}
+       </p>
 
-                       <div class="btn-toolbar">
-                               <div class="btn-group pull-right">
-                                       <a class="btn btn-danger" href="/mirror/{{ mirror.hostname }}/delete?confirmed=1">
-                                               {{ _("Delete %s") % mirror.hostname }}
-                                       </a>
-                                       <a class="btn" href="/mirror/{{ mirror.hostname }}">{{ _("Cancel") }}</a>
-                               </div>
-                       </div>
-               </div>
+       <div class="btn-toolbar pull-right">
+               <a class="btn btn-danger" href="/mirror/{{ mirror.hostname }}/delete?confirmed=1">
+                       {{ _("Delete %s") % mirror.hostname }}
+               </a>
+               <a class="btn" href="/mirror/{{ mirror.hostname }}">{{ _("Cancel") }}</a>
        </div>
+
+       <br class="clear">
 {% end block %}
index b1e0a367c3f1f0ded9040018be4c6340a5c5d0a2..6804b986805c072e1837cb8a3b3cdc822381c9c6 100644 (file)
                </li>
        </ul>
 
+       {% if current_user and current_user.has_perm("manage_mirrors") %}
+               <div class="btn-group pull-right">
+                       <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
+                               {{ _("Actions") }} <span class="caret"></span>
+                       </a>
+                       <ul class="dropdown-menu">
+                               <li>
+                                       <a href="/mirror/{{ mirror.hostname }}/edit">
+                                               <i class="icon-edit"></i>
+                                               {{ _("Edit settings") }}
+                                       </a>
+                               </li>
+
+                               <li class="divider"></li>
+                               <li>
+                                       <a href="/mirror/{{ mirror.hostname }}/delete">
+                                               <i class="icon-trash"></i>
+                                               {{ _("Delete mirror") }}
+                                       </a>
+                               </li>
+                       </ul>
+               </div>
+       {% end %}
+
        <div class="page-header">
-               <h1>
+               <h2>
                        {{ _("Mirror: %s") % mirror.hostname }}
                        <small>{{ _("hosted by %s") % mirror.owner }}</small>
-               </h1>
+               </h2>
        </div>
 
        <div class="row">
-               <div class="span5">
-                       <table class="table">
+               <div class="span6">
+                       <table class="table table-striped table-hover">
                                <tbody>
                                        <tr>
                                                <td>{{ _("Hostname") }}</td>
@@ -48,8 +72,8 @@
                                </tbody>
                        </table>
 
-                       <h2>{{ _("Status information") }}</h2>
-                       <table class="table">
+                       <h3>{{ _("Status information") }}</h3>
+                       <table class="table table-striped table-hover">
                                <tbody>
                                        <tr>
                                                <td>{{ _("Status") }}</td>
                                        </tr>
                                </tbody>
                        </table>
-
-                       {% if current_user and current_user.has_perm("manage_mirrors") %}
-                               <div class="btn-toolbar">
-                                       <div class="btn-group pull-right">
-                                               <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
-                                                       {{ _("Action") }}
-                                                       <span class="caret"></span>
-                                               </a>
-                                               <ul class="dropdown-menu">
-                                                       <li>
-                                                               <a href="/mirror/{{ mirror.hostname }}/edit">
-                                                                       <i class="icon-edit"></i>
-                                                                       {{ _("Edit settings") }}
-                                                               </a>
-                                                       </li>
-
-                                                       <li class="divider"></li>
-                                                       <li>
-                                                               <a href="/mirror/{{ mirror.hostname }}/delete">
-                                                                       <i class="icon-trash"></i>
-                                                                       {{ _("Delete mirror") }}
-                                                               </a>
-                                                       </li>
-                                               </ul>
-                                       </div>
-                               </div>
-                       {% end %}
                </div>
 
-               <div class="span7">
-                       <h2>{{ _("Map") }}</h2>
-
+               <div class="span6">
                        {% if mirror.longitude and mirror.latitude %}
-                               <p>
-                                       {{ _("The location of the mirror server is estimated by the IP address.") }}
-                               </p>
-                               <iframe width="525" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"
+                               <iframe width="100%" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"
                                        src="http://www.openstreetmap.org/export/embed.html?bbox={{ mirror.longitude - 4 }},{{ mirror.latitude - 4 }},{{ mirror.longitude + 4 }},{{ mirror.latitude + 4 }}&amp;layer=mapquest&amp;marker={{ mirror.latitude }},{{ mirror.longitude }}" style="border: 1px solid black">
                                </iframe>
                                <p>
                                        -
                                        &copy; <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> contributors, CC-BY-SA
                                </p>
+                               <p class="muted">
+                                       {{ _("The location of the mirror server is estimated by the IP address.") }}
+                               </p>
                        {% else %}
-                               {{ _("The location of the mirror server could not be estimated.") }}
+                               <p class="muted">
+                                       {{ _("The location of the mirror server could not be estimated.") }}
+                               </p>
                        {% end %}
                </div>
        </div>
+
+       {% if log %}
+               <h3>{{ _("Log") }}</h3>
+               {% module Log(log) %}
+       {% end %}
 {% end block %}
index e319b5dcf0ba23afe7353a819ef899ab7be0accb..ab6c7f482e9534dbad0bf249ad5f0aad6848c0f9 100644 (file)
@@ -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 %}
        <ul class="breadcrumb">
        </ul>
 
        <div class="page-header">
-               <h1>{{ _("Edit mirror: %s") % mirror.hostname }}</h1>
+               <h2>{{ _("Manage mirror: %s") % mirror.hostname }}</h2>
        </div>
 
-       <div class="row">
-               <div class="span6 offset3">
-                       <form class="form-horizontal" method="POST" action="">
-                               {% raw xsrf_form_html() %}
-                               <fieldset>
-                                       <div class="control-group">
-                                               <label class="control-label" for="name">{{ _("Hostname") }}</label>
-                                               <div class="controls">
-                                                       <input type="text" class="input-xlarge" id="name" name="name" value="{{ mirror.hostname }}">
+       <form class="form-horizontal" method="POST" action="">
+               {% raw xsrf_form_html() %}
+               <fieldset>
+                       <div class="control-group">
+                               <label class="control-label" for="name">{{ _("Hostname") }}</label>
+                               <div class="controls">
+                                       <input type="text" class="input-xlarge" id="name" name="name" value="{{ mirror.hostname }}">
 
-                                                       <p class="help-block">
-                                                               {{ _("The canonical hostname.") }}
-                                                       </p>
-                                               </div>
-                                       </div>
+                                       <p class="help-block">
+                                               {{ _("The canonical hostname.") }}
+                                       </p>
+                               </div>
+                       </div>
 
-                                       <div class="control-group">
-                                               <label class="control-label" for="enabled">{{ _("Enabled") }}</label>
-                                               <div class="controls">
-                                                       <label class="checkbox">
-                                                               <input type="checkbox" id="enabled" name="enabled" {% if mirror.enabled %}checked="checked"{% end %}>
-                                                               {{ _("Only enabled mirrors will be pushed out to the clients.") }}
-                                                       </label>
-                                               </div>
-                                       </div>
-                               </fieldset>
+                       <div class="control-group">
+                               <label class="control-label" for="enabled">{{ _("Enabled") }}</label>
+                               <div class="controls">
+                                       <label class="checkbox">
+                                               <input type="checkbox" id="enabled" name="enabled" {% if mirror.enabled %}checked="checked"{% end %}>
+                                               {{ _("Only enabled mirrors will be pushed out to the clients.") }}
+                                       </label>
+                               </div>
+                       </div>
+               </fieldset>
 
-                               <fieldset>
-                                       <legend>{{ _("Contact information") }}</legend>
+               <fieldset>
+                       <legend>{{ _("Contact information") }}</legend>
 
-                                       <div class="control-group">
-                                               <label class="control-label" for="owner">{{ _("Owner") }}</label>
-                                               <div class="controls">
-                                                       <input type="text" class="input-xlarge" id="owner" name="owner" value="{{ mirror.owner }}">
+                       <div class="control-group">
+                               <label class="control-label" for="owner">{{ _("Owner") }}</label>
+                               <div class="controls">
+                                       <input type="text" class="input-xlarge" id="owner" name="owner" value="{{ mirror.owner }}">
 
-                                                       <p class="help-block">
-                                                               {{ _("The owner of the mirror server.") }}
-                                                       </p>
-                                               </div>
-                                       </div>
+                                       <p class="help-block">
+                                               {{ _("The owner of the mirror server.") }}
+                                       </p>
+                               </div>
+                       </div>
 
-                                       <div class="control-group">
-                                               <label class="control-label" for="contact">{{ _("Contact address") }}</label>
-                                               <div class="controls">
-                                                       <input type="text" class="input-xlarge" id="contact" name="contact" value="{{ mirror.contact }}">
+                       <div class="control-group">
+                               <label class="control-label" for="contact">{{ _("Contact address") }}</label>
+                               <div class="controls">
+                                       <input type="text" class="input-xlarge" id="contact" name="contact" value="{{ mirror.contact }}">
 
-                                                       <p class="help-block">
-                                                               {{ _("An email address to contact an administrator of the mirror.") }}
-                                                               <br />
-                                                               <em>{{ _("This won't be made public.") }}</em>
-                                                       </p>
-                                               </div>
-                                       </div>
+                                       <p class="help-block">
+                                               {{ _("An email address to contact an administrator of the mirror.") }}
+                                               <br>
+                                               <em>{{ _("This won't be made public.") }}</em>
+                                       </p>
+                               </div>
+                       </div>
 
-                                       <div class="form-actions">
-                                               <button type="submit" class="btn btn-primary">{{ _("Save changes") }}</button>
-                                               <a class="btn" href="/mirror/{{ mirror.hostname }}">{{ _("Cancel") }}</a>
-                                       </div>
-                               </fieldset>
-                       </form>
-               </div>
-       </div>
+                       <div class="form-actions">
+                               <button type="submit" class="btn btn-primary">{{ _("Save changes") }}</button>
+                               <a class="btn" href="/mirror/{{ mirror.hostname }}">{{ _("Cancel") }}</a>
+                       </div>
+               </fieldset>
+       </form>
 {% end block %}
index 2c6121a57eec0d2e05ceb0397b09f45c9c553ac4..4f67e10915fb534ab62d4b9e1112041a84d5e5ba 100644 (file)
                </li>
        </ul>
 
+       {% if current_user and current_user.has_perm("manage_mirrors") %}
+               <div class="btn-group pull-right">
+                       <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
+                               {{ _("Actions") }} <span class="caret"></span>
+                       </a>
+                       <ul class="dropdown-menu">
+                               <li>
+                                       <a href="/mirror/new">
+                                               <i class="icon-asterisk"></i> {{ _("Add new mirror") }}
+                                       </a>
+                               </li>
+                       </ul>
+               </div>
+       {% end %}
+
        <div class="page-header">
-               <h1>
-                       {{ _("Mirrors") }}
-                       <small>({{ len(mirrors) }})</small>
-               </h1>
+               <h2>{{ _("Mirrors") }}</h2>
        </div>
 
-       <div class="row">
-               <div class="span12">
-                       <p>
-                               {{ _("On this page, you will see a list of all mirror servers.") }}
-                       </p>
+       <p>
+               {{ _("On this page, you will see a list of all mirror servers.") }}
+       </p>
 
-                       {% if mirrors %}
-                               <table class="table table-striped table-hover">
-                                       <thead>
-                                               <tr>
-                                                       <th>&nbsp;</th>
-                                                       <th>{{ _("Hostname") }}</th>
-                                                       <th>{{ _("Owner") }}</th>
-                                                       <th>{{ _("Status") }}</th>
-                                                       <th>{{ _("Last check") }}</th>
-                                               </tr>
-                                       </thead>
-                                       <tbody>
-                                               {% for mirror in mirrors %}
-                                                       <tr>
-                                                               <td>
-                                                                       [{{ mirror.country_code }}]
-                                                               </td>
-                                                               <td>
-                                                                       <a href="/mirror/{{ mirror.hostname }}">
-                                                                               {{ mirror.hostname }}
-                                                                       </a>
-                                                               </td>
-                                                               <td>
-                                                                       {{ mirror.owner or _("N/A") }}
-                                                               </td>
-                                                               <td>
-                                                                       {{ mirror.check_status }}
-                                                               </td>
-                                                               <td>
-                                                                       {% if mirror.last_check %}
-                                                                               {{ format_date(mirror.last_check, relative=True) }}
-                                                                       {% else %}
-                                                                               {{ _("Unknown") }}
-                                                                       {% end %}
-                                                               </td>
-                                                       </tr>
-                                               {% end %}
-                                       </tbody>
-                               </table>
-                       {% else %}
-                               <div class="alert alert-block">
-                                       <h4 class="alert-heading">{{ _("No mirrors") }}</h4>
-                                       {{ _("There are no mirrors configured, yet.") }}
-                               </div>
-                       {% end %}
-               </div>
-       </div>
+       {% if mirrors %}
+               <table class="table table-striped table-hover">
+                       <thead>
+                               <tr>
+                                       <th>{{ _("Hostname") }} / {{ _("Owner") }}</th>
+                                       <th></th>
+                                       <th>{{ _("Last check") }}</th>
+                               </tr>
+                       </thead>
+                       <tbody>
+                               {% for mirror in mirrors %}
+                                       <tr>
+                                               <td>
+                                                       <a href="/mirror/{{ mirror.hostname }}">
+                                                               {{ mirror.hostname }}
+                                                       </a>
+                                                       <p class="muted">
+                                                               {{ mirror.owner or _("N/A") }}
+                                                       </p>
+                                               </td>
+                                               <td>
+                                                       [{{ mirror.country_code }}] -
 
-       {% if current_user and current_user.has_perm("manage_mirrors") %}
-               <div class="row">
-                       <div class="span12">
-                               <a class="btn pull-right" href="/mirror/new">
-                                       <i class="icon-star"></i>
-                                       {{ _("Add new mirror") }}
-                               </a>
-                       </div>
-               </div>
+                                                       {% if mirror.check_status == "UP" %}
+                                                               <span class="text-success">
+                                                                       {{ _("Up") }}
+                                                               </span>
+                                                       {% elif mirror.check_status == "DOWN" %}
+                                                               <span class="text-error">
+                                                                       {{ _("Down") }}
+                                                               </span>
+                                                       {% else %}
+                                                               <span class="muted">
+                                                                       {{ _("Unknown") }}
+                                                               </span>
+                                                       {% end %}
+                                               </td>
+
+                                               <td>
+                                                       {% if mirror.last_check %}
+                                                               {{ format_date(mirror.last_check, relative=True) }}
+                                                       {% else %}
+                                                               {{ _("N/A") }}
+                                                       {% end %}
+                                               </td>
+                                       </tr>
+                               {% end %}
+                       </tbody>
+               </table>
+       {% else %}
+               <p class="muted">
+                       {{ _("There are no mirrors configured, yet.") }}
+               </p>
        {% end %}
 
-       <div class="row">
-               <div class="span12">
-                       <h2>{{ _("Log") }}</h2>
-                       {% module Log(log) %}
-               </div>
-       </div>
+       {% if log %}
+               <h2>{{ _("Log") }}</h2>
+               {% module Log(log) %}
+       {% end %}
 {% end block %}
index 8222f6065defc60364799ecbbe98251da33ab8c6..67ee96b7ad0f9ec7368e221e129b5e970dfac093 100644 (file)
@@ -1,6 +1,6 @@
 {% extends "base.html" %}
 
-{% block title %}{{ _("Create new mirror") }}{% end block %}
+{% block title %}{{ _("Add new mirror") }}{% end block %}
 
 {% block body %}
        <ul class="breadcrumb">
        </ul>
 
        <div class="page-header">
-               <h1>
-                       {{ _("Create a new mirror") }}
-               </h1>
+               <h2>{{ _("Add a new mirror") }}</h2>
        </div>
 
-       <div class="row">
-               <div class="span6 offset3">
-                       <form class="form-horizontal" method="POST" action="">
-                               {% raw xsrf_form_html() %}
-                               <fieldset>
-                                       <div class="control-group {% if hostname_missing %}error{% end %}">
-                                               <label class="control-label" for="name">{{ _("Hostname") }}</label>
-                                               <div class="controls">
-                                                       <input type="text" class="input-xlarge" id="name" name="name" value="{{ _hostname }}">
-
-                                                       <p class="help-block">
-                                                               {{ _("Enter the canonical hostname of the mirror.") }}
-                                                       </p>
-                                               </div>
-                                       </div>
-
-                                       <div class="control-group {% if path_invalid %}error{% end %}">
-                                               <label class="control-label" for="name">{{ _("Path") }}</label>
-                                               <div class="controls">
-                                                       <input type="text" class="input-xlarge" id="path" name="path" value="{{ path }}">
-
-                                                       <p class="help-block">
-                                                               {{ _("The path to the files on the server.") }}
-                                                       </p>
-                                               </div>
-                                       </div>
-
-                                       <div class="form-actions">
-                                               <button type="submit" class="btn btn-primary">{{ _("Create new mirror") }}</button>
-                                       </div>
-                               </fieldset>
-                       </form>
-               </div>
-       </div>
+       <form class="form-horizontal" method="POST" action="">
+               {% raw xsrf_form_html() %}
+               <fieldset>
+                       <div class="control-group {% if hostname_missing %}error{% end %}">
+                               <label class="control-label" for="name">{{ _("Hostname") }}</label>
+                               <div class="controls">
+                                       <input type="text" class="input-xlarge" id="name" name="name"
+                                               {% if _hostname %}value="{{ _hostname }}"{% end %}>
+
+                                       <p class="help-block">
+                                               {{ _("Enter the canonical hostname of the mirror.") }}
+                                       </p>
+                               </div>
+                       </div>
+
+                       <div class="control-group {% if path_invalid %}error{% end %}">
+                               <label class="control-label" for="name">{{ _("Path") }}</label>
+                               <div class="controls">
+                                       <input type="text" class="input-xlarge" id="path" name="path"
+                                               {% if path %}value="{{ path }}"{% end %}>
+
+                                       <p class="help-block">
+                                               {{ _("The path to the files on the server.") }}
+                                       </p>
+                               </div>
+                       </div>
+
+                       <div class="form-actions">
+                               <button type="submit" class="btn btn-primary">{{ _("Create new mirror") }}</button>
+                       </div>
+               </fieldset>
+       </form>
 {% end block %}
index 5a81da1373f3650f362646d6eda35dada5646109..c022f2f73550159a9d664deacfe934dcc0579fee 100644 (file)
@@ -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