github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ui/src/views/cluster/containers/nodeGraphs/dashboards/dashboardUtils.ts (about)

     1  // Copyright 2018 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  import { NodesSummary } from "src/redux/nodes";
    12  
    13  /**
    14   * GraphDashboardProps are the properties accepted by the renderable component
    15   * of each graph dashboard.
    16   */
    17  export interface GraphDashboardProps {
    18    /**
    19     * Summary of nodes data.
    20     */
    21    nodesSummary: NodesSummary;
    22    /**
    23     * List of node IDs which should be used in graphs which display a series per
    24     * node.
    25     */
    26    nodeIDs: string[];
    27    /**
    28     * List of nodes which should be queried for data. This will be empty if all
    29     * nodes should be queried.
    30     */
    31    nodeSources: string[];
    32    /**
    33     * List of stores which should be displayed in the dashboard. This will be
    34     * empty if all stores should be queried.
    35     */
    36    storeSources: string[];
    37    /**
    38     * tooltipSelection is a string used in tooltips to reference the currently
    39     * selected nodes. This is a prepositional phrase, currently either "across
    40     * all nodes" or "on node X".
    41     */
    42    tooltipSelection: string;
    43  }
    44  
    45  export function nodeDisplayName(nodesSummary: NodesSummary, nid: string) {
    46    const ns = nodesSummary.nodeStatusByID[nid];
    47    if (!ns) {
    48      // This should only happen immediately after loading a page, and
    49      // associated graphs should display no data.
    50      return "unknown node";
    51    }
    52    return nodesSummary.nodeDisplayNameByID[ns.desc.node_id];
    53  }
    54  
    55  export function storeIDsForNode(nodesSummary: NodesSummary, nid: string): string[] {
    56    return nodesSummary.storeIDsByNodeID[nid] || [];
    57  }