Migrate UI cleanup phase 4 from MIPS into ARM
[tomato.git] / release / src-rt-6.x.4708 / router / www / admin-bwm.asp
blob618378c05a5b627566e2504e280dfefa3024b499
1 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
2 <!--
3 Tomato GUI
4 Copyright (C) 2006-2010 Jonathan Zarate
5 http://www.polarcloud.com/tomato/
7 For use with Tomato Firmware only.
8 No part of this file may be used without permission.
9 -->
10 <html>
11 <head>
12 <meta http-equiv='content-type' content='text/html;charset=utf-8'>
13 <meta name='robots' content='noindex,nofollow'>
14 <meta name="viewport" content="width=device-width">
15 <title>[<% ident(); %>] Admin: Bandwidth Monitoring</title>
16 <link rel='stylesheet' type='text/css' href='tomato.css'>
17 <link rel='stylesheet' type='text/css' href='color.css'>
18 <script type='text/javascript' src='tomato.js'></script>
20 <!-- / / / -->
21 <style type='text/css'>
22 textarea {
23 width: 98%;
24 height: 15em;
26 </style>
28 <script type='text/javascript' src='debug.js'></script>
30 <script type='text/javascript'>
32 // <% nvram("rstats_enable,rstats_path,rstats_stime,rstats_offset,rstats_exclude,rstats_sshut,et0macaddr,cifs1,cifs2,jffs2_on,rstats_bak"); %>
34 function backupNameChanged()
36 if (location.href.match(/^(http.+?\/.+\/)/)) {
37 E('backup-link').href = RegExp.$1 + 'bwm/' + fixFile(E('backup-name').value) + '.gz?_http_id=' + nvram.http_id;
41 function backupButton()
43 var name;
45 name = fixFile(E('backup-name').value);
46 if (name.length <= 1) {
47 alert('Invalid filename');
48 return;
50 location.href = 'bwm/' + name + '.gz?_http_id=' + nvram.http_id;
53 function restoreButton()
55 var fom;
56 var name;
57 var i;
59 name = fixFile(E('restore-name').value);
60 name = name.toLowerCase();
61 if ((name.length <= 3) || (name.substring(name.length - 3, name.length).toLowerCase() != '.gz')) {
62 alert('Incorrect filename. Expecting a ".gz" file.');
63 return;
65 if (!confirm('Restore data from ' + name + '?')) return;
67 E('restore-button').disabled = 1;
68 fields.disableAll(E('config-section'), 1);
69 fields.disableAll(E('backup-section'), 1);
70 fields.disableAll(E('footer'), 1);
72 E('restore-form').submit();
75 function getPath()
77 var s = E('_f_loc').value;
78 return (s == '*user') ? E('_f_user').value : s;
81 function verifyFields(focused, quiet)
83 var b, v;
84 var path;
85 var eLoc, eUser, eTime, eOfs;
86 var bak;
88 eLoc = E('_f_loc');
89 eUser = E('_f_user');
90 eTime = E('_rstats_stime');
91 eOfs = E('_rstats_offset');
93 b = !E('_f_rstats_enable').checked;
94 eLoc.disabled = b;
95 eUser.disabled = b;
96 eTime.disabled = b;
97 eOfs.disabled = b;
98 E('_f_new').disabled = b;
99 E('_f_sshut').disabled = b;
100 E('backup-button').disabled = b;
101 E('backup-name').disabled = b;
102 E('restore-button').disabled = b;
103 E('restore-name').disabled = b;
104 ferror.clear(eLoc);
105 ferror.clear(eUser);
106 ferror.clear(eOfs);
107 if (b) return 1;
109 path = getPath();
110 E('newmsg').style.visibility = ((nvram.rstats_path != path) && (path != '*nvram') && (path != '')) ? 'visible' : 'hidden';
112 bak = 0;
113 v = eLoc.value;
114 b = (v == '*user');
115 elem.display(eUser, b);
116 if (b) {
117 if (!v_path(eUser, quiet, 1)) return 0;
119 /* JFFS2-BEGIN */
120 else if (v == '/jffs/') {
121 if (nvram.jffs2_on != '1') {
122 ferror.set(eLoc, 'JFFS2 is not enabled.', quiet);
123 return 0;
126 /* JFFS2-END */
127 /* CIFS-BEGIN */
128 else if (v.match(/^\/cifs(1|2)\/$/)) {
129 if (nvram['cifs' + RegExp.$1].substr(0, 1) != '1') {
130 ferror.set(eLoc, 'CIFS #' + RegExp.$1 + ' is not enabled.', quiet);
131 return 0;
134 /* CIFS-END */
135 else {
136 bak = 1;
139 E('_f_bak').disabled = bak;
141 return v_range(eOfs, quiet, 1, 31);
144 function save()
146 var fom, path, en, e, aj;
148 if (!verifyFields(null, false)) return;
150 aj = 1;
151 en = E('_f_rstats_enable').checked;
152 fom = E('_fom');
153 fom._service.value = 'rstats-restart';
154 if (en) {
155 path = getPath();
156 if (((E('_rstats_stime').value * 1) <= 48) &&
157 ((path == '*nvram') || (path == '/jffs/'))) {
158 if (!confirm('Frequent saving to NVRAM or JFFS2 is not recommended. Continue anyway?')) return;
160 if ((nvram.rstats_path != path) && (fom.rstats_path.value != path) && (path != '') && (path != '*nvram') &&
161 (path.substr(path.length - 1, 1) != '/')) {
162 if (!confirm('Note: ' + path + ' will be treated as a file. If this is a directory, please use a trailing /. Continue anyway?')) return;
164 fom.rstats_path.value = path;
166 if (E('_f_new').checked) {
167 fom._service.value = 'rstatsnew-restart';
168 aj = 0;
172 fom.rstats_path.disabled = !en;
173 fom.rstats_enable.value = en ? 1 : 0;
174 fom.rstats_sshut.value = E('_f_sshut').checked ? 1 : 0;
175 fom.rstats_bak.value = E('_f_bak').checked ? 1 : 0;
177 e = E('_rstats_exclude');
178 e.value = e.value.replace(/\s+/g, ',').replace(/,+/g, ',');
180 fields.disableAll(E('backup-section'), 1);
181 fields.disableAll(E('restore-section'), 1);
182 form.submit(fom, aj);
183 if (en) {
184 fields.disableAll(E('backup-section'), 0);
185 fields.disableAll(E('restore-section'), 0);
189 function init()
191 backupNameChanged();
193 </script>
195 </head>
196 <body onload="init()">
197 <table id='container' cellspacing=0>
198 <tr><td colspan=2 id='header'>
199 <div class='title'>Tomato</div>
200 <div class='version'>Version <% version(); %></div>
201 </td></tr>
202 <tr id='body'><td id='navi'><script type='text/javascript'>navi()</script></td>
203 <td id='content'>
204 <div id='ident'><% ident(); %></div>
206 <!-- / / / -->
208 <div class='section-title'>Bandwidth Monitoring</div>
209 <div class='section' id='config-section'>
210 <form id='_fom' method='post' action='tomato.cgi'>
211 <input type='hidden' name='_nextpage' value='admin-bwm.asp'>
212 <input type='hidden' name='_service' value='rstats-restart'>
213 <input type='hidden' name='rstats_enable'>
214 <input type='hidden' name='rstats_path'>
215 <input type='hidden' name='rstats_sshut'>
216 <input type='hidden' name='rstats_bak'>
218 <script type='text/javascript'>
219 switch (nvram.rstats_path) {
220 case '':
221 case '*nvram':
222 case '/jffs/':
223 case '/cifs1/':
224 case '/cifs2/':
225 loc = nvram.rstats_path;
226 break;
227 default:
228 loc = '*user';
229 break;
231 createFieldTable('', [
232 { title: 'Enable', name: 'f_rstats_enable', type: 'checkbox', value: nvram.rstats_enable == '1' },
233 { title: 'Save History Location', multi: [
234 { name: 'f_loc', type: 'select', options: [['','RAM (Temporary)'],['*nvram','NVRAM'],
235 /* JFFS2-BEGIN */
236 ['/jffs/','JFFS2'],
237 /* JFFS2-END */
238 /* CIFS-BEGIN */
239 ['/cifs1/','CIFS 1'],['/cifs2/','CIFS 2'],
240 /* CIFS-END */
241 ['*user','Custom Path']], value: loc },
242 { name: 'f_user', type: 'text', maxlen: 48, size: 50, value: nvram.rstats_path }
243 ] },
244 { title: 'Save Frequency', indent: 2, name: 'rstats_stime', type: 'select', value: nvram.rstats_stime, options: [
245 [1,'Every Hour'],[2,'Every 2 Hours'],[3,'Every 3 Hours'],[4,'Every 4 Hours'],[5,'Every 5 Hours'],[6,'Every 6 Hours'],
246 [9,'Every 9 Hours'],[12,'Every 12 Hours'],[24,'Every 24 Hours'],[48,'Every 2 Days'],[72,'Every 3 Days'],[96,'Every 4 Days'],
247 [120,'Every 5 Days'],[144,'Every 6 Days'],[168,'Every Week']] },
248 { title: 'Save On Shutdown', indent: 2, name: 'f_sshut', type: 'checkbox', value: nvram.rstats_sshut == '1' },
249 { title: 'Create New File<br><small>(Reset Data)</small>', indent: 2, name: 'f_new', type: 'checkbox', value: 0,
250 suffix: ' &nbsp; <b id="newmsg" style="visibility:hidden"><small>(note: enable if this is a new file)</small></b>' },
251 { title: 'Create Backups', indent: 2, name: 'f_bak', type: 'checkbox', value: nvram.rstats_bak == '1' },
252 { title: 'First Day Of The Month', name: 'rstats_offset', type: 'text', value: nvram.rstats_offset, maxlen: 2, size: 4 },
253 { title: 'Excluded Interfaces', name: 'rstats_exclude', type: 'text', value: nvram.rstats_exclude, maxlen: 64, size: 50, suffix: '&nbsp;<small>(comma separated list)</small>' }
255 </script>
256 </form>
257 </div>
259 <br>
261 <div class='section-title'>Backup</div>
262 <div class='section' id='backup-section'>
263 <form>
264 <script type='text/javascript'>
265 W("<input type='text' size='40' maxlength='64' id='backup-name' name='backup_name' onchange='backupNameChanged()' value='tomato_rstats_" + nvram.et0macaddr.replace(/:/g, '').toLowerCase() + "'>");
266 </script>
267 .gz &nbsp;
268 <input type='button' name='f_backup_button' id='backup-button' onclick='backupButton()' value='Backup'>
269 &nbsp;&nbsp;&nbsp;<a href='' id='backup-link'>Direct Download Link</a>
270 </form>
271 </div>
272 <br>
274 <div class='section-title'>Restore</div>
275 <div class='section' id='restore-section'>
276 <form id='restore-form' method='post' action='bwm/restore.cgi?_http_id=<% nv(http_id); %>' encType='multipart/form-data'>
277 <input type='file' size='40' id='restore-name' name='restore_name'>
278 <input type='button' name='f_restore_button' id='restore-button' value='Restore' onclick='restoreButton()'>
279 <br>
280 </form>
281 </div>
283 <!-- / / / -->
285 </td></tr>
286 <tr><td id='footer' colspan=2>
287 <form>
288 <span id='footer-msg'></span>
289 <input type='button' value='Save' id='save-button' onclick='save()'>
290 <input type='button' value='Cancel' id='cancel-button' onclick='javascript:reloadPage();'>
291 </form>
292 <div></div>
293 </td></tr>
294 </table>
295 <script type='text/javascript'>verifyFields(null, 1);</script>
296 </body>
297 </html>