From f9912de3c7320124232b8346d4addc78ab67f7c0 Mon Sep 17 00:00:00 2001 From: Anton Schwarz Date: Thu, 6 Jul 2023 16:46:47 +0200 Subject: [PATCH] Created `Page RSE` Added beginnings of `PageRSE` Added button to go back to list on PageRSE Work on RSEProtocols Table Restyled `PageRSEProtocols` column widths when working with column groups, it is worth noting that it is easier to set the width and style of the column group before setting the column width itself. removed column groups from `PageRSEProtocols` Added `PageRSEAttributes` table Finalised `PageRSEProtocols` --- .../components/Pages/RSE/PageRSE.stories.tsx | 20 +++ .../components/Pages/RSE/PageRSE.tsx | 133 ++++++++++++++++++ .../Pages/RSE/PageRSEAttributes.stories.tsx | 15 ++ .../Pages/RSE/PageRSEAttributes.tsx | 46 ++++++ .../Pages/RSE/PageRSEProtocols.stories.tsx | 15 ++ .../components/Pages/RSE/PageRSEProtocols.tsx | 107 ++++++++++++++ .../components/Tags/BoolTag.tsx | 2 +- src/component-library/outputtailwind.css | 9 ++ .../infrastructure/data/view-model/rse.d.ts | 30 ++++ test/fixtures/table-fixtures.ts | 40 ++++++ 10 files changed, 416 insertions(+), 1 deletion(-) create mode 100644 src/component-library/components/Pages/RSE/PageRSE.stories.tsx create mode 100644 src/component-library/components/Pages/RSE/PageRSE.tsx create mode 100644 src/component-library/components/Pages/RSE/PageRSEAttributes.stories.tsx create mode 100644 src/component-library/components/Pages/RSE/PageRSEAttributes.tsx create mode 100644 src/component-library/components/Pages/RSE/PageRSEProtocols.stories.tsx create mode 100644 src/component-library/components/Pages/RSE/PageRSEProtocols.tsx create mode 100644 src/lib/infrastructure/data/view-model/rse.d.ts diff --git a/src/component-library/components/Pages/RSE/PageRSE.stories.tsx b/src/component-library/components/Pages/RSE/PageRSE.stories.tsx new file mode 100644 index 00000000..6b1bc757 --- /dev/null +++ b/src/component-library/components/Pages/RSE/PageRSE.stories.tsx @@ -0,0 +1,20 @@ +import { RSEBlockState } from "@/lib/core/entity/rucio"; +import { StoryFn, Meta } from "@storybook/react"; +import { createRSE, createRSEProtocol, createRSEAttribute, mockUseComDOM } from "test/fixtures/table-fixtures"; +import { PageRSE as P } from "./PageRSE"; + +export default { + title: 'Components/Pages/RSE', + component: P, +} as Meta; + +const Template: StoryFn = (args) =>

; + +export const PageRSE = Template.bind({}); +PageRSE.args = { + rse: createRSE(), + rseblockstate: 7 as RSEBlockState, // 7 = all blocked + protocolscomdom: mockUseComDOM(Array.from({length: 20}, (_, i) => createRSEProtocol())), + attributescomdom: mockUseComDOM(Array.from({ length: 20 }, (_, i) => createRSEAttribute())), + fromrselist: true, +}; diff --git a/src/component-library/components/Pages/RSE/PageRSE.tsx b/src/component-library/components/Pages/RSE/PageRSE.tsx new file mode 100644 index 00000000..d6c54bd6 --- /dev/null +++ b/src/component-library/components/Pages/RSE/PageRSE.tsx @@ -0,0 +1,133 @@ +import { DateISO, RSE, RSEBlockState } from "@/lib/core/entity/rucio"; +import { H1 } from "../../Text/Headings/H1"; +import { twMerge } from "tailwind-merge"; +import { Generaltable } from "../../Helpers/Metatable"; +import { Titleth, Contenttd } from "../../Helpers/Metatable"; +import { BoolTag } from "../../Tags/BoolTag"; +import { RSETypeTag } from "../../Tags/RSETypeTag"; +import { RSETag } from "../../Tags/RSETag"; +import { HiArrowCircleLeft } from "react-icons/hi"; +import { RSEAttribute, RSEProtocol } from "@/lib/infrastructure/data/view-model/rse"; +import { UseComDOM } from "@/lib/infrastructure/hooks/useComDOM"; +import { PageRSEProtocols } from "./PageRSEProtocols"; +import { PageRSEAttributes } from "./PageRSEAttributes"; +import { H2 } from "../../Text/Headings/H2"; + +type PageRSEProps = { + rse: RSE + rseblockstate: RSEBlockState + protocolscomdom: UseComDOM + attributescomdom: UseComDOM + fromrselist?: boolean +} + +export const PageRSE = ( + props: PageRSEProps +) => { + return ( +

+
+
+

RSE Page for {props.rse.name}

+ + + + +
+ +
+ + + Name + {props.rse.name} + + + RSE Type + + + + Availability + + + + + + Volatile + + + + Deterministic + + + + Staging Area + + + +
+
+
+
+

RSE Protocols

+ +
+
+

RSE Attributes

+ +
+
+
+ ); +}; diff --git a/src/component-library/components/Pages/RSE/PageRSEAttributes.stories.tsx b/src/component-library/components/Pages/RSE/PageRSEAttributes.stories.tsx new file mode 100644 index 00000000..18fe8337 --- /dev/null +++ b/src/component-library/components/Pages/RSE/PageRSEAttributes.stories.tsx @@ -0,0 +1,15 @@ +import { StoryFn, Meta } from "@storybook/react"; +import { createRSEAttribute, mockUseComDOM } from "test/fixtures/table-fixtures"; +import { PageRSEAttributes as P } from "./PageRSEAttributes"; + +export default { + title: 'Components/Pages/RSE', + component: P, +} as Meta; + +const Template: StoryFn = (args) =>

; + +export const PageRSEAttributes = Template.bind({}); +PageRSEAttributes.args = { + comdom: mockUseComDOM(Array.from({ length: 20 }, (_, i) => createRSEAttribute())) +}; diff --git a/src/component-library/components/Pages/RSE/PageRSEAttributes.tsx b/src/component-library/components/Pages/RSE/PageRSEAttributes.tsx new file mode 100644 index 00000000..9b8722eb --- /dev/null +++ b/src/component-library/components/Pages/RSE/PageRSEAttributes.tsx @@ -0,0 +1,46 @@ +import { twMerge } from "tailwind-merge"; +import { UseComDOM } from "@/lib/infrastructure/hooks/useComDOM"; +import { RSEAttribute } from "@/lib/infrastructure/data/view-model/rse"; +import { createColumnHelper } from "@tanstack/react-table"; +import { TableFilterString } from "../../StreamedTables/TableFilterString"; +import { P } from "../../Text/Content/P"; +import { H3 } from "../../Text/Headings/H3"; +import { StreamedTable } from "../../StreamedTables/StreamedTable"; +import { BoolTag } from "../../Tags/BoolTag"; +import { NullTag } from "../../Tags/NullTag"; + +export const PageRSEAttributes = ( + props: { + comdom: UseComDOM + } +) => { + const columnHelper = createColumnHelper() + const tablecolumns: any[] = [ + columnHelper.accessor("key", { + id: "key", + header: info => , + cell: info =>

{info.getValue()}

+ }), + columnHelper.accessor("value", { + id: "value", + header: info =>

Value

, + cell: info => { + const val = info.getValue() + if (typeof (val) === "boolean") { + return + } else if (val === null) { + return + } else { + return

{val}

+ } + } + }), + ] + return ( + + tablecomdom={props.comdom} + tablecolumns={tablecolumns} + tablestyling={{}} + /> + ); +}; diff --git a/src/component-library/components/Pages/RSE/PageRSEProtocols.stories.tsx b/src/component-library/components/Pages/RSE/PageRSEProtocols.stories.tsx new file mode 100644 index 00000000..e3e0bf64 --- /dev/null +++ b/src/component-library/components/Pages/RSE/PageRSEProtocols.stories.tsx @@ -0,0 +1,15 @@ +import { StoryFn, Meta } from "@storybook/react"; +import { createRSEProtocol, mockUseComDOM } from "test/fixtures/table-fixtures"; +import { PageRSEProtocols as P } from "./PageRSEProtocols"; + +export default { + title: 'Components/Pages/RSE', + component: P, +} as Meta; + +const Template: StoryFn = (args) =>

; + +export const PageRSEProtocols = Template.bind({}); +PageRSEProtocols.args = { + comdom: mockUseComDOM(Array.from({length: 20}, (_, i) => createRSEProtocol())) +}; diff --git a/src/component-library/components/Pages/RSE/PageRSEProtocols.tsx b/src/component-library/components/Pages/RSE/PageRSEProtocols.tsx new file mode 100644 index 00000000..cc713614 --- /dev/null +++ b/src/component-library/components/Pages/RSE/PageRSEProtocols.tsx @@ -0,0 +1,107 @@ +import { RSEProtocol } from "@/lib/infrastructure/data/view-model/rse"; +import { createColumnHelper } from "@tanstack/react-table"; +import { P } from "../../Text/Content/P"; +import { twMerge } from "tailwind-merge"; +import { UseComDOM } from "@/lib/infrastructure/hooks/useComDOM"; +import { StreamedTable } from "../../StreamedTables/StreamedTable.stories"; +import { TableSortUpDown } from "../../StreamedTables/TableSortUpDown"; +import { TableFilterString } from "../../StreamedTables/TableFilterString"; +import { H3 } from "../../Text/Headings/H3"; + +export const PageRSEProtocols = ( + props: { + comdom: UseComDOM + } +) => { + const shortstyle = { style: "w-20" } + const shortstyleblue = { style: "w-20 bg-blue-100"} + const shortstylepink = { style: "w-20 bg-pink-100"} + const columnHelper = createColumnHelper() + const tablecolumns: any[] = [ + columnHelper.accessor("scheme", { + id: "scheme", + header: info =>

Scheme

, + cell: info =>

{info.getValue()}

, + meta: { style: "w-24" } + }), + columnHelper.accessor("hostname", { + id: "hostname", + header: info =>

Hostname

, + cell: info =>

{info.getValue()}

+ }), + columnHelper.accessor("port", { + id: "port", + header: info =>

Port

, + cell: info =>

{info.getValue()}

, + meta: { style: "w-24" } + }), + columnHelper.accessor("prefix", { + id: "prefix", + header: info =>

Prefix

, + cell: info =>

{info.getValue()}

, + }), + columnHelper.accessor("priorities_lan.read", { + id: "priorities_lan.read", + header: info => , + cell: info =>

{info.getValue()}

, + meta: shortstyleblue + }), + columnHelper.accessor("priorities_lan.write", { + id: "priorities_lan.write", + header: info => , + cell: info =>

{info.getValue()}

, + meta: shortstyleblue + }), + columnHelper.accessor("priorities_lan.delete", { + id: "priorities_lan.delete", + header: info => , + cell: info =>

{info.getValue()}

, + meta: shortstyleblue + }), + columnHelper.accessor("priorities_wan.read", { + id: "priorities_lan.read", + header: info => , + cell: info =>

{info.getValue()}

, + meta: shortstylepink + }), + columnHelper.accessor("priorities_wan.write", { + id: "priorities_lan.write", + header: info => , + cell: info =>

{info.getValue()}

, + meta: shortstylepink + }), + columnHelper.accessor("priorities_wan.delete", { + id: "priorities_lan.delete", + header: info => , + cell: info =>

{info.getValue()}

, + meta: shortstylepink, + }), + columnHelper.accessor("priorities_wan.tpc", { + id: "priorities_lan.tpc", + header: info => , + cell: info =>

{info.getValue()}

, + meta: shortstylepink, + }), + columnHelper.accessor("priorities_wan.tpcwrite", { + id: "priorities_lan.tpcwrite", + header: info => , + cell: info =>

{info.getValue()}

, + meta: shortstylepink, + }), + columnHelper.accessor("priorities_wan.tpcread", { + id: "priorities_lan.tpcread", + header: info => , + cell: info =>

{info.getValue()}

, + meta: shortstylepink, + }), + ] + return ( + + ); +}; \ No newline at end of file diff --git a/src/component-library/components/Tags/BoolTag.tsx b/src/component-library/components/Tags/BoolTag.tsx index 4e148a65..94425f99 100644 --- a/src/component-library/components/Tags/BoolTag.tsx +++ b/src/component-library/components/Tags/BoolTag.tsx @@ -13,7 +13,7 @@ export const BoolTag: FC= ( return ( (data: T[]): UseComDOM { @@ -131,6 +132,45 @@ export function createRSE(): RSE { } } +export function createRSEProtocol(): RSEProtocol { + return { + rseid: faker.string.uuid(), + scheme: faker.helpers.arrayElement(["srm", "gsiftp", "root", "davs", "s3", "file"]), + hostname: faker.internet.ip(), + port: faker.number.int({ min: 0, max: 1e4 }), + prefix: faker.lorem.words(3).replace(/\s/g, "."), + impl: "rucio.rse.protocols.gfal.Default", + priorities_lan: { + read: faker.number.int({ min: 0, max: 10 }), + write: faker.number.int({ min: 0, max: 10 }), + delete: faker.number.int({ min: 0, max: 10 }), + }, + priorities_wan: { + read: faker.number.int({ min: 0, max: 10 }), + write: faker.number.int({ min: 0, max: 10 }), + delete: faker.number.int({ min: 0, max: 10 }), + tpc: faker.number.int({ min: 0, max: 10 }), + tpcwrite: faker.number.int({ min: 0, max: 10 }), + tpcread: faker.number.int({ min: 0, max: 10 }), + }, + updated_at: faker.date.recent().toISOString(), + created_at: faker.date.past().toISOString(), + } +} + +export function createRSEAttribute(): RSEAttribute { + return { + key: faker.lorem.words(2).replace(/\s/g, "-"), + value: faker.helpers.arrayElement([ + faker.lorem.words(3), + faker.date.past().toISOString(), + faker.number.int({ min: 0, max: 1e6 }), + faker.datatype.boolean(), + null, + ]), + } +} + export function createRule(): Rule { return { id: faker.string.uuid(),