summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-multiwan/luasrc/view/multiwan_status.htm
blob: 8c4127b2370654d75571f3959c2dabb8fef7620f (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
<script type="text/javascript">//<![CDATA[
	XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "multiwan", "status")%>', null,
		function(x, st)
		{
			var tx = document.getElementById('multiwan_status_text');
			if (tx)
			{
				if (st && st.wans)
				{
					var temp = '';

					for( var i = 0; i < st.wans.length; i++ )
					{
						var stat = '<%:Unknown%>';
						var cssc = '';

						switch (st.wans[i].status)
						{
							case 'ok':
								stat = '<%:OK%>';
								cssc = 'wanok';
								break;

							case 'ko':
								stat = '<%:KO%>';
								cssc = 'wanko';
								break;

							case 'recovering':
								stat = String.format('<%:Recovering%>(%d)', st.wans[i].count);
								cssc = 'wanrecov';
								break;

							case 'failing':
								stat = String.format('<%:Failing%>(%d)', st.wans[i].count);
								cssc = 'wanfail';
								break;
						}

						temp += String.format(
							'<span class="%s"><strong>%s (<a href="%q">%s</a>) :</strong> %s</span>',
								cssc, st.wans[i].name, st.wans[i].link, st.wans[i].ifname, stat
						);
					}
					
					tx.innerHTML = temp;
				}
				else
				{
					tx.innerHTML = '';
				}
			}
		}
	);
//]]></script>

<style type="text/css">
  .wanok { background-color: rgb(144, 240, 144); }
  .wanko { background-color: rgb(240, 144, 144); }
  .wanrecov { background-color: rgb(240, 240, 0); }
  .wanfail { background-color: rgb(255, 165, 0); }
  .wanko, .wanok, .wanrecov, .wanfail {
	padding: 0.4em;
	margin: 0.4em;
  }
</style>

<fieldset class="cbi-section">
	<legend><%:Multi-WAN Status%></legend>
	<div id="multiwan_status_text" style="text-align:center;"><em><%:Collecting data...%></em></div>
</fieldset>