diff --git a/web/src/fileManager/FileContent.tsx b/web/src/fileManager/FileContent.tsx index 210fc5f..e66faf3 100644 --- a/web/src/fileManager/FileContent.tsx +++ b/web/src/fileManager/FileContent.tsx @@ -1,5 +1,6 @@ import { Accessor, Component, createResource, JSXElement } from "solid-js"; import { apiHost } from "../consts"; +import { PrettifyCSV } from "./PrettifyCSV"; export const FileContent: Component<{getFileName: Accessor}> = (props) => { const fetchFileContent = async (fileName: string) => { @@ -11,6 +12,7 @@ export const FileContent: Component<{getFileName: Accessor}> = (props) = } const [contentResource] = createResource(props.getFileName, fetchFileContent); + const lines = () => contentResource()?.split("
") ?? ["empty..."]; return (
@@ -24,15 +26,8 @@ export const FileContent: Component<{getFileName: Accessor}> = (props) =
Error while loading file content: ${contentResource.error}
)} { contentResource() && ( -
{splitLines(contentResource())}
+ )}
) -} - -function splitLines(str?: string): JSXElement { - const lines = str?.split("
") ?? ["empty..."] - return lines.map(line => -
{line}
- ); } \ No newline at end of file diff --git a/web/src/fileManager/PrettifyCSV.tsx b/web/src/fileManager/PrettifyCSV.tsx new file mode 100644 index 0000000..5480cc2 --- /dev/null +++ b/web/src/fileManager/PrettifyCSV.tsx @@ -0,0 +1,26 @@ +import { Component } from "solid-js"; + +export const PrettifyCSV: Component<{lines: () => string[];}> = ({ lines }) => { + const header = () => lines().slice(0, 1); + const content = () => lines().slice(1) ?? []; + return ( +
+
{header()}
+ + {content().map(line => )} +
+
+ ) +} + +const PrettifyLine: Component<{line: string;}> = ({ line }) => { + const splitLine = line.split(";"); + const params = splitLine.slice(0, 15); + const phenomena = splitLine.slice(15); + return ( + + { params.map(param => {param})} + { phenomena.join(",") } + + ) +} \ No newline at end of file