forked from rucio/webui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compound: Add components and apis for transfer
- Components: Add components for transfers and statistics display - App: Add pages for transfers and statistics - api: Add gateway, usecase, feature, controller, presenter for list-transfer-stats and list-transfers Provide E2E feature for rucio#359
- Loading branch information
Showing
34 changed files
with
1,032 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ListTransfer as ListTransferStory } from "@/component-library/Pages/Transfers/ListTransfer"; | ||
import { TransferViewModel } from "@/lib/infrastructure/data/view-model/request"; | ||
import useComDOM from "@/lib/infrastructure/hooks/useComDOM"; | ||
|
||
export default function Page({ params }: { params: { source: string, dest: string }}) { | ||
const TransferSearchComDOM = useComDOM<TransferViewModel>( | ||
'list-transfer-query', | ||
[], | ||
false, | ||
Infinity, | ||
200, | ||
true | ||
) | ||
TransferSearchComDOM.setRequest({ | ||
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-transfers`), | ||
method: 'GET', | ||
headers: new Headers({ | ||
'Content-Type': 'application/json' | ||
} as HeadersInit), | ||
params: { | ||
"sourceRSE": params.source, | ||
"destRSE": params.dest | ||
} | ||
}) | ||
return ( | ||
<ListTransferStory | ||
comdom={TransferSearchComDOM} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
src/component-library/Pages/Transfers/TransferStatistics.stories.tsx
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
src/component-library/Pages/Transfers/TransferStatistics.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { RequestState } from "@/lib/core/entity/rucio"; | ||
import { Meta, StoryFn } from "@storybook/react"; | ||
import { RequestStateTag as R } from "./RequestStateTag"; | ||
|
||
export default { | ||
title: 'Components/Tags', | ||
component: R, | ||
} as Meta<typeof R>; | ||
|
||
const Template: StoryFn<typeof R> = (args) => <R {...args} />; | ||
|
||
export const RequestStateTag = Template.bind({}); | ||
RequestStateTag.args = { | ||
state: RequestState.FAILED | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { RequestState } from "@/lib/core/entity/rucio" | ||
import React, { useEffect, useState } from "react"; | ||
import { twMerge } from "tailwind-merge"; | ||
|
||
type RequestStateTagProps = JSX.IntrinsicElements["span"] & { | ||
state: RequestState; | ||
forcesmall?: boolean; | ||
neversmall?: boolean; | ||
}; | ||
|
||
export const RequestStateTag: React.FC<RequestStateTagProps> = ( | ||
{ | ||
state = RequestState.SUBMITTED, | ||
forcesmall = false, | ||
neversmall = false, | ||
...props | ||
} | ||
) => { | ||
const { className, ...restprops } = props | ||
|
||
const [windowWidth, setWindowWidth] = useState(720) | ||
useEffect(() => { | ||
const handleResize = () => setWindowWidth(window.innerWidth) | ||
handleResize() | ||
window.addEventListener('resize', handleResize) | ||
}, []) | ||
const belowMedium = (windowWidth < 768) || forcesmall | ||
const stringMatch = { | ||
[RequestState.PREPARING]: "Preparing", | ||
[RequestState.DONE]: "Done", | ||
[RequestState.FAILED]: "Failed", | ||
[RequestState.LOST]: "Lost", | ||
[RequestState.MISMATCH_SCHEME]: "Mismatch Scheme", | ||
[RequestState.NO_SOURCES]: "No Source", | ||
[RequestState.ONLY_TAPE_SOURCES]: "Only Tape Sources", | ||
[RequestState.QUEUED]: "Queued", | ||
[RequestState.SUBMISSION_FAILED]: "Submission Failed", | ||
[RequestState.SUBMITTED]: "Submitted", | ||
[RequestState.SUBMITTING]: "Submitting", | ||
[RequestState.SUSPEND]: "Suspend", | ||
[RequestState.WAITING]: "Waiting" | ||
} | ||
|
||
const colPicker = (state: RequestState) => { | ||
switch (state) { | ||
case RequestState.SUBMITTED: | ||
return "emerald" | ||
case RequestState.DONE: | ||
return "blue" | ||
case RequestState.PREPARING: | ||
case RequestState.SUSPEND: | ||
case RequestState.QUEUED: | ||
case RequestState.SUBMITTING: | ||
case RequestState.WAITING: | ||
return "rose" | ||
case RequestState.FAILED: | ||
case RequestState.LOST: | ||
case RequestState.SUBMISSION_FAILED: | ||
return "amber" | ||
case RequestState.MISMATCH_SCHEME: | ||
case RequestState.NO_SOURCES: | ||
case RequestState.ONLY_TAPE_SOURCES: | ||
return "gray" | ||
} | ||
} | ||
|
||
const color = colPicker(state) | ||
|
||
return ( | ||
<span | ||
className={twMerge( | ||
"h-6 rounded text-center flex justify-center items-center", | ||
"font-bold", | ||
!neversmall ? "w-6 md:w-24 rounded-full md:rounded" : "w-24", | ||
forcesmall ? "w-6 md:w-6 rounded-full md:rounded-full" : "", | ||
`bg-${color}-100 text-${color}-800 dark:bg-${color}-900 dark:text-${color}-300`, | ||
className ?? "" | ||
)} | ||
> | ||
{belowMedium && !neversmall ? state : stringMatch[state]} | ||
</span> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { BaseDTO, BaseStreamableDTO } from "@/lib/sdk/dto"; | ||
import { DIDType, Request, RequestState, RequestStats, RequestType } from "../entity/rucio"; | ||
|
||
/** | ||
* The Data Transfer Object for the ListTransferStatistics which contains the stream | ||
*/ | ||
export interface ListTransferStatisticsDTO extends BaseStreamableDTO {} | ||
|
||
/** | ||
* The Data Transfer Object for the Statistics of a single Transfer Group | ||
*/ | ||
export interface TransferStatisticsDTO extends BaseDTO, RequestStats {} | ||
|
||
/** | ||
* The Data Transfer Object for the ListTransfer which contains the stream | ||
*/ | ||
export interface ListTransfersDTO extends BaseStreamableDTO {} | ||
|
||
/** | ||
* The Data Transfer Object for a single Transfer | ||
*/ | ||
export interface TransferDTO extends BaseDTO, Request {} | ||
|
||
export function getEmptyTransferStatsDTO(): TransferStatisticsDTO { | ||
return { | ||
status: 'error', | ||
account: '', | ||
source_rse: '', | ||
dest_rse: '', | ||
source_rse_id: '', | ||
dest_rse_id: '', | ||
state: RequestState.FAILED, | ||
activity: '', | ||
counter: 0, | ||
bytes: 0, | ||
} | ||
} | ||
|
||
export function getEmptyTransferDTO(): TransferDTO { | ||
return { | ||
status: 'error', | ||
id: '', | ||
account: '', | ||
request_type: RequestType.TRANSFER, | ||
scope: '', | ||
name: '', | ||
did_type: DIDType.UNKNOWN, | ||
source_rse_id: '', | ||
dest_rse_id: '', | ||
source_rse: '', | ||
dest_rse: '', | ||
state: RequestState.FAILED, | ||
activity: '', | ||
attributes: '', | ||
priority: 0, | ||
bytes: 0, | ||
requested_at: '', | ||
transfertool: '', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { TransferStatsViewModel } from "@/lib/infrastructure/data/view-model/request-stats"; | ||
import { BaseAuthenticatedInputPort, BaseStreamingOutputPort } from "@/lib/sdk/primary-ports"; | ||
import { ListTransferStatsError, ListTransferStatsRequest, ListTransferStatsResponse } from "../../usecase-models/list-transfer-stats-usecase-models"; | ||
|
||
/** | ||
* @interface ListTransferStatsInputPort that abstracts usecase. | ||
*/ | ||
export interface ListTransferStatsInputPort extends BaseAuthenticatedInputPort<ListTransferStatsRequest> {} | ||
|
||
/** | ||
* @interface ListTransferStatsOutputPort that abstracts usecase. | ||
*/ | ||
export interface ListTransferStatsOutputPort extends BaseStreamingOutputPort<ListTransferStatsResponse, ListTransferStatsError, TransferStatsViewModel> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { BaseAuthenticatedInputPort, BaseStreamingOutputPort } from "@/lib/sdk/primary-ports"; | ||
import { ListTransfersError, ListTransfersRequest, ListTransfersResponse } from "../../usecase-models/list-transfers-usecase-models"; | ||
import { TransferViewModel } from "@/lib/infrastructure/data/view-model/request"; | ||
|
||
/** | ||
* @interface ListTransfersInputPort that abstracts the usecase. | ||
*/ | ||
export interface ListTransfersInputPort extends BaseAuthenticatedInputPort<ListTransfersRequest> {} | ||
|
||
/** | ||
* @interface ListTransfersOutputPort that abstracts the usecase. | ||
*/ | ||
export interface ListTransfersOutputPort extends BaseStreamingOutputPort<ListTransfersResponse, ListTransfersError, TransferViewModel> {} |
18 changes: 18 additions & 0 deletions
18
src/lib/core/port/secondary/transfer-gateway-output-port.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ListTransfersDTO, ListTransferStatisticsDTO } from "../../dto/transfer-dto"; | ||
|
||
export default interface TransferGatewayOutputPort { | ||
|
||
/** | ||
* Gets the list of all transfer statistics | ||
* @param rucioAuthToken A valid Rucio Auth Token. | ||
*/ | ||
listTransferStatistics(rucioAuthToken: string): Promise<ListTransferStatisticsDTO> | ||
|
||
/** | ||
* Lists all active transfers over a given source-destination RSE pair | ||
* @param rucioAuthToken A valid Rucio Auth Token. | ||
* @param sourceRse The source RSE. | ||
* @param destRse The destination RSE. | ||
*/ | ||
listTransfers(rucioAuthToken: string, sourceRse: string, destRse: string): Promise<ListTransfersDTO> | ||
} |
Oops, something went wrong.