| Index: dashboard/dashboard/static/series_group.html
|
| diff --git a/dashboard/dashboard/static/series_group.html b/dashboard/dashboard/static/series_group.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..07337ded114f8f824cf9caaac8e8d635b062672e
|
| --- /dev/null
|
| +++ b/dashboard/dashboard/static/series_group.html
|
| @@ -0,0 +1,109 @@
|
| +<!DOCTYPE html>
|
| +<!--
|
| +Copyright 2017 The Chromium Authors. All rights reserved.
|
| +Use of this source code is governed by a BSD-style license that can be
|
| +found in the LICENSE file.
|
| +-->
|
| +
|
| +<link rel="import" href="/dashboard/static/simple_xhr.html">
|
| +<link rel="import" href="/tracing/base/base.html">
|
| +
|
| +<script>
|
| +'use strict';
|
| +
|
| +tr.exportTo('d', function() {
|
| + class SeriesGroup {
|
| + /**
|
| + * @param {string} mainPath
|
| + * @param {Array.<string>} selectedPaths
|
| + * @param {Array.<string>} unselectedPaths
|
| + */
|
| + constructor(mainPath, selectedPaths, unselectedPaths) {
|
| + this.mainPath_ = mainPath;
|
| + this.selectedPaths_ = selectedPaths;
|
| + this.unselectedPaths_ = unselectedPaths;
|
| + }
|
| +
|
| + get mainPath() {
|
| + return this.mainPath_;
|
| + }
|
| +
|
| + get selectedPaths() {
|
| + return this.selectedPaths_;
|
| + }
|
| +
|
| + get unselectedPaths() {
|
| + return this.unselectedPaths_;
|
| + }
|
| + }
|
| +
|
| + /**
|
| + * Builds a SeriesGroup instance from an element of a legacy chart state.
|
| + *
|
| + * The expected structure of the legacy chart state element is described in
|
| + * the docstring for listTestsRequestParams.
|
| + *
|
| + * @param {Array} element
|
| + */
|
| + SeriesGroup.fromLegacyChartStateElement = element => {
|
| + const mainPath = element[0];
|
| + const selectedParams = listTestsRequestParams(element, true);
|
| + const unselectedParams = listTestsRequestParams(element, false);
|
| + const selectedTests = simple_xhr.asPromise('/list_tests', selectedParams);
|
| + const unselectedTests = simple_xhr.asPromise(
|
| + 'list_tests', unselectedParams);
|
| +
|
| + return Promise.all([selectedTests, unselectedTests]).then(
|
| + tests => new SeriesGroup(mainPath, ...tests));
|
| + };
|
| +
|
| + /**
|
| + * Returns a dict of arguments to pass to /list_tests.
|
| + *
|
| + * The legacy chart state element should be a two-element array, where the
|
| + * first element is the main path, and the second element is another array.
|
| + * This array will either have a single element that is a magic string ('all',
|
| + * 'important', or 'none'), or an exact list of test paths.
|
| + *
|
| + * @param {Array} legacyChartStateElement
|
| + */
|
| + function listTestsRequestParams(legacyChartStateElement, selected) {
|
| + let selectedStr = '0';
|
| + if (selected === true) {
|
| + selectedStr = '1';
|
| + }
|
| +
|
| + return {
|
| + type: 'test_path_dict',
|
| + test_path_dict: JSON.stringify(testPathDict(...legacyChartStateElement)),
|
| + selected: selectedStr
|
| + };
|
| + }
|
| +
|
| + function testPathDict(mainPath, legacySelection) {
|
| + let selection = [];
|
| + if (legacySelection.length === 1 && legacySelection[0] === 'all') {
|
| + selection = 'all';
|
| + } else if (
|
| + legacySelection.length === 1 && legacySelection[0] === 'important') {
|
| + selection = 'core';
|
| + } else if (
|
| + legacySelection.length === 1 && legacySelection[0] === 'none') {
|
| + // TODO(eakuefner): Analyze existing page states to see if this is used.
|
| + selection = [];
|
| + } else {
|
| + selection = legacySelection;
|
| + }
|
| +
|
| + const dict = {};
|
| + dict[mainPath] = selection;
|
| + return dict;
|
| + }
|
| +
|
| + return {
|
| + SeriesGroup,
|
| + listTestsRequestParams
|
| + };
|
| +});
|
| +
|
| +</script>
|
|
|