diff --git a/src/component-library/pages/Dashboard/Dashboard.tsx b/src/component-library/pages/Dashboard/Dashboard.tsx index 088303f02..8b3f6040c 100644 --- a/src/component-library/pages/Dashboard/Dashboard.tsx +++ b/src/component-library/pages/Dashboard/Dashboard.tsx @@ -1,16 +1,16 @@ -import { useQuery } from '@tanstack/react-query'; -import { SiteHeaderViewModel } from '@/lib/infrastructure/data/view-model/site-header'; -import { getSiteHeader } from '@/app/(rucio)/queries'; -import { LoadingSpinner } from '@/component-library/atoms/loading/LoadingSpinner'; -import { Heading } from '@/component-library/atoms/misc/Heading'; -import { WarningField } from '@/component-library/features/fields/WarningField'; -import { AccountRoleBadge } from '@/component-library/features/badges/account/AccountRoleBadge'; -import { TopRulesWidget } from '@/component-library/pages/Dashboard/widgets/TopRulesWidget'; -import { useEffect, useRef, useState } from 'react'; -import { RuleViewModel } from '@/lib/infrastructure/data/view-model/rule'; -import useStreamReader, { StreamingStatus } from '@/lib/infrastructure/hooks/useStreamReader'; -import { RSEAccountUsageViewModel } from '@/lib/infrastructure/data/view-model/rse'; -import { TopStorageUsageWidget } from '@/component-library/pages/Dashboard/widgets/TopStorageUsageWidget'; +import {useQuery} from '@tanstack/react-query'; +import {SiteHeaderViewModel} from '@/lib/infrastructure/data/view-model/site-header'; +import {getSiteHeader} from '@/app/(rucio)/queries'; +import {LoadingSpinner} from '@/component-library/atoms/loading/LoadingSpinner'; +import {Heading} from '@/component-library/atoms/misc/Heading'; +import {WarningField} from '@/component-library/features/fields/WarningField'; +import {AccountRoleBadge} from '@/component-library/features/badges/account/AccountRoleBadge'; +import {TopRulesWidget} from '@/component-library/pages/Dashboard/widgets/TopRulesWidget'; +import {useEffect, useRef, useState} from 'react'; +import {RuleViewModel} from '@/lib/infrastructure/data/view-model/rule'; +import useStreamReader, {StreamingStatus} from '@/lib/infrastructure/hooks/useStreamReader'; +import {RSEAccountUsageViewModel} from '@/lib/infrastructure/data/view-model/rse'; +import {TopStorageUsageWidget} from '@/component-library/pages/Dashboard/widgets/TopStorageUsageWidget'; const AccountHeading = () => { const querySiteHeader = async () => { @@ -34,7 +34,7 @@ const AccountHeading = () => { retry: false, }); - if (isHeaderFetching) return ; + if (isHeaderFetching) return ; if (headerError || !header?.activeAccount) { return ( @@ -46,8 +46,8 @@ const AccountHeading = () => { return (
- - + +
); }; @@ -55,7 +55,7 @@ const AccountHeading = () => { const UsageView = () => { const usageBuffer = useRef([]); const [usages, setUsages] = useState(); - const { start, stop, error, status } = useStreamReader(); + const {start, stop, error, status} = useStreamReader(); useEffect(() => { // TODO: handle error view models @@ -80,18 +80,29 @@ const UsageView = () => { const isLoading = (!usages && !error) || status === StreamingStatus.RUNNING; - return ; + return ; }; const RulesView = () => { const rulesBuffer = useRef([]); const [rules, setRules] = useState(); - const { start, stop, error, status } = useStreamReader(); + const {start, stop, error, status} = useStreamReader(); + + const getCreatedAfterDate = () => { + // Only the rules that were created less than 15 days ago should get loaded + const now = new Date(); + const fifteenDaysAgo = new Date(now.setDate(now.getDate() - 15)); + return fifteenDaysAgo.toISOString(); + }; useEffect(() => { // TODO: handle error view models + const params = new URLSearchParams({ + scope: '*', + created_after: getCreatedAfterDate(), + }); start({ - url: '/api/feature/list-rules?scope=*', + url: '/api/feature/list-rules?' + params.toString(), onData: data => { if (!rulesBuffer.current) { rulesBuffer.current = data; @@ -111,17 +122,17 @@ const RulesView = () => { const isLoading = (!rules && !error) || status === StreamingStatus.RUNNING; - return ; + return ; }; export const Dashboard = () => { return (
- +
- - + +
); };