Skip to content

Commit

Permalink
bandwidth.sh: transition to i18n form; SVG labels NOT done
Browse files Browse the repository at this point in the history
  • Loading branch information
BashfulBladder committed Jun 22, 2013
1 parent 90285f0 commit 7f9c7cf
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 60 deletions.
94 changes: 47 additions & 47 deletions package/gargoyle/files/www/bandwidth.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/haserl
<?
# This program is copyright © 2008-2010 Eric Bishop and is distributed under the terms of the GNU GPL
#!/usr/bin/haserl2
<%
# This program is copyright © 2008-2013 Eric Bishop and is distributed under the terms of the GNU GPL
# version 2.0 with a special clarification/exception that permits adapting the program to
# configure proprietary "back end" software provided that all modifications to the web interface
# itself remain covered by the GPL.
# See http://gargoyle-router.com/faq.html#qfoss for more information
eval $( gargoyle_session_validator -c "$COOKIE_hash" -e "$COOKIE_exp" -a "$HTTP_USER_AGENT" -i "$REMOTE_ADDR" -r "login.sh" -t $(uci get gargoyle.global.session_timeout) -b "$COOKIE_browser_time" )
gargoyle_header_footer -h -s "status" -p "bandwidth" -c "internal.css" -j "table.js bandwidth.js" -n -i gargoyle qos_gargoyle
?>
gargoyle_header_footer -h -s "status" -p "bandwidth" -c "internal.css" -j "table.js bandwidth.js" -z "bandwidth.js" -n -i gargoyle qos_gargoyle
%>

<script>
<!--
<?
<%
echo 'var monitorNames = new Array();'
mnames=$(cat /tmp/bw_backup/*.sh 2>/dev/null | egrep "bw_get" | sed 's/^.*\-i \"//g' | sed 's/\".*$//g')
for m in $mnames ; do
Expand All @@ -23,92 +23,92 @@
tz_m=$(($tz_hundred_hours-($tz_h*100)))
tz_minutes=$((($tz_h*60)+$tz_m))
echo "var tzMinutes = $tz_minutes;";
?>
%>
//-->
</script>

<form>
<fieldset>
<legend class="sectionheader">Bandwidth Graph Display Options</legend>
<legend class="sectionheader"><%~ bandwidth.GOpSect %></legend>
<div>
<label for='plot_time_frame' id='time_frame_label'>Time Frame:</label>
<label for='plot_time_frame' id='time_frame_label'><%~ TFrm %>:</label>
<select id="plot_time_frame" onchange="resetPlots()">
<option value="1">15 Minutes</option>
<option value="2"> 6 Hours</option>
<option value="3">24 Hours</option>
<option value="4">30 Days</option>
<option value="5"> 1 Year</option>
<option value="1">15 <%~ minutes %></option>
<option value="2"> 6 <%~ hours %></option>
<option value="3">24 <%~ hours %></option>
<option value="4">30 <%~ days %></option>
<option value="5"> 1 <%~ year %></option>
</select>
</div>

<div id="control_column_container">
<div id="plot1_control_column">
<div><span id="plot1_title">Plot 1</span></div>
<div><select id="plot1_type" onchange="resetPlots()" ><option value="total">Total Bandwidth</option></select></div>
<div><span id="plot1_title"><%~ Plot %> 1</span></div>
<div><select id="plot1_type" onchange="resetPlots()" ><option value="total"><%~ TBdw %></option></select></div>
<div><select id="plot1_id" onchange="resetPlots()"></select></div>

</div>
<div id="plot2_control_column">
<div><span id="plot2_title">Plot 2</span></div>
<div><select id="plot2_type" onchange="resetPlots()" ><option value="none">None</option></select></div>
<div><span id="plot2_title"><%~ Plot %> 2</span></div>
<div><select id="plot2_type" onchange="resetPlots()" ><option value="none"><%~ None %></option></select></div>
<div><select id="plot2_id" onchange="resetPlots()"></select></div>
</div>
<div id="plot3_control_column">
<div><span id="plot3_title">Plot 3</span></div>
<div><select id="plot3_type" onchange="resetPlots()"><option value="none">None</option></select></div>
<div><span id="plot3_title"><%~ Plot %> 3</span></div>
<div><select id="plot3_type" onchange="resetPlots()"><option value="none"><%~ None %></option></select></div>
<div><select id="plot3_id" onchange="resetPlots()"></select></div>
</div>
</div>

<div>
<input type="checkbox" id="use_high_res_15m" onclick="highResChanged()">&nbsp;
<label id="use_high_res_15m_label" for="use_high_res_15m">Save High Resolution 15 Minute Timeframe Data For All Hosts</label>
<label id="use_high_res_15m_label" for="use_high_res_15m"><%~ HRInf %></label>
<br/>
<em>Not recommended for routers with &lt; 32MB of RAM</em>
<em><%~ HRWrn %></em>
</div>

<br/>All bandwidth usage reported is via the WAN interface only.
<br/>Traffic between local hosts is not reported.
<br/><%~ UsInf %>
<br/><%~ LclTrff %>
</fieldset>

<fieldset id="bandwidth_graphs">
<legend class="sectionheader">Bandwidth Graphs</legend>
<span class="bandwidth_title_text"><strong>Download</strong> (<span onclick='expand("Download")' class="pseudo_link">expand</span>)</span>
<span class="bandwidth_title_text"><strong>Upload</strong> (<span onclick='expand("Upload")' class="pseudo_link">expand</span>)</span>
<legend class="sectionheader"><%~ BGrSect %></legend>
<span class="bandwidth_title_text"><strong><%~ Dnld %></strong> (<span onclick='expand("Download","<%~ Dnld %>")' class="pseudo_link"><%~ expd %></span>)</span>
<span class="bandwidth_title_text"><strong><%~ Upld %></strong> (<span onclick='expand("Upload","<%~ Upld %>")' class="pseudo_link"><%~ expd %></span>)</span>
<br/>
<embed id="download_plot" style="margin-left:0px; margin-right:5px; float:left; width:240px; height:180px;" src="bandwidth.svg" type='image/svg+xml' pluginspage='http://www.adobe.com/svg/viewer/install/' />
<embed id="upload_plot" style="margin-left:0px; margin-right:5px; float:left; width:240px; height:180px;" src="bandwidth.svg" type='image/svg+xml' pluginspage='http://www.adobe.com/svg/viewer/install/' />
<br/>
<span class="bandwidth_title_text"><strong>Total</strong> (<span onclick='expand("Total")' class="pseudo_link">expand</span>)</span>
<span class="bandwidth_title_text"><strong><%~ Totl %></strong> (<span onclick='expand("Total","<%~ Totl %>")' class="pseudo_link"><%~ expd %></span>)</span>
<br/>
<embed id="total_plot" style="margin-left:0px; width:480px; height:360px;" src="bandwidth.svg" type='image/svg+xml' pluginspage='http://www.adobe.com/svg/viewer/install/' />
</fieldset>
<fieldset id="total_bandwidth_use">
<legend class="sectionheader">Bandwidth Usage Table</legend>
<legend class="sectionheader"><%~ BUTab %></legend>
<div>
<label for='table_time_frame' class="narrowleftcolumn" id='table_time_frame_label'>Display Interval:</label>
<label for='table_time_frame' class="narrowleftcolumn" id='table_time_frame_label'><%~ DspI %>:</label>
<select id="table_time_frame" class="rightcolumn" onchange="resetPlots()">
<option value="1">Minutes</option>
<option value="2">Quarter Hours</option>
<option value="3">Hours</option>
<option value="4">Days</option>
<option value="5">Months</option>
<option value="1"><%~ minutes %></option>
<option value="2"><%~ qhour %></option>
<option value="3"><%~ hours %></option>
<option value="4"><%~ days %></option>
<option value="5"><%~ mnths %></option>
</select>
</div>
<div>
<label for='table_type' class="narrowleftcolumn" id='total_type_label'>Display Type:</label>
<label for='table_type' class="narrowleftcolumn" id='total_type_label'><%~ DspT %>:</label>
<select id="table_type" class="rightcolumn" onchange="resetPlots()">
<option value="total">Total Bandwidth</option>
<option value="total"><%~ TBdw %></option>
</select>
</div>
<div id="table_id_container" style="display:none" >
<label for='table_id' class="narrowleftcolumn" id='total_id_label'>Display Id:</label>
<label for='table_id' class="narrowleftcolumn" id='total_id_label'><%~ DspID %>:</label>
<select id="table_id" class="rightcolumn" onchange="resetPlots()"></select>
</div>
<div class="bottom_gap">
<label for='table_units' class="narrowleftcolumn" id='table_units_label'>Table Units:</label>
<label for='table_units' class="narrowleftcolumn" id='table_units_label'><%~ TbUnt %>:</label>
<select id="table_units" class="rightcolumn" onchange="resetPlots()">
<option value="mixed">Auto (Mixed)</option>
<option value="mixed"><%~ AutoM %></option>
<option value="KBytes">KBytes</option>
<option value="MBytes">MBytes</option>
<option value="GBytes">GBytes</option>
Expand All @@ -119,21 +119,21 @@
<div id="bandwidth_table_container"></div>

<div>
<center><input type='button' id='delete_data_button' class='big_button' value='Delete Data' onclick='deleteData();' /></center>
<center><input type='button' id='delete_data_button' class='big_button' value='<%~ DelD %>' onclick='deleteData();' /></center>
</div>

</fieldset>

<fieldset id="download_bandwidth_data" >
<legend class="sectionheader">Download Bandwidth Data</legend>
<legend class="sectionheader"><%~ DBData %></legend>
<div>
<span style='text-decoration:underline'>Data is comma separated:</span>
<span style='text-decoration:underline'><%~ DSep %>:</span>
<br/>
<em>[Direction],[Interval Length],[Intervals Saved],[IP],[Interval Start],[Interval End],[Bytes Used]</em>
<em><%~ DFmt %></em>
<br/>
</div>
<div>
<center><input type='button' id='download_data_button' class='big_button' value='Download Now' onclick='window.location="bandwidth.csv";' /></center>
<center><input type='button' id='download_data_button' class='big_button' value='<%~ DNow %>' onclick='window.location="bandwidth.csv";' /></center>
</div>
</fieldset>
</form>
Expand All @@ -146,6 +146,6 @@
//-->
</script>

<?
<%
gargoyle_header_footer -f -s "status" -p "bandwidth"
?>
%>
6 changes: 3 additions & 3 deletions package/gargoyle/files/www/bandwidth_expand.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/haserl
<?
# This program is copyright © 2008,2009 Eric Bishop and is distributed under the terms of the GNU GPL
<%
# This program is copyright © 2008,2009,2013 Eric Bishop and is distributed under the terms of the GNU GPL
# version 2.0 with a special clarification/exception that permits adapting the program to
# configure proprietary "back end" software provided that all modifications to the web interface
# itself remain covered by the GPL.
# See http://gargoyle-router.com/faq.html#qfoss for more information
eval $( gargoyle_session_validator -c "$COOKIE_hash" -e "$COOKIE_exp" -a "$HTTP_USER_AGENT" -i "$REMOTE_ADDR" -r "login.sh" -t $(uci get gargoyle.global.session_timeout) -b "$COOKIE_browser_time" )
gargoyle_header_footer -m -c "internal.css" -j gargoyle_header_footer -m -c "internal.css"
?>
%>
<strong><span id="plot_title" style="margin-left:10px;"></span></strong>
<embed id="bandwidth_plot" style="margin-left:10px; margin-right:10px; width:800px; height:600px;" src="bandwidth.svg" type='image/svg+xml' pluginspage='http://www.adobe.com/svg/viewer/install/'></embed>

Expand Down
22 changes: 12 additions & 10 deletions package/gargoyle/files/www/js/bandwidth.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/*
* This program is copyright 2008-2012 Eric Bishop and is distributed under the terms of the GNU GPL
* This program is copyright 2008-2013 Eric Bishop and is distributed under the terms of the GNU GPL
* version 2.0 with a special clarification/exception that permits adapting the program to
* configure proprietary "back end" software provided that all modifications to the web interface
* itself remain covered by the GPL.
* See http://gargoyle-router.com/faq.html#qfoss for more information
*/
var bndwS=new Object(); //part of i18n

var ipMonitorIds;
var qosUploadMonitorIds;
var qosDownloadMonitorIds;
Expand Down Expand Up @@ -147,11 +149,11 @@ function initializePlotsAndTable()
var plotIdName = plotIdNames[idIndex];
if(haveQosUpload)
{
addOptionToSelectElement(plotIdName, "QoS Upload Class", "qos-upload");
addOptionToSelectElement(plotIdName, "QoS "+bndwS.UpCl, "qos-upload");
}
if(haveQosDownload)
{
addOptionToSelectElement(plotIdName, "QoS Download Class", "qos-download");
addOptionToSelectElement(plotIdName, "QoS "+bndwS.DlCl, "qos-download");
}
if(haveTor)
{
Expand All @@ -162,7 +164,7 @@ function initializePlotsAndTable()
addOptionToSelectElement(plotIdName, "OpenVPN", "openvpn");
}

addOptionToSelectElement(plotIdName, "Hostname", "hostname");
addOptionToSelectElement(plotIdName, bndwS.HsNm, "hostname");
addOptionToSelectElement(plotIdName, "IP", "ip");


Expand Down Expand Up @@ -735,7 +737,7 @@ function updateBandwidthTable(tablePointSets, interval, tableLastTimePoint)
// So, always add three hours, so when DST shifts an hour back in November date doesn't get pushed back to previous month and wrong month is displayed
nextDate = new Date( nextDate.getTime() + (3*60*60*1000))
}
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var monthNames = bndwS.EMonths;

for(rowIndex=0; rowIndex < (tablePointSets[0]).length; rowIndex++)
{
Expand Down Expand Up @@ -792,7 +794,7 @@ function updateBandwidthTable(tablePointSets, interval, tableLastTimePoint)
timePoint = nextDate.getTime()/1000;
}

var columnNames = ["Time", "Total", "Download", "Upload"];
var columnNames = [bndwS.Time, bndwS.Totl, bndwS.Dnld, bndwS.Dnld];
var bwTable=createTable(columnNames , rowData, "bandwidth_table", false, false);
tableContainer = document.getElementById('bandwidth_table_container');
if(tableContainer.firstChild != null)
Expand All @@ -804,7 +806,7 @@ function updateBandwidthTable(tablePointSets, interval, tableLastTimePoint)



function expand(name)
function expand(name, trname)
{
var expWindow = expandedWindows[name];
var xCoor = 0;
Expand All @@ -825,7 +827,7 @@ function expand(name)
xCoor = window.left + 225;
yCoor = window.top + 225;
}
expWindow= window.open("bandwidth_expand.sh", name + " Bandwidth Plot", "width=850,height=650,left=" + xCoor + ",top=" + yCoor );
expWindow= window.open("bandwidth_expand.sh", trname==null?name:trname + " "+bndwS.BPlot, "width=850,height=650,left=" + xCoor + ",top=" + yCoor );
expandedWindows[name] = expWindow;

var runOnWindowLoad = function(name)
Expand All @@ -842,7 +844,7 @@ function expand(name)
expandedFunctions[name] = getEmbeddedSvgPlotFunction("bandwidth_plot", loadWin.document);
if(expandedFunctions[name] != null)
{
plotTitle.appendChild(loadWin.document.createTextNode(name + " Bandwidth Usage"));
plotTitle.appendChild(loadWin.document.createTextNode(trname==null?name:trname + " "+bndwS.BUsag));
loadWin.onbeforeunload=function(){ expandedFunctions[name] = null; expandedWindows[name] = null; }
loaded = true;
}
Expand All @@ -860,7 +862,7 @@ function expand(name)

function highResChanged()
{
setControlsEnabled(false, true, "Resetting Graphs...");
setControlsEnabled(false, true, bndwS.RstGr);

var useHighRes15m = document.getElementById("use_high_res_15m").checked;
var commands = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* UTF-8 (with BOM) English-EN text strings for bandwidth.sh html elements
*/

bndwS.GOpSect="Bandwidth Graph Display Options";
bndwS.TFrm="Time Frame";
bndwS.year="year";
bndwS.Plot="Plot";
bndwS.TBdw="Total Bandwidth";
bndwS.None="None";
bndwS.HRInf="Save High Resolution 15 Minute Timeframe Data For All Hosts";
bndwS.HRWrn="Not recommended for routers with &lt; 32MB of RAM";
bndwS.UsInf="All bandwidth usage reported is via the WAN interface only.";
bndwS.LclTrff="Traffic between local hosts is not reported.";
bndwS.BGrSect="Bandwidth Graphs";
bndwS.Dnld="Download";
bndwS.Upld="Upload";
bndwS.Totl="Total";
bndwS.BUTab="Bandwidth Usage Table";
bndwS.DspI="Display Interval";
bndwS.qhour="quarter hours";
bndwS.mnths="months";
bndwS.DspT="Display Type";
bndwS.DspID="Display Id";
bndwS.TbUnt="Table Units";
bndwS.AutoM="Auto (Mixed)";
bndwS.DelD="Delete Data";
bndwS.DBData="Download Bandwidth Data";
bndwS.DSep="Data is comma separated";
bndwS.DFmt="[Direction],[Interval Length],[Intervals Saved],[IP],[Interval Start],[Interval End],[Bytes Used]";
bndwS.DNow="Download Now";
bndwS.expd="expand";

//javascript
bndwS.UpCl="Upload Class";
bndwS.DlCl="Download Class";
bndwS.HsNm="Hostname"
bndwS.EMonths=["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
bndwS.Time="Time";
bndwS.BPlot="Bandwidth Plot";
bndwS.BUsag="Bandwidth Usage";
bndwS.RstGr="Resetting Graphs...";
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* UTF-8 (with BOM) Spanish-ES text strings for bandwidth.sh html elements
*/

bndwS.GOpSect="Ancho de Banda Gráfico Opciones de Visualización";
bndwS.TFrm="Marco de Tiempo";
bndwS.Plot="Gráfico";
bndwS.TBdw="Ancho de Banda Total";
bndwS.None="Ninguno";
bndwS.HRInf="Guardar Alta Resolución 15 Minuto Periodo de Ejecución de Datos Para Todos los hosts";
bndwS.HRWrn="No recomendado para routers con &lt; 32MB de RAM";
bndwS.UsInf="Todo el uso de ancho de banda es reportado a través de la interfaz WAN sólo.";
bndwS.LclTrff="No se informa del tráfico entre los hosts locales.";
bndwS.BGrSect="Gráficos de Ancho de Banda";
bndwS.Dnld="Descargar";
bndwS.Upld="Cargar";
bndwS.Totl="Total";
bndwS.BUTab="Ancho de Banda de la Tabla Uso";
bndwS.DspI="Indicador de Intervalos";
bndwS.qhour="cuartos de hora";
bndwS.mnths="meses";
bndwS.year="año";
bndwS.DspT="Tipo de Pantalla";
bndwS.DspID="Pantalla Id";
bndwS.TbUnt="Tabla Unidades";
bndwS.AutoM="Auto (mixto)";
bndwS.DelD="Eliminar datos";
bndwS.DBData="Descarga de Datos de Ancho de Banda";
bndwS.DSep="Los datos son separadas por comas";
bndwS.DFmt="[Dirección],[Duración del Intervalo],[Intervalos Guardadas],[IP],[Inicio del Intervalo],[Fin del Intervalo],[Bytes Usados]";
bndwS.DNow="Descargar Ahora";
bndwS.expd="expandirse";

//javascript
bndwS.UpCl="Clase de Carga";
bndwS.DlCl="Clase de Descarga";
bndwS.HsNm="Nombre de host"
bndwS.EMonths=["ene", "feb", "mar", "abr", "may", "jun", "jul", "ago", "sep", "oct", "nov", "dic"];
bndwS.Time="Tiempo";
bndwS.BPlot="Ancho de Banda Gráfico";
bndwS.BUsag="Uso de Ancho de Banda";
bndwS.RstGr="Gráficos Restablecer...";

0 comments on commit 7f9c7cf

Please sign in to comment.