From 9c8b110aba58f937f142bc4df8cd4703c1d5f407 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Tue, 15 Oct 2019 20:27:39 +1100 Subject: [PATCH] Add basic scene list view --- ui/v2/src/components/scenes/SceneList.tsx | 3 +- .../src/components/scenes/SceneListTable.tsx | 104 ++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 ui/v2/src/components/scenes/SceneListTable.tsx diff --git a/ui/v2/src/components/scenes/SceneList.tsx b/ui/v2/src/components/scenes/SceneList.tsx index 4db728cf4..a46967702 100644 --- a/ui/v2/src/components/scenes/SceneList.tsx +++ b/ui/v2/src/components/scenes/SceneList.tsx @@ -8,6 +8,7 @@ import { ListFilterModel } from "../../models/list-filter/filter"; import { DisplayMode, FilterMode } from "../../models/list-filter/types"; import { WallPanel } from "../Wall/WallPanel"; import { SceneCard } from "./SceneCard"; +import { SceneListTable } from "./SceneListTable"; interface ISceneListProps extends IBaseProps {} @@ -27,7 +28,7 @@ export const SceneList: FunctionComponent = (props: ISceneListP ); } else if (filter.displayMode === DisplayMode.List) { - return

TODO

; + return ; } else if (filter.displayMode === DisplayMode.Wall) { return ; } diff --git a/ui/v2/src/components/scenes/SceneListTable.tsx b/ui/v2/src/components/scenes/SceneListTable.tsx new file mode 100644 index 000000000..7b7937131 --- /dev/null +++ b/ui/v2/src/components/scenes/SceneListTable.tsx @@ -0,0 +1,104 @@ +import { + H4, + HTMLTable, + H5, + H6, + } from "@blueprintjs/core"; + import React, { FunctionComponent } from "react"; + import { Link } from "react-router-dom"; + import * as GQL from "../../core/generated-graphql"; + import { TextUtils } from "../../utils/text"; + import { TagLink } from "../Shared/TagLink"; +import { NavigationUtils } from "../../utils/navigation"; + + interface ISceneListTableProps { + scenes: GQL.SlimSceneDataFragment[]; + } + + export const SceneListTable: FunctionComponent = (props: ISceneListTableProps) => { + + function renderDuration(scene : GQL.SlimSceneDataFragment) { + if (scene.file.duration === undefined) { return; } + return TextUtils.secondsToTimestamp(scene.file.duration); + } + + function renderTags(tags : GQL.SlimSceneDataTags[]) { + return tags.map((tag) => ( + +
{tag.name}
+ + )); + } + + function renderPerformers(performers : GQL.SlimSceneDataPerformers[]) { + return performers.map((performer) => ( + +
{performer.name}
+ + )); + } + + function renderStudio(studio : GQL.SlimSceneDataStudio | undefined) { + if (!!studio) { + return ( + +
{studio.name}
+ + ); + } + } + + function renderSceneRow(scene : GQL.SlimSceneDataFragment) { + return ( + <> + + + +
+ {!!scene.title ? scene.title : TextUtils.fileNameFromPath(scene.path)} +
+ + + + {scene.rating ? scene.rating : ''} + + + {renderDuration(scene)} + + + {renderTags(scene.tags)} + + + {renderPerformers(scene.performers)} + + + {renderStudio(scene.studio)} + + + + ) + } + + return ( + <> +
+ + + + Title + Rating + Duration + Tags + Performers + Studio + + + + {props.scenes.map(renderSceneRow)} + + +
+ + ); + }; + \ No newline at end of file