Commit 1a28b6ec authored by Iain R. Learmonth's avatar Iain R. Learmonth
Browse files

Adds a permalink button to the map view (Fixes: #24869)

parent ba625b42
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ define([
        'toprelays': 'showTopRelays',
        'aggregate/:aType(/:query)': 'aggregateSearch',
        'aggregate(/:aType)/': 'emptyAggregateSearch',
        'map(/:query)': 'aggregateMap',
        'map(_:property)(/:query)': 'aggregateMap',
    	// Default
    	'*actions': 'defaultAction'
    },
@@ -116,7 +116,7 @@ define([
      });
    },
    // Perform an aggregate search
    aggregateMap: function(query){
    aggregateMap: function(property, query){
        $(".breadcrumb").html("<li><a href=\"https://metrics.torproject.org/\">Home</a></li><li><a href=\"https://metrics.torproject.org/services.html\">Services</a></li><li><a href=\"#\">Relay Search</a></li><li class=\"active\">Map view" + ((query) ? " for " + query : "") + "</li>");

        $("#content").hide();
@@ -124,6 +124,7 @@ define([
        $(".progress").show();

        aggregateMapView.collection.aType = "cc";
        aggregateMapView.mapProperty = (property) ? property : "consensus_weight_fraction";

        if (query) {
          query = query.trim();
+5 −1
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ define([
    },
    plot: function() {
      $('input[name="aggregate-property"]').prop('disabled', true);

      var aggregate_property = $('input[name="aggregate-property"]:checked').val();
      var aggregates = this.collection.models;
      var explanations = this.explanations;
@@ -236,6 +235,7 @@ define([
      document.title = "Relay Search";
      var compiledTemplate = _.template(aggregateMapTemplate)
      this.$el.html(compiledTemplate({query: query,
                                     mapProperty: this.mapProperty,
                                     aggregates: this.collection.models,
                                     countries: CountryCodes,
                                     error: this.error,
@@ -252,6 +252,10 @@ define([
        $('#save_svg').bind('click', function(){
          thisView.save();
        });
        $('#permalink').bind('click', function(){
          aggregate_property = $('input[name="aggregate-property"]:checked').val();
          window.location.hash = "#map_" + aggregate_property + ((query) ? "/" + query : "");
        });
      } else {
        $('#no-svg').show();
      }
+7 −6
Original line number Diff line number Diff line
@@ -51,15 +51,16 @@
   <div class="panel panel-default">
   <div class="panel-body">
   <form id="map-radio-buttons">
     <label class="radio-inline"><input type="radio" name="aggregate-property" value="consensus_weight_fraction" checked="checked"> Consensus Weight</label>
     <label class="radio-inline"><input type="radio" name="aggregate-property" value="guard_probability"> Guard Probability</label>
     <label class="radio-inline"><input type="radio" name="aggregate-property" value="middle_probability"> Middle Probability</label>
     <label class="radio-inline"><input type="radio" name="aggregate-property" value="exit_probability"> Exit Probability</label>
     <label class="radio-inline"><input type="radio" name="aggregate-property" value="advertised_bandwidth"> Advertised Bandwidth</label>
     <label class="radio-inline"><input type="radio" name="aggregate-property" value="consensus_weight_to_bandwidth"> Consensus Weight to Bandwidth Ratio</label>
     <label class="radio-inline"><input type="radio" name="aggregate-property" value="consensus_weight_fraction"<% if (mapProperty == "consensus_weight_fraction") { %> checked="checked"<% } %>> Consensus Weight</label>
     <label class="radio-inline"><input type="radio" name="aggregate-property" value="guard_probability"<% if (mapProperty == "guard_probability") { %> checked="checked"<% } %>> Guard Probability</label>
     <label class="radio-inline"><input type="radio" name="aggregate-property" value="middle_probability"<% if (mapProperty == "middle_probability") { %> checked="checked"<% } %>> Middle Probability</label>
     <label class="radio-inline"><input type="radio" name="aggregate-property" value="exit_probability"<% if (mapProperty == "exit_probability") { %> checked="checked"<% } %>> Exit Probability</label>
     <label class="radio-inline"><input type="radio" name="aggregate-property" value="advertised_bandwidth"<% if (mapProperty == "advertised_bandwidth") { %> checked="checked"<% } %>> Advertised Bandwidth</label>
     <label class="radio-inline"><input type="radio" name="aggregate-property" value="consensus_weight_to_bandwidth"<% if (mapProperty == "consensus_weight_to_bandwidth") { %> checked="checked"<% } %>> Consensus Weight to Bandwidth Ratio</label>
   </form>
   <a class="btn btn-primary" href="#aggregate/cc<%= (query) ? "/" + query : "" %>">View Table</a>
   <a class="btn btn-secondary" id="save_svg">Save Map</a>
   <a class="btn btn-secondary" id="permalink">Permalink</a>
   </div>
   </div>
<% } %>