diff --git a/packages/main/plugins/Cardinality/CardinalityTotals.tsx b/packages/main/plugins/Cardinality/CardinalityTotals.tsx index 568fba49..f4ce9aa2 100644 --- a/packages/main/plugins/Cardinality/CardinalityTotals.tsx +++ b/packages/main/plugins/Cardinality/CardinalityTotals.tsx @@ -5,7 +5,7 @@ import { css, cx } from "@emotion/css"; import { Tooltip } from "@mui/material"; import ReplayIcon from '@mui/icons-material/Replay'; -import {format} from 'date-fns' +import { format } from 'date-fns' export const TotalRowStyle = css` @@ -69,6 +69,7 @@ export function Total(props: MaintainanceItem & MaintainanceActions) { const { id, type, + query, status, created_sec, from_sec, @@ -84,17 +85,18 @@ export function Total(props: MaintainanceItem & MaintainanceActions) {
{status}
{type}
-
{format(created_sec*1000,"dd-MM-yyyy hh:mm:ss")}
-
{format(from_sec*1000,"dd-MM-yyyy hh:mm:ss") }
-
{format(to_sec*1000,"dd-MM-yyyy hh:mm:ss")}
+
{query}
+
{format(created_sec * 1000, "dd-MM-yyyy hh:mm:ss")}
+
{format(from_sec * 1000, "dd-MM-yyyy hh:mm:ss")}
+
{format(to_sec * 1000, "dd-MM-yyyy hh:mm:ss")}
{series_dropped}
{series_created}
{JSON.stringify(logs)}
- - + +
@@ -113,30 +115,31 @@ export default function CardinalityTotals() { {" "}
-
-
Status
-
Type
-
Created sec
-
From sec
-
To sec
-
Series Dropped
-
Series Created
-
Logs
-
Undo
-
- <> - {totals?.length ? ( - totals?.map((total,key) => ( - - )) - ) : ( - <> no totals - )} - +
+
Status
+
Type
+
Query
+
Created sec
+
From sec
+
To sec
+
Series Dropped
+
Series Created
+
Logs
+
Undo
+
+ <> + {totals?.length ? ( + totals?.map((total, key) => ( + + )) + ) : ( + <> no totals + )} +
diff --git a/packages/main/plugins/Cardinality/api/CardinalityRequest.tsx b/packages/main/plugins/Cardinality/api/CardinalityRequest.tsx index 09e72338..573d445f 100644 --- a/packages/main/plugins/Cardinality/api/CardinalityRequest.tsx +++ b/packages/main/plugins/Cardinality/api/CardinalityRequest.tsx @@ -69,6 +69,70 @@ export const getDeletedFingerprints = async ( } }; +export const undoFingerPrintAction = async ( + id, + url, + setIsLoading, + headers, + auth, + setError +) => { + try { + const { u, p } = auth; + + const urlUndo = `${url}/api/v1/undo/${id}`; + await fetch(urlUndo, { + method: "POST", + + headers: { + ...headers, + Authorization: `Basic ${btoa(u + ":" + p)}`, + }, + }).then((response) => { + if ( + (response && response?.status === 500) || + response?.status === 400 + ) { + setError(response.statusText); + setIsLoading(false); + let error = response.text(); + store.dispatch( + createAlert({ + message: `Deleted fingerprints not undone, ${error}`, + type: "error", + }) + ); + } + + if ( + (response && response?.status === 200) || + response?.status === 200 + ) { + setIsLoading(false); + setError(""); + store.dispatch( + createAlert({ + message: `Undone deleted fingerprints`, + type: "success", + }) + ); + console.log(response); + } + }); + } catch (e) { + setError(JSON.stringify(e)); + setIsLoading(false); + store.dispatch( + createAlert({ + message: `Deleted fingerprints not undone`, + type: "error", + }) + ); + console.log(e); + setIsLoading(false); + } +}; + export const deleteFingerprints = async ( url, query, @@ -181,7 +245,7 @@ const requestCardinality = async ( setIsLoading(true); // set //this makes the multiple fetch requests - + try { const { u, p } = auth; const responses = await Promise.all( @@ -276,14 +340,10 @@ export const useCardinalityRequest = ( const { url, headers, user_pass } = useDataSourceData("logs"); - // const [isLoading, setIsLoading] = useState(false); // const [error, setError] = useState(""); // const [tsdbStatus, setTsdbStatus] = useState({}); - - - const handleDelete = async (query, amount) => { const locale = moment.tz.guess(true); const mDay = moment.tz(reqDate, locale).add(1, "day"); @@ -306,7 +366,6 @@ export const useCardinalityRequest = ( }; const handleGetDeletedFingerprints = async () => { - await getDeletedFingerprints( url, setError, @@ -315,7 +374,6 @@ export const useCardinalityRequest = ( headers, user_pass ); - }; const handleCardinalityRequest = async (params: any) => { diff --git a/packages/main/plugins/Cardinality/api/mock.ts b/packages/main/plugins/Cardinality/api/mock.ts index 1e40967f..1247db27 100644 --- a/packages/main/plugins/Cardinality/api/mock.ts +++ b/packages/main/plugins/Cardinality/api/mock.ts @@ -1,7 +1,10 @@ +import { MaintainanceItem } from '../api/types' -export const totalsMock = [ + +export const totalsMock: MaintainanceItem[] = [ { id: "85331a29-ea2f-4d6c-89ae-fa87349e4d7f", + query: "{a=\"b\"}", type: "delete", status: "running", created_sec: 1704359839, @@ -17,6 +20,7 @@ export const totalsMock = [ }, { id: "85331a29-ea2f-4d6c-89ae-fa87349e4d7f", + query: "{a=\"b\"}", type: "delete", status: "running", created_sec: 1704359839, @@ -32,6 +36,7 @@ export const totalsMock = [ }, { id: "85331a29-ea2f-4d6c-89ae-fa87349e4d7f", + query: "{__name=\"server\",type=\"clickhouse\",level=\"info\"}", type: "delete", status: "running", created_sec: 1704359839, @@ -47,6 +52,7 @@ export const totalsMock = [ }, { id: "85331a29-ea2f-4d6c-89ae-fa87349e4d7f", + query: "{__name=\"server\",type=\"clickhouse\",level=\"debug\"}", type: "delete", status: "running", created_sec: 1704359839, @@ -60,4 +66,5 @@ export const totalsMock = [ "INFO backing up data", ], }, -]; \ No newline at end of file +]; + diff --git a/packages/main/plugins/Cardinality/api/types.tsx b/packages/main/plugins/Cardinality/api/types.tsx index f50724b2..bc07e48e 100644 --- a/packages/main/plugins/Cardinality/api/types.tsx +++ b/packages/main/plugins/Cardinality/api/types.tsx @@ -7,6 +7,7 @@ export interface CardinalityRequest { export interface MaintainanceItem { id: string; + query: string; created_sec: number; // ts sec from_sec: number; // ts sec to_sec: number; // ts sec diff --git a/packages/main/views/Main/DesktopView.tsx b/packages/main/views/Main/DesktopView.tsx index 6bedc17f..8289ed4a 100644 --- a/packages/main/views/Main/DesktopView.tsx +++ b/packages/main/views/Main/DesktopView.tsx @@ -43,8 +43,8 @@ export function DesktopView({ const realMinWidth = !isSplit ? widthTotal : widthTotal / 4 > 370 - ? widthTotal / 4 - : 370; + ? widthTotal / 4 + : 370; setMinWidth(realMinWidth); }, [ setWidthLeft, @@ -102,10 +102,7 @@ export function DesktopView({ return ( - - {panelsRenderer(leftOpen, rightOpen)} - - + {panelsRenderer(leftOpen, rightOpen)}