Skip to content

Commit 1654618

Browse files
authored
feat: add error thresholds setting for visualization panels on notebooks (#3533)
1 parent b27b06a commit 1654618

File tree

13 files changed

+673
-81
lines changed

13 files changed

+673
-81
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
"normalizr": "^3.4.1",
193193
"onigasm": "^2.2.4",
194194
"papaparse": "^5.2.0",
195+
"qrcode.react": "^1.0.1",
195196
"qs": "^6.5.2",
196197
"react": "^17.0.2",
197198
"react-beautiful-dnd": "^13.0.0",

src/flows/components/Sidebar.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@import '@influxdata/clockface/dist/variables.scss';
22

33
.flow-sidebar {
4-
flex: 0 0 300px;
5-
width: 300px;
4+
flex: 0 0 calc(420px - $cf-space-2xs);
5+
width: 420px - $cf-space-2xs;
66
padding: 0 $cf-space-2xs;
77

88
.sidebar--item {
@@ -42,6 +42,7 @@
4242

4343
.flow-sidebar--submenu-wrapper {
4444
width: calc(100% - 16px);
45+
padding-bottom: 20px;
4546
}
4647

4748
.flow-sidebar--dropdownmenu {

src/flows/pipes/Notification/Threshold.tsx

Lines changed: 7 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -19,74 +19,12 @@ import 'src/flows/pipes/Notification/Threshold.scss'
1919

2020
// Utils
2121
import {event} from 'src/cloud/utils/reporting'
22-
23-
enum ThresholdFormat {
24-
Value = 'value',
25-
Range = 'range',
26-
Deadman = 'deadman',
27-
}
28-
29-
type Threshold = {
30-
value: number
31-
type: string
32-
field: string
33-
max?: number
34-
min?: number
35-
deadmanCheckValue?: string
36-
deadmanStopValue: string
37-
}
38-
39-
export const deadmanType = 'missing-for-longer-than'
40-
41-
export const THRESHOLD_TYPES = {
42-
greater: {
43-
name: 'greater than',
44-
format: ThresholdFormat.Value,
45-
condition: data => `(r) => (r["${data.field}"] > ${data.value})`,
46-
},
47-
'greater-equal': {
48-
name: 'greater than or equal to',
49-
format: ThresholdFormat.Value,
50-
condition: data => `(r) => (r["${data.field}"] >= ${data.value})`,
51-
},
52-
less: {
53-
name: 'less than',
54-
format: ThresholdFormat.Value,
55-
condition: data => `(r) => (r["${data.field}"] < ${data.value})`,
56-
},
57-
'less-equal': {
58-
name: 'less than or equal to',
59-
format: ThresholdFormat.Value,
60-
condition: data => `(r) => (r["${data.field}"] <= ${data.value})`,
61-
},
62-
equal: {
63-
name: 'equal to',
64-
format: ThresholdFormat.Value,
65-
condition: data => `(r) => (r["${data.field}"] == ${data.value})`,
66-
},
67-
'not-equal': {
68-
name: 'not equal to',
69-
format: ThresholdFormat.Value,
70-
condition: data => `(r) => (r["${data.field}"] != ${data.value})`,
71-
},
72-
between: {
73-
name: 'between',
74-
format: ThresholdFormat.Range,
75-
condition: data =>
76-
`(r) => (r["${data.field}"] > ${data.min} and r["${data.field}"] < ${data.max})`,
77-
},
78-
'not-between': {
79-
name: 'not between',
80-
format: ThresholdFormat.Range,
81-
condition: data =>
82-
`(r) => (r["${data.field}"] < ${data.min} or r["${data.field}"] > ${data.max})`,
83-
},
84-
[deadmanType]: {
85-
name: 'missing for longer than',
86-
format: ThresholdFormat.Deadman,
87-
condition: _ => `(r) => (r["dead"])`,
88-
},
89-
}
22+
import {
23+
deadmanType,
24+
Threshold,
25+
ThresholdFormat,
26+
THRESHOLD_TYPES,
27+
} from 'src/flows/pipes/Visualization/threshold'
9028

9129
interface Props {
9230
readOnly?: boolean
@@ -102,7 +40,7 @@ const Threshold: FC<Props> = ({readOnly}) => {
10240
const thresholds = useMemo(() => data?.thresholds ?? [], [data?.thresholds])
10341

10442
const setThresholdType = useCallback(
105-
(type, index) => {
43+
(type: string, index) => {
10644
if (!THRESHOLD_TYPES[type]) {
10745
return
10846
}

src/flows/pipes/Notification/view.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ import {PipeContext} from 'src/flows/context/pipe'
3434
import {FlowQueryContext} from 'src/flows/context/flow.query'
3535
import {remove} from 'src/shared/contexts/query'
3636
import Expressions from 'src/flows/pipes/Notification/Expressions'
37-
import Threshold, {
37+
import Threshold from 'src/flows/pipes/Notification/Threshold'
38+
import {
3839
deadmanType,
3940
THRESHOLD_TYPES,
40-
} from 'src/flows/pipes/Notification/Threshold'
41+
} from 'src/flows/pipes/Visualization/threshold'
4142
import {
4243
ENDPOINT_DEFINITIONS,
4344
ENDPOINT_ORDER,

src/flows/pipes/Visualization/Controls.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import {
1313
} from 'src/visualization'
1414
import {ViewType} from 'src/types'
1515
import {event} from 'src/cloud/utils/reporting'
16-
16+
import ErrorThresholds from 'src/flows/pipes/Visualization/ErrorThresholds'
1717
import {SidebarContext} from 'src/flows/context/sidebar'
1818
import {PipeContext, PipeProvider} from 'src/flows/context/pipe'
19+
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
1920

2021
const WrappedViewOptions: FC = () => {
2122
const {data, update, results} = useContext(PipeContext)
@@ -33,11 +34,14 @@ const WrappedViewOptions: FC = () => {
3334
)
3435

3536
return (
36-
<ViewOptions
37-
properties={data.properties}
38-
results={results.parsed}
39-
update={updateProperties}
40-
/>
37+
<>
38+
<ViewOptions
39+
properties={data.properties}
40+
results={results.parsed}
41+
update={updateProperties}
42+
/>
43+
{isFlagEnabled('flowErrorThresholds') && <ErrorThresholds />}
44+
</>
4145
)
4246
}
4347

0 commit comments

Comments
 (0)