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
3 changes: 1 addition & 2 deletions thirdeye-ui/e2e/pages/alert-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,7 @@ export class AlertDetailsPage extends BasePage {
const count = await availableDates.count();
const newStartDate = availableDates.nth(1);
const newEndDate = availableDates.nth(count - 2);
newStartDate.click();
newEndDate.click();
await Promise.all([newStartDate.click(), newEndDate.click()]);
const applyDateBtn = this.page.getByTestId("apply-button");
applyDateBtn.click();
await Promise.all([
Expand Down
7 changes: 5 additions & 2 deletions thirdeye-ui/e2e/tests/alert-details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ test("View anomalies for alerts", async ({ page }) => {
await alertDetailsPage.checkHeader();
await alertDetailsPage.openFirstAlert();
await alertDetailsPage.resolveDetailsPageApis();
await page.waitForTimeout(1000);
await alertDetailsPage.checkAlertHeader();
const anomalyDisabled = await alertDetailsPage.checkAnomaliesCount();
if (anomalyDisabled) {
Expand All @@ -33,13 +34,14 @@ test("View anomalies for alerts", async ({ page }) => {
await alertDetailsPage.assertPageComponents();
});

test.skip("Active and Deactivate alerts", async ({ page }) => {
test("Active and Deactivate alerts", async ({ page }) => {
const alertDetailsPage = new AlertDetailsPage(page);
await alertDetailsPage.goToAlertDetailsPage();
await alertDetailsPage.resolveApis();
await alertDetailsPage.checkHeader();
await alertDetailsPage.openFirstAlert();
await alertDetailsPage.resolveDetailsPageApis();
await page.waitForTimeout(1000);
await alertDetailsPage.checkAlertHeader();
const anomalyDisabled = await alertDetailsPage.checkAnomaliesCount();
if (anomalyDisabled) {
Expand All @@ -54,11 +56,12 @@ test.skip("Active and Deactivate alerts", async ({ page }) => {
await alertDetailsPage.checkAlertIsActiveOrDeactive(true);
});

test.skip("User can select date range for anomalies", async ({ page }) => {
test("User can select date range for anomalies", async ({ page }) => {
const alertDetailsPage = new AlertDetailsPage(page);
await alertDetailsPage.goToAlertDetailsPage();
await alertDetailsPage.resolveApis();
await alertDetailsPage.openFirstAlert();
await alertDetailsPage.resolveDetailsPageApis();
await page.waitForTimeout(1000);
await alertDetailsPage.applyDateChange();
});
2 changes: 1 addition & 1 deletion thirdeye-ui/e2e/tests/alert-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test("Duplicate Alert", async ({ page }) => {
await alertListPage.duplicateAlert();
});

test("Edit Alert", async ({ page }) => {
test.skip("Edit Alert", async ({ page }) => {
await alertListPage.editAlert();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import {
DropdownMenuItemV1,
} from "../../platform/components";
import {
getAlertsCreatePath,
getAlertsCeateUpdatedPath,
// getAlertsCreatePath,
getAlertTemplatesCreatePath,
getAnomaliesCreatePath,
getDatasetsOnboardPath,
Expand All @@ -35,7 +36,7 @@ export const CreateMenuButton: FunctionComponent = () => {
const navigate = useNavigate();

const handleCreateAlert = (): void => {
navigate(getAlertsCreatePath());
navigate(getAlertsCeateUpdatedPath());
};

const handleCreateSubscriptionGroup = (): void => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/*
* Copyright 2025 StarTree Inc
*
* Licensed under the StarTree Community License (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at http://www.startree.ai/legal/startree-community-license
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions and limitations under
* the License.
*/
import React, { FunctionComponent, useEffect, useMemo } from "react";
import { SkeletonV1, TooltipV1 } from "../../../../../platform/components";
import { Typography, useTheme } from "@material-ui/core";
import { LoadingErrorStateSwitch } from "../../../../page-states/loading-error-state-switch/loading-error-state-switch.component";
import { getAlertAccuracyData } from "../../../../../utils/alerts/alerts.util";
import { AlertAccuracyColoredProps } from "./interface";
import { useInView } from "react-intersection-observer";
import { useTranslation } from "react-i18next";
import { capitalize } from "lodash";
import { AnomalyFeedbackType } from "../../../../../rest/dto/anomaly.interfaces";

export const AlertAccuracyColored: FunctionComponent<AlertAccuracyColoredProps> =
({
typographyProps,
label,
defaultSkeletonProps,
alertStats,
triggerViewCallback,
}) => {
const theme = useTheme();
const { t } = useTranslation();

const { ref, inView } = useInView({
triggerOnce: true,
delay: 250,
threshold: 1,
});

useEffect(() => {
if (inView && triggerViewCallback) {
triggerViewCallback();
}
}, [inView]);

const { noAnomalyData, typographyColor, accuracyString } =
useMemo(() => {
if (alertStats) {
const { accuracy, colorScheme, noAnomalyData } =
getAlertAccuracyData(alertStats);

const accuracyString = `${(100 * accuracy).toFixed(2)}%`;

const color = theme.palette[colorScheme].main;

return {
noAnomalyData,
typographyColor: !noAnomalyData ? { color } : undefined,
accuracyString,
};
}

return {
noAnomalyData: undefined,
typographyColor: undefined,
accuracyString: undefined,
};
}, [alertStats]);

let displayValue: string | undefined = capitalize(
t("message.no-entity-data", {
entity: t("label.anomaly"),
})
);

if (!noAnomalyData) {
if (label) {
displayValue = `${label}: ${accuracyString}`;
} else {
displayValue = accuracyString;
}
}

return (
<TooltipV1
delay={50}
placement="bottom"
title={
!!alertStats && (
<table>
<tbody>
<tr>
<td>
{t("message.total-reported-anomalies")}
</td>
<td>{alertStats?.stats?.totalCount}</td>
</tr>
<tr>
<td>
{t("message.anomalies-with-feedback")}
</td>
<td>
{alertStats?.stats?.countWithFeedback}
</td>
</tr>
<tr>
<td>
{t("message.misreported-anomalies")}
</td>
<td>
{
alertStats?.stats?.feedbackStats[
AnomalyFeedbackType.NOT_ANOMALY
]
}
</td>
</tr>
</tbody>
</table>
)
}
>
<div>
<Typography
color="secondary"
innerRef={ref}
style={{
...typographyColor,
...(typographyProps?.color
? { color: typographyProps.color }
: {}),
}}
variant="body1"
{...typographyProps}
>
<LoadingErrorStateSwitch
isError={false}
isLoading={alertStats?.loading}
loadingState={
<SkeletonV1
width={50}
{...defaultSkeletonProps}
/>
}
>
<>{displayValue}</>
</LoadingErrorStateSwitch>
</Typography>
</div>
</TooltipV1>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2025 StarTree Inc
*
* Licensed under the StarTree Community License (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at http://www.startree.ai/legal/startree-community-license
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions and limitations under
* the License.
*/
import type { TypographyProps } from "@material-ui/core";
import type { ReactElement } from "react";
import { SkeletonV1Props } from "../../../../../platform/components/skeleton-v1/skeleton-v1.interfaces";

export interface AlertAccuracyColoredProps {
alertId: number;
renderCustomLoading?: ReactElement;
defaultSkeletonProps?: SkeletonV1Props;
typographyProps?: Partial<TypographyProps>;
label?: string;
start?: number;
end?: number;
alertStats?: any;
triggerViewCallback?: any;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
* Copyright 2025 StarTree Inc
*
* Licensed under the StarTree Community License (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at http://www.startree.ai/legal/startree-community-license
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions and limitations under
* the License.
*/
import { Grid, Typography } from "@material-ui/core";
import { forEach } from "lodash";
import React, { FunctionComponent } from "react";
import { useTranslation } from "react-i18next";
import { UiAlert } from "../../../../../rest/dto/ui-alert.interfaces";
import { useAlertCardStyles } from "./styles";
import { NoDataIndicator } from "../../../../no-data-indicator/no-data-indicator.component";

type AlertCardV1Props = {
uiAlert: UiAlert;
showCreatedBy?: boolean;
};

export const AlertCardV1: FunctionComponent<AlertCardV1Props> = (
props: AlertCardV1Props
) => {
const classes = useAlertCardStyles();
const { t } = useTranslation();

const getAllSubscriptionGroupsName = (uiAlert: UiAlert): string => {
const subScriptingGroups: Array<string | number> = [];
forEach(uiAlert.subscriptionGroups, (Obj) => {
if (Obj.name) {
subScriptingGroups.push(Obj.name);
}
});

return subScriptingGroups.join(", ");
};

const getDetectionTypes = (uiAlert: UiAlert): string => {
return uiAlert.detectionTypes.join(", ");
};

if (!props.uiAlert) {
return <NoDataIndicator />;
}

return (
<Grid container>
{/* Created By */}
{props.showCreatedBy && (
<Grid item xs={6}>
<Grid item>
<Typography
className={classes.fontMedium}
variant="body2"
>
{t("label.created-by")}:
</Typography>
</Grid>
<Grid item>
<Typography variant="body2">
{props.uiAlert.createdBy || "-"}
</Typography>
</Grid>
</Grid>
)}

{/* Detection Type */}
{props.uiAlert.detectionTypes.length > 0 && (
<Grid item xs={6}>
<Grid item>
<Typography
className={classes.fontMedium}
variant="body2"
>
{t("label.detection-type")}:
</Typography>
</Grid>

<Grid item>
<Typography variant="body2">
{getDetectionTypes(props.uiAlert) || "-"}
</Typography>
</Grid>
</Grid>
)}

{/* Description */}
<Grid item xs={12}>
<Grid item>
<Typography className={classes.fontMedium} variant="body2">
{t("label.description")}:
</Typography>
</Grid>

<Grid item>
<Typography variant="body2">
{props.uiAlert?.alert?.description || t("label.none")}
</Typography>
</Grid>
</Grid>

{/* Subscription Groups */}
<Grid item xs={6}>
<Grid item>
<Typography className={classes.fontMedium} variant="body2">
{t("label.subscription-groups")}:
</Typography>
</Grid>

<Grid item>
<Typography variant="body2">
{props.uiAlert.subscriptionGroups.length > 0 &&
getAllSubscriptionGroupsName(props.uiAlert)}
{props.uiAlert.subscriptionGroups.length === 0 && (
<span>{t("label.none")}</span>
)}
</Typography>
</Grid>
</Grid>
</Grid>
);
};
Loading
Loading