diff options
Diffstat (limited to 'tools/pharos-dashboard')
72 files changed, 1000 insertions, 84 deletions
diff --git a/tools/pharos-dashboard/account/__init__.py b/tools/pharos-dashboard/account/__init__.py index e69de29b..b5914ce7 100644 --- a/tools/pharos-dashboard/account/__init__.py +++ b/tools/pharos-dashboard/account/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/account/admin.py b/tools/pharos-dashboard/account/admin.py index 7fab1238..18b2e1a8 100644 --- a/tools/pharos-dashboard/account/admin.py +++ b/tools/pharos-dashboard/account/admin.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.contrib import admin from account.models import UserProfile diff --git a/tools/pharos-dashboard/account/apps.py b/tools/pharos-dashboard/account/apps.py index 999566ca..9814648f 100644 --- a/tools/pharos-dashboard/account/apps.py +++ b/tools/pharos-dashboard/account/apps.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.apps import AppConfig diff --git a/tools/pharos-dashboard/account/forms.py b/tools/pharos-dashboard/account/forms.py index 92c55d85..7653e2b1 100644 --- a/tools/pharos-dashboard/account/forms.py +++ b/tools/pharos-dashboard/account/forms.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + import django.forms as forms import pytz as pytz diff --git a/tools/pharos-dashboard/account/jira_util.py b/tools/pharos-dashboard/account/jira_util.py index c066a686..c333f8c4 100644 --- a/tools/pharos-dashboard/account/jira_util.py +++ b/tools/pharos-dashboard/account/jira_util.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + import base64 import os diff --git a/tools/pharos-dashboard/account/middleware.py b/tools/pharos-dashboard/account/middleware.py index 6f7cac7a..0f1dbd86 100644 --- a/tools/pharos-dashboard/account/middleware.py +++ b/tools/pharos-dashboard/account/middleware.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.utils import timezone from django.utils.deprecation import MiddlewareMixin diff --git a/tools/pharos-dashboard/account/migrations/__init__.py b/tools/pharos-dashboard/account/migrations/__init__.py index e69de29b..b5914ce7 100644 --- a/tools/pharos-dashboard/account/migrations/__init__.py +++ b/tools/pharos-dashboard/account/migrations/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/account/models.py b/tools/pharos-dashboard/account/models.py index fb2c8ddd..621f6697 100644 --- a/tools/pharos-dashboard/account/models.py +++ b/tools/pharos-dashboard/account/models.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.db import models from django.contrib.auth.models import User diff --git a/tools/pharos-dashboard/account/tests/__init__.py b/tools/pharos-dashboard/account/tests/__init__.py index e69de29b..b5914ce7 100644 --- a/tools/pharos-dashboard/account/tests/__init__.py +++ b/tools/pharos-dashboard/account/tests/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/account/tests/test_general.py b/tools/pharos-dashboard/account/tests/test_general.py index ba80b62c..72e7ea11 100644 --- a/tools/pharos-dashboard/account/tests/test_general.py +++ b/tools/pharos-dashboard/account/tests/test_general.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.contrib.auth.models import User from django.test import Client from django.test import TestCase diff --git a/tools/pharos-dashboard/account/urls.py b/tools/pharos-dashboard/account/urls.py index 7289da69..3962a0c6 100644 --- a/tools/pharos-dashboard/account/urls.py +++ b/tools/pharos-dashboard/account/urls.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + """pharos_dashboard URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: diff --git a/tools/pharos-dashboard/account/views.py b/tools/pharos-dashboard/account/views.py index fd1762e5..3b4269de 100644 --- a/tools/pharos-dashboard/account/views.py +++ b/tools/pharos-dashboard/account/views.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + import os import urllib diff --git a/tools/pharos-dashboard/api/__init__.py b/tools/pharos-dashboard/api/__init__.py new file mode 100644 index 00000000..b5914ce7 --- /dev/null +++ b/tools/pharos-dashboard/api/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/api/serializers.py b/tools/pharos-dashboard/api/serializers.py new file mode 100644 index 00000000..78e6020e --- /dev/null +++ b/tools/pharos-dashboard/api/serializers.py @@ -0,0 +1,32 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from rest_framework import serializers + +from booking.models import Booking +from dashboard.models import Server, Resource + + +class BookingSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = Booking + fields = ('id', 'resource', 'start', 'end', 'purpose') + + +class ServerSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = Server + fields = ('id', 'resource', 'name', 'model', 'cpu', 'ram', 'storage') + + +class ResourceSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = Resource + fields = ('id', 'name', 'description', 'url', 'server_set') diff --git a/tools/pharos-dashboard/api/urls.py b/tools/pharos-dashboard/api/urls.py new file mode 100644 index 00000000..5206ac7f --- /dev/null +++ b/tools/pharos-dashboard/api/urls.py @@ -0,0 +1,38 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +"""pharos_dashboard URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from rest_framework import routers + +from api.views import * + +router = routers.DefaultRouter() +router.register(r'resources', ResourceViewSet) +router.register(r'servers', ServerViewSet) +router.register(r'bookings', BookingViewSet) + +urlpatterns = [ + url(r'^', include(router.urls)), +]
\ No newline at end of file diff --git a/tools/pharos-dashboard/api/views.py b/tools/pharos-dashboard/api/views.py new file mode 100644 index 00000000..761ce6e7 --- /dev/null +++ b/tools/pharos-dashboard/api/views.py @@ -0,0 +1,33 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from rest_framework import viewsets + +from api.serializers import ResourceSerializer, ServerSerializer, BookingSerializer +from booking.models import Booking +from dashboard.models import Resource, Server + + +class BookingViewSet(viewsets.ModelViewSet): + queryset = Booking.objects.all() + serializer_class = BookingSerializer + filter_fields = ('resource', 'user') + + +class ServerViewSet(viewsets.ModelViewSet): + queryset = Server.objects.all() + serializer_class = ServerSerializer + filter_fields = ('resource', 'name') + + +class ResourceViewSet(viewsets.ModelViewSet): + queryset = Resource.objects.all() + serializer_class = ResourceSerializer + filter_fields = ('name',)
\ No newline at end of file diff --git a/tools/pharos-dashboard/booking/__init__.py b/tools/pharos-dashboard/booking/__init__.py index e69de29b..b5914ce7 100644 --- a/tools/pharos-dashboard/booking/__init__.py +++ b/tools/pharos-dashboard/booking/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/booking/admin.py b/tools/pharos-dashboard/booking/admin.py index 6055bed9..7a7f251a 100644 --- a/tools/pharos-dashboard/booking/admin.py +++ b/tools/pharos-dashboard/booking/admin.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.contrib import admin from booking.models import Booking diff --git a/tools/pharos-dashboard/booking/apps.py b/tools/pharos-dashboard/booking/apps.py index 2d5f36f2..99bf115f 100644 --- a/tools/pharos-dashboard/booking/apps.py +++ b/tools/pharos-dashboard/booking/apps.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.apps import AppConfig diff --git a/tools/pharos-dashboard/booking/forms.py b/tools/pharos-dashboard/booking/forms.py index 5b32c868..02ac887a 100644 --- a/tools/pharos-dashboard/booking/forms.py +++ b/tools/pharos-dashboard/booking/forms.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + import django.forms as forms diff --git a/tools/pharos-dashboard/booking/migrations/__init__.py b/tools/pharos-dashboard/booking/migrations/__init__.py index e69de29b..b5914ce7 100644 --- a/tools/pharos-dashboard/booking/migrations/__init__.py +++ b/tools/pharos-dashboard/booking/migrations/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/booking/models.py b/tools/pharos-dashboard/booking/models.py index e772fb5b..200dc830 100644 --- a/tools/pharos-dashboard/booking/models.py +++ b/tools/pharos-dashboard/booking/models.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.contrib.auth.models import User from django.db import models from jira import JIRA @@ -6,6 +16,7 @@ from jira import JIRAError from dashboard.models import Resource from django.conf import settings + class Booking(models.Model): id = models.AutoField(primary_key=True) user = models.ForeignKey(User, models.CASCADE) # delete if user is deleted diff --git a/tools/pharos-dashboard/booking/tests/__init__.py b/tools/pharos-dashboard/booking/tests/__init__.py index e69de29b..b5914ce7 100644 --- a/tools/pharos-dashboard/booking/tests/__init__.py +++ b/tools/pharos-dashboard/booking/tests/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/booking/tests/test_models.py b/tools/pharos-dashboard/booking/tests/test_models.py index 7a572c5f..612b35c0 100644 --- a/tools/pharos-dashboard/booking/tests/test_models.py +++ b/tools/pharos-dashboard/booking/tests/test_models.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from datetime import timedelta from django.contrib.auth.models import User, Permission diff --git a/tools/pharos-dashboard/booking/tests/test_views.py b/tools/pharos-dashboard/booking/tests/test_views.py index c5dff586..e568c155 100644 --- a/tools/pharos-dashboard/booking/tests/test_views.py +++ b/tools/pharos-dashboard/booking/tests/test_views.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from datetime import timedelta from django.contrib import auth diff --git a/tools/pharos-dashboard/booking/urls.py b/tools/pharos-dashboard/booking/urls.py index bdcd52d4..53206233 100644 --- a/tools/pharos-dashboard/booking/urls.py +++ b/tools/pharos-dashboard/booking/urls.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + """pharos_dashboard URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: diff --git a/tools/pharos-dashboard/booking/views.py b/tools/pharos-dashboard/booking/views.py index d0b2aefe..2fe167af 100644 --- a/tools/pharos-dashboard/booking/views.py +++ b/tools/pharos-dashboard/booking/views.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from datetime import timedelta from django.conf import settings diff --git a/tools/pharos-dashboard/dashboard/__init__.py b/tools/pharos-dashboard/dashboard/__init__.py index e69de29b..b5914ce7 100644 --- a/tools/pharos-dashboard/dashboard/__init__.py +++ b/tools/pharos-dashboard/dashboard/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/dashboard/admin.py b/tools/pharos-dashboard/dashboard/admin.py index 71a1e7d2..a1463a7a 100644 --- a/tools/pharos-dashboard/dashboard/admin.py +++ b/tools/pharos-dashboard/dashboard/admin.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.contrib import admin from dashboard.models import * diff --git a/tools/pharos-dashboard/dashboard/apps.py b/tools/pharos-dashboard/dashboard/apps.py index 50878e76..e0c4f442 100644 --- a/tools/pharos-dashboard/dashboard/apps.py +++ b/tools/pharos-dashboard/dashboard/apps.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.apps import AppConfig diff --git a/tools/pharos-dashboard/dashboard/migrations/__init__.py b/tools/pharos-dashboard/dashboard/migrations/__init__.py index e69de29b..b5914ce7 100644 --- a/tools/pharos-dashboard/dashboard/migrations/__init__.py +++ b/tools/pharos-dashboard/dashboard/migrations/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/dashboard/models.py b/tools/pharos-dashboard/dashboard/models.py index 734da386..050834ea 100644 --- a/tools/pharos-dashboard/dashboard/models.py +++ b/tools/pharos-dashboard/dashboard/models.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from datetime import timedelta from django.utils import timezone diff --git a/tools/pharos-dashboard/dashboard/tasks.py b/tools/pharos-dashboard/dashboard/tasks.py new file mode 100644 index 00000000..4c09bf90 --- /dev/null +++ b/tools/pharos-dashboard/dashboard/tasks.py @@ -0,0 +1,23 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from celery import shared_task +from datetime import timedelta +from django.utils import timezone + +from jenkins.models import JenkinsStatistic +from notification.models import BookingNotification + + +@shared_task +def database_cleanup(): + now = timezone.now() + JenkinsStatistic.objects.filter(timestamp__lt=now - timedelta(weeks=4)).delete() + BookingNotification.objects.filter(submit_time__lt=now - timedelta(weeks=4)).delete()
\ No newline at end of file diff --git a/tools/pharos-dashboard/dashboard/templatetags/__init__.py b/tools/pharos-dashboard/dashboard/templatetags/__init__.py index e69de29b..b5914ce7 100644 --- a/tools/pharos-dashboard/dashboard/templatetags/__init__.py +++ b/tools/pharos-dashboard/dashboard/templatetags/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/dashboard/templatetags/jenkins_filters.py b/tools/pharos-dashboard/dashboard/templatetags/jenkins_filters.py index f5038ea5..e7e14257 100644 --- a/tools/pharos-dashboard/dashboard/templatetags/jenkins_filters.py +++ b/tools/pharos-dashboard/dashboard/templatetags/jenkins_filters.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.template.defaultfilters import register diff --git a/tools/pharos-dashboard/dashboard/templatetags/jira_filters.py b/tools/pharos-dashboard/dashboard/templatetags/jira_filters.py index 1be0600b..70208436 100644 --- a/tools/pharos-dashboard/dashboard/templatetags/jira_filters.py +++ b/tools/pharos-dashboard/dashboard/templatetags/jira_filters.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.template.defaultfilters import register from django.conf import settings diff --git a/tools/pharos-dashboard/dashboard/urls.py b/tools/pharos-dashboard/dashboard/urls.py index baa2d633..f04f5ca9 100644 --- a/tools/pharos-dashboard/dashboard/urls.py +++ b/tools/pharos-dashboard/dashboard/urls.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + """pharos_dashboard URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: @@ -14,7 +24,6 @@ Including another URLconf 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf.urls import url - from dashboard.views import * urlpatterns = [ diff --git a/tools/pharos-dashboard/dashboard/views.py b/tools/pharos-dashboard/dashboard/views.py index 0eddc130..022a4af0 100644 --- a/tools/pharos-dashboard/dashboard/views.py +++ b/tools/pharos-dashboard/dashboard/views.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from datetime import timedelta from django.http import JsonResponse diff --git a/tools/pharos-dashboard/jenkins/__init__.py b/tools/pharos-dashboard/jenkins/__init__.py index e69de29b..b5914ce7 100644 --- a/tools/pharos-dashboard/jenkins/__init__.py +++ b/tools/pharos-dashboard/jenkins/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/jenkins/adapter.py b/tools/pharos-dashboard/jenkins/adapter.py index f9e352a1..ff0508d9 100644 --- a/tools/pharos-dashboard/jenkins/adapter.py +++ b/tools/pharos-dashboard/jenkins/adapter.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + import logging import re diff --git a/tools/pharos-dashboard/jenkins/apps.py b/tools/pharos-dashboard/jenkins/apps.py index 5abd2155..41faf600 100644 --- a/tools/pharos-dashboard/jenkins/apps.py +++ b/tools/pharos-dashboard/jenkins/apps.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.apps import AppConfig diff --git a/tools/pharos-dashboard/jenkins/migrations/__init__.py b/tools/pharos-dashboard/jenkins/migrations/__init__.py index e69de29b..b5914ce7 100644 --- a/tools/pharos-dashboard/jenkins/migrations/__init__.py +++ b/tools/pharos-dashboard/jenkins/migrations/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/jenkins/models.py b/tools/pharos-dashboard/jenkins/models.py index 354887ab..0875bba5 100644 --- a/tools/pharos-dashboard/jenkins/models.py +++ b/tools/pharos-dashboard/jenkins/models.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from django.db import models from django.utils import timezone diff --git a/tools/pharos-dashboard/jenkins/tasks.py b/tools/pharos-dashboard/jenkins/tasks.py index 6998cf3b..7c037827 100644 --- a/tools/pharos-dashboard/jenkins/tasks.py +++ b/tools/pharos-dashboard/jenkins/tasks.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from celery import shared_task from jenkins.models import JenkinsSlave, JenkinsStatistic diff --git a/tools/pharos-dashboard/jenkins/tests.py b/tools/pharos-dashboard/jenkins/tests.py index b1414515..4f350d20 100644 --- a/tools/pharos-dashboard/jenkins/tests.py +++ b/tools/pharos-dashboard/jenkins/tests.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + from unittest import TestCase import jenkins.adapter as jenkins diff --git a/tools/pharos-dashboard/manage.py b/tools/pharos-dashboard/manage.py index 97a5ba4a..80c496f3 100755..100644 --- a/tools/pharos-dashboard/manage.py +++ b/tools/pharos-dashboard/manage.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + #!/usr/bin/env python import os import sys diff --git a/tools/pharos-dashboard/notification/__init__.py b/tools/pharos-dashboard/notification/__init__.py new file mode 100644 index 00000000..37dcbddf --- /dev/null +++ b/tools/pharos-dashboard/notification/__init__.py @@ -0,0 +1,11 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +default_app_config = 'notification.apps.NotificationConfig'
\ No newline at end of file diff --git a/tools/pharos-dashboard/notification/admin.py b/tools/pharos-dashboard/notification/admin.py new file mode 100644 index 00000000..bcaa1ab7 --- /dev/null +++ b/tools/pharos-dashboard/notification/admin.py @@ -0,0 +1,17 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.conf import settings +from django.contrib import admin + +from notification.models import BookingNotification + +if settings.DEBUG: + admin.site.register(BookingNotification)
\ No newline at end of file diff --git a/tools/pharos-dashboard/notification/apps.py b/tools/pharos-dashboard/notification/apps.py new file mode 100644 index 00000000..2de22c4e --- /dev/null +++ b/tools/pharos-dashboard/notification/apps.py @@ -0,0 +1,18 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.apps import AppConfig + + +class NotificationConfig(AppConfig): + name = 'notification' + + def ready(self): + import notification.signals #noqa
\ No newline at end of file diff --git a/tools/pharos-dashboard/notification/models.py b/tools/pharos-dashboard/notification/models.py new file mode 100644 index 00000000..2d199181 --- /dev/null +++ b/tools/pharos-dashboard/notification/models.py @@ -0,0 +1,32 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.db import models + +class BookingNotification(models.Model): + id = models.AutoField(primary_key=True) + type = models.CharField(max_length=100) + booking = models.ForeignKey('booking.Booking', on_delete=models.CASCADE) + submit_time = models.DateTimeField() + submitted = models.BooleanField(default=False) + + def get_content(self): + return { + 'start': self.booking.start.isoformat(), + 'end': self.booking.end.isoformat(), + 'user': self.booking.user.username, + 'purpose': self.booking.purpose + } + + def save(self, *args, **kwargs): + notifications = self.booking.bookingnotification_set.filter(type=self.type) + if notifications.count() > 1: + raise ValueError('Doubled Notification') + return super(BookingNotification, self).save(*args, **kwargs)
\ No newline at end of file diff --git a/tools/pharos-dashboard/notification/signals.py b/tools/pharos-dashboard/notification/signals.py new file mode 100644 index 00000000..936c25ba --- /dev/null +++ b/tools/pharos-dashboard/notification/signals.py @@ -0,0 +1,25 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.db.models.signals import post_save +from django.dispatch import receiver + +from booking.models import Booking +from notification.models import BookingNotification + + +@receiver(post_save, sender=Booking) +def booking_notification_handler(sender, instance, **kwargs): + BookingNotification.objects.update_or_create( + booking=instance, type='booking_start', defaults={'submit_time': instance.start} + ) + BookingNotification.objects.update_or_create( + booking=instance, type='booking_end', defaults={'submit_time': instance.end} + )
\ No newline at end of file diff --git a/tools/pharos-dashboard/notification/tasks.py b/tools/pharos-dashboard/notification/tasks.py new file mode 100644 index 00000000..61ab14af --- /dev/null +++ b/tools/pharos-dashboard/notification/tasks.py @@ -0,0 +1,33 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from celery import shared_task +from datetime import timedelta + +from django.conf import settings +from django.utils import timezone + +from notification.models import BookingNotification +from notification_framework.notification import Notification + + +@shared_task +def send_booking_notifications(): + messaging = Notification(dashboard_url=settings.RABBITMQ_URL) + + now = timezone.now() + notifications = BookingNotification.objects.filter(submitted=False, + submit_time__gt=now, + submit_time__lt=now + timedelta(minutes=5)) + for notification in notifications: + messaging.send(notification.type, notification.booking.resource.name, + notification.get_content()) + notification.submitted = True + notification.save() diff --git a/tools/pharos-dashboard/notification_framework/__init__.py b/tools/pharos-dashboard/notification_framework/__init__.py new file mode 100644 index 00000000..b5914ce7 --- /dev/null +++ b/tools/pharos-dashboard/notification_framework/__init__.py @@ -0,0 +1,10 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + diff --git a/tools/pharos-dashboard/notification_framework/notification.py b/tools/pharos-dashboard/notification_framework/notification.py new file mode 100644 index 00000000..84fbcffa --- /dev/null +++ b/tools/pharos-dashboard/notification_framework/notification.py @@ -0,0 +1,114 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +import json +import re + +import pika + + +class Notification(object): + """ + This class can be used by the dashboard and the labs to exchange notifications about booking + events and pod status. It utilizes rabbitmq to communicate. + + Notifications are associated to an event and to a topic. + Events are: + [ 'booking_start', 'booking_stop', 'pod_status' ] + The topic is usually a POD name, ie: + 'Intel POD 2' + """ + + def __init__(self, dashboard_url, verbose=False): + self.rabbitmq_broker = dashboard_url + self.verbose = verbose + self._registry = {} + + self.connection = pika.BlockingConnection(pika.ConnectionParameters( + host=self.rabbitmq_broker)) + self.channel = self.connection.channel() + + self.channel.exchange_declare(exchange='notifications', type='topic') + + self.result = self.channel.queue_declare(exclusive=True) + self.queue_name = self.result.method.queue + + def register(self, function, event, regex): + """ + Registers a function to be called for the specified event. + :param function: the function to register + :param event: the event type + :param regex: a regex to specify for wich topics the function will be called. Some + possible Expressions can be: + 'Intel POD 2' : Intel POD 2 + 'Intel POD .*' : All Intel Pods + '.*' : All Topics + """ + + if event not in self._registry: + self._registry[event] = [(function, regex)] + else: + self._registry[event].append((function, regex)) + + def receive(self): + """ + Start receiving notifications. This is a blocking operation, if a notification is received, + the registered functions will be called. + """ + if self.verbose: + print('Start receiving Notifications. Keys: ', self._registry.keys()) + self._receive_message(self._registry.keys()) + + def send(self, event, topic, content): + """ + Send an event notification. + :param event: the event type + :param topic: the pod name + :param content: a JSON-serializable dictionary + """ + message = { + 'event': event, + 'topic': topic, + 'content': content + } + self._send_message(message) + + def _send_message(self, event): + routing_key = event['type'] + message = json.dumps(event) + self.channel.basic_publish(exchange='notifications', + routing_key=routing_key, + body=message, + properties=pika.BasicProperties( + content_type='application/json' + )) + if self.verbose: + print(" [x] Sent %r:%r" % (routing_key, message)) + + def _receive_message(self, binding_keys): + for key in binding_keys: + self.channel.queue_bind(exchange='notifications', + queue=self.queue_name, + routing_key=key) + self.channel.basic_consume(self._message_callback, + queue=self.queue_name, + no_ack=True) + self.channel.start_consuming() + + def _message_callback(self, ch, method, properties, body): + if self.verbose: + print(" [x] Got %r:%r" % (method.routing_key, body)) + if method.routing_key not in self._registry: + return + for func, regex in self._registry[method.routing_key]: + message = json.loads(body.decode()) + match = re.match(regex, message['topic']) + if match: + func(body) diff --git a/tools/pharos-dashboard/pharos_dashboard/__init__.py b/tools/pharos-dashboard/pharos_dashboard/__init__.py index b6fc8176..f104c4db 100644 --- a/tools/pharos-dashboard/pharos_dashboard/__init__.py +++ b/tools/pharos-dashboard/pharos_dashboard/__init__.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + # This will make sure the app is always imported when # Django starts so that shared_task will use this app. from .celery import app as celery_app # noqa diff --git a/tools/pharos-dashboard/pharos_dashboard/celery.py b/tools/pharos-dashboard/pharos_dashboard/celery.py index 4cf6a7af..f60f2433 100644 --- a/tools/pharos-dashboard/pharos_dashboard/celery.py +++ b/tools/pharos-dashboard/pharos_dashboard/celery.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + import os from celery import Celery diff --git a/tools/pharos-dashboard/pharos_dashboard/urls.py b/tools/pharos-dashboard/pharos_dashboard/urls.py index d8bf5608..adcb5b8f 100644 --- a/tools/pharos-dashboard/pharos_dashboard/urls.py +++ b/tools/pharos-dashboard/pharos_dashboard/urls.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + """pharos_dashboard URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: @@ -18,12 +28,16 @@ from django.conf.urls import url, include from django.conf.urls.static import static from django.contrib import admin + urlpatterns = [ url(r'^', include('dashboard.urls', namespace='dashboard')), url(r'^booking/', include('booking.urls', namespace='booking')), url(r'^accounts/', include('account.urls', namespace='account')), url(r'^admin/', admin.site.urls), + url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), + + url(r'^api/', include('api.urls')) ] if settings.DEBUG is True: diff --git a/tools/pharos-dashboard/pharos_dashboard/wsgi.py b/tools/pharos-dashboard/pharos_dashboard/wsgi.py index b1277516..3d43361b 100644 --- a/tools/pharos-dashboard/pharos_dashboard/wsgi.py +++ b/tools/pharos-dashboard/pharos_dashboard/wsgi.py @@ -1,3 +1,13 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + """ WSGI config for pharos_dashboard project. diff --git a/tools/pharos-dashboard/static/js/booking-calendar.js b/tools/pharos-dashboard/static/js/booking-calendar.js index f8a9a0ff..9cb0f32f 100644 --- a/tools/pharos-dashboard/static/js/booking-calendar.js +++ b/tools/pharos-dashboard/static/js/booking-calendar.js @@ -1,3 +1,13 @@ +/***************************************************************************** +* Copyright (c) 2016 Max Breitenfeldt and others. +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Apache License, Version 2.0 +* which accompanies this distribution, and is available at +* http://www.apache.org/licenses/LICENSE-2.0 +*****************************************************************************/ + + function parseCalendarEvents(bookings) { var events = []; for (var i = 0; i < bookings.length; i++) { @@ -33,4 +43,4 @@ $(document).ready(function () { loadEvents(bookings_url); $('#starttimepicker').datetimepicker(timepickerOptions); $('#endtimepicker').datetimepicker(timepickerOptions); -});
\ No newline at end of file +}); diff --git a/tools/pharos-dashboard/static/js/dataTables-sort.js b/tools/pharos-dashboard/static/js/dataTables-sort.js index 7189ca15..3072d2f1 100644 --- a/tools/pharos-dashboard/static/js/dataTables-sort.js +++ b/tools/pharos-dashboard/static/js/dataTables-sort.js @@ -1,3 +1,13 @@ +/***************************************************************************** +* Copyright (c) 2016 Max Breitenfeldt and others. +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Apache License, Version 2.0 +* which accompanies this distribution, and is available at +* http://www.apache.org/licenses/LICENSE-2.0 +*****************************************************************************/ + + /** * This is a sort function for dataTables to sort tables by the status column. * The order should be: online < online/idle < offline diff --git a/tools/pharos-dashboard/static/js/datetimepicker-options.js b/tools/pharos-dashboard/static/js/datetimepicker-options.js index 2d19ddae..d43f5fb8 100644 --- a/tools/pharos-dashboard/static/js/datetimepicker-options.js +++ b/tools/pharos-dashboard/static/js/datetimepicker-options.js @@ -1,3 +1,13 @@ +/***************************************************************************** +* Copyright (c) 2016 Max Breitenfeldt and others. +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Apache License, Version 2.0 +* which accompanies this distribution, and is available at +* http://www.apache.org/licenses/LICENSE-2.0 +*****************************************************************************/ + + var timepickerOptions = { format: 'MM/DD/YYYY HH:00' };
\ No newline at end of file diff --git a/tools/pharos-dashboard/static/js/flot-pie-chart.js b/tools/pharos-dashboard/static/js/flot-pie-chart.js index 98d174e4..3b80b2a2 100644 --- a/tools/pharos-dashboard/static/js/flot-pie-chart.js +++ b/tools/pharos-dashboard/static/js/flot-pie-chart.js @@ -1,17 +1,25 @@ +/***************************************************************************** +* Copyright (c) 2016 Max Breitenfeldt and others. +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Apache License, Version 2.0 +* which accompanies this distribution, and is available at +* http://www.apache.org/licenses/LICENSE-2.0 +*****************************************************************************/ + + function loadChartData(chart_id, url) { $.ajax({ url: url, type: 'get', success: function (data) { var data = data['data']; - $(function () { - var plotObj = $.plot($("#" + chart_id), data, { - series: { - pie: { - show: true - } + var plotObj = $.plot($("#" + chart_id), data, { + series: { + pie: { + show: true } - }); + } }); }, failure: function (data) { diff --git a/tools/pharos-dashboard/static/js/fullcalendar-options.js b/tools/pharos-dashboard/static/js/fullcalendar-options.js index f4fa50b3..22a1b95e 100644 --- a/tools/pharos-dashboard/static/js/fullcalendar-options.js +++ b/tools/pharos-dashboard/static/js/fullcalendar-options.js @@ -1,3 +1,13 @@ +/***************************************************************************** +* Copyright (c) 2016 Max Breitenfeldt and others. +* +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Apache License, Version 2.0 +* which accompanies this distribution, and is available at +* http://www.apache.org/licenses/LICENSE-2.0 +*****************************************************************************/ + + var tmpevent; function sendEventToForm(event) { diff --git a/tools/pharos-dashboard/templates/account/user_list.html b/tools/pharos-dashboard/templates/account/user_list.html index 7618dc95..c2b81938 100644 --- a/tools/pharos-dashboard/templates/account/user_list.html +++ b/tools/pharos-dashboard/templates/account/user_list.html @@ -13,18 +13,22 @@ <tbody> {% for user in users %} <tr> - <th> + <td> {{ user.username }} - </th> - <th> + </td> + <td> {{ user.userprofile.company }} - </th> - <th> - <a href={{ user.userprofile.ssh_public_key.url }}>Download</a> - </th> - <th> - <a href={{ user.userprofile.pgp_public_key.url }}>Download</a> - </th> + </td> + <td> + {% if user.userprofile.ssh_public_key %} + <a href={{ user.userprofile.ssh_public_key.url }}>SSH</a> + {% endif %} + </td> + <td> + {% if user.userprofile.pgp_public_key %} + <a href={{ user.userprofile.pgp_public_key.url }}>GPG</a> + {% endif %} + </td> </tr> {% endfor %} </tbody> @@ -39,4 +43,4 @@ }); }); </script> -{% endblock tablejs %}
\ No newline at end of file +{% endblock tablejs %} diff --git a/tools/pharos-dashboard/templates/base.html b/tools/pharos-dashboard/templates/base.html index 42156e3b..c5da483d 100644 --- a/tools/pharos-dashboard/templates/base.html +++ b/tools/pharos-dashboard/templates/base.html @@ -76,6 +76,11 @@ class="fa fa-fw"></i>Users </a> </li> + <li> + <a href="{% url 'api-root' %}"><i + class="fa fa-fw"></i>API + </a> + </li> </ul> </div> <!-- /.sidebar-collapse --> diff --git a/tools/pharos-dashboard/templates/booking/booking_table.html b/tools/pharos-dashboard/templates/booking/booking_table.html index 3d0b7575..216eaf57 100644 --- a/tools/pharos-dashboard/templates/booking/booking_table.html +++ b/tools/pharos-dashboard/templates/booking/booking_table.html @@ -13,21 +13,21 @@ <tbody> {% for booking in bookings %} <tr> - <th> + <td> {{ booking.user.username }} - </th> - <th> + </td> + <td> {{ booking.purpose }} - </th> - <th> + </td> + <td> {{ booking.start }} - </th> - <th> + </td> + <td> {{ booking.end }} - </th> - <th><a target='_blank' + </td> + <td><a target='_blank' href={{ booking.get_jira_issue | jira_issue_url }}>{{ booking.get_jira_issue }}</a> - </th> + </td> </tr> {% endfor %} </tbody>
\ No newline at end of file diff --git a/tools/pharos-dashboard/templates/dashboard/ci_pods.html b/tools/pharos-dashboard/templates/dashboard/ci_pods.html index a754252c..7ef62a43 100644 --- a/tools/pharos-dashboard/templates/dashboard/ci_pods.html +++ b/tools/pharos-dashboard/templates/dashboard/ci_pods.html @@ -17,29 +17,29 @@ <tbody> {% for pod in ci_pods %} <tr> - <th> + <td> <a target='_blank' href={{ pod.url }}>{{ pod.name }}</a> - </th> - <th> + </td> + <td> <a target='_blank' href={{ pod.slave.url }}>{{ pod.slave.name }}</a> - </th> - <th style="background-color:{{ pod.slave.status | jenkins_status_color }}"> + </td> + <td style="background-color:{{ pod.slave.status | jenkins_status_color }}"> {{ pod.slave.status }} - </th> - <th {{ pod.slave.last_job_result | jenkins_job_blink }}> + </td> + <td {{ pod.slave.last_job_result | jenkins_job_blink }}> {{ pod.slave.last_job_installer }} - </th> - <th {{ pod.slave.last_job_result | jenkins_job_blink }}> + </td> + <td {{ pod.slave.last_job_result | jenkins_job_blink }}> {{ pod.slave.last_job_scenario }} - </th> - <th {{ pod.slave.last_job_result | jenkins_job_blink }}> + </td> + <td {{ pod.slave.last_job_result | jenkins_job_blink }}> {{ pod.slave.last_job_branch }} - </th> - <th><a {{ pod.slave.last_job_result | jenkins_job_blink }} + </td> + <td><a {{ pod.slave.last_job_result | jenkins_job_blink }} style="color:{{ pod.slave.last_job_result | jenkins_job_color }}" target='_blank' href={{ pod.slave.last_job_url }}>{{ pod.slave.last_job_name }}</a> - </th> + </td> </tr> {% endfor %} </tbody> diff --git a/tools/pharos-dashboard/templates/dashboard/dev_pods.html b/tools/pharos-dashboard/templates/dashboard/dev_pods.html index c4cb1ba7..2b4b0177 100644 --- a/tools/pharos-dashboard/templates/dashboard/dev_pods.html +++ b/tools/pharos-dashboard/templates/dashboard/dev_pods.html @@ -19,37 +19,37 @@ <tbody> {% for pod, booking, utilization in dev_pods %} <tr> - <th> + <td> <a href={% url 'dashboard:resource' resource_id=pod.id %}>{{ pod.name }}</a> - </th> - <th> + </td> + <td> <a target='_blank' href={{ pod.slave.url }}>{{ pod.slave.name }}</a> - </th> - <th> + </td> + <td> {{ booking.user.username }} - </th> - <th> + </td> + <td> {{ booking.end }} - </th> - <th> + </td> + <td> {{ booking.purpose }} - </th> - <th> + </td> + <td> {{ utilization }} - </th> - <th style="background-color:{{ pod.slave.status | jenkins_status_color }}"> + </td> + <td style="background-color:{{ pod.slave.status | jenkins_status_color }}"> {{ pod.slave.status }} - </th> - <th> + </td> + <td> <a href="{% url 'booking:create' resource_id=pod.id %}" class="btn btn-primary"> Book </a> - </th> - <th> + </td> + <td> <a href="{% url 'dashboard:resource' resource_id=pod.id %}" class="btn btn-primary"> Info </a> - </th> + </td> </tr> {% endfor %} </tbody> diff --git a/tools/pharos-dashboard/templates/dashboard/jenkins_slaves.html b/tools/pharos-dashboard/templates/dashboard/jenkins_slaves.html index 830ed198..aa74507c 100644 --- a/tools/pharos-dashboard/templates/dashboard/jenkins_slaves.html +++ b/tools/pharos-dashboard/templates/dashboard/jenkins_slaves.html @@ -14,17 +14,17 @@ <tbody> {% for slave in slaves %} <tr> - <th><a target='_blank' + <td><a target='_blank' href={{ slave.url }}>{{ slave.name }}</a> - </th> - <th style="background-color:{{ slave.status | jenkins_status_color }}"> + </td> + <td style="background-color:{{ slave.status | jenkins_status_color }}"> {{ slave.status }} - </th> - <th><a {{ slave.last_job_result | jenkins_job_blink }} + </td> + <td><a {{ slave.last_job_result | jenkins_job_blink }} style="color:{{ slave.last_job_result | jenkins_job_color }}" target="_blank" href={{ slave.last_job_url }}> {{ slave.last_job_name }}</a> - </th> + </td> </tr> {% endfor %} </tbody> diff --git a/tools/pharos-dashboard/templates/dashboard/resource_detail.html b/tools/pharos-dashboard/templates/dashboard/resource_detail.html index 6067e1ea..657d5656 100644 --- a/tools/pharos-dashboard/templates/dashboard/resource_detail.html +++ b/tools/pharos-dashboard/templates/dashboard/resource_detail.html @@ -164,15 +164,15 @@ <tbody> {% for user in resource.vpn_users.all %} <tr> - <th> + <td> {{ user.username }} - </th> - <th> + </td> + <td> {{ user.email }} - </th> - <th> + </td> + <td> {{ user.userprofile.company }} - </th> + </td> </tr> {% endfor %} </table> diff --git a/tools/pharos-dashboard/templates/dashboard/server_table.html b/tools/pharos-dashboard/templates/dashboard/server_table.html index fee7e8b1..f01bd603 100644 --- a/tools/pharos-dashboard/templates/dashboard/server_table.html +++ b/tools/pharos-dashboard/templates/dashboard/server_table.html @@ -10,21 +10,21 @@ <tbody> {% for server in resource.server_set.all %} <tr> - <th> + <td> {{ server.name }} - </th> - <th> + </td> + <td> {{ server.model }} - </th> - <th> + </td> + <td> {{ server.cpu }} - </th> - <th> + </td> + <td> {{ server.ram }} - </th> - <th> + </td> + <td> {{ server.storage }} - </th> + </td> </tr> {% endfor %} </tbody>
\ No newline at end of file diff --git a/tools/pharos-dashboard/templates/rest_framework/api.html b/tools/pharos-dashboard/templates/rest_framework/api.html new file mode 100644 index 00000000..9c6c4f7d --- /dev/null +++ b/tools/pharos-dashboard/templates/rest_framework/api.html @@ -0,0 +1,9 @@ +{% extends "rest_framework/base.html" %} + +{% block title %}Pharos Dashboard API{% endblock %} + +{% block branding %} + <a class='navbar-brand' rel="nofollow" href=#> + Pharos Dashboard API + </a> +{% endblock %}
\ No newline at end of file |