diff options
author | Renato Botelho <garga@pfSense.org> | 2013-08-15 12:17:37 -0700 |
---|---|---|
committer | Renato Botelho <garga@pfSense.org> | 2013-08-15 12:17:37 -0700 |
commit | f59c7ae0b5ea1104ae684b23c3029593a7e12728 (patch) | |
tree | 977bbf0ba6652751edd2ae1ef46f4a7f222e1a86 /usr | |
parent | 108e868d70ab8d0ff546f93c98d5ccd1110bd295 (diff) | |
parent | 5ef8ec8891b59d08d8d6f947cba2c88d4785a2fc (diff) | |
download | pfsense-f59c7ae0b5ea1104ae684b23c3029593a7e12728.zip pfsense-f59c7ae0b5ea1104ae684b23c3029593a7e12728.tar.gz |
Merge pull request #772 from CharlieMarshall/jQueryWidgets
convert dashboard progress bars to jqueryUI
Diffstat (limited to 'usr')
-rw-r--r-- | usr/local/www/javascript/index/ajax.js | 33 | ||||
-rwxr-xr-x | usr/local/www/javascript/jquery/jquery-ui.custom.css | 6 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/system_information.widget.php | 49 |
3 files changed, 45 insertions, 43 deletions
diff --git a/usr/local/www/javascript/index/ajax.js b/usr/local/www/javascript/index/ajax.js index fa33914..73bd208 100644 --- a/usr/local/www/javascript/index/ajax.js +++ b/usr/local/www/javascript/index/ajax.js @@ -51,10 +51,8 @@ function stats(x) { function updateMemory(x) { if(jQuery('#memusagemeter')) jQuery("#memusagemeter").html(x + '%'); - if(jQuery('#memwidtha')) - jQuery("#memwidtha").css('width',x + 'px'); - if(jQuery('#memwidthb')) - jQuery("#memwidthb").css('width', (100 - x) + 'px'); + if(jQuery('#memUsagePB')) + jQuery('#memUsagePB').progressbar( { value: parseInt(x) } ); } function updateMbuf(x) { @@ -65,19 +63,15 @@ function updateMbuf(x) { function updateMbufMeter(x) { if(jQuery('#mbufusagemeter')) jQuery("#mbufusagemeter").html(x + '%'); - if(jQuery('#mbufwidtha')) - jQuery("#mbufwidtha").css('width',x + 'px'); - if(jQuery('#mbufwidthb')) - jQuery("#mbufwidthb").css('width', (100 - x) + 'px'); + if(jQuery('#mbufPB')) + jQuery('#mbufPB').progressbar( { value: parseInt(x) } ); } function updateCPU(x) { if(jQuery('#cpumeter')) jQuery("#cpumeter").html(x + '%'); - if(jQuery('#cpuwidtha')) - jQuery("#cpuwidtha").css('width',x + 'px'); - if(jQuery('#cpuwidthb')) - jQuery("#cpuwidthb").css('width',(100 - x) + 'px'); + if(jQuery('#cpuPB')) + jQuery('#cpuPB').progressbar( { value: parseInt(x) } ); /* Load CPU Graph widget if enabled */ if(widgetActive('cpu_graphs')) { GraphValue(graph[0], x); @@ -87,10 +81,8 @@ function updateCPU(x) { function updateTemp(x) { if(jQuery("#tempmeter")) jQuery("#tempmeter").html(x + '\u00B0' + 'C'); - if(jQuery('#tempwidtha')) - jQuery("#tempwidtha").css('width',x + 'px'); - if(jQuery('#tempwidthb')) - jQuery("#tempwidthb").css('width',(100 - x) + 'px'); + if(jQuery('#tempPB')) + jQuery("#tempPB").progressbar( { value: parseInt(x) } ); } function updateDateTime(x) { @@ -111,10 +103,8 @@ function updateState(x) { function updateStateMeter(x) { if(jQuery('#pfstateusagemeter')) jQuery("#pfstateusagemeter").html(x + '%'); - if(jQuery('#pfstatewidtha')) - jQuery("#pfstatewidtha").css('width',x + 'px'); - if(jQuery('#pfstatewidthb')) - jQuery("#pfstatewidthb").css('width',(100 - x) + 'px'); + if(jQuery('#statePB')) + jQuery('#statePB').progressbar( { value: parseInt(x) } ); } function updateGatewayStats(x){ @@ -192,4 +182,5 @@ function widgetActive(x) { /* start updater */ jQuery(document).ready(function(){ setTimer(); -});
\ No newline at end of file +}); + diff --git a/usr/local/www/javascript/jquery/jquery-ui.custom.css b/usr/local/www/javascript/jquery/jquery-ui.custom.css index 6f4a5ac..7dca82a 100755 --- a/usr/local/www/javascript/jquery/jquery-ui.custom.css +++ b/usr/local/www/javascript/jquery/jquery-ui.custom.css @@ -58,7 +58,7 @@ .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Trebuchet MS, Helvetica, Arial, sans-serif; font-size: 1em; } .ui-widget-content { border: 1px solid #aaaaaa; background: #c9c9c9 url(images/ui-bg_inset-soft_50_c9c9c9_1x100.png) 50% bottom repeat-x; color: #333333; } .ui-widget-content a { color: #333333; } -.ui-widget-header { border: 1px solid #bbbbbb; background: #dddddd url(images/ui-bg_glass_35_dddddd_1x400.png) 50% 50% repeat-x; color: #444444; font-weight: bold; } +.ui-widget-header { border: 1px solid #bbbbbb; color: #444444; font-weight: bold; } .ui-widget-header a { color: #444444; } /* Interaction states @@ -561,5 +561,5 @@ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra pad * * http://docs.jquery.com/UI/Progressbar#theming */ -.ui-progressbar { height:2em; text-align: left; overflow: hidden; } -.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
\ No newline at end of file +.ui-progressbar { height:1em; text-align: left; overflow: hidden; } +.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; background-color:#990000; } diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php index 2bba499..398fc47 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -85,6 +85,23 @@ if($_REQUEST['getupdatestatus']) { $curcfg = $config['system']['firmware']; ?> +<script> + jQuery(function() { + jQuery("#statePB").progressbar( { value: <?php echo get_pfstate(true); ?> } ); + jQuery("#mbufPB").progressbar( { value: <?php echo get_mbuf(true); ?> } ); + jQuery("#cpuPB").progressbar( { value:false } ); + jQuery("#memUsagePB").progressbar( { value: <?php echo mem_usage(); ?> } ); + jQuery("#diskUsagePB").progressbar( { value: <?php echo disk_usage(); ?> } ); + + <?php if($showswap == true): ?> + jQuery("#swapUsagePB").progressbar( { value: <?php echo swap_usage(); ?> } ); + <?php endif; ?> + <?php if (get_temp() != ""): ?> + jQuery("#tempPB").progressbar( { value: <?php echo get_temp(); ?> } ); + <?php endif; ?> + }); +</script> +<link rel="stylesheet" href="javascript/jquery/jquery-ui.custom.css" /> <table width="100%" border="0" cellspacing="0" cellpadding="0" summary="system information"> <tbody> @@ -189,8 +206,8 @@ $curcfg = $config['system']['firmware']; <?php $pfstatetext = get_pfstate(); $pfstateusage = get_pfstate(true); ?> - <img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" name="pfstatewidtha" id="pfstatewidtha" width="<?= round($pfstateusage); ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" name="pfstatewidthb" id="pfstatewidthb" width="<?= (100 - $pfstateusage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" /> - <br/><span id="pfstateusagemeter"><?= $pfstateusage.'%'; ?></span> (<span id="pfstate"><?= htmlspecialchars($pfstatetext); ?></span>) + <div id="statePB"></div> + <span id="pfstateusagemeter"><?= $pfstateusage.'%'; ?></span> (<span id="pfstate"><?= htmlspecialchars($pfstatetext); ?></span>) <br /> <a href="diag_dump_states.php"><?=gettext("Show states");?></a> </td> @@ -202,8 +219,8 @@ $curcfg = $config['system']['firmware']; $mbufstext = get_mbuf(); $mbufusage = get_mbuf(true); ?> - <img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" name="mbufwidtha" id="mbufwidtha" width="<?= round($mbufusage); ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" name="mbufwidthb" id="mbufwidthb" width="<?= (100 - $mbufusage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" /> - <br/><span id="mbufusagemeter"><?= $mbufusage.'%'; ?></span> (<span id="mbuf"><?= $mbufstext ?></span>) + <div id="mbufPB"></div> + <span id="mbufusagemeter"><?= $mbufusage.'%'; ?></span> (<span id="mbuf"><?= $mbufstext ?></span>) </td> </tr> <?php if (get_temp() != ""): ?> @@ -211,8 +228,7 @@ $curcfg = $config['system']['firmware']; <td width="25%" class="vncellt"><?=gettext("Temperature");?></td> <td width="75%" class="listr"> <?php $TempMeter = $temp = get_temp(); ?> - <img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" name="tempwidtha" id="tempwidtha" width="<?= round($TempMeter); ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" name="tempwidthb" id="tempwidthb" width="<?= (100 - $TempMeter); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" /> - + <div id="tempPB"></div> <span id="tempmeter"><?= $temp."°C"; ?></span> </td> </tr> @@ -226,19 +242,16 @@ $curcfg = $config['system']['firmware']; <tr> <td width="25%" class="vncellt"><?=gettext("CPU usage");?></td> <td width="75%" class="listr"> - <?php $cpuUsage = "0"; ?> - <img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" name="cpuwidtha" id="cpuwidtha" width="<?= $cpuUsage; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" name="cpuwidthb" id="cpuwidthb" width="<?= (100 - $cpuUsage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" /> - - <br/><span id="cpumeter">(Updating in 10 seconds)</span> + <div id="cpuPB"></div> + <span id="cpumeter">(Updating in 10 seconds)</span> </td> </tr> <tr> <td width="25%" class="vncellt"><?=gettext("Memory usage");?></td> <td width="75%" class="listr"> <?php $memUsage = mem_usage(); ?> - <img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" name="memwidtha" id="memwidtha" width="<?= $memUsage; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" name="memwidthb" id="memwidthb" width="<?= (100 - $memUsage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" /> - - <br/><span id="memusagemeter"><?= $memUsage.'%'; ?></span> of <?= sprintf("%.0f", `/sbin/sysctl -n hw.physmem` / (1024*1024)) ?> MB + <div id="memUsagePB"></div> + <span id="memusagemeter"><?= $memUsage.'%'; ?></span> of <?= sprintf("%.0f", `/sbin/sysctl -n hw.physmem` / (1024*1024)) ?> MB </td> </tr> <?php if($showswap == true): ?> @@ -246,9 +259,8 @@ $curcfg = $config['system']['firmware']; <td width="25%" class="vncellt"><?=gettext("SWAP usage");?></td> <td width="75%" class="listr"> <?php $swapusage = swap_usage(); ?> - <img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" width="<?= $swapusage; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" width="<?= (100 - $swapusage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" /> - - <br/><span id="swapusagemeter"><?= $swapusage.'%'; ?></span> of <?= sprintf("%.0f", `/usr/sbin/swapinfo -m | /usr/bin/grep -v Device | /usr/bin/awk '{ print $2;}'`) ?> MB + <div id="swapUsagePB"></div> + <span id="swapusagemeter"><?= $swapusage.'%'; ?></span> of <?= sprintf("%.0f", `/usr/sbin/swapinfo -m | /usr/bin/grep -v Device | /usr/bin/awk '{ print $2;}'`) ?> MB </td> </tr> <?php endif; ?> @@ -256,9 +268,8 @@ $curcfg = $config['system']['firmware']; <td width="25%" class="vncellt"><?=gettext("Disk usage");?></td> <td width="75%" class="listr"> <?php $diskusage = disk_usage(); ?> - <img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_blue.gif" height="15" width="<?= $diskusage; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_gray.gif" height="15" width="<?= (100 - $diskusage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" /> - - <br/><span id="diskusagemeter"><?= $diskusage.'%'; ?></span> of <?= `/bin/df -h / | /usr/bin/grep -v 'Size' | /usr/bin/awk '{ print $2 }'` ?> + <div id="diskUsagePB"></div> + <span id="diskusagemeter"><?= $diskusage.'%'; ?></span> of <?= `/bin/df -h / | /usr/bin/grep -v 'Size' | /usr/bin/awk '{ print $2 }'` ?> </td> </tr> </tbody> |