Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions thirdeye-ui/src/app/locale/languages/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@
"selected-time-range": "selected time range",
"sendgrid-api-key": "SendGrid API Key",
"sensitivity": "Sensitivity",
"setting-up-detection": "Setting up detections...",
"settings": "Settings",
"setup-entity": "Setup {{entity}}",
"show-all": "Show All",
Expand Down
11 changes: 11 additions & 0 deletions thirdeye-ui/src/app/pages/create-alert/hooks/state/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type RequestState = { status?: ActionStatus; errorMessages?: ErrorMessage[] };
type ApiState = {
evaluationState: RequestState | null;
insightState: RequestState | null;
alertRecommedationState: RequestState | null;
};

export type MultipleDimensionEnumeratorOptions =
Expand Down Expand Up @@ -112,6 +113,7 @@ export const useCreateAlertStore = create<CreateAlertStore>((set) => ({
apiState: {
evaluationState: null,
insightState: null,
alertRecommedationState: null,
},
alertTemplates: null,
selectedDataset: null,
Expand Down Expand Up @@ -157,6 +159,7 @@ export const useCreateAlertStore = create<CreateAlertStore>((set) => ({
granularity: undefined,
anomalyDetectionType: null,
workingAlert: {},
alertRecommendations: null,
selectedDetectionAlgorithm: null,
enumeratorQuery: "",
selectedEnumerationItems: null,
Expand All @@ -170,6 +173,7 @@ export const useCreateAlertStore = create<CreateAlertStore>((set) => ({
editedDatasourceFieldValue: "",
anomalyDetectionType: null,
workingAlert: {},
alertRecommendations: null,
selectedDetectionAlgorithm: null,
enumeratorQuery: "",
selectedEnumerationItems: null,
Expand All @@ -181,6 +185,7 @@ export const useCreateAlertStore = create<CreateAlertStore>((set) => ({
granularity: undefined,
anomalyDetectionType: null,
workingAlert: {},
alertRecommendations: null,
selectedDetectionAlgorithm: null,
enumeratorQuery: "",
selectedEnumerationItems: null,
Expand All @@ -192,12 +197,14 @@ export const useCreateAlertStore = create<CreateAlertStore>((set) => ({
anomalyDetectionType: null,
selectedDetectionAlgorithm: null,
enumeratorQuery: "",
alertRecommendations: null,
selectedEnumerationItems: null,
workingAlertEvaluation: null,
}),
setQueryFilters: (queryFilters: string) =>
set({
queryFilters: queryFilters,
alertRecommendations: null,
selectedDetectionAlgorithm: null,
enumeratorQuery: "",
}),
Expand All @@ -213,6 +220,7 @@ export const useCreateAlertStore = create<CreateAlertStore>((set) => ({
anomalyDetectionType: anomalyDetectionType,
multipleDimensionEnumeratorType: null,
enumeratorQuery: "",
alertRecommendations: null,
selectedDetectionAlgorithm: null,
selectedEnumerationItems: null,
workingAlertEvaluation: null,
Expand All @@ -236,6 +244,7 @@ export const useCreateAlertStore = create<CreateAlertStore>((set) => ({
) =>
set({
multipleDimensionEnumeratorType: multipleDimensionEnumeratorType,
alertRecommendations: null,
selectedDetectionAlgorithm: null,
selectedEnumerationItems: null,
enumeratorQuery: "",
Expand All @@ -244,6 +253,7 @@ export const useCreateAlertStore = create<CreateAlertStore>((set) => ({
setEnumeratorQuery: (enumeratorQuery: string) =>
set({
enumeratorQuery: enumeratorQuery,
alertRecommendations: null,
selectedDetectionAlgorithm: null,
selectedEnumerationItems: null,
}),
Expand Down Expand Up @@ -291,6 +301,7 @@ export const useCreateAlertStore = create<CreateAlertStore>((set) => ({
apiState: {
evaluationState: null,
insightState: null,
alertRecommedationState: null,
},
alertTemplates: null,
selectedDataset: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* the License.
*/
// external
import React, { useEffect, useState } from "react";
import React, { useEffect } from "react";
import { Box, CircularProgress, Grid, Typography } from "@material-ui/core";
import { useTranslation } from "react-i18next";

Expand Down Expand Up @@ -48,6 +48,7 @@ import { MultipleDimensionView } from "./multiple-dimension";
// utils
import { defaultStartingAlert, getWorkingAlert } from "../../../utils";
import { notifyIfErrors } from "../../../../../utils/notifications/notifications.util";
import { ActionStatus } from "../../../../../rest/actions.interfaces";

export const SelectDetection = (): JSX.Element => {
const { t } = useTranslation();
Expand All @@ -71,7 +72,8 @@ export const SelectDetection = (): JSX.Element => {
setApiState,
} = useCreateAlertStore();
const { notify } = useNotificationProviderV1();
const [alertInsightLoading] = useState(false);
const alertInsightLoading =
apiState.insightState?.status === ActionStatus.Working;

const { getEvaluation, evaluation, status, errorMessages } =
useGetEvaluation();
Expand Down Expand Up @@ -100,6 +102,13 @@ export const SelectDetection = (): JSX.Element => {
const handleAnomalyDetectionChange = async (
item: string
): Promise<void> => {
setApiState({
...apiState,
alertRecommedationState: {
...apiState.alertRecommedationState,
status: ActionStatus.Working,
},
});
setAnomalyDetectionType(item);
let updatedAlert = workingAlert;
if (item === AnomalyDetectionOptions.SINGLE) {
Expand Down Expand Up @@ -137,12 +146,26 @@ export const SelectDetection = (): JSX.Element => {
getAlertRecommendation(workingAlert as EditableAlert)
.then((recommendations) => {
setAlertRecommendations(recommendations);
setApiState({
...apiState,
alertRecommedationState: {
...apiState.alertRecommedationState,
status: ActionStatus.Done,
},
});
})
.catch(() => {
notify(
NotificationTypeV1.Error,
t("errors.could-not-compute-detection-recommendations")
);
setApiState({
...apiState,
alertRecommedationState: {
...apiState.alertRecommedationState,
status: ActionStatus.Error,
},
});
});
const start = updatedAlertInsight?.defaultStartTime;
const end = updatedAlertInsight?.defaultEndTime;
Expand Down Expand Up @@ -197,7 +220,7 @@ export const SelectDetection = (): JSX.Element => {
style={{ marginLeft: "4px" }}
variant="caption"
>
{t("label.loading-insights")}
{t("label.setting-up-detection")}
</Typography>
</Box>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,36 @@ export const RecommendedDimesnionsModal = ({
isMultiDimensionAlert: true,
});
setWorkingAlert(workingAlertUpdated);
setApiState({
...apiState,
alertRecommedationState: {
...apiState.alertRecommedationState,
status: ActionStatus.Working,
},
});
getAlertRecommendation(workingAlertUpdated as EditableAlert)
.then((recommendations) => {
setAlertRecommendations(recommendations);
setApiState({
...apiState,
alertRecommedationState: {
...apiState.alertRecommedationState,
status: ActionStatus.Done,
},
});
})
.catch(() => {
notify(
NotificationTypeV1.Error,
t("errors.could-not-compute-detection-recommendations")
);
setApiState({
...apiState,
alertRecommedationState: {
...apiState.alertRecommedationState,
status: ActionStatus.Error,
},
});
});
const start = alertInsight?.defaultStartTime;
const end = alertInsight?.defaultEndTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,36 @@ export const SqlQueryView = (): JSX.Element => {
isMultiDimensionAlert: true,
});
setWorkingAlert(workingAlertUpdated);
setApiState({
...apiState,
alertRecommedationState: {
...apiState.alertRecommedationState,
status: ActionStatus.Working,
},
});
getAlertRecommendation(workingAlertUpdated as EditableAlert)
.then((recommendations) => {
setAlertRecommendations(recommendations);
setApiState({
...apiState,
alertRecommedationState: {
...apiState.alertRecommedationState,
status: ActionStatus.Done,
},
});
})
.catch(() => {
notify(
NotificationTypeV1.Error,
t("errors.could-not-compute-detection-recommendations")
);
setApiState({
...apiState,
alertRecommedationState: {
...apiState.alertRecommedationState,
status: ActionStatus.Error,
},
});
});
const start = alertInsight?.defaultStartTime;
const end = alertInsight?.defaultEndTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { EditableAlert } from "../../../../rest/dto/alert.interfaces";

// apis
import { getAlertInsight } from "../../../../rest/alerts/alerts.rest";
import { ActionStatus } from "../../../../rest/actions.interfaces";

export const SelectGranularity = (): JSX.Element => {
const { t } = useTranslation();
Expand All @@ -56,6 +57,8 @@ export const SelectGranularity = (): JSX.Element => {
setSelectedTimeRange,
setWorkingAlert,
queryFilters,
apiState,
setApiState,
} = useCreateAlertStore();

const GRANULARITY_OPTIONS = [
Expand Down Expand Up @@ -116,6 +119,13 @@ export const SelectGranularity = (): JSX.Element => {
min: 0,
max: 1,
});
setApiState({
...apiState,
insightState: {
...apiState.insightState,
status: ActionStatus.Working,
},
});

const newAlertInsight = await getAlertInsight({
alert: {
Expand All @@ -124,6 +134,13 @@ export const SelectGranularity = (): JSX.Element => {
workingAlertUpdated.templateProperties,
} as EditableAlert,
});
setApiState({
...apiState,
insightState: {
...apiState.insightState,
status: ActionStatus.Done,
},
});

if (newAlertInsight) {
setAlertInsight(newAlertInsight);
Expand All @@ -140,6 +157,13 @@ export const SelectGranularity = (): JSX.Element => {
entity: t("label.alert-insight"),
})
);
setApiState({
...apiState,
insightState: {
...apiState.insightState,
status: ActionStatus.Error,
},
});
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { useCreateAlertStore } from "../../hooks/state";

export const SelectDatasetAndMetric = (): JSX.Element => {
const { t } = useTranslation();
const { datasetsInfo } = useGetDatasourcesTree();
const { datasetsInfo, isDatasourcesTreeLoading } = useGetDatasourcesTree();
const {
selectedDataset,
selectedMetric,
Expand All @@ -54,6 +54,7 @@ export const SelectDatasetAndMetric = (): JSX.Element => {
getOptionLabel={(option) =>
option.dataset.name as string
}
loading={isDatasourcesTreeLoading}
noOptionsText={t(
"message.no-options-available-entity",
{ entity: t("label.dataset") }
Expand Down
Loading
Loading