chore(ui): user offset and raw filter from the api response

This commit is contained in:
Łukasz Mierzwa
2019-07-14 18:22:09 +01:00
parent e36f25a248
commit 2bdbfeb16f
4 changed files with 71 additions and 18 deletions

View File

@@ -4,7 +4,6 @@ import PropTypes from "prop-types";
import { observer } from "mobx-react";
import { AlertStore } from "Stores/AlertStore";
import { QueryOperators, FormatQuery } from "Common/Query";
import { LabelWithPercent } from "Components/Labels/LabelWithPercent";
const LabelsTable = observer(({ alertStore }) => (
@@ -24,26 +23,17 @@ const LabelsTable = observer(({ alertStore }) => (
</span>
</td>
<td width="75%" className="mw-100 p-1">
{nameStats.values.slice(0, 9).map((valueStats, i, array) => (
{nameStats.values.slice(0, 9).map((valueStats, i) => (
<LabelWithPercent
key={valueStats.value}
name={nameStats.name}
value={valueStats.value}
hits={valueStats.hits}
percent={valueStats.percent}
offset={array
.slice(0, i)
.map(ns => ns.percent)
.reduce((a, b) => a + b, 0)}
offset={valueStats.offset}
isActive={
alertStore.filters.values.filter(
f =>
f.raw ===
FormatQuery(
nameStats.name,
QueryOperators.Equal,
valueStats.value
)
f => f.raw === valueStats.raw
).length > 0
}
/>