TensorBoard stores regex groups in url bar.
This also causes the regex groups to persist across tab switches. I also cleaned the code and UI a little; I removed the activation toggle for the individual regex groups, which is redundant because it duplicates the existing system for opening/closing tag groups. Also found and fixed a bug in the TF.URIStorage module. Change: 136070622
This commit is contained in:
parent
555a7f5905
commit
3d84306711
@ -44,7 +44,7 @@ categories are exclusive.
|
|||||||
<dom-module id="tf-categorizer">
|
<dom-module id="tf-categorizer">
|
||||||
<template>
|
<template>
|
||||||
<div class="inputs">
|
<div class="inputs">
|
||||||
<tf-regex-group id="regex-group" regexes="{{regexes}}"></tf-regex-group>
|
<tf-regex-group id="regexGroup" regexes="{{regexes}}"></tf-regex-group>
|
||||||
</div>
|
</div>
|
||||||
<div id="underscore-categorization">
|
<div id="underscore-categorization">
|
||||||
<paper-checkbox
|
<paper-checkbox
|
||||||
|
@ -28,12 +28,11 @@ Example:
|
|||||||
<tf-regex-group regexes="{{regexes}}"></tf-regex-group>
|
<tf-regex-group regexes="{{regexes}}"></tf-regex-group>
|
||||||
|
|
||||||
It contains a series of regular expression input fields. From this, it computes
|
It contains a series of regular expression input fields. From this, it computes
|
||||||
`regexes', an array in which every element is either a string representing an
|
`regexes', an array in which every element is either a string representing a
|
||||||
active, valid, nonempty regular expression, or the value `null`
|
valid, nonempty regular expression, or the value `null`
|
||||||
|
|
||||||
Public Properties:
|
Public Properties:
|
||||||
`regexes` a readonly, notifying array of strings, where each string is an
|
`regexes` a readonly, notifying array of strings, where each string is a regex
|
||||||
active, valid, nonempty regex
|
|
||||||
|
|
||||||
It maintains an invariant that the final regex should always be an empty string,
|
It maintains an invariant that the final regex should always be an empty string,
|
||||||
so the user can easily add more regular expressions. It does this by adding
|
so the user can easily add more regular expressions. It does this by adding
|
||||||
@ -47,17 +46,12 @@ more regexes).
|
|||||||
<div class="regex-list">
|
<div class="regex-list">
|
||||||
<template is="dom-repeat" items="{{rawRegexes}}">
|
<template is="dom-repeat" items="{{rawRegexes}}">
|
||||||
<div class="regex-line">
|
<div class="regex-line">
|
||||||
<paper-checkbox
|
|
||||||
class="active-button"
|
|
||||||
checked="{{item.active}}"
|
|
||||||
disabled="[[!item.valid]]"
|
|
||||||
></paper-checkbox>
|
|
||||||
<paper-input
|
<paper-input
|
||||||
id="text-input"
|
id="text-input"
|
||||||
class="regex-input"
|
class="regex-input"
|
||||||
label="Write a regex to create a tag group"
|
label="Write a regex to create a tag group"
|
||||||
no-label-float
|
no-label-float
|
||||||
bind-value="{{item.regex}}"
|
value="{{item.regex}}"
|
||||||
invalid="[[!item.valid]]"
|
invalid="[[!item.valid]]"
|
||||||
on-keyup="moveFocus"
|
on-keyup="moveFocus"
|
||||||
></paper-input>
|
></paper-input>
|
||||||
@ -71,16 +65,11 @@ more regexes).
|
|||||||
</div>
|
</div>
|
||||||
<style>
|
<style>
|
||||||
.regex-input {
|
.regex-input {
|
||||||
width: 230px;
|
width: 250px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-left: -3px;
|
margin-left: -3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
paper-checkbox {
|
|
||||||
--paper-checkbox-checked-color: var(--tb-ui-dark-accent);
|
|
||||||
--paper-checkbox-unchecked-color: var(--tb-ui-dark-accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.delete-button {
|
.delete-button {
|
||||||
color: var(--paper-grey-700);
|
color: var(--paper-grey-700);
|
||||||
width: 40px;
|
width: 40px;
|
||||||
@ -111,16 +100,16 @@ more regexes).
|
|||||||
properties: {
|
properties: {
|
||||||
rawRegexes: {
|
rawRegexes: {
|
||||||
type: Array,
|
type: Array,
|
||||||
value: function() {
|
value: TF.URIStorage.getObjectInitializer('rawRegexes', [{regex: "", valid: true}]),
|
||||||
return [{regex: "", active: true, valid: true}];
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
regexes: {type: Array, computed: "usableRegexes(rawRegexes.*)", notify: true},
|
regexes: {type: Array, computed: "usableRegexes(rawRegexes.*)", notify: true},
|
||||||
},
|
},
|
||||||
observers: [
|
observers: [
|
||||||
"addNewRegexIfNeeded(rawRegexes.*)",
|
"addNewRegexIfNeeded(rawRegexes.*)",
|
||||||
"checkValidity(rawRegexes.*)",
|
"checkValidity(rawRegexes.*)",
|
||||||
|
"_uriStoreRegexes(rawRegexes.*)",
|
||||||
],
|
],
|
||||||
|
_uriStoreRegexes: TF.URIStorage.getObjectObserver('rawRegexes', [{regex: "", valid: true}]),
|
||||||
checkValidity: function(x) {
|
checkValidity: function(x) {
|
||||||
var match = x.path.match(/rawRegexes\.(\d+)\.regex/);
|
var match = x.path.match(/rawRegexes\.(\d+)\.regex/);
|
||||||
if (match) {
|
if (match) {
|
||||||
@ -142,7 +131,7 @@ more regexes).
|
|||||||
// Checking validity here (rather than using the data property)
|
// Checking validity here (rather than using the data property)
|
||||||
// is necessary because otherwise we might send invalid regexes due
|
// is necessary because otherwise we might send invalid regexes due
|
||||||
// to the fact that this function can call before the observer does
|
// to the fact that this function can call before the observer does
|
||||||
return r.regex !== "" && r.active && isValid(r.regex);
|
return r.regex !== "" && isValid(r.regex);
|
||||||
}).map(function(r) {
|
}).map(function(r) {
|
||||||
return r.regex;
|
return r.regex;
|
||||||
});
|
});
|
||||||
@ -150,7 +139,7 @@ more regexes).
|
|||||||
addNewRegexIfNeeded: function() {
|
addNewRegexIfNeeded: function() {
|
||||||
var last = this.rawRegexes[this.rawRegexes.length - 1];
|
var last = this.rawRegexes[this.rawRegexes.length - 1];
|
||||||
if (last.regex !== "") {
|
if (last.regex !== "") {
|
||||||
this.push("rawRegexes", {regex: "", active: true, valid: true});
|
this.push("rawRegexes", {regex: "", valid: true});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deleteRegex: function(e) {
|
deleteRegex: function(e) {
|
||||||
|
@ -178,8 +178,7 @@ module TF.URIStorage {
|
|||||||
*/
|
*/
|
||||||
export function getObjectInitializer(
|
export function getObjectInitializer(
|
||||||
propertyName: string, defaultVal: Object): Function {
|
propertyName: string, defaultVal: Object): Function {
|
||||||
let clone = _.cloneDeep(defaultVal);
|
return _getInitializer(getObject, propertyName, defaultVal);
|
||||||
return _getInitializer(getObject, propertyName, clone);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -297,8 +296,11 @@ module TF.URIStorage {
|
|||||||
return function() {
|
return function() {
|
||||||
let URIStorageName = getURIStorageName(this, propertyName);
|
let URIStorageName = getURIStorageName(this, propertyName);
|
||||||
let setComponentValue = () => {
|
let setComponentValue = () => {
|
||||||
|
// Clone, in case the caller will mutuate this object, we
|
||||||
|
// don't want to mutate our default instance
|
||||||
|
let v = _.clone(defaultVal);
|
||||||
let uriValue = get(URIStorageName);
|
let uriValue = get(URIStorageName);
|
||||||
this[propertyName] = uriValue !== undefined ? uriValue : defaultVal;
|
this[propertyName] = uriValue !== undefined ? uriValue : v;
|
||||||
};
|
};
|
||||||
// Set the value on the property.
|
// Set the value on the property.
|
||||||
setComponentValue();
|
setComponentValue();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user