mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
Convert diagnostics pages to template
This commit is contained in:
parent
eff6306f7d
commit
25fe3c7ee8
@ -19,7 +19,7 @@
|
|||||||
Plinth module for running diagnostics
|
Plinth module for running diagnostics
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, cherrypy
|
import cherrypy
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from auth import require
|
from auth import require
|
||||||
from plugin_mount import PagePlugin
|
from plugin_mount import PagePlugin
|
||||||
@ -38,13 +38,8 @@ class diagnostics(PagePlugin):
|
|||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@require()
|
@require()
|
||||||
def index(self):
|
def index(self):
|
||||||
main = _("""
|
return util.render_template(template='diagnostics',
|
||||||
<p>The system diagnostic test will run a number of checks on your
|
title=_('System Diagnostics'))
|
||||||
system to confirm that network services are running and configured
|
|
||||||
properly. It may take a minute to complete.</p>
|
|
||||||
""")
|
|
||||||
main += '<p><a class="btn btn-primary btn-large" href="'+cfg.server_dir+'/sys/diagnostics/test">Run diagnostic test »</a></p>'
|
|
||||||
return util.render_template(title=_("System Diagnostics"), main=main)
|
|
||||||
|
|
||||||
class test(PagePlugin):
|
class test(PagePlugin):
|
||||||
order = 31
|
order = 31
|
||||||
@ -55,17 +50,8 @@ class test(PagePlugin):
|
|||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@require()
|
@require()
|
||||||
def index(self):
|
def index(self):
|
||||||
main = ''
|
|
||||||
output, error = actions.superuser_run("diagnostic-test")
|
output, error = actions.superuser_run("diagnostic-test")
|
||||||
|
return util.render_template(template='diagnostics_test',
|
||||||
if error:
|
title=_('Diagnostic Test'),
|
||||||
main += _("The diagnostic test encountered an error:</br>")
|
diagnostics_output=output,
|
||||||
for line in error.split('\n'):
|
diagnostics_error=error)
|
||||||
main += line + "</br>"
|
|
||||||
|
|
||||||
if output:
|
|
||||||
main += _("Output of diagnostic test:</br>")
|
|
||||||
for line in output.split('\n'):
|
|
||||||
main += line + "</br>"
|
|
||||||
|
|
||||||
return util.render_template(title=_("Diagnostic Test"), main=main)
|
|
||||||
|
|||||||
13
modules/installed/system/templates/diagnostics.html
Normal file
13
modules/installed/system/templates/diagnostics.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{% extends 'login_nav.html' %}
|
||||||
|
|
||||||
|
{% block main_block %}
|
||||||
|
|
||||||
|
<p>The system diagnostic test will run a number of checks on your
|
||||||
|
system to confirm that network services are running and configured
|
||||||
|
properly. It may take a minute to complete.</p>
|
||||||
|
|
||||||
|
<p><a class="btn btn-primary btn-large"
|
||||||
|
href="{{ basehref }}/sys/diagnostics/test">Run diagnostic test
|
||||||
|
»</a></p>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
15
modules/installed/system/templates/diagnostics_test.html
Normal file
15
modules/installed/system/templates/diagnostics_test.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{% extends 'login_nav.html' %}
|
||||||
|
|
||||||
|
{% block main_block %}
|
||||||
|
|
||||||
|
{% if diagnostics_error %}
|
||||||
|
<p>The diagnostic test encountered an error:<p>
|
||||||
|
<pre>{{ diagnostics_error }}</pre>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if diagnostics_output %}
|
||||||
|
<p>Output of diagnostic test:</p>
|
||||||
|
<pre>{{ diagnostics_output }}</pre>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
Loading…
x
Reference in New Issue
Block a user