Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
54f54982
Commit
54f54982
authored
8 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
Task #8887: added two methods to browse the tasks/claims in html tables.
parent
4079bf9b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/ResourceAssignment/ResourceAssignmentEditor/lib/webservice.py
+131
-0
131 additions, 0 deletions
...urceAssignment/ResourceAssignmentEditor/lib/webservice.py
with
131 additions
and
0 deletions
SAS/ResourceAssignment/ResourceAssignmentEditor/lib/webservice.py
+
131
−
0
View file @
54f54982
...
@@ -313,6 +313,137 @@ def getUpdateEvents():
...
@@ -313,6 +313,137 @@ def getUpdateEvents():
def
getLofarTime
():
def
getLofarTime
():
return
jsonify
({
'
lofarTime
'
:
asIsoFormat
(
datetime
.
utcnow
())})
return
jsonify
({
'
lofarTime
'
:
asIsoFormat
(
datetime
.
utcnow
())})
#ugly method to generate html tables for all tasks
@app.route
(
'
/tasks.html
'
)
def
getTasksHtml
():
tasks
=
rarpc
.
getTasks
()
if
not
tasks
:
abort
(
404
)
updateTaskMomDetails
(
tasks
,
momrpc
)
html
=
'
<!DOCTYPE html><html><head><title>Tasks</title><style>table, th, td {border: 1px solid black; border-collapse: collapse; padding: 4px;}</style></head><body><table style=
"
width:100%
"
>
\n
'
props
=
sorted
(
tasks
[
0
].
keys
())
html
+=
'
<tr>%s</tr>
\n
'
%
''
.
join
(
'
<th>%s</th>
'
%
prop
for
prop
in
props
)
for
task
in
tasks
:
html
+=
'
<tr>
'
for
prop
in
props
:
if
prop
in
task
:
if
prop
==
'
id
'
:
html
+=
'
<td><a href=
"
/rest/tasks/%s.html
"
>%s</a></td>
'
%
(
task
[
prop
],
task
[
prop
])
else
:
html
+=
'
<td>%s</td>
'
%
task
[
prop
]
html
+=
'
</tr>
\n
'
html
+=
'
</table></body></html>
\n
'
return
html
#ugly method to generate html tables for the task and it's claims
@app.route
(
'
/tasks/<int:task_id>.html
'
,
methods
=
[
'
GET
'
])
def
getTaskHtml
(
task_id
):
task
=
rarpc
.
getTask
(
task_id
)
if
not
task
:
abort
(
404
,
'
No such task %s
'
%
task_id
)
task
[
'
name
'
]
=
'
Task %d
'
%
task
[
'
id
'
]
updateTaskMomDetails
(
task
,
momrpc
)
html
=
'
<!DOCTYPE html><html><head><title>Tasks</title><style>table, th, td {border: 1px solid black; border-collapse: collapse; padding: 4px;}</style></head><body><table style=
""
>
\n
'
html
+=
'
<h1>Task %s</h1>
'
%
task_id
props
=
sorted
(
task
.
keys
())
html
+=
'
<tr><th>key</th><th>value</th></tr>
\n
'
for
prop
in
props
:
html
+=
'
<tr><td>%s</td>
'
%
prop
if
prop
==
'
id
'
:
html
+=
'
<td><a href=
"
/rest/tasks/%s.html
"
>%s</a></td>
'
%
(
task
[
prop
],
task
[
prop
])
elif
prop
==
'
predecessor_ids
'
or
prop
==
'
successor_ids
'
:
ids
=
task
[
prop
]
if
ids
:
html
+=
'
<td>%s</td>
'
%
'
,
'
.
join
(
'
<a href=
"
/rest/tasks/%s.html
"
>%s</a>
'
%
(
id
,
id
)
for
id
in
ids
)
else
:
html
+=
'
<td></td>
'
else
:
html
+=
'
<td>%s</td>
'
%
task
[
prop
]
html
+=
'
</tr>
'
html
+=
'
</table>
\n
<br>
'
claims
=
rarpc
.
getResourceClaims
(
task_ids
=
[
task_id
],
extended
=
True
,
include_properties
=
True
)
if
claims
:
html
+=
'
<h1>Claims</h1>
'
for
claim
in
claims
:
html
+=
'
<table>
'
for
claim_key
,
claim_value
in
claim
.
items
():
if
claim_key
==
'
properties
'
:
html
+=
'
<tr><td>properties</td><td><table>
'
if
claim_value
:
propnames
=
sorted
(
claim_value
[
0
].
keys
())
html
+=
'
<tr>%s</tr>
\n
'
%
''
.
join
(
'
<th>%s</th>
'
%
propname
for
propname
in
propnames
)
for
prop
in
claim_value
:
html
+=
'
<tr>%s</tr>
\n
'
%
''
.
join
(
'
<td>%s</td>
'
%
prop
[
propname
]
for
propname
in
propnames
)
html
+=
'
</table></td></tr>
'
elif
claim_key
==
'
saps
'
:
html
+=
'
<tr><td>saps</td><td><table>
'
saps
=
claim_value
if
saps
:
sap_keys
=
[
'
sap_nr
'
,
'
properties
'
]
html
+=
'
<tr>%s</tr>
\n
'
%
''
.
join
(
'
<th>%s</th>
'
%
sap_key
for
sap_key
in
sap_keys
)
for
sap
in
saps
:
html
+=
'
<tr>
'
for
sap_key
in
sap_keys
:
if
sap_key
==
'
properties
'
:
html
+=
'
<td><table>
'
sap_props
=
sap
[
sap_key
]
if
sap_props
:
propnames
=
sorted
(
sap_props
[
0
].
keys
())
html
+=
'
<tr>%s</tr>
\n
'
%
''
.
join
(
'
<th>%s</th>
'
%
propname
for
propname
in
propnames
)
for
prop
in
sap_props
:
html
+=
'
<tr>%s</tr>
\n
'
%
''
.
join
(
'
<td>%s</td>
'
%
prop
[
propname
]
for
propname
in
propnames
)
html
+=
'
</table></td>
'
else
:
html
+=
'
<td>%s</td>
'
%
(
sap
[
sap_key
])
html
+=
'
</tr>
'
html
+=
'
</table></td></tr>
'
else
:
html
+=
'
<tr><td>%s</td><td>%s</td></tr>
'
%
(
claim_key
,
claim_value
)
html
+=
'
</table>
'
html
+=
'
<br>
'
html
+=
'
</body></html>
\n
'
return
html
@app.route
(
'
/rest/tasks/<int:task_id>/resourceclaims.html
'
,
methods
=
[
'
GET
'
])
@gzipped
def
resourceClaimsForTaskHtml
(
task_id
):
claims
=
rarpc
.
getResourceClaims
(
task_ids
=
[
task_id
],
extended
=
True
,
include_properties
=
True
)
if
not
claims
:
abort
(
404
,
'
No resource claims for task %s
'
%
task_id
)
html
=
'
<!DOCTYPE html><html><head><title>Tasks</title><style>table, th, td {border: 1px solid black; border-collapse: collapse; padding: 4px;}</style></head><body><table style=
""
>
\n
'
for
claim
in
claims
:
html
+=
'
<tr><td>%s</td>
'
%
claim
html
+=
'
</table></body></html>
\n
'
return
html
def
main
():
def
main
():
# make sure we run in UTC timezone
# make sure we run in UTC timezone
import
os
import
os
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment