Skip to content
Browse files

filter by value! yay!

  • Loading branch information...
1 parent 1b217b4 commit f044e0a5e877ca0e9ae88b7156328073124c9758 Jordan Evans committed Aug 16, 2011
Showing with 75 additions and 0 deletions.
  1. +12 −0 railroad/static/js/configurator.js
  2. +43 −0 railroad/static/js/functions.js
  3. +20 −0 railroad/templates/form.html
View
12 railroad/static/js/configurator.js
@@ -308,6 +308,18 @@ $(document).ready(function() {
event.stopPropagation();
});
+ $('#filter').bind('click', function () {
+ lowValue = parseInt($('#min').val());
+ // Since formatGraph bumps the max value by 20%, we need to reflect that
+ // here as well, so the user
+ highValue = parseInt($('#max').val()) * 1.2;
+ prepareFilterGraphs();
+ filterGraphs(lowValue, highValue);
+ });
+
+ $('#unfilter').bind('click', function () {
+ selectServiceObjs();
+ });
// Handle configurator form submissions
$('#configurator #add').bind('click', function() {
View
43 railroad/static/js/functions.js
@@ -312,6 +312,49 @@ function sortGraphs(name, reversed) {
}
}
+function filterGraphs(lowValue, highValue) {
+ var meta = $('#graphs').data('meta');
+ $('.service_row').hide();
+ for (var i=0; i < meta.length; i++) {
+ if (!meta[i].isGraphed) {
+ drawGraph(elem, meta[i].data);
+ meta[i].isGraphed = true;
+ }
+ if (meta[i].data) {
+ if (meta[i].data.options && meta[i].data.options.yaxis) {
+ var max = meta[i].data.options.yaxis.max;
+ if (lowValue) {
+ if (highValue) {
+ if (max >= lowValue && max <= highValue) {
+ setupGraph(meta[i]);
+ }
+ } else if (max >= lowValue) {
+ setupGraph(meta[i]);
+ }
+ } else if (highValue) {
+ if (max <= highValue) {
+ setupGraph(meta[i]);
+ }
+ }
+ }
+ }
+ }
+}
+
+function prepareFilterGraphs() {
+ getAllData(function () {
+ var meta = $('#graphs').data('meta');
+ for (var i=0; i < meta.length; i++) {
+ if (!meta[i].jQueryElement) {
+ meta[i].jQueryElement = $(meta[i].html);
+ $('#graphs').append($(meta[i].jQueryElement).hide());
+ }
+ if (meta[i].data.data) {
+ meta[i].data = formatGraph(meta[i].jQueryElement, meta[i].data);
+ }
+ }
+ });
+}
/* Triggered when the preference panel has been closed. Update the page if
* needed. */
function redrawOnClosePreference() {
View
20 railroad/templates/form.html
@@ -33,6 +33,26 @@
</li>
</ul>
</fieldset>
+ <fieldset>
+ <legend>Filter by value</legend>
+ <ul class="fieldset_ul">
+ <li>
+ <label for="min">Min</label>
+ <input class="value" name="min" id="min" type="text">
+ </li>
+ <li>
+ <label for="max">Max</label>
+ <input class="value" name="max" id="max" type="text">
+ </li>
+ <li>
+ <label>&nbsp;</label>
+ <ul class="liButtons">
+ <li id="filter">Filter</li
+ ><li id="unfilter">Unfilter</li>
+ </ul>
+ </li>
+ </ul>
+ </fieldset>
</div>
<div class="right">
<fieldset>

0 comments on commit f044e0a

Please sign in to comment.
Something went wrong with that request. Please try again.