Skip to content
Snippets Groups Projects
Commit f3b1e4bd authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #8574: moved fake data into module fakedata.py. Added more tasks.

parent f5bfb6cf
Branches
Tags
No related merge requests found
......@@ -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
......
......@@ -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/*)
......
#!/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)}
]
......@@ -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;
});
};
......
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment