diff --git a/.gitattributes b/.gitattributes index c52c9740d7b9138990fb72f95bdc6c7cf4df437e..dea7eb753ef494c745ef9b3a35c6e747ff42da03 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4748,6 +4748,7 @@ SAS/ResourceAssignment/ResourceAssignmentEditor/config/__init__.py -text SAS/ResourceAssignment/ResourceAssignmentEditor/config/default.py -text SAS/ResourceAssignment/ResourceAssignmentEditor/lib/CMakeLists.txt -text SAS/ResourceAssignment/ResourceAssignmentEditor/lib/__init__.py -text +SAS/ResourceAssignment/ResourceAssignmentEditor/lib/fakedata.py -text SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/app.js -text SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/controller.js -text SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/css/bootstrap.min.css -text diff --git a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/CMakeLists.txt b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/CMakeLists.txt index e3243bcc282617bbe7e55c5a875b9dd3683668df..d9733020e796dbdef77be2dff2adc50e4faf85e5 100644 --- a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/CMakeLists.txt +++ b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/CMakeLists.txt @@ -4,6 +4,7 @@ python_install( __init__.py webservice.py utils.py + fakedata.py DESTINATION resourceassignementeditor) file(GLOB_RECURSE jquery_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} static/js/jquery/*) diff --git a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/fakedata.py b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/fakedata.py new file mode 100644 index 0000000000000000000000000000000000000000..20b7749428a1a60437870f156e1c60e213c2661d --- /dev/null +++ b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/fakedata.py @@ -0,0 +1,40 @@ +#!/usr/bin/python + +# Copyright (C) 2012-2015 ASTRON (Netherlands Institute for Radio Astronomy) +# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This file is part of the LOFAR software suite. +# The LOFAR software suite is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# The LOFAR software suite is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. + +# $Id: webservice.py 32739 2015-10-30 15:21:48Z schaap $ + +from datetime import datetime +from datetime import timedelta + +observartionTasks = [{'id': 0, 'momId': 123, 'obsId': 876, 'status': 'scheduled', 'name': 'Lobos Obs 2a', 'from': datetime.utcnow() - timedelta(hours=1), 'to': datetime.utcnow() + timedelta(hours=5)}, + {'id': 1, 'momId': 345, 'obsId': 654, 'status': 'approved', 'name': 'LOTAAS Obs 32q', 'from': datetime.utcnow() + timedelta(hours=6), 'to': datetime.utcnow() + timedelta(hours=12)}, + {'id': 2, 'momId': 567, 'obsId': 432, 'status': 'approved', 'name': 'Pulsar Obs 3', 'from': datetime.utcnow() + timedelta(hours=13), 'to': datetime.utcnow() + timedelta(hours=32)} + ] + +pipelineTasks = [{'id': 100, 'momId': 100123, 'obsId': 100876, 'status': 'scheduled', 'name': 'Averaging', 'from': datetime.utcnow() - timedelta(hours=1), 'to': datetime.utcnow() + timedelta(hours=1)}, + {'id': 101, 'momId': 100124, 'obsId': 100875, 'status': 'scheduled', 'name': 'Averaging', 'from': datetime.utcnow() + timedelta(hours=1), 'to': datetime.utcnow() + timedelta(hours=2)} + ] + +maintenanceTasks = [{'id': 200, 'momId': 200124, 'obsId': 200875, 'status': 'scheduled', 'name': 'Mowing', 'from': datetime.utcnow() + timedelta(days=1), 'to': datetime.utcnow() + timedelta(days=2)} + ] + +reservationTasks = [{'id': 300, 'momId': 300124, 'obsId': 300875, 'status': 'scheduled', 'name': 'Glow', 'from': datetime.utcnow() + timedelta(days=1), 'to': datetime.utcnow() + timedelta(days=3)} + ] +ingestTasks = [{'id': 400, 'momId': 400124, 'obsId': 400875, 'status': 'scheduled', 'name': 'Ingest', 'from': datetime.utcnow() - timedelta(hours=1), 'to': datetime.utcnow() + timedelta(hours=10)} + ] diff --git a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/controller.js b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/controller.js index 3c9814f9dc574f5eeb9e602478deb7b6a0fb9c6a..466676343959f4138ff2660148876de0076459e5 100644 --- a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/controller.js +++ b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/controller.js @@ -6,14 +6,14 @@ angular.module('raeApp').controller('DataController', ['$http', '$scope', functi function getTasks() { $http.get('/rest/tasks').success(function(result) { - for(var key in result.tasks) { - var elem = result.tasks[key]; - elem.from = new Date(elem.from); - elem.to = new Date(elem.to); - } +// for(var key in result.data) { +// var elem = result.tasks[key]; +// elem.from = new Date(elem.from); +// elem.to = new Date(elem.to); +// } store.tasks = result.tasks; - store.gtasks = [result]; + store.gtasks = result.tasks; }); }; diff --git a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/webservice.py b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/webservice.py index 53e55ea648c3b63517de07766907f500b20a1be6..5102847ae16086312b0eb6248aa0d7cade627223 100755 --- a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/webservice.py +++ b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/webservice.py @@ -32,6 +32,7 @@ from flask import render_template from flask import url_for from flask.json import jsonify from resourceassignementeditor.utils import gzipped +from resourceassignementeditor.fakedata import * __root_path = os.path.dirname(os.path.abspath(__file__)) print '__root_path=%s' % __root_path @@ -91,10 +92,14 @@ def resourceclaims(): @app.route('/rest/tasks') @gzipped def tasks(): - data = {'name': 'Observations', 'tasks': [{'id': 0, 'momId': 123, 'obsId': 876, 'status': 'scheduled', 'name': 'Lobos Obs 2a', 'from': datetime.utcnow() - timedelta(hours=1), 'to': datetime.utcnow() + timedelta(hours=1)}, - {'id': 1, 'momId': 345, 'obsId': 654, 'status': 'approved', 'name': 'LOTAAS Obs 32q', 'from': datetime.utcnow() + timedelta(hours=5), 'to': datetime.utcnow() + timedelta(hours=6)}, - {'id': 2, 'momId': 567, 'obsId': 432, 'status': 'approved', 'name': 'Pulsar Obs 3', 'from': datetime.utcnow() + timedelta(hours=10), 'to': datetime.utcnow() + timedelta(hours=32)} - ] } + data = {'tasks': [ + {'name': 'Observations', 'tasks': observartionTasks}, + {'name': 'Pipelines', 'tasks': pipelineTasks}, + {'name': 'Maintenance', 'tasks': maintenanceTasks}, + {'name': 'Reservations', 'tasks': reservationTasks}, + {'name': 'Ingest', 'tasks': ingestTasks} + ]} + return jsonify(data) def main(argv=None, debug=False):