Commit ba7ad5f6 authored by Laura Schlimmer's avatar Laura Schlimmer
Browse files

turn autorefresh off when time is selected

parent 3d32c187
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ FnordMetric.util.MetricPreviewWidget = function(viewport, query_params) {


  function onDateSubmit(timestamp) {
    auto_refresh.off();
    var timestamp = parseInt(timestamp, 10);
    var start_time = 
      parseInt(getQueryParamOrDefaultValue("start_time"), 10);
@@ -367,6 +368,7 @@ FnordMetric.util.MetricPreviewWidget = function(viewport, query_params) {

    var controls_autorefresh = FnordMetric.createButton(
      "#", "btn", "<i class='fa fa-refresh'></i> Auto Refresh");
    auto_refresh.btn = controls_autorefresh;

    secondary_controls.appendChild(controls_query);
    secondary_controls.appendChild(controls_embed);
@@ -461,14 +463,10 @@ FnordMetric.util.MetricPreviewWidget = function(viewport, query_params) {
    controls_autorefresh.addEventListener('click', function(e) {
      e.preventDefault();
      if (auto_refresh.state()) {
        this.className = "btn";
        auto_refresh.off();
      } else {
        this.className += " on";
        auto_refresh.on();
        console.log(auto_refresh.state());
      }
      //auto_refresh.state = !auto_
    }, false);


@@ -482,6 +480,7 @@ FnordMetric.util.MetricPreviewWidget = function(viewport, query_params) {

    prev_timespan.addEventListener('click', function(e) {
      e.preventDefault();
      auto_refresh.off();
      var end = query_params.end_time;
      end_time = query_params.start_time;
      var diff = end - query_params.start_time;
@@ -494,6 +493,7 @@ FnordMetric.util.MetricPreviewWidget = function(viewport, query_params) {

    next_timespan.addEventListener('click', function(e) {
      e.preventDefault();
      auto_refresh.off();
      var start = query_params.start_time;
      var end =
        parseInt(query_params.end_time ,10) + 
+5 −2
Original line number Diff line number Diff line
@@ -91,7 +91,6 @@ FnordMetric.util.setURLQueryString = function(hash, query_params, encode, push_s
  }

  if (push_state) {
    console.log("push state");
    window.history.pushState({url:path}, "#", path);
  }
  window.location.hash = path;
@@ -696,17 +695,21 @@ FnordMetric.util.autoRefresh = function(onRefresh) {
  var curr_state = false;
  var intervalID;

  this.btn;

  function state() {
    return curr_state;
  }

  function on() {
    this.btn.className += " on";
    curr_state = true;
    //30000
    //refresh every 30 seconds
    intervalID = window.setInterval(onRefresh, 30000);
  }

  function off() {
    this.btn.className = "btn";
    curr_state = false;
    window.clearInterval(intervalID);
  }