Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
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: 0 additions & 1 deletion src/@types/parseable/api/savedFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export type SavedFilterType = {
stream_name: string;
filter_name: string;
filter_id: string;
user_id: string;
query: {
filter_type: 'sql' | 'builder';
filter_query?: string;
Expand Down
12 changes: 6 additions & 6 deletions src/api/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ export const LOG_STREAM_LIST_URL = `${API_V1}/logstream`;
export const LOG_STREAMS_SCHEMA_URL = (streamName: string) => `${LOG_STREAM_LIST_URL}/${streamName}/schema`;
export const LOG_QUERY_URL = (params?: Params) => `${API_V1}/query` + parseParamsToQueryString(params);
export const LOG_STREAMS_ALERTS_URL = (streamName: string) => `${LOG_STREAM_LIST_URL}/${streamName}/alert`;
export const LIST_SAVED_FILTERS_URL = (userId: string) => `${API_V1}/filters/${userId}`;
export const LIST_DASHBOARDS = (userId: string) => `${API_V1}/dashboards/${userId}`;
export const UPDATE_SAVED_FILTERS_URL = (filterId: string) => `${API_V1}/filters/filter/${filterId}`;
export const UPDATE_DASHBOARDS_URL = (dashboardId: string) => `${API_V1}/dashboards/dashboard/${dashboardId}`;
export const DELETE_DASHBOARDS_URL = (dashboardId: string) => `${API_V1}/dashboards/dashboard/${dashboardId}`;
export const LIST_SAVED_FILTERS_URL = `${API_V1}/filters`;
export const LIST_DASHBOARDS = `${API_V1}/dashboards`;
export const UPDATE_SAVED_FILTERS_URL = (filterId: string) => `${API_V1}/filters/${filterId}`;
export const UPDATE_DASHBOARDS_URL = (dashboardId: string) => `${API_V1}/dashboards/${dashboardId}`;
export const DELETE_DASHBOARDS_URL = (dashboardId: string) => `${API_V1}/dashboards/${dashboardId}`;
export const CREATE_SAVED_FILTERS_URL = `${API_V1}/filters`;
export const CREATE_DASHBOARDS_URL = `${API_V1}/dashboards`;
export const DELETE_SAVED_FILTERS_URL = (filterId: string) => `${API_V1}/filters/filter/${filterId}`;
export const DELETE_SAVED_FILTERS_URL = (filterId: string) => `${API_V1}/filters/${filterId}`;
export const LOG_STREAMS_RETRNTION_URL = (streamName: string) => `${LOG_STREAM_LIST_URL}/${streamName}/retention`;
export const LOG_STREAMS_STATS_URL = (streamName: string) => `${LOG_STREAM_LIST_URL}/${streamName}/stats`;
export const LOG_STREAMS_INFO_URL = (streamName: string) => `${LOG_STREAM_LIST_URL}/${streamName}/info`;
Expand Down
8 changes: 4 additions & 4 deletions src/api/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ import {

const { optimizeEndTime } = timeRangeUtils;

export const getDashboards = (userId: string) => {
return Axios().get<Dashboard[]>(LIST_DASHBOARDS(userId));
export const getDashboards = () => {
return Axios().get<Dashboard[]>(LIST_DASHBOARDS);
};

export const putDashboard = (dashboardId: string, dashboard: UpdateDashboardType) => {
return Axios().put(UPDATE_DASHBOARDS_URL(dashboardId), dashboard);
};

export const postDashboard = (dashboard: CreateDashboardType, userId: string) => {
return Axios().post(CREATE_DASHBOARDS_URL, { ...dashboard, user_id: userId });
export const postDashboard = (dashboard: CreateDashboardType) => {
return Axios().post(CREATE_DASHBOARDS_URL, { ...dashboard});
};

export const removeDashboard = (dashboardId: string) => {
Expand Down
4 changes: 2 additions & 2 deletions src/api/logStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export const putLogStreamAlerts = (streamName: string, data: any) => {
return Axios().put(LOG_STREAMS_ALERTS_URL(streamName), data);
};

export const getSavedFilters = (userId: string) => {
return Axios().get<SavedFilterType[]>(LIST_SAVED_FILTERS_URL(userId));
export const getSavedFilters = () => {
return Axios().get<SavedFilterType[]>(LIST_SAVED_FILTERS_URL);
};

export const putSavedFilters = (filterId: string, filter: SavedFilterType) => {
Expand Down
6 changes: 2 additions & 4 deletions src/hooks/useDashboards.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useMutation, useQuery } from 'react-query';
import { notifyError, notifySuccess } from '@/utils/notification';
import { AxiosError, isAxiosError } from 'axios';
import Cookies from 'js-cookie';
import _ from 'lodash';
import { useDashboardsStore, dashboardsStoreReducers } from '@/pages/Dashboards/providers/DashboardsProvider';
import { getDashboards, getQueryData, postDashboard, putDashboard, removeDashboard } from '@/api/dashboard';
Expand All @@ -19,13 +18,12 @@ const { setDashboards, setTileData, selectDashboard } = dashboardsStoreReducers;
export const useDashboardsQuery = (opts: { updateTimeRange?: (dashboard: Dashboard) => void }) => {
const [activeDashboard, setDashboardsStore] = useDashboardsStore((store) => store.activeDashboard);

const username = Cookies.get('username');
const {
isError: fetchDashaboardsError,
isSuccess: fetchDashboardsSuccess,
isLoading: fetchDashboardsLoading,
refetch: fetchDashboards,
} = useQuery(['dashboards'], () => getDashboards(username || ''), {
} = useQuery(['dashboards'], () => getDashboards(), {
retry: false,
enabled: false, // not on mount
refetchOnWindowFocus: false,
Expand All @@ -42,7 +40,7 @@ export const useDashboardsQuery = (opts: { updateTimeRange?: (dashboard: Dashboa
});

const { mutate: createDashboard, isLoading: isCreatingDashboard } = useMutation(
(data: { dashboard: CreateDashboardType; onSuccess?: () => void }) => postDashboard(data.dashboard, username || ''),
(data: { dashboard: CreateDashboardType; onSuccess?: () => void }) => postDashboard(data.dashboard),
{
onSuccess: (response, variables) => {
const { dashboard_id } = response.data;
Expand Down
4 changes: 1 addition & 3 deletions src/hooks/useSavedFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { getSavedFilters, deleteSavedFilter, putSavedFilters, postSavedFilters }
import { notifyError, notifySuccess } from '@/utils/notification';
import { AxiosError, isAxiosError } from 'axios';
import { useAppStore, appStoreReducers } from '@/layouts/MainLayout/providers/AppProvider';
import Cookies from 'js-cookie';
import _ from 'lodash';
import { CreateSavedFilterType, SavedFilterType } from '@/@types/parseable/api/savedFilters';
import { useLogsStore, logsStoreReducers } from '@/pages/Stream/providers/LogsProvider';
Expand All @@ -13,10 +12,9 @@ const { updateSavedFilterId } = logsStoreReducers;
const useSavedFiltersQuery = () => {
const [, setAppStore] = useAppStore((_store) => null);
const [, setLogsStore] = useLogsStore((_store) => null);
const username = Cookies.get('username');
const { isError, isSuccess, isLoading, refetch, isRefetching } = useQuery(
['saved-filters'],
() => getSavedFilters(username || ''),
() => getSavedFilters(),
{
retry: false,
enabled: false, // not on mount
Expand Down
7 changes: 1 addition & 6 deletions src/pages/Stream/components/Querier/SaveFilterModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import _ from 'lodash';
import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
import { CreateSavedFilterType, SavedFilterType } from '@/@types/parseable/api/savedFilters';
import useSavedFiltersQuery from '@/hooks/useSavedFilters';
import Cookies from 'js-cookie';
import timeRangeUtils from '@/utils/timeRangeUtils';

const { defaultTimeRangeOption, makeTimeRangeOptions, getDefaultTimeRangeOption } = timeRangeUtils;
Expand All @@ -29,7 +28,6 @@ const sanitizeFilterItem = (formObject: FormObjectType): SavedFilterType => {
filter_id = '',
query,
selectedTimeRangeOption,
user_id,
version = '',
} = formObject;
return {
Expand All @@ -39,12 +37,10 @@ const sanitizeFilterItem = (formObject: FormObjectType): SavedFilterType => {
filter_name,
time_filter: selectedTimeRangeOption.time_filter,
query,
user_id,
};
};

const SaveFilterModal = () => {
const username = Cookies.get('username');
const [isSaveFiltersModalOpen, setFilterStore] = useFilterStore((store) => store.isSaveFiltersModalOpen);
const [appliedQuery] = useFilterStore((store) => store.appliedQuery);
const [activeSavedFilters] = useAppStore((store) => store.activeSavedFilters);
Expand Down Expand Up @@ -88,7 +84,6 @@ const SaveFilterModal = () => {
},
isNew: true,
isError: false,
user_id: username || '',
timeRangeOptions,
selectedTimeRangeOption,
});
Expand Down Expand Up @@ -129,7 +124,7 @@ const SaveFilterModal = () => {
});
}

if (!_.isEmpty(formObject.filter_id) && !_.isEmpty(formObject.user_id) && !_.isEmpty(formObject.version)) {
if (!_.isEmpty(formObject.filter_id) && !_.isEmpty(formObject.version)) {
updateSavedFilters({ filter: sanitizeFilterItem(formObject), onSuccess: closeModal });
} else {
const keysToRemove = ['filter_id', 'version'];
Expand Down