<commit_before><link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-ajax/iron-ajax.html">

<!--
//TODO: Description

@demo demo/index.html
-->
<dom-module id="gn-api">
  <template>
    
    <iron-ajax
      auto
      url="http://localhost:8080/greennav/vehicles"
      handle-as="json"
      last-response="{{ vehicles }}"></iron-ajax>
      
    <iron-ajax
      auto
      id="route"
      handle-as="json"
      last-response="{{ route }}"></iron-ajax>
      
    <iron-ajax
      auto
      id="range"
      handle-as="json"
      last-response="{{ range }}"></iron-ajax>
      
  </template>

  <script>
  Polymer({
    is: 'gn-api',
    
    properties: {
      
      /**
       * List of available vehicles obtained from the backend
       */
      vehicles: { 
        type: Array, 
        notify: true 
      },
      
      /**
       * Set the vehicle to route with. Needed for route and range
       * calculation.
       * 
       * Possible values are listed in the vehicles variable
       */
      vehicle: String,
      
      /**
       * Route/range start as OSM-ID
       */
      startOsmId: Number,
      
      /**
       * Route target as OSM-ID
       */
      targetOsmId: Number,
      
      /**
       * Battery load percentage.
       * Can be any value from 100 to 0
       */
      battery: Number,
      
      /**
       * Result of the routing. Needs vehicle, startOsmId,
       * targetOsmId and battery to be defined. It's not 
       * calculated automatically, call getRoute() first!
       */
      route: {
        type: Object,
        notify: true
      },
      
      /**
       * Result of the range. Needs vehicle, startOsmId
       * and battery to be defined. It's not 
       * calculated automatically, call getRange() first!
       */
      range: {
        type: Object,
        notify: true
      }
    },
    
    /**
     * Sets the route variable
     */
    getRoute : function() {
      var ajax = document.querySelector('#route');
      ajax.url = "http://localhost:8080/greennav/" +
        "vehicles/"   + this.vehicle +
        "/routes/"    + this.startOsmId +
        "-"           + this.targetOsmId +
        "/opt/energy" +
        "?battery="   + this.battery +
        "&algorithm=EnergyAStar";
    },
    
    /**
     * Sets the range variable
     */
    getRange : function() {
      var ajax = document.querySelector('#range');
      ajax.url = "http://localhost:8080/greennav/" +
        "vehicles/"   + this.vehicle +
        "/ranges/"    + this.startOsmId +
        "?battery="   + this.battery;
    }
  });
  </script>
</dom-module><commit_msg>Updated server port because of potential trouble with other services running on the same port<commit_after><link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-ajax/iron-ajax.html">

<!--
//TODO: Description

@demo demo/index.html
-->
<dom-module id="gn-api">
  <template>
    
    <iron-ajax
      auto
      url="http://localhost:6833/greennav/vehicles"
      handle-as="json"
      last-response="{{ vehicles }}"></iron-ajax>
      
    <iron-ajax
      auto
      id="route"
      handle-as="json"
      last-response="{{ route }}"></iron-ajax>
      
    <iron-ajax
      auto
      id="range"
      handle-as="json"
      last-response="{{ range }}"></iron-ajax>
      
  </template>

  <script>
  Polymer({
    is: 'gn-api',
    
    properties: {
      
      /**
       * List of available vehicles obtained from the backend
       */
      vehicles: { 
        type: Array, 
        notify: true 
      },
      
      /**
       * Set the vehicle to route with. Needed for route and range
       * calculation.
       * 
       * Possible values are listed in the vehicles variable
       */
      vehicle: String,
      
      /**
       * Route/range start as OSM-ID
       */
      startOsmId: Number,
      
      /**
       * Route target as OSM-ID
       */
      targetOsmId: Number,
      
      /**
       * Battery load percentage.
       * Can be any value from 100 to 0
       */
      battery: Number,
      
      /**
       * Result of the routing. Needs vehicle, startOsmId,
       * targetOsmId and battery to be defined. It's not 
       * calculated automatically, call getRoute() first!
       */
      route: {
        type: Object,
        notify: true
      },
      
      /**
       * Result of the range. Needs vehicle, startOsmId
       * and battery to be defined. It's not 
       * calculated automatically, call getRange() first!
       */
      range: {
        type: Object,
        notify: true
      }
    },
    
    /**
     * Sets the route variable
     */
    getRoute : function() {
      var ajax = document.querySelector('#route');
      ajax.url = "http://localhost:6833/greennav/" +
        "vehicles/"   + this.vehicle +
        "/routes/"    + this.startOsmId +
        "-"           + this.targetOsmId +
        "/opt/energy" +
        "?battery="   + this.battery +
        "&algorithm=EnergyAStar";
    },
    
    /**
     * Sets the range variable
     */
    getRange : function() {
      var ajax = document.querySelector('#range');
      ajax.url = "http://localhost:6833/greennav/" +
        "vehicles/"   + this.vehicle +
        "/ranges/"    + this.startOsmId +
        "?battery="   + this.battery;
    }
  });
  </script>
</dom-module>
{'fraction_non_alphanumeric': 0.13676797627872497, 'fraction_numerical': 0.005930318754633061, 'mean_word_length': 1.5835327908089996, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3159179', 'n_tokens_mistral': 1650, 'n_tokens_neox': 1590, 'n_words': 389}