@netdata/charts
Version:
Netdata frontend SDK and chart utilities
198 lines • 8.62 kB
JavaScript
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import React from "react";
import { Flex, TextSmall } from "@netdata/netdata-ui";
import { useIsHeatmap } from "../../helpers/heatmap";
import { useAttributeValue, useIsMinimal } from "../provider";
import Aggregate from "./aggregate";
import PostAggregate from "./postAggregate";
import Dimensions from "./dimensions";
import Instances from "./instances";
import Nodes from "./nodes";
import ContextScope from "./contextScope";
import GroupBy from "./groupBy";
import PostGroupBy from "./postGroupBy";
import TimeAggregation from "./timeAggregation";
import Labels from "./labels";
import Reset from "./reset";
import ShowPostAggregations from "./showPostAggregations";
// import Config from "./config" // TODO use it for dropdown form
import N from "@netdata/netdata-ui/dist/components/icon/assets/N.svg";
import I from "@netdata/netdata-ui/dist/components/icon/assets/I.svg";
import D from "@netdata/netdata-ui/dist/components/icon/assets/D.svg";
import L from "@netdata/netdata-ui/dist/components/icon/assets/L.svg";
import GroupBySVG from "@netdata/netdata-ui/dist/components/icon/assets/group_by.svg";
import gear from "@netdata/netdata-ui/dist/components/icon/assets/gear.svg";
import chevronRightEnd from "@netdata/netdata-ui/dist/components/icon/assets/chevron_right_end.svg";
import Icon from "../icon";
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
var uppercasedAggrLabel = {
secondaryLabel: "The"
};
var emptyObject = {};
var plainLabelProps = {
groupBy: {
icon: /*#__PURE__*/_jsx(Icon, {
svg: GroupBySVG,
color: "textLite",
size: "12px"
}),
padding: [0]
},
nodes: {
icon: /*#__PURE__*/_jsx(Icon, {
svg: N,
color: "textLite",
size: "16px"
}),
padding: [0]
},
instances: {
icon: /*#__PURE__*/_jsx(Icon, {
svg: I,
color: "textLite",
size: "16px"
}),
padding: [0]
},
dimensions: {
icon: /*#__PURE__*/_jsx(Icon, {
svg: D,
color: "textLite",
size: "16px"
}),
padding: [0]
},
labels: {
icon: /*#__PURE__*/_jsx(Icon, {
svg: L,
color: "textLite",
size: "16px"
}),
padding: [0]
},
config: {
icon: /*#__PURE__*/_jsx(Icon, {
svg: gear,
color: "textLite",
size: "12px"
}),
padding: [0.5]
},
showPostAggregations: {
icon: /*#__PURE__*/_jsx(Icon, {
svg: chevronRightEnd,
color: "textLite",
size: "10px"
}),
padding: [0]
}
};
var FilterToolbox = function FilterToolbox(_ref) {
var plain = _ref.plain;
var isHeatmap = useIsHeatmap();
var filterElements = useAttributeValue("filterElements");
var showPostAggregations = useAttributeValue("showPostAggregations");
var isMinimal = useIsMinimal();
if (filterElements) return filterElements.map(function (Element, index) {
return /*#__PURE__*/_jsx(Element, {
showPostAggregations: showPostAggregations
}, index);
});
if (plain) return /*#__PURE__*/_jsxs(_Fragment, {
children: [/*#__PURE__*/_jsx(GroupBy, {
labelProps: plainLabelProps.groupBy
}), /*#__PURE__*/_jsx(Aggregate, {
labelProps: isHeatmap ? emptyObject : emptyObject,
defaultMinimal: true
}), /*#__PURE__*/_jsx(Nodes, {
labelProps: plainLabelProps.nodes
}), /*#__PURE__*/_jsx(Instances, {
labelProps: plainLabelProps.instances
}), /*#__PURE__*/_jsx(Dimensions, {
labelProps: plainLabelProps.dimensions
}), /*#__PURE__*/_jsx(Labels, {
labelProps: plainLabelProps.labels
})]
});
if (showPostAggregations) {
return /*#__PURE__*/_jsxs(_Fragment, {
children: [/*#__PURE__*/_jsxs(Flex, {
padding: isMinimal ? [2, 0.5] : [0.5],
flexWrap: true,
gap: 2,
children: [/*#__PURE__*/_jsxs(Flex, {
alignItems: "center",
children: [/*#__PURE__*/_jsx(ShowPostAggregations, {
labelProps: plainLabelProps.showPostAggregations
}), !isHeatmap && /*#__PURE__*/_jsx(ContextScope, {}), !isHeatmap && /*#__PURE__*/_jsx(PostGroupBy, {
labelProps: isMinimal ? plainLabelProps.groupBy : {
secondaryLabel: "Group by"
}
}), /*#__PURE__*/_jsx(PostAggregate, {
labelProps: _objectSpread({}, isHeatmap ? isMinimal ? emptyObject : uppercasedAggrLabel : emptyObject)
}), !isMinimal ? /*#__PURE__*/_jsxs(TextSmall, {
color: "textLite",
whiteSpace: "nowrap",
children: ["of the:", " "]
}) : /*#__PURE__*/_jsx(TextSmall, {
color: "textNoFocus",
children: "<"
})]
}), /*#__PURE__*/_jsxs(Flex, {
round: true,
border: {
side: "all",
size: "2px",
type: "dashed",
color: "border"
},
alignItems: "center",
children: [!isHeatmap && /*#__PURE__*/_jsx(GroupBy, {
labelProps: isMinimal ? plainLabelProps.groupBy : {
secondaryLabel: "Group by"
}
}), /*#__PURE__*/_jsx(Aggregate, {
labelProps: isHeatmap ? isMinimal ? emptyObject : uppercasedAggrLabel : emptyObject
}), /*#__PURE__*/_jsx(Nodes, {
labelProps: isMinimal ? plainLabelProps.nodes : emptyObject
}), /*#__PURE__*/_jsx(Instances, {
labelProps: isMinimal ? plainLabelProps.instances : emptyObject
}), /*#__PURE__*/_jsx(Dimensions, {
labelProps: isMinimal ? plainLabelProps.dimensions : emptyObject
}), /*#__PURE__*/_jsx(Labels, {
labelProps: isMinimal ? plainLabelProps.labels : emptyObject
})]
}), !isMinimal && /*#__PURE__*/_jsx(TimeAggregation, {})]
}), /*#__PURE__*/_jsx(Reset, {})]
});
}
return /*#__PURE__*/_jsxs(_Fragment, {
children: [/*#__PURE__*/_jsxs(Flex, {
flexWrap: true,
padding: isMinimal ? [2, 0.5] : [0.5],
children: [/*#__PURE__*/_jsx(ShowPostAggregations, {
labelProps: plainLabelProps.showPostAggregations
}), !isHeatmap && /*#__PURE__*/_jsx(ContextScope, {}), !isHeatmap && /*#__PURE__*/_jsx(GroupBy, {
labelProps: isMinimal ? plainLabelProps.groupBy : {
secondaryLabel: "Group by"
}
}), /*#__PURE__*/_jsx(Aggregate, {
labelProps: isHeatmap ? isMinimal ? emptyObject : uppercasedAggrLabel : emptyObject
}), /*#__PURE__*/_jsx(Nodes, {
labelProps: isMinimal ? plainLabelProps.nodes : emptyObject
}), /*#__PURE__*/_jsx(Instances, {
labelProps: isMinimal ? plainLabelProps.instances : emptyObject
}), /*#__PURE__*/_jsx(Dimensions, {
labelProps: isMinimal ? plainLabelProps.dimensions : emptyObject
}), /*#__PURE__*/_jsx(Labels, {
labelProps: isMinimal ? plainLabelProps.labels : emptyObject
}), !isMinimal && /*#__PURE__*/_jsx(TimeAggregation, {})]
}), /*#__PURE__*/_jsx(Reset, {})]
});
};
export default FilterToolbox;