diff options
author | maxbr <maxbr@mi.fu-berlin.de> | 2016-09-12 11:18:10 +0200 |
---|---|---|
committer | maxbr <maxbr@mi.fu-berlin.de> | 2016-09-12 11:18:10 +0200 |
commit | 167ed9ae59ded96d526b421c932b41554465f9eb (patch) | |
tree | ac1af5411311199cb88da6b9eacb407cfdbad852 /tools/pharos-dashboard/dashboard/views.py | |
parent | d4b606f0e7b656138216644004ee6d18ff754b93 (diff) |
Add info to the resource view
JIRA: PHAROS-266
This adds a panel containing lab owner contact information, jenkins
utilization timerange options and a table containing vpn users of a pod
to the resource view.
Change-Id: If991c74d3c93cd08f622771acc048ab998e16c48
Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
Diffstat (limited to 'tools/pharos-dashboard/dashboard/views.py')
-rw-r--r-- | tools/pharos-dashboard/dashboard/views.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/pharos-dashboard/dashboard/views.py b/tools/pharos-dashboard/dashboard/views.py index c34a7a57..0eddc130 100644 --- a/tools/pharos-dashboard/dashboard/views.py +++ b/tools/pharos-dashboard/dashboard/views.py @@ -1,7 +1,9 @@ from datetime import timedelta +from django.http import JsonResponse from django.shortcuts import get_object_or_404 from django.utils import timezone +from django.views import View from django.views.generic import TemplateView from booking.models import Booking @@ -104,3 +106,28 @@ class BookingUtilizationJSON(View): }, ] return JsonResponse({'data': utilization}) + + +class JenkinsUtilizationJSON(View): + def get(self, request, *args, **kwargs): + resource = get_object_or_404(Resource, id=kwargs['resource_id']) + weeks = int(kwargs['weeks']) + utilization = resource.slave.get_utilization(timedelta(weeks=weeks)) + utilization = [ + { + 'label': 'Offline', + 'data': utilization['offline'], + 'color': '#d9534f' + }, + { + 'label': 'Online', + 'data': utilization['online'], + 'color': '#5cb85c' + }, + { + 'label': 'Idle', + 'data': utilization['idle'], + 'color': '#5bc0de' + }, + ] + return JsonResponse({'data': utilization}) |