提交 a3e1558f 编写于 作者: R Renato Utsch 提交者: TensorFlower Gardener

Add support for booleans on TF.URIStorage. Also add "Show download links" to URIStorage.

Change: 126930259
上级 cf7f7de7
......@@ -46,7 +46,7 @@ The #center div contains tf-charts embedded inside tf-collapsable-panes.
></tf-categorizer>
<paper-checkbox
id="download-option"
checked="{{_show_download_links}}"
checked="{{_showDownloadLinks}}"
>Data download links</paper-checkbox>
</div>
<div class="sidebar-section">
......@@ -89,12 +89,12 @@ The #center div contains tf-charts embedded inside tf-collapsable-panes.
></tf-chart>
<paper-icon-button
class="expand-button"
shift$="[[_show_download_links]]"
shift$="[[_showDownloadLinks]]"
icon="fullscreen"
on-tap="toggleSelected"
></paper-icon-button>
</div>
<template is="dom-if" if="[[_show_download_links]]">
<template is="dom-if" if="[[_showDownloadLinks]]">
<div class="card-bottom-row">
<tf-downloader
selected-runs="[[selectedRuns]]"
......@@ -135,7 +135,13 @@ The #center div contains tf-charts embedded inside tf-collapsable-panes.
type: Array,
computed: "_getVisibleTags(selectedRuns.*, run2tag.*)"
},
_show_download_links: Boolean,
_showDownloadLinks: {
type: Boolean,
notify: true,
value: TF.URIStorage.getBooleanInitializer('_showDownloadLinks',
false),
observer: '_showDownloadLinksObserver'
},
colorScale: {
type: Object,
notify: true,
......@@ -146,8 +152,8 @@ The #center div contains tf-charts embedded inside tf-collapsable-panes.
this.fire("rendered");
});
},
observers: ['redraw(_show_download_links)'],
redraw: function(_show_download_links) {
observers: ['redraw(_showDownloadLinks)'],
redraw: function(_showDownloadLinks) {
var els = this.getElementsByTagName("tf-chart");
for (var i=0; i<els.length; i++) {
els[i].redraw();
......@@ -161,6 +167,8 @@ The #center div contains tf-charts embedded inside tf-collapsable-panes.
_getScalarUrl: function() {
return this.router.scalars;
},
_showDownloadLinksObserver: TF.URIStorage.getBooleanObserver(
'_showDownloadLinks', false),
toggleSelected: function(e) {
var currentTarget = Polymer.dom(e.currentTarget);
var parentDiv = currentTarget.parentNode.parentNode;
......
......@@ -50,7 +50,26 @@ module TF.URIStorage {
export let DISAMBIGUATOR = 'disambiguator';
/**
* Return a string stored in the URI, given a corresonding key.
* Return a boolean stored in the URI, given a corresponding key.
* Undefined if not found.
*/
export function getBoolean(key: string): boolean {
let items = _componentToDict(_readComponent());
let item = items[key];
return item === 'true' ? true : item === 'false' ? false : undefined;
}
/**
* Store a boolean in the URI, with a corresponding key.
*/
export function setBoolean(key: string, value: boolean) {
let items = _componentToDict(_readComponent());
items[key] = value.toString();
_writeComponent(_dictToComponent(items));
}
/**
* Return a string stored in the URI, given a corresponding key.
* Undefined if not found.
*/
export function getString(key: string): string {
......@@ -116,6 +135,17 @@ module TF.URIStorage {
return components.join('.');
}
/**
* Return a function that:
* (1) Initializes a Polymer boolean property with a default value, if its
* value is not already set
* (2) Sets up listener that updates Polymer property on hash change.
*/
export function getBooleanInitializer(
propertyName: string, defaultVal: boolean): Function {
return _getInitializer(getBoolean, propertyName, defaultVal);
}
/**
* Return a function that:
* (1) Initializes a Polymer string property with a default value, if its
......@@ -152,6 +182,14 @@ module TF.URIStorage {
return _getInitializer(getObject, propertyName, clone);
}
/**
* Return a function that updates URIStorage when a string property changes.
*/
export function getBooleanObserver(
propertyName: string, defaultVal: boolean): Function {
return _getObserver(getBoolean, setBoolean, propertyName, defaultVal);
}
/**
* Return a function that updates URIStorage when a string property changes.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册