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

WIP

parent 1d2e8df3
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -29,21 +29,25 @@ FnordMetric.views.MetricList = function() {

  function onRowClick(e) {
    e.preventDefault();
    var metric = this.firstChild.innerText;
    var metric = this.firstChild.id;
    //FIXME
    FnordMetric.util.setFragmentURL(
    FnordMetric.util.setURLQueryString(
      "metric", metric, false);
    location.reload();
  };

  function renderMetricButton(elem) {
  function renderMetricButton(elem, metric) {
    var button = FnordMetric.createButton(
      "#", undefined, "Open in Query Editor");
    elem.appendChild(button);

    button.onclick = function(e) {
      e.preventDefault();
      var metric = this.firstChild.innerText;
      var query = 
        "SELECT * FROM " + metric[0].key;
      FnordMetric.util.setFragmentURL(
        "query_playground", "sql_query", query, true);
      location.reload();
    }
  }

@@ -62,7 +66,7 @@ FnordMetric.views.MetricList = function() {
    }

    if (action == "metric") {
      renderMetricButton(viewport);
      renderMetricButton(viewport, metrics);
    }

    var table_view = FnordMetric.util.TableView([
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ FnordMetric.views.QueryPlayground = function() {
  function runQuery(result_pane, editor_pane, view, query_str) {
    if (query_str == undefined) {
      query_str = editorViews[view].getQuery();
      FnordMetric.util.setFragmentURL(urlName[view], query_str, true);
      FnordMetric.util.setURLQueryString(urlName[view], query_str, true);
    }

    FnordMetric.util.displayLoader(result_pane);
+2 −14
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ FnordMetric.util.TableView = function(columns, elem, per_page) {
      row.map(function(cell) {
        var list_cell = document.createElement("td");
        list_cell.innerHTML = cell;
        list_cell.setAttribute("id", cell);
        list_row.appendChild(list_cell);
      });
    });
@@ -147,17 +148,4 @@ FnordMetric.util.TableView = function(columns, elem, per_page) {
};


/*
    function searchRows(search_key) {
      //destroyRows();
      destroyListPagination();
      //FIXME works but seems not to be the best solution
      var data = [];
      metrics_data.map(function(item) {
       if (item.key.indexOf(search_key) > -1) {
          data.push(item);
        }
      });
      renderTable(data);
    }
*/
+13 −1
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ FnordMetric.util.displayErrorMessage = function(elem, msg) {
  elem.innerHTML = "<div>" + msg + "</div>"; // XSS!
}

FnordMetric.util.setFragmentURL = function(name, value, encode) {
FnordMetric.util.setURLQueryString = function(name, value, encode) {
  var fragment = window.location.hash.substr(1).split("?");
  fragment = fragment.length > 0 ? fragment[0] : "";
  var value = value;
@@ -125,6 +125,18 @@ FnordMetric.util.setFragmentURL = function(name, value, encode) {
  window.location.hash = hash;
}

FnordMetric.util.setFragmentURL = function(hash, name, value, encode) {
  console.log(window.location.pathname);
  var path = window.location.pathname;
  var value = value;
  if (encode) {
    value = encodeURIComponent(value);
  }
  var hash = 
    path + "#" + hash + "?" + name + "=" + value;
  window.location = hash;
}

FnordMetric.util.openPopup = function(elem, text) {
  function closePopup() {
    elem.removeChild(popup);