diff options
author | maxbr <maxbr@mi.fu-berlin.de> | 2016-09-12 11:16:30 +0200 |
---|---|---|
committer | maxbr <maxbr@mi.fu-berlin.de> | 2016-09-12 11:16:30 +0200 |
commit | d4b606f0e7b656138216644004ee6d18ff754b93 (patch) | |
tree | b5dd6d1cf46a2a3014a3f403faef3884f14aedfb /tools | |
parent | c684fe13cf6f3b4666a664bfdc638e446b2d123f (diff) |
Add utilization column to dev pod tab
JIRA: PHAROS-263
Change-Id: I25d5d4bf4ecc23febdc0c11eae3298ada9372e83
Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/pharos-dashboard/dashboard/views.py | 12 | ||||
-rw-r--r-- | tools/pharos-dashboard/templates/dashboard/ci_pods.html | 2 | ||||
-rw-r--r-- | tools/pharos-dashboard/templates/dashboard/dev_pods.html | 16 |
3 files changed, 24 insertions, 6 deletions
diff --git a/tools/pharos-dashboard/dashboard/views.py b/tools/pharos-dashboard/dashboard/views.py index 8954f6c3..c34a7a57 100644 --- a/tools/pharos-dashboard/dashboard/views.py +++ b/tools/pharos-dashboard/dashboard/views.py @@ -40,10 +40,18 @@ class DevelopmentPodsView(TemplateView): dev_pods = [] for resource in resources: - dev_pod = (resource, None) + booking_utilization = resource.get_booking_utilization(weeks=4) + total = booking_utilization['booked_seconds'] + booking_utilization['available_seconds'] + try: + utilization_percentage = "%d%%" % (float(booking_utilization['booked_seconds']) / + total * 100) + except (ValueError, ZeroDivisionError): + return "" + + dev_pod = (resource, None, utilization_percentage) for booking in bookings: if booking.resource == resource: - dev_pod = (resource, booking) + dev_pod = (resource, booking, utilization_percentage) dev_pods.append(dev_pod) context = super(DevelopmentPodsView, self).get_context_data(**kwargs) diff --git a/tools/pharos-dashboard/templates/dashboard/ci_pods.html b/tools/pharos-dashboard/templates/dashboard/ci_pods.html index 2982a6ff..a754252c 100644 --- a/tools/pharos-dashboard/templates/dashboard/ci_pods.html +++ b/tools/pharos-dashboard/templates/dashboard/ci_pods.html @@ -41,7 +41,7 @@ href={{ pod.slave.last_job_url }}>{{ pod.slave.last_job_name }}</a> </th> </tr> - {% endfor %}` + {% endfor %} </tbody> {% endblock table %} diff --git a/tools/pharos-dashboard/templates/dashboard/dev_pods.html b/tools/pharos-dashboard/templates/dashboard/dev_pods.html index 9c84bb91..c4cb1ba7 100644 --- a/tools/pharos-dashboard/templates/dashboard/dev_pods.html +++ b/tools/pharos-dashboard/templates/dashboard/dev_pods.html @@ -10,12 +10,14 @@ <th>Booked by</th> <th>Booked until</th> <th>Purpose</th> + <th>Utilization</th> <th>Status</th> <th></th> + <th></th> </tr> </thead> <tbody> - {% for pod, booking in dev_pods %} + {% for pod, booking, utilization in dev_pods %} <tr> <th> <a href={% url 'dashboard:resource' resource_id=pod.id %}>{{ pod.name }}</a> @@ -32,6 +34,9 @@ <th> {{ booking.purpose }} </th> + <th> + {{ utilization }} + </th> <th style="background-color:{{ pod.slave.status | jenkins_status_color }}"> {{ pod.slave.status }} </th> @@ -40,6 +45,11 @@ Book </a> </th> + <th> + <a href="{% url 'dashboard:resource' resource_id=pod.id %}" class="btn btn-primary"> + Info + </a> + </th> </tr> {% endfor %} </tbody> @@ -50,9 +60,9 @@ $(document).ready(function () { $('#table').DataTable({ columnDefs: [ - {type: 'status', targets: 5} + {type: 'status', targets: 6} ], - "order": [[5, "asc"]] + "order": [[6, "asc"]] }); }); </script> |