Commit d256451f authored by Daniele Venzano's avatar Daniele Venzano

Update web interface to reflect internal changes made in the last release

parent df44a8ff
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
import json import json
import datetime import datetime
from jinja2 import Environment, FileSystemLoader, Markup from jinja2 import Environment, FileSystemLoader, Markup, TemplateSyntaxError
from tornado.escape import squeeze, linkify, url_escape, xhtml_escape from tornado.escape import squeeze, linkify, url_escape, xhtml_escape
import tornado.web import tornado.web
...@@ -121,8 +121,11 @@ class ZoeRequestHandler(tornado.web.RequestHandler): ...@@ -121,8 +121,11 @@ class ZoeRequestHandler(tornado.web.RequestHandler):
template = self._jinja_env.get_template(template_name) template = self._jinja_env.get_template(template_name)
try: try:
html = self._render(template, **kwargs) html = self._render(template, **kwargs)
except Exception: except TemplateSyntaxError as e:
zoe_api.web.utils.error_page(self, 'Jinja2 template exception', 500) zoe_api.web.utils.error_page(self, 'Template syntax error at {}:{}:<br> {}'.format(e.name, e.lineno, e.message), 500)
return
except Exception as e:
zoe_api.web.utils.error_page(self, 'Jinja2 template exception: {}'.format(e), 500)
return return
self.finish(html) self.finish(html)
......
...@@ -33,7 +33,9 @@ class ExecutionDefineWeb(ZoeRequestHandler): ...@@ -33,7 +33,9 @@ class ExecutionDefineWeb(ZoeRequestHandler):
@catch_exceptions @catch_exceptions
def get(self): def get(self):
"""Define a new execution.""" """Define a new execution."""
get_auth(self) uid, role_ = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
self.render('execution_new.html') self.render('execution_new.html')
...@@ -49,6 +51,8 @@ class ExecutionStartWeb(ZoeRequestHandler): ...@@ -49,6 +51,8 @@ class ExecutionStartWeb(ZoeRequestHandler):
def post(self): def post(self):
"""Start an execution.""" """Start an execution."""
uid, role = get_auth(self) uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
app_descr_json = self.request.files['file'][0]['body'].decode('utf-8') app_descr_json = self.request.files['file'][0]['body'].decode('utf-8')
app_descr = json.loads(app_descr_json) app_descr = json.loads(app_descr_json)
...@@ -70,6 +74,8 @@ class ExecutionRestartWeb(ZoeRequestHandler): ...@@ -70,6 +74,8 @@ class ExecutionRestartWeb(ZoeRequestHandler):
def get(self, execution_id: int): def get(self, execution_id: int):
"""Restart an already defined (and not running) execution.""" """Restart an already defined (and not running) execution."""
uid, role = get_auth(self) uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
e = self.api_endpoint.execution_by_id(uid, role, execution_id) e = self.api_endpoint.execution_by_id(uid, role, execution_id)
new_id = self.api_endpoint.execution_start(uid, role, e.name, e.description) new_id = self.api_endpoint.execution_start(uid, role, e.name, e.description)
...@@ -88,6 +94,8 @@ class ExecutionTerminateWeb(ZoeRequestHandler): ...@@ -88,6 +94,8 @@ class ExecutionTerminateWeb(ZoeRequestHandler):
def get(self, execution_id: int): def get(self, execution_id: int):
"""Terminate an execution.""" """Terminate an execution."""
uid, role = get_auth(self) uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
success, message = self.api_endpoint.execution_terminate(uid, role, execution_id) success, message = self.api_endpoint.execution_terminate(uid, role, execution_id)
if not success: if not success:
...@@ -107,6 +115,8 @@ class ExecutionDeleteWeb(ZoeRequestHandler): ...@@ -107,6 +115,8 @@ class ExecutionDeleteWeb(ZoeRequestHandler):
def get(self, execution_id: int): def get(self, execution_id: int):
"""Delete an execution.""" """Delete an execution."""
uid, role = get_auth(self) uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
success, message = self.api_endpoint.execution_delete(uid, role, execution_id) success, message = self.api_endpoint.execution_delete(uid, role, execution_id)
if not success: if not success:
...@@ -126,6 +136,8 @@ class ExecutionInspectWeb(ZoeRequestHandler): ...@@ -126,6 +136,8 @@ class ExecutionInspectWeb(ZoeRequestHandler):
def get(self, execution_id): def get(self, execution_id):
"""Gather details about an execution.""" """Gather details about an execution."""
uid, role = get_auth(self) uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
e = self.api_endpoint.execution_by_id(uid, role, execution_id) e = self.api_endpoint.execution_by_id(uid, role, execution_id)
...@@ -133,8 +145,11 @@ class ExecutionInspectWeb(ZoeRequestHandler): ...@@ -133,8 +145,11 @@ class ExecutionInspectWeb(ZoeRequestHandler):
for service in e.services: for service in e.services:
services_info.append(self.api_endpoint.service_by_id(uid, role, service.id)) services_info.append(self.api_endpoint.service_by_id(uid, role, service.id))
endpoints = self.api_endpoint.execution_endpoints(uid, role, e)[1]
template_vars = { template_vars = {
"e": e, "e": e,
"services_info": services_info "services_info": services_info,
"endpoints": endpoints,
} }
self.render('execution_inspect.html', **template_vars) self.render('execution_inspect.html', **template_vars)
...@@ -33,7 +33,7 @@ class RootWeb(ZoeRequestHandler): ...@@ -33,7 +33,7 @@ class RootWeb(ZoeRequestHandler):
@catch_exceptions @catch_exceptions
def get(self): def get(self):
"""Home page without authentication.""" """Home page without authentication."""
self.render('index.html') self.redirect("/user")
class LoginWeb(ZoeRequestHandler): class LoginWeb(ZoeRequestHandler):
...@@ -72,6 +72,8 @@ class HomeWeb(ZoeRequestHandler): ...@@ -72,6 +72,8 @@ class HomeWeb(ZoeRequestHandler):
def get(self): def get(self):
"""Home page with authentication.""" """Home page with authentication."""
uid, role = get_auth(self) uid, role = get_auth(self)
if uid is None:
return self.redirect(self.get_argument('next', u'/login'))
if role == 'user' or role == 'admin': if role == 'user' or role == 'admin':
executions = self.api_endpoint.execution_list(uid, role) executions = self.api_endpoint.execution_list(uid, role)
......
This diff is collapsed.
...@@ -32,6 +32,10 @@ table.app_list td { ...@@ -32,6 +32,10 @@ table.app_list td {
padding-right: 1.5em; padding-right: 1.5em;
} }
table.app_list tr.even {
background-color: #F3FEEA;
}
div.status_line { div.status_line {
float: left; float: left;
} }
...@@ -62,84 +66,98 @@ span.fakelink { ...@@ -62,84 +66,98 @@ span.fakelink {
} }
#wrapper { #wrapper {
width: 800px; width: 800px;
} }
#navigation { #navigation {
background-color: #fff; background-color: #fff;
border: #ddd 1px solid; border: #ddd 1px solid;
border-radius: 10px; border-radius: 10px;
margin: 10px; margin: 10px;
padding: 10px; padding: 10px;
} }
#navigation li { #navigation li {
margin: 2px 0; margin: 2px 0;
} }
label.error { label.error {
color: #ff0000; color: #ff0000;
margin-left: 10px; margin-left: 10px;
position: relative; position: relative;
} }
.wizard { .wizard {
background-color: #fff; background-color: #fff;
border: #ddd 1px solid; border: #ddd 1px solid;
border-radius: 10px; border-radius: 10px;
margin: 10px; margin: 10px;
padding: 10px; padding: 10px;
} }
.wizard .wizard-header { .wizard .wizard-header {
background-color: #f4f4f4; background-color: #f4f4f4;
border-bottom: #ddd 1px solid; border-bottom: #ddd 1px solid;
border-top-left-radius: 10px; border-top-left-radius: 10px;
border-top-right-radius: 10px; border-top-right-radius: 10px;
padding: 5px 10px; padding: 5px 10px;
margin: 0 0 10px 0; margin: 0 0 10px 0;
} }
.wizard .wizard-step { .wizard .wizard-step {
margin: 10px 0; margin: 10px 0;
} }
.wizard .wizard-step p { .wizard .wizard-step p {
padding: 5px; padding: 5px;
} }
.navigation { .navigation {
border-top: #ddd 1px solid; border-top: #ddd 1px solid;
margin-top: 10px; margin-top: 10px;
padding-top: 10px; padding-top: 10px;
} }
.navigation ul { .navigation ul {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
} }
.navigation li { .navigation li {
float: left; float: left;
margin-right: 10px; margin-right: 10px;
} }
.clearfix:before, .clearfix:after { .clearfix:before, .clearfix:after {
content: "\0020"; content: "\0020";
display: block; display: block;
height: 0; height: 0;
visibility: hidden; visibility: hidden;
} }
.clearfix:after { .clearfix:after {
clear: both; clear: both;
} }
input { input {
margin-top: 5px; margin-top: 5px;
} }
section { section {
padding-bottom: 10px; padding-bottom: 10px;
} }
\ No newline at end of file
#loginbox {
width: 25em;
margin: 0 auto;
text-align: center;
}
#loginbox img {
width: 100%;
}
fieldset {
border: 0;
}
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
document.write((bytes / Math.pow(k, i)).toPrecision(dm) + ' ' + sizes[i]); document.write((bytes / Math.pow(k, i)).toPrecision(dm) + ' ' + sizes[i]);
} }
</script> </script>
<h1>Zoe - Analytics on demand</h1>
<div id="content">{% block content %}{% endblock %}</div> <div id="content">{% block content %}{% endblock %}</div>
<div id="footer"> <div id="footer">
{% block footer %} {% block footer %}
......
{% extends "base.html" %} {% extends "base.html" %}
{% block content %}
<h1>Zoe - Analytics on demand</h1>
{{ super() }}
{% endblock %}
{% block footer %} {% block footer %}
<p><a href="{{ reverse_url("home_user") }}">Home</a></p> <p><a href="{{ reverse_url("home_user") }}">Home</a></p>
{{ super() }} {{ super() }}
......
...@@ -23,6 +23,19 @@ ...@@ -23,6 +23,19 @@
<p>Error message: <code>{{ e.error_message }}</code></p> <p>Error message: <code>{{ e.error_message }}</code></p>
{% endif %} {% endif %}
<div id="endpoints">
<h3>Endpoints</h3>
{% if endpoints|length > 0 %}
<ul>
{% for endp in endpoints %}
<li><a href="{{ endp[1] }}">{{ endp[0] }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>This execution does not have any active endpoint</p>
{% endif %}
</div>
<div id="container_list"> <div id="container_list">
{% if services_info|length > 0 %} {% if services_info|length > 0 %}
<h3>Services:</h3> <h3>Services:</h3>
...@@ -32,19 +45,10 @@ ...@@ -32,19 +45,10 @@
<li class="container_name" id="{{ s['id'] }}">{{ s['name'] }}</li> <li class="container_name" id="{{ s['id'] }}">{{ s['name'] }}</li>
<ul> <ul>
<li>Zoe status: {{ s['status'] }}</li> <li>Zoe status: {{ s['status'] }}</li>
<li>Docker status: {{ s['backend_status'] }}</li> <li>Backend status: {{ s['backend_status'] }}</li>
{% if s['error_message'] is not none %} {% if s['error_message'] is not none %}
<li>Error: {{ s['error_message'] }}</li> <li>Error: {{ s['error_message'] }}</li>
{% endif %} {% endif %}
{% if s['backend_status'] == 'started' %}
{% for p in s['description']['ports'] %}
{% if s['proxy_address'] is not none %}
<li><a href="http://{{ s['proxy_address'] }}">{{ p['name'] }}</a></li>
{% else %}
<li><a> {{ p['name'] }} IP: {{ s['ip_address'] }}</a></li>
{% endif %}
{% endfor %}
{% endif %}
</ul> </ul>
{% endfor %} {% endfor %}
</ul> </ul>
......
{% extends "base.html" %} {% extends "base_user.html" %}
{% block title %}Home{% endblock %} {% block title %}Home{% endblock %}
{% block content %} {% block content %}
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
{% else %} {% else %}
<td><script>format_timestamp("{{ e.time_end }}")</script></td> <td><script>format_timestamp("{{ e.time_end }}")</script></td>
{% endif %} {% endif %}
{% if e.status == "running" or e.status == "submitted" or e.status == "scheduled" %} {% if e.is_active %}
<td><a href="/executions/terminate/{{ e.id }}">Terminate</a></td> <td><a href="/executions/terminate/{{ e.id }}">Terminate</a></td>
{% else %} {% else %}
<td><a href="/executions/restart/{{ e.id }}">Restart</a>, <td><a href="/executions/restart/{{ e.id }}">Restart</a>,
......
<div id="main-container"> {% extends "base.html" %}
<div id="main"> {% block title %}Login{% endblock %}
<h1> {% block content %}
<img alt="zoe dummy login page" src="{{ static_url("img/logo.png") }}">
</h1>
<div id="login-form">
<form action="/login" method="post" id="login_form">
<fieldset>
<label for="username">Username</label>
<input autocapitalize="off" autocorrect="off" class="text-input" id="username" name="username" tabindex="1" type="text" value="">
</fieldset>
<fieldset> <div id="loginbox">
<label for="password">Password</label> <img alt="ZOE logo" src="{{ static_url("logo.svg") }}">
<input class="text-input" id="password" name="password" tabindex="2" type="password" value=""> <div id="login-form">
</fieldset> <form action="/login" method="post" id="login_form">
<fieldset> <fieldset>
<span class="errormessage">{{errormessage}}</span> <label for="username">Username:</label>
</fieldset> <input autocapitalize="off" autocorrect="off" class="text-input" id="username" name="username" tabindex="1" type="text" value=""><br>
<div id="form_btn"> <label for="password">Password:</label>
<input id="signin-btn" class="btn btn-blue" type="submit" value="Sign In" tabindex="3"> <input class="text-input" id="password" name="password" tabindex="2" type="password" value="">
</div> </fieldset>
</form>
</div> <div id="form_btn">
<input id="signin-btn" class="btn btn-blue" type="submit" value="Login" tabindex="3">
</div> </div>
</div> </form>
</div>
</div>
{% endblock %}
...@@ -84,7 +84,7 @@ def get_auth(handler: ZoeRequestHandler): ...@@ -84,7 +84,7 @@ def get_auth(handler: ZoeRequestHandler):
log.info('Authentication done using cookie') log.info('Authentication done using cookie')
return uid, role return uid, role
else: else:
handler.redirect(handler.get_argument('next', u'/login')) return None, None
def error_page(handler: ZoeRequestHandler, error_message: str, status: int): def error_page(handler: ZoeRequestHandler, error_message: str, status: int):
......
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