aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorboard/components/tf-dashboard-common/tf-downloader.html
blob: c7251ec5786fd30535bd4c9a58c5a1cc6c80ab98 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../../bower_components/paper-menu/paper-menu.html">
<link rel="import" href="../../bower_components/paper-item/paper-item.html">

<dom-module id="tf-downloader">
  <template>
    <paper-dropdown-menu
      no-label-float="true"
      label="run to download"
      selected-item-label="{{_run}}"
    >
      <paper-menu class="dropdown-content">
        <template is="dom-repeat" items="[[_runs]]">
          <paper-item no-label-float=true>[[item]]</paper-item>
        </template>
      </paper-menu>
    </paper-dropdown-menu>
    <a
      download="[[_csvName(_run)]]"
      href="[[_csvUrl(_run, urlFn)]]"
    >CSV</a>
    <a
      download="[[_jsonName(_run)]]"
      href="[[_jsonUrl(_run, urlFn)]]"
    >JSON</a>
    <style>
      :host {
        display: block;
      }
      paper-dropdown-menu {
        width: 220px;
        --paper-input-container-label: {
          font-size: 10px;
        }
        --paper-input-container-input: {
          font-size: 10px;
        }
      }
      a {
        font-size: 10px;
        border-radius: 3px;
        border: 1px solid #EEE;
      }
      paper-input {
        font-size: 22px;
      }
    </style>
  </template>
  <script>
    Polymer({
      is: "tf-downloader",
      properties: {
        _run: String,
        _runs: {
          type: Array,
          computed: "_computeRuns(runToTag.*, selectedRuns.*)",
        },
        selectedRuns: Array,
        runToTag: Object,
        tag: String,
        urlFn: Function,
      },
      _computeRuns: function(runToTagChange, selectedRunsChange) {
        var runToTag = this.runToTag;
        var tag = this.tag;
        return this.selectedRuns.filter(function(x) {
          return runToTag[x].indexOf(tag) !== -1;
        })
      },
      _csvUrl: function(_run, urlFn) {
        return urlFn(this.tag, _run) + "&format=csv";
      },
      _jsonUrl: function(_run, urlFn) {
        return urlFn(this.tag, _run);
      },
      _csvName: function(_run) {
        return "run_" + _run + ",tag_" + this.tag + ".csv";
      },
      _jsonName: function(_run) {
        return "run-" + _run + "-tag-" + this.tag + ".json";
      },
    });
  </script>
</dom-module>