Commit 639cf0ac authored by ic's avatar ic

Non styled library for data view with graphical charts

parent f88b8747
......@@ -54,13 +54,24 @@ class PakonPluginPage(ConfigPageMixin, PakonPluginConfigHandler):
return json.loads(data["response_data"])
def call_ajax_action(self, action):
if action == "perform_query":
if action == "eventsource":
if bottle.request.method != 'GET':
raise bottle.HTTPError(405, "Wrong http method (only GET is allowed).")
query_data = bottle.request.GET.get('query', {})
data = current_state.backend.perform("pakon", "perform_query", {"query_data": query_data})
bottle.response.set_header("Content-Type", "text/event-stream")
bottle.response.set_header("Cache-Control", "no-cache")
return bottle.template(
"pakon/eventsource",
results=self._prepare_data(data),
)
elif action == "perform_query":
if bottle.request.method != 'POST':
raise bottle.HTTPError(404, "Wrong http method (only POST is allowed.")
raise bottle.HTTPError(405, "Wrong http method (only POST is allowed).")
query_data = bottle.request.POST.get('query', {})
data = current_state.backend.perform(
"pakon", "perform_query", {"query_data": query_data})
data = current_state.backend.perform("pakon", "perform_query", {"query_data": query_data})
if "text/html" in bottle.request.headers["Accept"]:
return bottle.template(
"pakon/_results",
......
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
<div id="pakon-results">
%if results:
<table id="pakon-results-table">
<tbody>
%for record in results:
<tr>
%for item in record:
<td>{{ item }}</td>
%end
</tr>
%end
</tbody>
</table>
%if reversed(results):
<table id="pakon-results-table">
<thead>
<tr>
<th>čas</th>
<th>port</th>
<th>lokální zařízení</th>
<th>vzdálená služba</th>
<th>protokol</th>
<th>f</th>
<th>g</th>
<th>h</th>
</tr>
</thead>
<tbody>
%for record in results:
<tr>
%for item in record:
<td>{{ item }}</td>
%end
</tr>
%end
</tbody>
</table>
%else:
<p>{{ trans("No results found.") }}</p>
%end
%else:
<p>{{ trans("No results found.") }}</p>
%end
</div>
%for record in reversed(results):
data: ["{{ record[0] }}", "{{ record[1] }}", "{{ record[2] }}", "{{ record[3] }}", "{{ record[4] }}", "{{ record[5] }}", "{{ record[6] }}", "{{ record[7] }}"]
%end
......@@ -2,18 +2,89 @@
%rebase("config/base.tpl", **locals())
<div id="page-pakon-plugin" class="config-page">
%include("_messages.tpl")
%include("_messages.tpl")
<form action="{{ url("config_action", page_name="pakon", action="perform_query") }}" class="config-form" method="post">
<div class="row">
<label for="field-lan_ipaddr">Router IP address</label>
<input name="query" value="{{ query }}" type="text" id="field-query"/>
<input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}" id="csrf-token">
</div>
<div class="row">
<button type="submit" name="action" id="pakon-query-trigger" value="query-trigger" class="button">{{ trans("Query") }}</button>
</div>
</form>
<h3>{{ trans("Results") }}</h3>
%include("pakon/_results.tpl", results=results)
<!--
<form action="{{ url("config_action", page_name="pakon", action="perform_query") }}" class="config-form" method="post">
<div class="row">
<label for="field-lan_ipaddr">Router IP address</label>
<input name="query" value="{{ query }}" type="text" id="field-query"/>
<input type="hidden" name="csrf_token" value="{{ get_csrf_token() }}" id="csrf-token">
</div>
<div class="row">
<button type="submit" name="action" id="pakon-query-trigger" value="query-trigger" class="button">{{ trans("Query") }}</button>
</div>
</form>
-->
<fieldset>
<legend>{{ trans("Data view - settings") }}:</legend>
<label for="date-from">
{{ trans("Date From") }}:
<input type="date" name="date-from" id="date-from">
</label>
<label for="time-from">
{{ trans("Time") }}:
<input type="time" name="time-from" id="time-from" title="{{ trans("Time From") }}">
</label>
<br>
<label for="date-to">
{{ trans("Date To") }}:
<input type="date" name="date-to" id="date-to">
</label>
<label for="time-to">
{{ trans("Time") }}:
<input type="time" name="time-to" id="time-to" title="{{ trans("Time To") }}">
</label>
<hr>
<label for="aggregate">
{{ trans("Aggregation - by hostname") }}:
<input type="checkbox" name="aggregate" id="aggregate" checked>
</label>
<hr>
<label for="hostname-filter">
{{ trans("Only following hostnames") }}:
<br>
<textarea name="hostname-filter" id="hostname-filter"></textarea>
<br>
<small>{{ trans("(All hostnames if empty)") }}</small>
</label>
<hr>
<label for="srcMAC-filter">
{{ trans("Only following MAC addresses") }}:
<br>
<textarea name="srcMAC-filter" id="srcMAC-filter"></textarea>
<br>
<small>{{ trans("(All MAC adresses if empty)") }}</small>
</label>
<hr>
<label for="apply-changes">
<input type="submit" id="apply-changes" value="aplikovat změny" disabled>
</label>
</fieldset>
<h3>{{ trans("Statistics") }}</h3>
<div id="pakon-results-statistics"></div>
<h3>{{ trans("Results") }}</h3>
%include("pakon/_results.tpl", results=results)
</div>
<script>
const cntp = new czNicTurrisPakon(window);
cntp.settings = {
'eventSource': {
'baseUrl': new URL('ajax', window.location.href),
'dumpIntoStatistics': false,
},
'statisticsData': {
'graphs': {
'type': 'doughnut',
},
},
'lang': '{{ lang() }}',
};
cntp.run();
const cs = window.document.currentScript;
cs.parentNode.removeChild(cs);
</script>
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