From 167ed9ae59ded96d526b421c932b41554465f9eb Mon Sep 17 00:00:00 2001 From: maxbr Date: Mon, 12 Sep 2016 11:18:10 +0200 Subject: 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 --- tools/pharos-dashboard/dashboard/views.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tools/pharos-dashboard/dashboard/views.py') 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}) -- cgit 1.2.3-korg