diff --git a/ADVANCED.md b/ADVANCED.md index 4be89ec..acc15a8 100644 --- a/ADVANCED.md +++ b/ADVANCED.md @@ -20,7 +20,7 @@ curl -s -i -H Canonical-Resource : endpoint-test http://localhost:8880/noisy_reg You can now access live results as follows: - [Diffy](http://localhost:8888) - ![Diffy](/images/diffy_diffy.png) + ![Diffy](/images/diffy_ui.png) - [Grafana Dashboards](http://localhost:3000/explore) - Loki (logs) ![Loki](/images/loki_diffy.png) diff --git a/frontend/src/features/info/InfoView.tsx b/frontend/src/features/info/InfoView.tsx index 0b5bd31..09d1e22 100644 --- a/frontend/src/features/info/InfoView.tsx +++ b/frontend/src/features/info/InfoView.tsx @@ -1,10 +1,17 @@ -import { Grid, Typography } from '@mui/material'; -import { fetchinfo } from './infoApiSlice'; +import DeleteIcon from '@mui/icons-material/Delete'; +import { Alert, Grid, IconButton, Snackbar, Tooltip, Typography } from '@mui/material'; +import { useAppDispatch, useAppSelector } from '../../app/hooks' + +import { fetchinfo, useDeleteRequestsMutation } from './infoApiSlice'; +import { openDeleteRequestsAlert, closeDeleteRequestsAlert } from '../selections/selectionsSlice'; export default function InfoView(){ - const target = 'Unknown'; + const dispatch = useAppDispatch(); const info = fetchinfo(); - + const alertIsOpen = useAppSelector((state) => state.selections.deleteRequestAlertIsOpen); + const closeAlert = () => dispatch(closeDeleteRequestsAlert()); + const [deleteRequests, { isLoading: isUpdating, isSuccess }] = useDeleteRequestsMutation(); + return Candidate Server @@ -42,5 +49,22 @@ export default function InfoView(){ {info.relativeThreshold}% relative, {info.absoluteThreshold}% absolute + + + deleteRequests().then(() => dispatch(openDeleteRequestsAlert()))}> + + + + + + + + All requests deleted! + + + } \ No newline at end of file diff --git a/frontend/src/features/info/infoApiSlice.ts b/frontend/src/features/info/infoApiSlice.ts index 2bae544..58d688b 100644 --- a/frontend/src/features/info/infoApiSlice.ts +++ b/frontend/src/features/info/infoApiSlice.ts @@ -24,12 +24,20 @@ export const apiInfoSlice = createApi({ query(){ return '/info'; } + }), + deleteRequests: builder.mutation({ + query(){ + return { + url: `/clear`, + method: 'GET' + } + }, }) } }, }); -export const {useFetchInfoQuery} = apiInfoSlice; +export const {useFetchInfoQuery, useDeleteRequestsMutation} = apiInfoSlice; export function fetchinfo(){ const target = 'Unknown'; return useFetchInfoQuery().data || { diff --git a/frontend/src/features/selections/selectionsSlice.ts b/frontend/src/features/selections/selectionsSlice.ts index a39ba25..9022773 100644 --- a/frontend/src/features/selections/selectionsSlice.ts +++ b/frontend/src/features/selections/selectionsSlice.ts @@ -2,6 +2,7 @@ import {createSlice, PayloadAction} from '@reduxjs/toolkit'; interface Selections { noiseCancellationIsOn: boolean, // Noise cancellation from AppBarView infoIsOpen: boolean, // InfoView dialog + deleteRequestAlertIsOpen: boolean, // Alert that shows up inside info view when all reqests are deleted requestIsOpen: boolean, // RequestView Dialog endpointName: string|undefined, // Selected endpoint from EnpointsView fieldPrefix: string|undefined, // Selected field prefix from FieldsView @@ -13,6 +14,7 @@ const initialState: Selections = { fieldPrefix: undefined, requestId: undefined, infoIsOpen: false, + deleteRequestAlertIsOpen: false, requestIsOpen: false }; const slice = createSlice({ @@ -28,6 +30,12 @@ const slice = createSlice({ closeInfoView(state){ state.infoIsOpen = false; }, + openDeleteRequestsAlert(state){ + state.deleteRequestAlertIsOpen = true; + }, + closeDeleteRequestsAlert(state){ + state.deleteRequestAlertIsOpen = false; + }, openRequestView(state){ state.requestIsOpen = true; }, @@ -50,6 +58,8 @@ export const { toggleNoiseCancellation, openInfoView, closeInfoView, + openDeleteRequestsAlert, + closeDeleteRequestsAlert, openRequestView, closeRequestView, selectEndpoint, diff --git a/images/diffy-ui.png b/images/diffy-ui.png new file mode 100644 index 0000000..d64ced5 Binary files /dev/null and b/images/diffy-ui.png differ diff --git a/images/diffy_diffy.png b/images/diffy_diffy.png deleted file mode 100644 index c899b47..0000000 Binary files a/images/diffy_diffy.png and /dev/null differ