Commit af309300 authored by Daniele Venzano's avatar Daniele Venzano

Fix templates

parent 8340ec27
......@@ -67,7 +67,7 @@ class ExecutionListWeb(ZoeWebRequestHandler):
'max_page': math.ceil(executions_count / self.PAGINATION_ITEM_COUNT),
'last_page': len(executions) < self.PAGINATION_ITEM_COUNT
}
self.render('execution_list.html', **template_vars)
self.render('execution_list.jinja2', **template_vars)
class ExecutionRestartWeb(ZoeWebRequestHandler):
......@@ -117,7 +117,6 @@ class ExecutionInspectWeb(ZoeWebRequestHandler):
services_info, endpoints = self.api_endpoint.execution_endpoints(self.current_user, e)
template_vars = {
"user": self.current_user,
"e": e,
"services_info": services_info,
"endpoints": endpoints,
......@@ -132,7 +131,7 @@ class ExecutionInspectWeb(ZoeWebRequestHandler):
e_time_start = int((e.time_start - datetime.datetime(1970, 1, 1)) / datetime.timedelta(seconds=1) * 1000)
template_vars['grafana_url'] = grafana_url_template.format(e_time_start, e_time_end, execution_id)
self.render('execution_inspect.html', **template_vars)
self.render('execution_inspect.jinja2', **template_vars)
class ServiceLogsWeb(ZoeWebRequestHandler):
......@@ -146,7 +145,6 @@ class ServiceLogsWeb(ZoeWebRequestHandler):
service = self.api_endpoint.service_by_id(self.current_user, service_id)
template_vars = {
"user": self.current_user,
"service": service,
}
self.render('service_logs.html', **template_vars)
self.render('service_logs.jinja2', **template_vars)
......@@ -110,7 +110,8 @@ class ZoeWebRequestHandler(ZoeRequestHandler):
'locale': self.locale,
'handler': self,
'zoe_version': zoe_lib.version.ZOE_VERSION,
'server_address': self.request.host
'server_address': self.request.host,
'user': self.current_user
}
ctx.update(kwargs)
......@@ -140,11 +141,11 @@ class ZoeWebRequestHandler(ZoeRequestHandler):
try:
user = super().get_current_user()
except ZoeAuthException as e:
self.render('login.html', error=e.message)
self.render('login.jinja2', error=e.message)
return None
return user
def error_page(self, error_message: str, status: int=400):
"""Generate an error page."""
self.set_status(status)
self.render('error.html', error=error_message)
self.render('error.jinja2', error=error_message)
......@@ -32,7 +32,7 @@ class LoginWeb(ZoeWebRequestHandler):
def get(self):
"""Login page."""
self.render('login.html')
self.render('login.jinja2')
def post(self):
"""Try to authenticate."""
......@@ -98,10 +98,9 @@ class HomeWeb(ZoeWebRequestHandler):
total_cores = sum([r.cores.max for r in running_reservations])
template_vars = {
"user": self.current_user,
"total_memory": total_memory,
"total_cores": total_cores,
'last_executions': sorted(last_executions, key=lambda e: e.id),
'running_executions': sorted(last_running_executions, key=lambda e: e.id)
}
self.render('home_user.html', **template_vars)
self.render('home_user.jinja2', **template_vars)
......@@ -50,11 +50,10 @@ class StatusEndpointWeb(ZoeWebRequestHandler):
max_service_count = max([len(services_per_node[name]) for name in services_per_node])
template_vars = {
"user": self.current_user,
"stats": stats,
"executions_in_queue": executions_in_queue,
"services_per_node": services_per_node,
"max_service_count": max_service_count
}
self.render('status.html', **template_vars)
self.render('status.jinja2', **template_vars)
{% extends "base.html" %}
{% extends "base.jinja2" %}
{% block content_header %}
<div class="header">
......@@ -15,14 +15,14 @@
<div class="nav-item">
<a href="{{ reverse_url("execution_list") }}">Executions</a>
</div>
{% if role == "admin" %}
{% if user.role.can_see_status %}
<div class="nav-item">
<a href="{{ reverse_url("status") }}">Status</a>
</div>
{% endif %}
</div>
<div id="user_info">
{{ uid }} ({{ role }}) <a href="{{ reverse_url("logout") }}">logout</a>
{{ user.username }} ({{ user.role.name }}) <a href="{{ reverse_url("logout") }}">logout</a>
</div>
</div>
{% endblock %}
......
{% extends "base_user.html" %}
{% extends "base_user.jinja2" %}
{% block title %}Error{% endblock %}
{% block content %}
......
{% extends "base_user.html" %}
{% extends "base_user.jinja2" %}
{% block title %}Inspect execution {{ e.name }}{% endblock %}
{% block custom_head %}
<script src="/static/moment.min.js" type="application/javascript"></script>
<script src="/static/moment-timezone.min.js" type="application/javascript"></script>
<script>
var locale = window.navigator.userLanguage || window.navigator.language;
let locale = window.navigator.userLanguage || window.navigator.language;
moment.locale(locale);
function format_timestamp(ts) {
......@@ -21,7 +21,7 @@
<div id="contents">
<ul>
<li>Application name: {{ e.description['name'] }}</li>
{% if role == "admin" %}
{% if user.role.can_operate_others %}
<li>Owner: {{ e.user_id }}</li>
{% endif %}
<li>Time submitted: <script>format_timestamp("{{ e.time_submit }}")</script></li>
......
{% extends "base_user.html" %}
{% extends "base_user.jinja2" %}
{% block title %}Home{% endblock %}
{% block custom_head %}
......@@ -33,7 +33,7 @@
<tr>
<th>ID</th>
<th>Execution name</th>
{% if role == "admin" %}
{% if user.role.can_operate_others %}
<th>User</th>
{% endif %}
<th>Status</th>
......@@ -48,8 +48,8 @@
<tr>
<td>{{ e.id }}</td>
<td class="exec-name"><a href="/executions/inspect/{{ e.id }}">{{ e.name }}</a></td>
{% if role == "admin" %}
<td>{{ e.user_id }}</td>
{% if user.role.can_operate_others %}
<td>{{ e.owner.username }}</td>
{% endif %}
<td>{{ e.status }}</td>
<td sorttable_customkey="{{ e.time_submit }}"><script>format_timestamp("{{ e.time_submit }}")</script></td>
......
{% extends "base_user.html" %}
{% extends "base_user.jinja2" %}
{% block title %}Home{% endblock %}
{% block custom_head %}
......
{% extends "base.html" %}
{% extends "base.jinja2" %}
{% block title %}Login{% endblock %}
{% block custom_head %}
......
{% extends "base_user.html" %}
{% extends "base_user.jinja2" %}
{% block title %}Service {{ service.name }} logs{% endblock %}
{% block content %}
<h1>Zoe - Analytics on demand</h1>
......
{% extends "base_user.html" %}
{% extends "base_user.jinja2" %}
{% block title %}Zoe system status{% endblock %}
{% block custom_head %}
......
{% extends "base_user.html" %}
{% extends "base_user.jinja2" %}
{% block title %}ZApp Shop{% endblock %}
......@@ -27,7 +27,7 @@
});
</script>
{% if role != "guest" %}
{% if user.role.can_access_api %}
<div class="zapp-category">
<h3>Custom JSON upload</h3>
<form method="post" action="{{ reverse_url('execution_start') }}" enctype="multipart/form-data">
......
{% extends "base_user.html" %}
{% extends "base_user.jinja2" %}
{% block title %}ZApp Shop{% endblock %}
......@@ -64,7 +64,7 @@
{% endfor %}
{% endif %}
<hr>
{% if role != "guest" %}
{% if can_access_api %}
<label class="label-inline"><input type="checkbox" onchange="set_submit_text(this)" name="download_json"> Download JSON with these parameters for command-line execution</label>
<br><br>
{% endif %}
......
......@@ -21,6 +21,7 @@ from tornado.web import MissingArgumentError
from zoe_api import zapp_shop
from zoe_api.web.request_handler import ZoeWebRequestHandler
from zoe_api.exceptions import ZoeException
from zoe_lib.config import get_conf
log = logging.getLogger(__name__)
......@@ -37,10 +38,9 @@ class ZAppShopHomeWeb(ZoeWebRequestHandler):
zapps = zapp_shop.zshop_list_apps(self.current_user.role)
template_vars = {
"user": self.current_user,
'zapps': zapps,
}
self.render('zapp_shop.html', **template_vars)
self.render('zapp_shop.jinja2', **template_vars)
class ZAppLogoWeb(ZoeWebRequestHandler):
......@@ -52,6 +52,7 @@ class ZAppLogoWeb(ZoeWebRequestHandler):
return
self.set_header("Content-type", "image/png")
self.set_header("Cache-Control", "public,max-age=1209600")
manifest_index = int(zapp_id.split('-')[-1])
zapp_id = "-".join(zapp_id.split('-')[:-1])
......@@ -74,14 +75,13 @@ class ZAppStartWeb(ZoeWebRequestHandler):
zapp = zapps[manifest_index]
template_vars = {
"user": self.current_user,
'zapp': zapp,
'max_core_limit': get_conf().max_core_limit,
'max_memory_limit': get_conf().max_memory_limit,
'resources_are_customizable': self.current_user.role.can_customize_resources,
'additional_volumes': get_conf().additional_volumes
}
self.render('zapp_start.html', **template_vars)
self.render('zapp_start.jinja2', **template_vars)
def post(self, zapp_id):
"""Write the parameters in the description and start the ZApp."""
......@@ -105,7 +105,11 @@ class ZAppStartWeb(ZoeWebRequestHandler):
self.finish()
return
except MissingArgumentError:
new_id = self.api_endpoint.execution_start(self.current_user, exec_name, app_descr)
try:
new_id = self.api_endpoint.execution_start(self.current_user, exec_name, app_descr)
except ZoeException as e:
self.error_page(e.message, 500)
return
self.redirect(self.reverse_url('execution_inspect', new_id))
......@@ -125,7 +129,7 @@ class ZAppStartWeb(ZoeWebRequestHandler):
else:
log.warning('Unknown parameter kind: {}, ignoring...'.format(param.kind))
if role == "admin" or (role != "guest" and (role == "user" and not get_conf().no_user_edit_limits_web)):
if role.can_customize_resources:
for service in app_descr['services']:
argument_name = service['name'] + '-resource_memory_min'
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment