diff mbox

[Branch,~linaro-validation/lava-scheduler/trunk] Rev 147: Add a common template for health job and device detail

Message ID 20120313032610.10714.50811.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Spring Zhang March 13, 2012, 3:26 a.m. UTC
Merge authors:
  Spring Zhang (qzhang)
Related merge proposals:
  https://code.launchpad.net/~qzhang/lava-scheduler/add-template4device/+merge/95154
  proposed by: Spring Zhang (qzhang)
  review: Approve - Michael Hudson-Doyle (mwhudson)
  review: Resubmit - Spring Zhang (qzhang)
------------------------------------------------------------
revno: 147 [merge]
committer: Spring Zhang <spring.zhang@linaro.org>
branch nick: lava-scheduler
timestamp: Tue 2012-03-13 11:23:57 +0800
message:
  Add a common template for health job and device detail
added:
  lava_scheduler_app/templates/lava_scheduler_app/_device_base.html
modified:
  lava_scheduler_app/templates/lava_scheduler_app/device.html
  lava_scheduler_app/templates/lava_scheduler_app/health_jobs.html
  lava_scheduler_app/views.py


--
lp:lava-scheduler
https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk

You are subscribed to branch lp:lava-scheduler.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk/+edit-subscription
diff mbox

Patch

=== added file 'lava_scheduler_app/templates/lava_scheduler_app/_device_base.html'
--- lava_scheduler_app/templates/lava_scheduler_app/_device_base.html	1970-01-01 00:00:00 +0000
+++ lava_scheduler_app/templates/lava_scheduler_app/_device_base.html	2012-03-09 02:49:54 +0000
@@ -0,0 +1,145 @@ 
+{% extends "lava_scheduler_app/_content.html" %}
+
+{% load django_tables2 %}
+
+{% block extrahead %}
+{{ block.super }}
+<style type="text/css">
+.column {
+    position: relative;
+    float: left;
+    padding-right: 2em;
+    padding-bottom: 1em;
+}
+</style>
+<style>
+  details, summary { display: block; padding: 0.2em; }
+  summary { cursor: pointer; }
+  summary:hover, summary:focus { background: #ddd; }
+  .no-details details > * { display: none; }
+  .no-details details.open > * { display: block; }
+  .no-details details summary:before { float: left; width: 20px; content: '► '; }
+  .no-details details.open summary:before { content: '▼ '; }
+  .no-details details summary { display: block; }
+</style>
+<script type="text/javascript" src="{{ STATIC_URL }}lava_scheduler_app/js/jquery.details.min.js"></script> 
+{% endblock %}
+
+
+{% block content %}
+{% block device_heading %}{% endblock %}
+
+{% if show_maintenance %}
+<form style="display:inline; float:right" method="POST"
+      action="{% url lava.scheduler.device.maintenance device.pk %}">
+  {% csrf_token %}
+  <button id="maintenance-button">Put into maintenance mode</button>
+</form>
+<form method="POST"
+      action="{% url lava.scheduler.device.maintenance device.pk %}"
+      id="maintenance-dialog" style="display: none">
+  {% csrf_token %}
+  <input name="reason" style="width: 100%"/>
+</form>
+{% endif %}
+{% if show_online %}
+<form style="display:inline; float:right" method="POST"
+      action="{% url lava.scheduler.device.online device.pk %}">
+  {% csrf_token %}
+  <button id="online-button">Put online</button>
+</form>
+<form method="POST"
+      action="{% url lava.scheduler.device.online device.pk %}"
+      id="online-dialog" style="display: none">
+  {% csrf_token %}
+  <input name="reason" style="width: 100%"/>
+</form>
+{% endif %}
+
+<div id="columns">
+  <div class="column">
+    <dt>Hostname:</dt>
+    <dd>{{ device.hostname }}</dd>
+
+    <dt>Device type:</dt>
+    <dd>{{ device.device_type }}</dd>
+
+    <dt>Device Tags</dt>
+    {% for tag in device.tags.all %}
+    <dd>{{ tag.name }}</dd>
+    {% empty %}
+    <dd><i>None</i></dd>
+    {% endfor %}
+  </div>
+  <div class="column">
+    <dt>Status:</dt>
+    <dd>
+      {{ device.get_status_display }}
+      {% if transition %}
+      (reason: <i>{{ transition }}</i>)
+      {% endif %}
+    </dd>
+    <dt>Health Status:</dt>
+    <dd>
+      {{ device.get_health_status_display }}
+    </dd>
+    {% if device.current_job %}
+    <dt>Currently running:</dt>
+    <dd><a href="{{ device.current_job.get_absolute_url }}"
+      >Job {{ device.current_job }}</a></dd>
+    {% endif %}
+  </div>
+  <div style="clear: both"></div>
+</div>
+
+{% block content_columns %}
+{% endblock %}
+
+<details>
+  <summary>See status transitions</summary>
+  {% render_table transition_table %}
+</details>
+
+<script>
+$(document).ready(
+  function() {
+    $('html').addClass($.fn.details.support ? 'details' : 'no-details');
+    $('details').details();
+    $('script').css('visibility', 'hidden');
+{% if show_maintenance %}
+    $("#maintenance-button").button();
+    $("#maintenance-button").click(function (e) {
+        e.preventDefault();
+        $("#maintenance-dialog").dialog('open');
+    });
+    $("#maintenance-dialog").dialog(
+        {
+            autoOpen: false,
+            buttons: {'OK': function () {$("#maintenance-dialog").submit()}},
+            modal: true,
+            title: "Reason for offlining"
+        }
+    );
+
+{% endif %}
+{% if show_online %}
+    $("#online-button").button();
+    $("#online-button").click(function (e) {
+        e.preventDefault();
+        $("#online-dialog").dialog('open');
+    });
+    $("#online-dialog").dialog(
+        {
+            autoOpen: false,
+            buttons: {'OK': function () {$("#online-dialog").submit()}},
+            modal: true,
+            title: "Reason for onlining"
+        }
+    );
+{% endif %}
+  }
+);
+</script>
+
+{% endblock %}
+

=== modified file 'lava_scheduler_app/templates/lava_scheduler_app/device.html'
--- lava_scheduler_app/templates/lava_scheduler_app/device.html	2012-03-05 00:23:16 +0000
+++ lava_scheduler_app/templates/lava_scheduler_app/device.html	2012-03-12 10:00:23 +0000
@@ -1,141 +1,11 @@ 
-{% extends "lava_scheduler_app/_content.html" %}
+{% extends "lava_scheduler_app/_device_base.html" %}
 
 {% load django_tables2 %}
 
-{% block extrahead %}
-{{ block.super }}
-<style type="text/css">
-.column {
-    position: relative;
-    float: left;
-    padding-right: 2em;
-    padding-bottom: 1em;
-}
-</style>
-<style>
-  details, summary { display: block; padding: 0.2em; }
-  summary { cursor: pointer; }
-  summary:hover, summary:focus { background: #ddd; }
-  .no-details details > * { display: none; }
-  .no-details details.open > * { display: block; }
-  .no-details details summary:before { float: left; width: 20px; content: '► '; }
-  .no-details details.open summary:before { content: '▼ '; }
-  .no-details details summary { display: block; }
-</style>
-<script type="text/javascript" src="{{ STATIC_URL }}lava_scheduler_app/js/jquery.details.min.js"></script> 
-{% endblock %}
-
-{% block content %}
+{% block device_heading %}
 <h2>Device {{ device }}</h2>
-
-{% if show_maintenance %}
-<form style="display:inline; float:right" method="POST"
-      action="{% url lava.scheduler.device.maintenance device.pk %}">
-  {% csrf_token %}
-  <button id="maintenance-button">Put into maintenance mode</button>
-</form>
-<form method="POST"
-      action="{% url lava.scheduler.device.maintenance device.pk %}"
-      id="maintenance-dialog" style="display: none">
-  {% csrf_token %}
-  <input name="reason" style="width: 100%"/>
-</form>
-{% endif %}
-{% if show_online %}
-<form style="display:inline; float:right" method="POST"
-      action="{% url lava.scheduler.device.online device.pk %}">
-  {% csrf_token %}
-  <button id="online-button">Put online</button>
-</form>
-<form method="POST"
-      action="{% url lava.scheduler.device.online device.pk %}"
-      id="online-dialog" style="display: none">
-  {% csrf_token %}
-  <input name="reason" style="width: 100%"/>
-</form>
-{% endif %}
-
-<div id="columns">
-  <div class="column">
-    <dt>Hostname:</dt>
-    <dd>{{ device.hostname }}</dd>
-
-    <dt>Device type:</dt>
-    <dd>{{ device.device_type }}</dd>
-
-    <dt>Device Tags</dt>
-    {% for tag in device.tags.all %}
-    <dd>{{ tag.name }}</dd>
-    {% empty %}
-    <dd><i>None</i></dd>
-    {% endfor %}
-  </div>
-  <div class="column">
-    <dt>Status:</dt>
-    <dd>
-      {{ device.get_status_display }}
-      {% if transition %}
-      (reason: <i>{{ transition }}</i>)
-      {% endif %}
-    </dd>
-    <dt>Health Status:</dt>
-    <dd>
-      {{ device.get_health_status_display }}
-    </dd>
-    {% if device.current_job %}
-    <dt>Currently running:</dt>
-    <dd><a href="{{ device.current_job.get_absolute_url }}"
-      >Job {{ device.current_job }}</a></dd>
-    {% endif %}
-  </div>
-  <div style="clear: both"></div>
-</div>
-
+{% endblock %}
+
+{% block content_columns %}
 {% render_table recent_job_table %}
-
-<details>
-  <summary>See status transitions</summary>
-  {% render_table transition_table %}
-</details>
-<script>
-$(document).ready(
-  function() {
-    $('html').addClass($.fn.details.support ? 'details' : 'no-details');
-    $('details').details();
-    $('script').css('visibility', 'hidden');
-{% if show_maintenance %}
-    $("#maintenance-button").button();
-    $("#maintenance-button").click(function (e) {
-        e.preventDefault();
-        $("#maintenance-dialog").dialog('open');
-    });
-    $("#maintenance-dialog").dialog(
-        {
-            autoOpen: false,
-            buttons: {'OK': function () {$("#maintenance-dialog").submit()}},
-            modal: true,
-            title: "Reason for offlining"
-        }
-    );
-
-{% endif %}
-{% if show_online %}
-    $("#online-button").button();
-    $("#online-button").click(function (e) {
-        e.preventDefault();
-        $("#online-dialog").dialog('open');
-    });
-    $("#online-dialog").dialog(
-        {
-            autoOpen: false,
-            buttons: {'OK': function () {$("#online-dialog").submit()}},
-            modal: true,
-            title: "Reason for onlining"
-        }
-    );
-{% endif %}
-  }
-);
-</script>
-
 {% endblock %}

=== modified file 'lava_scheduler_app/templates/lava_scheduler_app/health_jobs.html'
--- lava_scheduler_app/templates/lava_scheduler_app/health_jobs.html	2012-03-01 23:38:16 +0000
+++ lava_scheduler_app/templates/lava_scheduler_app/health_jobs.html	2012-03-09 02:49:54 +0000
@@ -1,69 +1,11 @@ 
-{% extends "lava_scheduler_app/_content.html" %}
+{% extends "lava_scheduler_app/_device_base.html" %}
 
 {% load django_tables2 %}
 
-{% block extrahead %}
-{{ block.super }}
-<style type="text/css">
-.column {
-    position: relative;
-    float: left;
-    padding-right: 2em;
-    padding-bottom: 1em;
-}
-</style>
-{% endblock %}
-
-{% block content %}
+{% block device_heading %}
 <h2>Device {{ device }} Health Job List</h2>
-
-{% if show_maintenance %}
-<form style="display:inline; float:right" method="POST"
-      action="{% url lava.scheduler.device.maintenance device.pk %}">
-  {% csrf_token %}
-  <button id="maintenance-button">Put into maintenance mode</button>
-</form>
-{% endif %}
-{% if show_online %}
-<form style="display:inline; float:right" method="POST"
-      action="{% url lava.scheduler.device.online device.pk %}">
-  {% csrf_token %}
-  <button id="online-button">Put online</button>
-</form>
-{% endif %}
-
-<div id="columns">
-  <div class="column">
-    <dt>Hostname:</dt>
-    <dd>{{ device.hostname }}</dd>
-
-    <dt>Device type:</dt>
-    <dd>{{ device.device_type }}</dd>
-
-    <dt>Device Tags</dt>
-    {% for tag in device.tags.all %}
-    <dd>{{ tag.name }}</dd>
-    {% empty %}
-    <dd><i>None</i></dd>
-    {% endfor %}
-  </div>
-  <div class="column">
-    <dt>Status:</dt>
-    <dd>{{ device.get_status_display }}</dd>
-    <dt>Health Status:</dt>
-    <dd>
-      {{ device.get_health_status_display }}
-    </dd>
-    {% if device.current_job %}
-    <dt>Currently running:</dt>
-    <dd><a href="{{ device.current_job.get_absolute_url }}"
-      >Job {{ device.current_job }}</a></dd>
-    {% endif %}
-  </div>
-  <div style="clear: both"></div>
-</div>
-
-
+{% endblock %}
+
+{% block content_columns %}
 {% render_table health_job_table %}
-
 {% endblock %}

=== modified file 'lava_scheduler_app/views.py'
--- lava_scheduler_app/views.py	2012-03-07 01:59:51 +0000
+++ lava_scheduler_app/views.py	2012-03-13 03:18:14 +0000
@@ -184,7 +184,8 @@ 
             "hostname", "last_health_report_job")
 
     def render_hostname(self, record):
-        return pklink(record)
+        return mark_safe('<a href="%s">%s</a>' % (
+            record.get_device_health_url(), escape(record.pk)))
 
     def render_last_health_report_job(self, record):
         report = record.last_health_report_job
@@ -226,7 +227,7 @@ 
 
     def get_queryset(self):
         device, = self.params
-        TestJob.objects.select_related(
+        return TestJob.objects.select_related(
             "submitter",
             ).filter(
             actual_device=device,
@@ -249,6 +250,9 @@ 
         "lava_scheduler_app/health_jobs.html",
         {
             'device': device,
+            'transition_table': DeviceTransitionTable(
+                'transitions', reverse(transition_json, kwargs=dict(pk=device.pk)),
+                params=(device,)),
             'health_job_table': HealthJobTable(
                 'health_jobs', reverse(health_jobs_json, kwargs=dict(pk=pk)),
                 params=(device,)),