summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-mwan3/luasrc/view/mwan/advanced_diagnostics.htm
blob: e4a14adadea700f0d20a942c8ff9a79d0da934c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<%+header%>

<ul class="cbi-tabmenu">
	<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/hotplugscript")%>"><%:Hotplug Script%></a></li>
	<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/mwanconfig")%>"><%:MWAN Config%></a></li>
	<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/networkconfig")%>"><%:Network Config%></a></li>
	<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/wirelessconfig")%>"><%:Wireless Config%></a></li>
	<li class="cbi-tab"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/diagnostics")%>"><%:Diagnostics%></a></li>
	<li class="cbi-tab-disabled"><a href="<%=luci.dispatcher.build_url("admin/network/mwan/advanced/troubleshooting")%>"><%:Troubleshooting%></a></li>
</ul>

<%
	local uci = require "luci.model.uci"

	interfaceNames = ""
	uci.cursor():foreach("mwan3", "interface",
		function (section)
			interfaceNames = interfaceNames .. section[".name"] .. " "
		end
	)
%>

<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript">//<![CDATA[
	var stxhr = new XHR();

	function update_status(tool, task)
	{
		var iface = document.getElementById('mwaniface').value;
		var output = document.getElementById('diag_output');

		if (tool == "service")
			{
				output.innerHTML =
					'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="padding: 20px; vertical-align: middle;" /> ' +
					String.format("<%:Waiting for MWAN to %s...%>", task)
				;
			}
			else
			{
				output.innerHTML =
					'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="padding: 20px; vertical-align: middle;" /> ' +
					"<%:Waiting for diagnostic results...%>"
				;
			}

		output.parentNode.style.display = 'block';
		output.style.display = 'inline';

		stxhr.get('<%=luci.dispatcher.build_url("admin", "network", "mwan", "advanced")%>/diagnostics_display' + '/' + iface + '/' + tool + '/' + task, null,
			function(x, mArray)
			{
				if (mArray.diagnostics)
				{
					output.innerHTML = String.format('<pre id="diag_output_css">%h</pre>', mArray.diagnostics[0]);
				}
				else
				{
					output.innerHTML = '<pre id="diag_output_css"><strong><%:No diagnostic results returned%></strong></pre>';
				}
			}
		);
	}
//]]></script>

<div id="mwan_diagnostics" class="cbi-map">
	<fieldset id="diag_select" class="cbi-section">
		<legend><%:MWAN Interface Diagnostics%></legend>
		<select id="mwaniface">
			<% for z in interfaceNames:gmatch("[^ ]+") do -%><option value="<%=z%>"><%=z%></option><%- end %>
		</select>
		<div id="buttoncss">
			<input type="button" value="<%:Ping default gateway%>" class="cbi-button cbi-button-apply" onclick="update_status('ping', 'gateway')" />
			<input type="button" value="<%:Ping tracking IP%>" class="cbi-button cbi-button-apply" onclick="update_status('ping', 'track_ip')" />
			<input type="button" value="<%:Check IP rules%>" class="cbi-button cbi-button-apply" onclick="update_status('rulechk', null)" />
			<input type="button" value="<%:Check routing table%>" class="cbi-button cbi-button-apply" onclick="update_status('routechk', null)" />
			<input type="button" value="<%:Hotplug ifup%>" class="cbi-button cbi-button-apply" onclick="update_status('hotplug', 'ifup')" />
			<input type="button" value="<%:Hotplug ifdown%>" class="cbi-button cbi-button-apply" onclick="update_status('hotplug', 'ifdown')" />
		</div>
	</fieldset>
	<fieldset id="diag_select" class="cbi-section">
		<legend><%:MWAN Service Control%></legend>
		<div id="buttoncss">
			<input type="button" value="<%:Restart MWAN%>" class="cbi-button cbi-button-apply" onclick="update_status('service', 'restart')" />
			<input type="button" value="<%:Stop MWAN%>" class="cbi-button cbi-button-apply" onclick="update_status('service', 'stop')" />
			<input type="button" value="<%:Start MWAN%>" class="cbi-button cbi-button-apply" onclick="update_status('service', 'start')" />
		</div>
	</fieldset>
	<fieldset class="cbi-section" style="display:none">
		<legend><%:Diagnostic Results%></legend>
		<div id="diag_output"></div>
	</fieldset>
</div>

<style type="text/css">
  #mwaniface {
	float: left;
	margin: 8px 20px 0px 0px;
  }
  #buttoncss {
	display: table;
	float: left;
	text-align: left;
  }
  .cbi-button {
	margin: 8px 20px 0px 0px;
	min-width: 153px;
  }
  #diag_output_css {
	padding: 20px;
	text-align: left;
  }
</style>

<%+footer%>