format html + put js in static
This commit is contained in:
parent
0ed9acd405
commit
7fb593c98a
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,6 +2,6 @@
|
||||
__pycache__
|
||||
db.sqlite3
|
||||
venv
|
||||
static
|
||||
/static
|
||||
*.log
|
||||
*.pid
|
||||
39
deployment/static/deployment/js/event_source.js
Normal file
39
deployment/static/deployment/js/event_source.js
Normal file
@ -0,0 +1,39 @@
|
||||
var start = function (url) {
|
||||
|
||||
var es = new ReconnectingEventSource(url);
|
||||
|
||||
es.onopen = function () {
|
||||
console.log('connected');
|
||||
};
|
||||
|
||||
es.addEventListener('stream-error', function (e) {
|
||||
es.close();
|
||||
message = JSON.parse(e.data);
|
||||
console.log('stream error: ' + message.condition + ': ' + message.text);
|
||||
}, false);
|
||||
|
||||
es.onerror = function (e) {
|
||||
console.log('connection error');
|
||||
};
|
||||
|
||||
// listening on `message` events and update the corresponding table line.
|
||||
// If the status is `FAILED`, we reload the window to ensure a new csrf_token.
|
||||
es.addEventListener('message', function (e) {
|
||||
message = JSON.parse(e.data);
|
||||
console.log("id: " + message.id);
|
||||
console.log("status: " + message.status);
|
||||
|
||||
const tr = document.getElementById(message.id);
|
||||
if (tr) {
|
||||
var th = tr.querySelector("th[name='status']");
|
||||
th.innerHTML = message.status;
|
||||
|
||||
if (message.status == "FAILED") {
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
}, false);
|
||||
};
|
||||
@ -1,23 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{% block title %}mumui{% endblock %}</title>
|
||||
{% block headscript %}{% endblock %}
|
||||
</head>
|
||||
|
||||
<body {% block bodyattr %}{% endblock %}>
|
||||
<main>
|
||||
{% if user.is_authenticated or "login" in request.path %}
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
{% if user.is_authenticated %}
|
||||
<p><a href="{% url 'logout' %}">log out</a></p>
|
||||
{% endif %}
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
{% if user.is_authenticated %}
|
||||
<p><a href="{% url 'logout' %}">log out</a></p>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<p>You are not logged in</p>
|
||||
<a href="{% url 'login' %}">log In</a>
|
||||
<p>You are not logged in</p>
|
||||
<a href="{% url 'login' %}">log In</a>
|
||||
{% endif %}
|
||||
</main>
|
||||
{% block script %}{% endblock %}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -2,16 +2,16 @@
|
||||
|
||||
{% load static %}
|
||||
|
||||
{% block title %}deployment's board{% endblock %}
|
||||
{% block title %} deployment's board {% endblock %}
|
||||
|
||||
{% block headscript %}
|
||||
<script src="{% static 'django_eventstream/json2.js' %}"></script>
|
||||
<script src="{% static 'django_eventstream/eventsource.min.js' %}"></script>
|
||||
<script src="{% static 'django_eventstream/reconnecting-eventsource.js' %}"></script>
|
||||
<script src="{% static 'django_eventstream/json2.js' %}"></script>
|
||||
<script src="{% static 'django_eventstream/eventsource.min.js' %}"></script>
|
||||
<script src="{% static 'django_eventstream/reconnecting-eventsource.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block bodyattr %}
|
||||
onload="start();"
|
||||
onload="start('{{ url|safe }}');"
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
@ -48,19 +48,19 @@
|
||||
</table>
|
||||
<div class="pagination">
|
||||
<span class="step-links">
|
||||
{% if page_obj.has_previous %}
|
||||
<a href="?page=1">« first</a>
|
||||
<a href="?page={{ page_obj.previous_page_number }}">previous</a>
|
||||
{% endif %}
|
||||
|
||||
<span class="current">
|
||||
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
|
||||
</span>
|
||||
|
||||
{% if page_obj.has_next %}
|
||||
<a href="?page={{ page_obj.next_page_number }}">next</a>
|
||||
<a href="?page={{ page_obj.paginator.num_pages }}">last »</a>
|
||||
{% endif %}
|
||||
{% if page_obj.has_previous %}
|
||||
<a href="?page=1">« first</a>
|
||||
<a href="?page={{ page_obj.previous_page_number }}">previous</a>
|
||||
{% endif %}
|
||||
|
||||
<span class="current">
|
||||
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
|
||||
</span>
|
||||
|
||||
{% if page_obj.has_next %}
|
||||
<a href="?page={{ page_obj.next_page_number }}">next</a>
|
||||
<a href="?page={{ page_obj.paginator.num_pages }}">last »</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
{% else %}
|
||||
@ -72,45 +72,6 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script>
|
||||
var start = function () {
|
||||
|
||||
var es = new ReconnectingEventSource('{{ url|safe }}');
|
||||
|
||||
es.onopen = function () {
|
||||
console.log('connected');
|
||||
};
|
||||
|
||||
es.addEventListener('stream-error', function (e) {
|
||||
es.close();
|
||||
message = JSON.parse(e.data);
|
||||
console.log('stream error: ' + message.condition + ': ' + message.text);
|
||||
}, false);
|
||||
|
||||
es.onerror = function (e) {
|
||||
console.log('connection error');
|
||||
};
|
||||
|
||||
// listening on `message` events and update the corresponding table line.
|
||||
// If the status is `FAILED`, we reload the window to ensure a new csrf_token.
|
||||
es.addEventListener('message', function (e) {
|
||||
message = JSON.parse(e.data);
|
||||
console.log("id: " + message.id);
|
||||
console.log("status: " + message.status);
|
||||
|
||||
const tr = document.getElementById(message.id);
|
||||
if (tr) {
|
||||
var th = tr.querySelector("th[name='status']");
|
||||
th.innerHTML = message.status;
|
||||
|
||||
if (message.status == "FAILED") {
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
}, false);
|
||||
};
|
||||
<script src="{% static 'deployment/js/event_source.js' %}" />
|
||||
</script>
|
||||
{% endblock %}
|
||||
@ -1,6 +1,6 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}new deployment{% endblock %}
|
||||
{% block title %} new deployment {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ user.username }}'s new deployment
|
||||
|
||||
@ -1,24 +1,24 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}deployment details: {{ deployment.name }}{% endblock %}
|
||||
{% block title %} deployment details: {{ deployment.name }} {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<table>
|
||||
<tr>
|
||||
<th>id</th>
|
||||
<th>name</th>
|
||||
<th>type</th>
|
||||
<th>status</th>
|
||||
<th>id</th>
|
||||
<th>name</th>
|
||||
<th>type</th>
|
||||
<th>status</th>
|
||||
</tr>
|
||||
<tr id="{{ deployment.id }}">
|
||||
<th name="id">{{ deployment.id }}</th>
|
||||
<th name="name">{{ deployment.name }}</th>
|
||||
<th name="type">{{ deployment.type }}</th>
|
||||
<th name="status">{{ deployment.status }}</th>
|
||||
<th name="id">{{ deployment.id }}</th>
|
||||
<th name="name">{{ deployment.name }}</th>
|
||||
<th name="type">{{ deployment.type }}</th>
|
||||
<th name="status">{{ deployment.status }}</th>
|
||||
</tr>
|
||||
</table>
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="submit" value="delete">
|
||||
</form>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@ -1,16 +1,16 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}login{% endblock %}
|
||||
{% block title %} login {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if not user.is_authenticated %}
|
||||
<h2>log in</h2>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit">log in</button>
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit">log in</button>
|
||||
</form>
|
||||
{% else %}
|
||||
you're already log in !
|
||||
<div>you're already log in !</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Loading…
x
Reference in New Issue
Block a user