Skip to content

Commit

Permalink
v 4.0.3 feedback alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
gooduling committed Oct 10, 2022
1 parent 21c3337 commit 2544d1b
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "anodot-datasource",
"version": "4.0.2",
"version": "4.0.3",
"description": "Anodot Grafana Datasource for anodot-panel plugin",
"scripts": {
"build": "grafana-toolkit plugin:build",
Expand Down
38 changes: 26 additions & 12 deletions src/Alerts/QueryEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import FormSelect from '../components/FormField/FormSelect';
import { alertAcknowledgeOptions, alertTypesOptions, severityOptions } from '../utils/constants';
import { alertAcknowledgeOptions, alertTypesOptions, feedbackOptions, severityOptions } from '../utils/constants';
import { AlertsQuery, ScenarioProps } from '../types';
import FormSwitch from '../components/FormField/FormSwitch';
import defaults from 'lodash/defaults';
Expand All @@ -9,6 +9,7 @@ import { SelectableValue } from '@grafana/data';
export const defaultAlertsQuery: Partial<AlertsQuery> = {
showOpen: false,
acknowledge: '',
feedback: [],
};

const AlertsQueryEditor = (props: ScenarioProps<AlertsQuery>) => {
Expand Down Expand Up @@ -37,17 +38,15 @@ const AlertsQueryEditor = (props: ScenarioProps<AlertsQuery>) => {

return (
<>
<div className="gf-form-inline">
<div className="gf-form gf-form--grow">
<FormSelect
isMulti
inputWidth={0}
label={'Recipient (Users / Channels)'}
value={query.recipient}
options={subscribersOptions}
onChange={(value) => onFormChange('recipient', value, true)}
/>
</div>
<div className="gf-form gf-form--grow">
<FormSelect
isMulti
inputWidth={0}
label={'Recipient (Users / Channels)'}
value={query.recipient}
options={subscribersOptions}
onChange={(value) => onFormChange('recipient', value, true)}
/>
</div>
<div className="gf-form-inline">
<div className="gf-form gf-form--grow">
Expand All @@ -70,6 +69,21 @@ const AlertsQueryEditor = (props: ScenarioProps<AlertsQuery>) => {
/>
</div>
</div>
<div className="gf-form gf-form--grow">
<FormSelect
isMulti
inputWidth={0}
label={'Feedback'}
value={query.feedback}
options={feedbackOptions}
onChange={(currentMultiValues, { option }) => {
if (option.value === 'noFeedback') {
currentMultiValues = [option];
}
return onFormChange('feedback', currentMultiValues, true);
}}
/>
</div>
<div className="gf-form-inline">
<div className="gf-form gf-form--grow">
<FormSelect
Expand Down
10 changes: 10 additions & 0 deletions src/Topology/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import FormSwitch from '../components/FormField/FormSwitch';
import FormInput from '../components/FormField/FormInput';
import { SelectableValue } from '@grafana/data';
import MetricSearchField from '../components/MetricSearchField';
// import DimensionsRows from '../components/KeyValueControl';

export const defaultTopologyQuery: Partial<TopologyQuery> = {
deltaValue: 5,
Expand Down Expand Up @@ -320,6 +321,15 @@ class TopologyQueryEditor extends React.Component<Props, TopologyQueryState> {
required
/>
</div>
{/*<div style={{ marginBottom: 4 }}>*/}
{/* <DimensionsRows*/}
{/* key={firstMetricName}*/}
{/* getValues={getValues}*/}
{/* dimensionsQuery={JSON.parse(query.dimensions)}*/}
{/* onChangeDimensions={(value) => onFormChange('dimensions', JSON.stringify(value), true)}*/}
{/* availableDimensionsNames={availableOptions}*/}
{/* />*/}
{/*</div>*/}
</>
);
}
Expand Down
6 changes: 5 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export async function getAnomalyChart(anomaly, params, ds) {

export async function getAlerts(query, ds) {
const { timeInterval } = ds;
const { severities = [], types = [], recipient = [], showOpen, acknowledge } = query;
const { severities = [], types = [], recipient = [], showOpen, acknowledge, feedback = [] } = query;
let subscribers = [];
let channels = [];

Expand All @@ -98,6 +98,10 @@ export async function getAlerts(query, ds) {
sort: 'updatedTime',
};

feedback.forEach((option) => {
params[option.value] = true;
});

if (showOpen) {
params.status = 'OPEN';
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormField/FormSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface FormSelectProps extends SelectCommonProps<any> {
isLoading?: boolean;
isMulti?: boolean;
isClearable?: boolean;
onChange(event?: any): any;
onChange(event?: any, currentSelection?: any): any;
onInputChange?(str: string, options?: any): any;
notOptions?: NotOptionsType;
error?: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface AlertsQuery extends EditorQuery {
recipient: object;
showOpen: boolean;
acknowledge: '' | 'ACK' | 'NOACK';
feedback: object[];
}

export interface MetricsQuery extends EditorQuery {
Expand Down
6 changes: 6 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ export const alertTypesOptions = [
{ label: 'No Data', value: 'noData' },
];

export const feedbackOptions = [
{ label: 'Good catch', value: 'positiveFeedback' },
{ label: 'Not interesting', value: 'negativeFeedback' },
{ label: 'No Feedback', value: 'noFeedback' },
];

export const alertAcknowledgeOptions = [
{ label: 'All', value: '' },
{ label: 'Acknowledged', value: 'ACK' },
Expand Down

0 comments on commit 2544d1b

Please sign in to comment.