]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
web: Refactor job queue
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 Oct 2017 16:26:41 +0000 (17:26 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 Oct 2017 16:26:41 +0000 (17:26 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
po/POTFILES.in
src/templates/index.html
src/templates/jobs-filter.html [deleted file]
src/templates/jobs-index.html [deleted file]
src/templates/queue.html [new file with mode: 0644]
src/web/__init__.py
src/web/base.py
src/web/jobs.py

index 9a4965411db25ac550ceb8e2c2cb24cf5f19c96e..7b5d672030a76adff37dc994724f3e41de2d2ad4 100644 (file)
@@ -182,8 +182,6 @@ dist_templates_DATA = \
        src/templates/job-schedule-rebuild.html \
        src/templates/job-schedule-test.html \
        src/templates/jobs-detail.html \
-       src/templates/jobs-filter.html \
-       src/templates/jobs-index.html \
        src/templates/keys-delete.html \
        src/templates/keys-import.html \
        src/templates/keys-list.html \
@@ -193,6 +191,7 @@ dist_templates_DATA = \
        src/templates/package-detail-list.html \
        src/templates/package-properties.html \
        src/templates/packages-list.html \
+       src/templates/queue.html \
        src/templates/register-activation-fail.html \
        src/templates/register-activation-success.html \
        src/templates/register-fail.html \
index b57938b333c1282a3179faedc76a0acca8897964..b14e27604d3e1129bf3ddc8f9849bdf2eb83ea4d 100644 (file)
@@ -71,8 +71,6 @@ src/templates/jobs-buildroot.html
 src/templates/job-schedule-rebuild.html
 src/templates/job-schedule-test.html
 src/templates/jobs-detail.html
-src/templates/jobs-filter.html
-src/templates/jobs-index.html
 src/templates/keys-delete.html
 src/templates/keys-import.html
 src/templates/keys-list.html
@@ -131,6 +129,7 @@ src/templates/packages/builds/times.html
 src/templates/packages/changelog.html
 src/templates/packages-list.html
 src/templates/packages/view-file.html
+src/templates/queue.html
 src/templates/register-activation-fail.html
 src/templates/register-activation-success.html
 src/templates/register-fail.html
index 93dc37777a2b398f598803518be54ff012205d0c..da1c8ed81ba70b3d48410aee9b7b4819b7536b07 100644 (file)
 
        <ul class="nav nav-pills">
                <li>
-                       <a href="/jobs">{{ _("Show more build jobs") }}</a>
+                       <a href="/queue">
+                               {{ _("Job Queue") }}
+
+                               <!-- should be a badge -->
+                               ({{ len(backend.jobqueue) }})
+                       </a>
                </li>
        </ul>
 {% end %}
diff --git a/src/templates/jobs-filter.html b/src/templates/jobs-filter.html
deleted file mode 100644 (file)
index 65f215b..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-{% extends "base.html" %}
-
-{% block title %}{{ _("Filter jobs") }}{% end block %}
-
-{% block body %}
-       <ul class="breadcrumb">
-               <li>
-                       <a href="/">{{ _("Home") }}</a>
-                       <span class="divider">/</span>
-               </li>
-               <li>
-                       <a href="/jobs">{{ _("Jobs") }}</a>
-                       <span class="divider">/</span>
-               </li>
-               <li class="active">
-                       <a href="/jobs/filter">{{ _("Filter") }}</a>
-               </li>
-       </ul>
-
-       <div class="page-header">
-               <h2>{{ _("Filter jobs") }}</h2>
-       </div>
-
-       <form class="form-horizontal" method="GET" action="/jobs">
-               <fieldset>
-                       <div class="control-group">
-                               <label class="control-label">{{ _("Builder") }}</label>
-                               <div class="controls">
-                                       <select name="builder">
-                                               <option value="">{{ _("[Choose one]") }}</option>
-                                               {% for b in builders %}
-                                                       <option value="{{ b.name }}">{{ b.name }}</option>
-                                               {% end %}
-                                       </select>
-                                       <span class="help-block">
-                                               {{ _("Only show jobs, that have been built by this builder.") }}
-                                       </span>
-                               </div>
-                       </div>
-
-                       <hr>
-
-                       <div class="control-group">
-                               <label class="control-label">{{ _("Architecture") }}</label>
-                               <div class="controls">
-                                       <select name="arch">
-                                               <option value="">{{ _("[Choose one]") }}</option>
-                                               {% for a in arches %}
-                                                       <option value="{{ a.name }}">{{ a.name }}</option>
-                                               {% end %}
-                                       </select>
-                                       <span class="help-block">
-                                               {{ _("Only show jobs, with this architecture.") }}
-                                       </span>
-                               </div>
-                       </div>
-
-                       <div class="form-actions">
-                               <button type="submit" class="btn btn-primary">{{ _("Go!") }}</button>
-                       </div>
-               </fieldset>
-       </form>
-{% end block %}
diff --git a/src/templates/jobs-index.html b/src/templates/jobs-index.html
deleted file mode 100644 (file)
index 58291ed..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-{% extends "base.html" %}
-
-{% block title %}{{ _("Jobs") }}{% end block %}
-
-{% block body %}
-       <ul class="breadcrumb">
-               <li>
-                       <a href="/">{{ _("Home") }}</a>
-                       <span class="divider">/</span>
-               </li>
-               <li class="active">
-                       <a href="/jobs">{{ _("Jobs") }}</a>
-               </li>
-       </ul>
-
-       <ul class="nav nav-pills pull-right">
-               <li>
-                       <a href="/jobs/filter">{{ _("Filter jobs") }}</a>
-               </li>
-       </ul>
-
-       <div class="page-header">
-               <h2>{{ _("Jobs") }}</h2>
-       </div>
-
-       {% if arch or builder or date %}
-               <ul>
-                       {% if date %}
-                               <li>
-                                       {{ _("Showing only jobs from %s.") % date }}
-                               </li>
-                       {% end %}
-
-                       {% if builder %}
-                               <li>
-                                       <a href="/builder/{{ builder.name }}">
-                                               {{ _("Showing only builds that have been built on %s.") % builder.name }}
-                                       </a>
-                               </li>
-                       {% end %}
-
-                       {% if arch %}
-                               <li>
-                                       <a href="/arch/{{ arch.name }}">
-                                               {{ _("Showing only jobs built for %s.") % arch.name }}
-                                       </a>
-                               </li>
-                       {% end %}
-               </ul>
-
-               <hr>
-       {% end %}
-
-       {% module JobsList(jobs) %}
-{% end block %}
diff --git a/src/templates/queue.html b/src/templates/queue.html
new file mode 100644 (file)
index 0000000..5ad565f
--- /dev/null
@@ -0,0 +1,41 @@
+{% extends "base.html" %}
+
+{% block title %}{{ _("Job Queue") }} - {{ arch or _("All Architectures") }}{% end block %}
+
+{% block body %}
+       <ul class="breadcrumb">
+               <li>
+                       <a href="/">{{ _("Home") }}</a>
+                       <span class="divider">/</span>
+               </li>
+               <li {% if not arch %}class="active"{% end %}>
+                       <a href="/queue">{{ _("Job Queue") }}</a>
+                       {% if arch %}
+                               <span class="divider">/</span>
+                       {% end %}
+               </li>
+               {% if arch %}
+                       <li class="active">
+                               <a href="/queue/{{ arch }}">{{ arch }}</a>
+                       </li>
+               {% end %}
+       </ul>
+
+       <div class="page-header">
+               <h2>{{ _("Job Queue") }}</h2>
+       </div>
+
+       <ul class="nav nav-pills">
+               <li {% if not arch %}class="active"{% end %}>
+                       <a href="/queue">{{ _("All") }}</a>
+               </li>
+
+               {% for a in backend.arches %}
+                       <li {% if a == arch %}class="active"{% end %}>
+                               <a href="/queue/{{ a }}">{{ a }}</a>
+                       </li>
+               {% end %}
+       </ul>
+
+       {% module JobsList(queue) %}
+{% end block %}
index 4cf457b227273b5890b9b379cbc5373dc709e1ea..3069997ae34cdd8395761944d7d539699622e5b3 100644 (file)
@@ -160,9 +160,10 @@ class Application(tornado.web.Application):
                        (r"/build/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/watchers", builds.BuildWatchersHandler),
                        (r"/build/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/delete", builds.BuildDeleteHandler),
 
+                       (r"/queue", jobs.ShowQueueHandler),
+                       (r"/queue/([\w_]+)", jobs.ShowQueueHandler),
+
                        # Jobs
-                       (r"/jobs", jobs.JobsIndexHandler),
-                       (r"/jobs/filter", jobs.JobsFilterHandler),
                        (r"/job/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})", jobs.JobDetailHandler),
                        (r"/job/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/abort", jobs.JobAbortHandler),
                        (r"/job/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/buildroot", jobs.JobBuildrootHandler),
index d3ceaa5c2aa15cfdffb09a026dd449f09efc4e82..6bf8c32e7d5d2dd6d30be1b24383303238a7e12d 100644 (file)
@@ -76,6 +76,7 @@ class BaseHandler(tornado.web.RequestHandler):
                ns = tornado.web.RequestHandler.get_template_namespace(self)
 
                ns.update({
+                       "backend"         : self.backend,
                        "bugtracker"      : self.pakfire.bugzilla,
                        "hostname"        : self.request.host,
                        "format_date"     : self.format_date,
index f3f016cfd76688516a88cef8e9a6d25aa5904cfb..f17817bb13a0492b85609c440424276ca2c385b0 100644 (file)
@@ -4,36 +4,17 @@ import tornado.web
 
 from . import base
 
-class JobsIndexHandler(base.BaseHandler):
-       def get(self):
-               # Filter for a certain arch.
-               arch = self.get_argument("arch", None)
-               if not arch or not self.backend.arches.exists(arch):
-                       raise tornado.web.HTTPError(400, "Architecture does not exist")
-
-               # Check if we need to filter for a certain builder.
-               builder_name = self.get_argument("builder", None)
-               if builder_name:
-                       builder = self.pakfire.builders.get_by_name(builder_name)
-               else:
-                       builder = None
-
-               # Filter for a certain date.
-               date = self.get_argument("date", None)
-
-               # Get all jobs, that fulfill the criteria.
-               jobs = self.pakfire.jobs.get_latest(limit=50, arch=arch, builder=builder,
-                       date=date)
+class ShowQueueHandler(base.BaseHandler):
+       def get(self, arch=None):
+               if arch:
+                       if not self.backend.arches.exists(arch):
+                               raise tornado.web.HTTPError(400, "Architecture does not exist")
 
-               self.render("jobs-index.html", jobs=jobs, arch=arch, builder=builder,
-                       date=date)
-
-
-class JobsFilterHandler(base.BaseHandler):
-       def get(self):
-               builders = self.pakfire.builders.get_all()
+                       queue = self.backend.jobqueue.for_arches([arch, "noarch"])
+               else:
+                       queue = self.backend.jobqueue
 
-               self.render("jobs-filter.html", arches=self.backend.arches, builders=builders)
+               self.render("queue.html", arch=arch, queue=queue)
 
 
 class JobDetailHandler(base.BaseHandler):