aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorboard/components/tf-dashboard-common/tf-url-generator.html
blob: 1207f4024954b290566a297a072972fbcd96e157 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<link rel="import" href="../polymer/polymer.html">

<!-- tf-url-generator is a plumbing component that provides upward bindable properties
  for each route that TensorBoard uses to retrieve data from the backend. The properties
  are generally functions that take in a run and a tag and produce a url for retrieving
  data for that run and tag (although there are exceptions: for example, outRunsUrl is just
  a string because no additional data is required to retrieve runs).

  tf-url-generator takes a "router" object that provides the functions that back each
  property - that makes it easy to overwrite how TensorBoard retrieves data from the
  backend, e.g. for creating demo instances.
 -->
<dom-module id="tf-url-generator">
  <script src="urlGenerator.js"></script>
  <script>
    var polymerObject = {
      is: "tf-url-generator",
      _computeRuns: function(router) {
        return router.runs();
      },
      properties: {
        router: {
          type: Object,
        },
        outRunsUrl: {
          type: String,
          computed: "_computeRuns(router)",
          readOnly: true,
          notify: true,
        },
      },
    };
    TF.Urls.routes.forEach(function(route) {
      /* for each route (other than runs, handled seperately):
       * out`RouteName`: {
       *  type: Function,
       *  readOnly: true,
       *  notify: true,
       *  value: function() {
       *    return TF.Urls.`routeName`Url;
       *  }
       */
      if (route === "runs") {
        return;
      }
      var computeFnName = "_compute" + route;
      polymerObject[computeFnName] = function(router) {
        return router[route];
      };
      var urlName = route + "Url";
      var propertyName = Polymer.CaseMap.dashToCamelCase("out-" + urlName + "Generator");
      polymerObject.properties[propertyName] = {
        type: Function,
        computed: computeFnName + "(router)",
        notify: true,
      }
    });
    Polymer(polymerObject);
  </script>
</dom-module>