diff --git a/src/@types/parseable/api/savedFilters.ts b/src/@types/parseable/api/savedFilters.ts index 6f6e5e73..3737b180 100644 --- a/src/@types/parseable/api/savedFilters.ts +++ b/src/@types/parseable/api/savedFilters.ts @@ -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; diff --git a/src/api/constants.ts b/src/api/constants.ts index edace540..9b259855 100644 --- a/src/api/constants.ts +++ b/src/api/constants.ts @@ -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`; diff --git a/src/api/dashboard.ts b/src/api/dashboard.ts index e5140d4b..5452ce03 100644 --- a/src/api/dashboard.ts +++ b/src/api/dashboard.ts @@ -18,16 +18,16 @@ import { const { optimizeEndTime } = timeRangeUtils; -export const getDashboards = (userId: string) => { - return Axios().get(LIST_DASHBOARDS(userId)); +export const getDashboards = () => { + return Axios().get(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) => { diff --git a/src/api/logStream.ts b/src/api/logStream.ts index 4b320daf..9a2c86f1 100644 --- a/src/api/logStream.ts +++ b/src/api/logStream.ts @@ -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(LIST_SAVED_FILTERS_URL(userId)); +export const getSavedFilters = () => { + return Axios().get(LIST_SAVED_FILTERS_URL); }; export const putSavedFilters = (filterId: string, filter: SavedFilterType) => { diff --git a/src/hooks/useDashboards.tsx b/src/hooks/useDashboards.tsx index eeb3c2ea..ab1adf35 100644 --- a/src/hooks/useDashboards.tsx +++ b/src/hooks/useDashboards.tsx @@ -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'; @@ -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, @@ -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; diff --git a/src/hooks/useSavedFilters.tsx b/src/hooks/useSavedFilters.tsx index e45bd189..0789ed93 100644 --- a/src/hooks/useSavedFilters.tsx +++ b/src/hooks/useSavedFilters.tsx @@ -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'; @@ -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 diff --git a/src/pages/Stream/components/Querier/SaveFilterModal.tsx b/src/pages/Stream/components/Querier/SaveFilterModal.tsx index c12b7708..5fbce403 100644 --- a/src/pages/Stream/components/Querier/SaveFilterModal.tsx +++ b/src/pages/Stream/components/Querier/SaveFilterModal.tsx @@ -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; @@ -29,7 +28,6 @@ const sanitizeFilterItem = (formObject: FormObjectType): SavedFilterType => { filter_id = '', query, selectedTimeRangeOption, - user_id, version = '', } = formObject; return { @@ -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); @@ -88,7 +84,6 @@ const SaveFilterModal = () => { }, isNew: true, isError: false, - user_id: username || '', timeRangeOptions, selectedTimeRangeOption, }); @@ -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'];