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 (
);
};
diff --git a/src/lib/core/use-case/list-rules-usecase.ts b/src/lib/core/use-case/list-rules-usecase.ts
index b0f90e7d0..136df4bf6 100644
--- a/src/lib/core/use-case/list-rules-usecase.ts
+++ b/src/lib/core/use-case/list-rules-usecase.ts
@@ -30,8 +30,8 @@ export default class ListRulesUseCase
}
async makeGatewayRequest(requestModel: AuthenticatedRequestModel): Promise {
- const { rucioAuthToken, scope, account } = requestModel;
- const dto: ListRulesDTO = await this.gateway.listRules(rucioAuthToken, { scope, account });
+ const { rucioAuthToken, scope, account, created_after } = requestModel;
+ const dto: ListRulesDTO = await this.gateway.listRules(rucioAuthToken, { scope, account, created_after });
return dto;
}
diff --git a/src/lib/core/usecase-models/list-rules-usecase-models.ts b/src/lib/core/usecase-models/list-rules-usecase-models.ts
index e494044dc..d7ae4bc9d 100644
--- a/src/lib/core/usecase-models/list-rules-usecase-models.ts
+++ b/src/lib/core/usecase-models/list-rules-usecase-models.ts
@@ -7,6 +7,7 @@ import { Rule } from '@/lib/core/entity/rucio';
export interface ListRulesRequest {
account?: string;
scope?: string;
+ created_after?: Date;
}
/**
diff --git a/src/lib/infrastructure/controller/list-rules-controller.ts b/src/lib/infrastructure/controller/list-rules-controller.ts
index 1bab4f461..a4298186e 100644
--- a/src/lib/infrastructure/controller/list-rules-controller.ts
+++ b/src/lib/infrastructure/controller/list-rules-controller.ts
@@ -10,6 +10,7 @@ import USECASE_FACTORY from '@/lib/infrastructure/ioc/ioc-symbols-usecase-factor
export type ListRulesControllerParameters = TAuthenticatedControllerParameters & {
scope?: string;
account?: string;
+ created_after?: string;
};
@injectable()
@@ -22,6 +23,7 @@ class ListRulesController extends BaseController {
+ const daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
+ const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
+
+ const dayOfWeek = daysOfWeek[date.getUTCDay()];
+ const day = String(date.getUTCDate()).padStart(2, '0');
+ const month = months[date.getUTCMonth()];
+ const year = date.getUTCFullYear();
+
+ const hours = String(date.getUTCHours()).padStart(2, '0');
+ const minutes = String(date.getUTCMinutes()).padStart(2, '0');
+ const seconds = String(date.getUTCSeconds()).padStart(2, '0');
+
+ return `${dayOfWeek}, ${day} ${month} ${year} ${hours}:${minutes}:${seconds} UTC`;
};
diff --git a/src/pages/api/feature/list-rules.ts b/src/pages/api/feature/list-rules.ts
index 0b8a69598..54bdd9a9e 100644
--- a/src/pages/api/feature/list-rules.ts
+++ b/src/pages/api/feature/list-rules.ts
@@ -20,13 +20,15 @@ async function listRules(req: NextApiRequest, res: NextApiResponse, rucioAuthTok
const account = sessionUser.rucioAccount;
- const { scope } = req.query as { scope?: string };
+ // TODO: check if created_after is an actual date
+ const { scope, created_after } = req.query as { scope?: string; created_after?: string };
const controllerParameters: ListRulesControllerParameters = {
response: res,
rucioAuthToken: rucioAuthToken,
account: account,
scope: scope,
+ created_after: created_after,
};
const controller = appContainer.get>(CONTROLLERS.LIST_RULES);