Skip to content
Snippets Groups Projects
Verified Commit 54a4d985 authored by Leonardo's avatar Leonardo Committed by Dennis Collaris
Browse files

chore: remove webpage alerts

parent ecdc4998
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import { Button, Input, LoadingSpinner } from '../../components';
import { EditorState } from 'lexical';
import { MonitorType } from '../components/Sidebar';
import { wsUpdateInsight, wsCreateInsight, wsDeleteInsight } from '../../data-access/broker/wsInsightSharing';
import { addError } from '../../data-access/store/configSlice';
type Props = {
insight: InsightResponse;
......@@ -45,30 +46,22 @@ export function AlertingForm(props: Props) {
const handleSave = async () => {
if (!name || name.trim() === '') {
alert('Please enter a name for the alert.');
return;
}
if (!description || description.trim() === '') {
alert('Please enter a description for the alert.');
return;
}
if (!editorState) {
alert('Please enter content in the text editor before saving.');
dispatch(addError('Name is required'));
return;
}
const alertData : InsightRequest = {
const alertData: InsightRequest = {
name,
description,
recipients,
template: JSON.stringify(editorState),
saveStateId: session.currentSaveState || '',
type: 'alert' as const,
frequency: ''
frequency: '',
};
setLoading(true);
if (props.insight.id) {
wsUpdateInsight(props.insight.id, alertData, (data: any, status: string) => {
setLoading(false);
......@@ -124,20 +117,8 @@ export function AlertingForm(props: Props) {
return (
<div>
<span className="text-lg text-secondary-600 font-bold mb-4">Alert ID: {props.insight.id}</span>
<Input
label="Name"
type="text"
value={name}
onChange={setName}
className="mb-4"
/>
<Input
label="Description"
type="text"
value={description}
onChange={setDescription}
className="mb-4"
/>
<Input label="Name" type="text" value={name} onChange={setName} className="mb-4" />
<Input label="Description" type="text" value={description} onChange={setDescription} className="mb-4" />
<Accordion defaultOpenAll={true} className="border-t divide-y">
<AccordionItem className="pt-2 pb-4">
<AccordionHead showArrow={false}>
......@@ -152,8 +133,8 @@ export function AlertingForm(props: Props) {
setRecipientInput(String(value));
const recipientList = String(value)
.split(/[, ]/)
.map(r => r.trim())
.filter(r => r.length > 0);
.map((r) => r.trim())
.filter((r) => r.length > 0);
setRecipients(recipientList);
}}
placeholder="Enter recipient(s)"
......@@ -183,4 +164,4 @@ export function AlertingForm(props: Props) {
</div>
</div>
);
}
\ No newline at end of file
}
......@@ -7,6 +7,7 @@ import { useAppDispatch, useSessionCache } from '../../data-access';
import { MonitorType } from '../components/Sidebar';
import { EditorState } from 'lexical';
import { wsCreateInsight, wsDeleteInsight, wsUpdateInsight } from '../../data-access/broker/wsInsightSharing';
import { addError } from '../../data-access/store/configSlice';
type Props = {
insight: InsightResponse;
......@@ -59,15 +60,7 @@ export function ReportingForm(props: Props) {
const handleSave = async () => {
if (!name || name.trim() === '') {
alert('Please enter a name for the report.');
return;
}
if (!description || description.trim() === '') {
alert('Please enter a description for the report.');
return;
}
if (!editorState) {
alert('Please enter content in the text editor before saving.');
dispatch(addError('Please enter a name for the report.'));
return;
}
......@@ -77,7 +70,7 @@ export function ReportingForm(props: Props) {
recipients,
frequency,
template: JSON.stringify(editorState),
saveStateId: session.currentSaveState || "",
saveStateId: session.currentSaveState || '',
type: 'report' as const,
};
......@@ -107,7 +100,7 @@ export function ReportingForm(props: Props) {
alert('Failed to create report.');
}
});
}
}
};
const handleDelete = async () => {
......@@ -136,20 +129,8 @@ export function ReportingForm(props: Props) {
) : (
<div>
<span className="text-lg text-secondary-600 font-bold mb-4">Report ID: {props.insight.id}</span>
<Input
label="Name"
type="text"
value={name}
onChange={handleSetName}
className="mb-4"
/>
<Input
label="Description"
type="text"
value={description}
onChange={handleSetDescription}
className="mb-4"
/>
<Input label="Name" type="text" value={name} onChange={handleSetName} className="mb-4" />
<Input label="Description" type="text" value={description} onChange={handleSetDescription} className="mb-4" />
<Accordion defaultOpenAll={true} className="border-t divide-y">
<AccordionItem className="pt-2 pb-4">
<AccordionHead showArrow={false}>
......@@ -164,8 +145,8 @@ export function ReportingForm(props: Props) {
setRecipientInput(String(value));
const recipientList = String(value)
.split(/[, ]/)
.map(r => r.trim())
.filter(r => r.length > 0);
.map((r) => r.trim())
.filter((r) => r.length > 0);
setRecipients(recipientList);
}}
placeholder="Enter recipient(s)"
......@@ -210,4 +191,4 @@ export function ReportingForm(props: Props) {
</div>
</div>
);
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment