Commit 0d61a5c2 authored by Amy Stamile's avatar Amy Stamile
Browse files

Minor tweaks

parent bd0380a7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -98,6 +98,6 @@
    "react-dom": "^16.12.0",
    "requirejs": "^2.3.6",
    "typeface-roboto": "0.0.75",
    "wicket": "1.3.5",
    "wicket": "1.3.5"
  }
}
+8 −7
Original line number Diff line number Diff line
@@ -103,8 +103,8 @@ export default function SearchAndFilterInput(props) {
  const [dateCheckVal, setDateCheckVal] = React.useState(false);
  const [dateFromVal, setDateFromVal] = React.useState(null);
  const [dateToVal, setDateToVal] = React.useState(null);
  const [maxPages, setMaxPages] = React.useState(getMaxNumberPages);
  const [maxNumberFootprints, setMaxNumberFootprints] = React.useState(getNumberMatched);
  const [maxPages, setMaxPages] = React.useState(0);
  const [maxNumberFootprints, setMaxNumberFootprints] = React.useState(0);
  const [limitVal, setLimitVal] = React.useState(0);

  // Clear all values
@@ -167,18 +167,19 @@ export default function SearchAndFilterInput(props) {
  }

  // limit
  const handleLimitChange = (event) => {
    setLimitVal(event.target.value);
  const handleLimitChange = (event, value) => {
    setLimitVal(value);
    setTimeout(() => {
      setMaxPages(getMaxNumberPages);
    }, 1000);
  }

  // resets pagination and limit when switching targets
  useEffect(() => {
    setTimeout(() => {
      setMaxNumberFootprints(getNumberMatched);
      setMaxPages(getMaxNumberPages);
      setLimitVal(10);
      setMaxPages(getMaxNumberPages);
    }, 1000);
  }, [props.target]);

@@ -187,6 +188,7 @@ export default function SearchAndFilterInput(props) {
    setCurrentPage(value);
  };


  /* Control IDs for reference:
  applyButton
  clearButton
@@ -330,12 +332,11 @@ export default function SearchAndFilterInput(props) {
                  <Slider
                    id="valueSlider"
                    size="small"
                    defaultValue={10}
                    aria-label="Small"
                    valueLabelDisplay="auto"
                    onChange={handleLimitChange}
                    value={limitVal}
                    max={maxNumberFootprints}
                    defaultValue={10}
                  />
              </div>
            </div>
+3 −4
Original line number Diff line number Diff line
@@ -56,10 +56,9 @@ function setNumberMatched(matched) {
  _numberMatched = matched;
  let sliderElement = document.getElementById('valueSlider');
  let limitVal = sliderElement.lastChild.firstChild.value;
  if (limitVal == 0){
    limitVal = 10;
    if (limitVal != 0 && matched != 0){
      setMaxNumberPages(Math.floor(matched/limitVal));
    }
  setMaxNumberPages(Math.floor(_numberMatched/limitVal));
}

/**
+41 −27
Original line number Diff line number Diff line
@@ -76,34 +76,11 @@ export default L.Control.AstroDrawControl = L.Control.Draw.extend({
    );
    L.DomEvent.on(L.DomUtil.get("clearButton"), "click", this.clearMap, this);

    let sliderElement = document.getElementById('valueSlider');
    sliderElement.addEventListener('click', event => {
      this._map._footprintControl.remove();
      for(let i = 0; i < this._map._geoLayers.length; i++){
        this._map._geoLayers[i].clearLayers();
      }
      let currentPage = getCurrentPage();
      let limitVal = sliderElement.lastChild.firstChild.value;
      let queryString = "?page=" + currentPage;
      queryString += "&limit=" + limitVal;
      this._map.loadFootprintLayer(this._map._target, queryString);
    });

    let pagElement = document.getElementById('pagination');
    pagElement.addEventListener('click', event => {
      this._map._footprintControl.remove();
      for(let i = 0; i < this._map._geoLayers.length; i++){
        this._map._geoLayers[i].clearLayers();
      }
      setTimeout(() => {
        let currentPage = getCurrentPage();
        let limitVal = sliderElement.lastChild.firstChild.value;
        let queryString = "?page=" + currentPage;
        queryString += "&limit=" + limitVal;
        this._map.loadFootprintLayer(this._map._target, queryString);
      }, 1000);
    });
    this.valueSlider = L.DomUtil.get("valueSlider")
    L.DomEvent.on(this.valueSlider, "click", this.applyLimit, this);

    this.pagination = L.DomUtil.get("pagination")
    L.DomEvent.on(this.pagination, "click", this.applyPage, this);

    map.on("draw:created", this.shapesToWKT, this);

@@ -136,9 +113,46 @@ export default L.Control.AstroDrawControl = L.Control.Draw.extend({
    for(let i = 0; i < this._map._geoLayers.length; i++){
      this._map._geoLayers[i].clearLayers();
    }
  },


  applyLimit: function() {
    this._map._footprintControl.remove();

    for(let i = 0; i < this._map._geoLayers.length; i++){
      this._map._geoLayers[i].clearLayers();
    }
    let currentPage = getCurrentPage();

    let sliderElement = L.DomUtil.get("valueSlider");
    let limitVal = sliderElement.lastChild.firstChild.value;

    let queryString = "?page=" + currentPage;
    queryString += "&limit=" + limitVal;

    this._map.loadFootprintLayer(this._map._target, queryString);
  },



  applyPage: function() {
    this._map._footprintControl.remove();

    for(let i = 0; i < this._map._geoLayers.length; i++){
      this._map._geoLayers[i].clearLayers();
    }
    let currentPage = getCurrentPage();

    let sliderElement = L.DomUtil.get("valueSlider");
    let limitVal = sliderElement.lastChild.firstChild.value;

    let queryString = "?page=" + currentPage;
    queryString += "&limit=" + limitVal;

    this._map.loadFootprintLayer(this._map._target, queryString);
  },


  /**
   * @function shapesToFootprint
   * @description Is called when a user draws a shape using the on map drawing features.
+2 −3
Original line number Diff line number Diff line
@@ -95,8 +95,6 @@ export default L.Map.AstroMap = L.Map.extend({
    this.loadLayerCollection("cylindrical");

    setCurrentPage(1);
    setMaxNumberPages(0);
    setNumberMatched(0);
    this.loadFootprintLayer(target, "?page=1");

    // Listen to baselayerchange event so that we can set the current layer being
@@ -128,6 +126,7 @@ export default L.Map.AstroMap = L.Map.extend({
   */
  loadFootprintLayer: function(name, queryString) {
    var matched = 0;
    
    getItemCollection(name, queryString).then(result => {
      if (result != undefined) {
        this._geoLayers = new Array(result.length);
@@ -142,11 +141,11 @@ export default L.Map.AstroMap = L.Map.extend({
            this._geoLayers[i].addData(result[i].features[j]);
          }
        }
        setNumberMatched(matched);
        this._footprintControl = L.control
          .layers(null, this._footprintCollection)
          .addTo(this);
      }
      setNumberMatched(matched);
    });
  },

Loading