Commit a5d3f9bd authored by Daniele Venzano's avatar Daniele Venzano
Browse files

Use javascript to format timestamps according to the browser locale and timezone

parent 4dcb84c1
from datetime import datetime
from flask import Blueprint
web_bp = Blueprint('web', __name__, template_folder='templates', static_folder='static')
......@@ -8,11 +6,3 @@ import zoe_web.web.start
import zoe_web.web.status
import zoe_web.web.applications
@web_bp.app_template_filter('format_timestamp')
def _jinja2_filter_datetime(timestamp):
try:
dt = datetime.fromtimestamp(timestamp)
except TypeError:
return timestamp
return dt.ctime()
This diff is collapsed.
......@@ -6,6 +6,7 @@
<title>{% block title %}{% endblock %} - Zoe</title>
<script src="/static/jquery-2.1.4.min.js" type="application/javascript"></script>
<script src="/static/sorttable.js" type="application/javascript"></script>
<script src="/static/moment.min.js" type="application/javascript"></script>
<link rel="stylesheet" href="/static/zoe.css" type="text/css">
{% endblock %}
</head>
......@@ -23,6 +24,12 @@
}
update_status();
window.setInterval(update_status, 5000);
moment.locale(window.navigator.userLanguage || window.navigator.language);
function format_timestamp(ts) {
document.write(moment(ts, "X").calendar())
}
</script>
<h1>Zoe - Analytics on demand</h1>
<div id="content">{% block content %}{% endblock %}</div>
......
......@@ -28,7 +28,7 @@
<td>{{ a.required_resources.container_count }}</td>
<td>{{ a.required_resources.worker_resources["memory_limit"] }}</td>
<td>{{ a.required_resources.worker_resources["cores"] }}</td>
<td>{{ a.master_image|replace('10.0.0.2:5000/zoe/', '') }}</td>
<td>{{ a.master_image }}</td>
<td><a href="{{ url_for('web.execution_new', app_id=a.id) }}">Run</a></td>
<td><a href="{{ url_for('web.application_delete', app_id=a.id) }}">Delete</a></td>
</tr>
......@@ -50,8 +50,8 @@
<th>Application name</th>
<th>Execution name</th>
<th>Status</th>
<th>Scheduled at</th>
<th>Started at</th>
<th>Scheduled</th>
<th>Started</th>
<th>Container count</th>
</tr>
</thead>
......@@ -61,15 +61,16 @@
<td>{{ e[0]['name'] }}</td>
<td>{{ e[1]['name'] }}</td>
<td>{{ e[1]['status'] }}</td>
<td>{{ e[1]['scheduled_at']|format_timestamp }}</td>
<td><script>format_timestamp({{ e[1]['scheduled_at'] }})</script></td>
{% if e[1]['started_at'] == 'None' %}
<td>not yet</td>
<td></td>
{% else %}
<td>{{ e[1]['started_at']|format_timestamp }}</td>
<td><a href="{{ e[2] }}">Open</a></td>
<td><script>format_timestamp({{ e[1]['started_at'] }})</script></td>
{% endif %}
<td>{{ e[1]['cluster']|count }}</td>
{% if e[1]['started_at'] != 'None' %}
<td><a href="{{ e[2] }}">Open</a></td>
{% endif %}
<td><a href="{{ url_for('web.execution_terminate', exec_id=e[1]['id']) }}">Terminate</a></td>
</tr>
{% endfor %}
......@@ -90,9 +91,8 @@
<th>Application name</th>
<th>Execution name</th>
<th>Status</th>
<th>Scheduled at</th>
<th>Started at</th>
<th>Finished at</th>
<th>Scheduled</th>
<th>Duration</th>
</tr>
</thead>
<tbody>
......@@ -101,13 +101,8 @@
<td>{{ e[0]['name'] }}</td>
<td>{{ e[1]['name'] }}</td>
<td>{{ e[1]['status'] }}</td>
<td>{{ e[1]['scheduled_at']|format_timestamp }}</td>
{% if e[1]['started_at'] == 'None' %}
<td>never</td>
{% else %}
<td>{{ e[1]['started_at']|format_timestamp }}</td>
{% endif %}
<td>{{ e[1]['finished_at']|format_timestamp }}</td>
<td><script>format_timestamp({{ e[1]['scheduled_at'] }})</script></td>
<td><script>document.write(moment.duration({{ e[1]['finished_at'] }} - {{ e[1]['scheduled_at'] }}).humanize())</script></td>
{% if e[1]['started_at'] != None %}
<td><a href="{{ url_for('api.history_logs_get', execution_id=e[1]['id']) }}">Logs</a></td>
{% endif %}
......
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