Add templates
This commit is contained in:
@ -6,11 +6,16 @@
|
||||
<title>{% block title %}Waiting Room{% endblock %}</title>
|
||||
<script src="https://unpkg.com/htmx.org@2.0.3" integrity="sha384-0895/pl2MU10Hqc6jd4RvrthNlDiE9U1tWmX7WRESftEDRosgxNsQG/Ze9YMRzHq" crossorigin="anonymous"></script>
|
||||
<script src="https://unpkg.com/htmx-ext-ws@2.0.1/ws.js"></script>
|
||||
<script>
|
||||
if (!localStorage.getItem('userId')) {
|
||||
localStorage.setItem('userId', '{{ user_id }}');
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
{% include 'progress_bar.html' %}
|
||||
<section>{% block content %}{% endblock %}</section>
|
||||
{% include 'components/tasks/layout.html' %}
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
15
waiting_room/templates/components/tasks/layout.html
Normal file
15
waiting_room/templates/components/tasks/layout.html
Normal file
@ -0,0 +1,15 @@
|
||||
<section
|
||||
id="component-notification"
|
||||
hx-ext="ws"
|
||||
style="
|
||||
position: fixed;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 2rem;
|
||||
background: lightgray;
|
||||
">
|
||||
{% include 'components/tasks/update.html' %}
|
||||
</section>
|
||||
<script>
|
||||
document.querySelector('#component-notification').setAttribute('ws-connect', '/ws/' + localStorage.getItem('userId') + '/');
|
||||
</script>
|
11
waiting_room/templates/components/tasks/update.html
Normal file
11
waiting_room/templates/components/tasks/update.html
Normal file
@ -0,0 +1,11 @@
|
||||
<div id="component-notification__update">
|
||||
<h1>Task</h1>
|
||||
{% if result %}
|
||||
<h2>Done!</h2>
|
||||
<a href="{% url 'waiting_room:index' %}?result={{ result }}">Go to result</a>
|
||||
{% elif progress %}
|
||||
<progress value="{{ progress }}" max="100">{{ progress }}</progress>
|
||||
{% else %}
|
||||
<p>Nothing</p>
|
||||
{% endif %}
|
||||
</div>
|
@ -5,13 +5,16 @@
|
||||
{% block content %}
|
||||
<h1>Index</h1>
|
||||
<section
|
||||
id="form-start-task"
|
||||
hx-ext="ws"
|
||||
ws-connect="/ws/nombre_temporal/"
|
||||
>
|
||||
<form id="form" ws-send>
|
||||
<input type="submit" name="task" value="calculate">
|
||||
</form>
|
||||
</section>
|
||||
<script>
|
||||
document.querySelector('#form-start-task').setAttribute('ws-connect', '/ws/' + localStorage.getItem('userId') + '/');
|
||||
</script>
|
||||
<section>
|
||||
{% if result %}
|
||||
<h2>The result is {{ result }}</h2>
|
||||
|
@ -1,20 +0,0 @@
|
||||
<section
|
||||
hx-ext="ws"
|
||||
ws-connect="/ws/nombre_temporal/"
|
||||
hx-swap-oob="innerHTML:notification"
|
||||
style="
|
||||
position: fixed;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 2rem;
|
||||
background: lightgray;
|
||||
">
|
||||
<div id="notification"></div>
|
||||
<!-- <h1>Task</h1>
|
||||
{% if result %}
|
||||
<h3>Done!</h3>
|
||||
<a href="{% url 'waiting_room:index' %}?result={{ result }}">Show result</a>
|
||||
{% else %}
|
||||
<progress value="{{ progress }}" max="100">{{ progress }}</progress>
|
||||
{% endif %} -->
|
||||
</section>
|
Reference in New Issue
Block a user