UNPKG

@netdata/charts

Version:

Netdata frontend SDK and chart utilities

69 lines 2.92 kB
import React from "react"; import { TextMicro } from "@netdata/netdata-ui"; import checkmark_s from "@netdata/netdata-ui/dist/components/icon/assets/checkmark_s.svg"; import warning_triangle_hollow from "@netdata/netdata-ui/dist/components/icon/assets/warning_triangle_hollow.svg"; import Icon from "../icon"; import { useChart } from "../provider"; import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; var Totals = function Totals(_ref) { var _ref$selected = _ref.selected, selected = _ref$selected === void 0 ? [] : _ref$selected, _ref$qr = _ref.qr, qr = _ref$qr === void 0 ? 0 : _ref$qr, _ref$fl = _ref.fl, fl = _ref$fl === void 0 ? 0 : _ref$fl, _ref$sl = _ref.sl, sl = _ref$sl === void 0 ? 0 : _ref$sl, _ref$ex = _ref.ex, ex = _ref$ex === void 0 ? 0 : _ref$ex, _ref$teaser = _ref.teaser, teaser = _ref$teaser === void 0 ? false : _ref$teaser, resourceName = _ref.resourceName, _ref$totalSelected = _ref.totalSelected, totalSelected = _ref$totalSelected === void 0 ? [] : _ref$totalSelected; var total = sl + ex; var selectedCount = (totalSelected === null || totalSelected === void 0 ? void 0 : totalSelected.length) || selected.length; var queriedSelectedCount = selectedCount && selectedCount < qr ? selectedCount : qr; var couldBeMore = fl > 0 || teaser && qr < (selectedCount || total); var possiblesCount = (teaser ? selectedCount || total : selectedCount) || sl; var chart = useChart(); return /*#__PURE__*/_jsxs(TextMicro, { color: "textLite", children: [/*#__PURE__*/_jsx(TextMicro, { color: teaser ? "text" : "primary", children: queriedSelectedCount }), !teaser ? " queried" : " ", !teaser && /*#__PURE__*/_jsx(Icon, { margin: [-0.5, 1, -0.5, 0], width: "14px", height: "14px", color: "primary", svg: checkmark_s }), !!fl && /*#__PURE__*/_jsxs(_Fragment, { children: [!teaser ? "+ " : /*#__PURE__*/_jsx(TextMicro, { color: "errorLite", children: " +" }), /*#__PURE__*/_jsx(TextMicro, { color: "errorLite", children: fl }), !teaser ? "failed " : " ", /*#__PURE__*/_jsx(Icon, { margin: [-0.5, 1, -0.5, 0], width: "14px", height: "14px", color: "errorLite", svg: warning_triangle_hollow })] }), couldBeMore && /*#__PURE__*/_jsxs(_Fragment, { children: ["of ", /*#__PURE__*/_jsx(TextMicro, { color: teaser ? "textLite" : "text", children: possiblesCount }), !teaser ? " selected" : " "] }), !teaser && qr !== total && /*#__PURE__*/_jsxs(_Fragment, { children: ["of ", /*#__PURE__*/_jsx(TextMicro, { children: total }), " available"] }), resourceName ? chart.intl(resourceName, { count: couldBeMore ? possiblesCount : queriedSelectedCount }) : ""] }); }; export default Totals;