idle: added iframe to auto reload if networking is down
This commit is contained in:
parent
c91d3dc282
commit
e4a3020981
5 changed files with 47 additions and 3 deletions
|
|
@ -6,6 +6,10 @@ import time
|
|||
|
||||
app = Blueprint('idle', __name__, template_folder='templates', static_folder='static')
|
||||
|
||||
@app.route('/iframe/<building>')
|
||||
@auth_required
|
||||
def iframe(building, userid):
|
||||
return render_template('iframe.html', url="/idle/" + building)
|
||||
|
||||
# one day it'll be clean, but that day is not today
|
||||
@app.route('/idle/<building>')
|
||||
|
|
|
|||
|
|
@ -35,3 +35,8 @@ def monitoring_redis(token):
|
|||
except:
|
||||
return 'BAD', 500
|
||||
return 'OK', 200
|
||||
|
||||
|
||||
@app.route('/monitoring/200')
|
||||
def get_200():
|
||||
return 'OK', 200
|
||||
|
|
|
|||
34
templates/iframe.html
Normal file
34
templates/iframe.html
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Friends42</title>
|
||||
</head>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: Tahoma, Verdana, Arial, sans-serif;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<iframe src="{{ url }}" allowfullscreen="" frameborder="0" height="100%" width="100%" style="position: absolute;"></iframe>
|
||||
<script>
|
||||
const iframe = document.querySelector('iframe');
|
||||
let was_down = false;
|
||||
setInterval(e => {
|
||||
try {
|
||||
if (!('performance' in iframe.contentWindow)) {
|
||||
return;
|
||||
}
|
||||
let status = iframe.contentWindow.performance.getEntriesByType('navigation')[0].responseStatus;
|
||||
if (status !== 200) {
|
||||
iframe.contentWindow.location.reload();
|
||||
}
|
||||
} catch (e) {
|
||||
iframe.src = iframe.src;
|
||||
}
|
||||
}, 5000)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -32,8 +32,9 @@
|
|||
</small>
|
||||
</h4>
|
||||
{% elif message.sp_author %}
|
||||
<h4 class="mb-2">Message de {{ message.sp_author }}
|
||||
<span style="{{ message.sp_tag_style | safe }}">{{ message.sp_tag }}</span>
|
||||
<h4 class="mb-2">Message de
|
||||
<span style="{{ message.sp_tag_style | safe }}">{{ message.sp_author }}</span>
|
||||
{{ message.sp_tag | safe }}
|
||||
<small class="text-muted font-sm"><i class="fa-solid fa-hashtag"></i>{{ message.id }}
|
||||
</small>
|
||||
</h4>
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@
|
|||
}
|
||||
|
||||
function kiosk_open() {
|
||||
location.replace('/idle/' + document.getElementById('kiosk-building').value);
|
||||
location.replace('/iframe/' + document.getElementById('kiosk-building').value);
|
||||
}
|
||||
|
||||
function kiosk_load() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue