Add new task skeleton

This commit is contained in:
2025-10-08 11:54:45 +02:00
parent cdf659ec4a
commit ad90a4ed58
10 changed files with 289 additions and 0 deletions

View File

@@ -0,0 +1 @@
{}

8
task_2_ts/Dockerfile Normal file
View File

@@ -0,0 +1,8 @@
FROM node
WORKDIR /app
COPY package.json .
RUN npm i
COPY . .
## EXPOSE [Port you mentioned in the vite.config file]
EXPOSE 5173
CMD ["npm", "run", "dev"]

115
task_2_ts/css/layout.css Normal file
View File

@@ -0,0 +1,115 @@
:root {
--spacing: 0.25rem;
--border-color: #a0a0a0;
}
/* Style for definition list */
dl {
margin-top: 0;
margin-bottom: 20px;
}
dt,
dd {
line-height: 1.42857143;
}
dt {
font-weight: 700;
}
dd {
margin-left: 0;
}
body h1,
body h2 {
margin-bottom: 0;
}
nav {
border-bottom: 1px solid var(--border-color);
}
article {
width: 400px;
}
body>main {
max-height: calc(100vh - 100px);
overflow-y: auto;
padding: var(--spacing) !important;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
align-items: start;
gap: var(--spacing);
& article {
margin: 0;
padding: var(--spacing);
&>header {
margin: calc(var(--spacing) * -1) calc(var(--spacing) * -1) var(--spacing);
padding: var(--spacing);
}
}
}
/* Set a fixed scrollable wrapper */
#table-content {
max-height: 400px;
overflow: auto;
/* Set header to stick to the top of the container. */
& thead tr th {
position: sticky;
top: 0;
}
/* If we use border, we must use table-collapse to avoid a slight movement of the header row */
& table {
border-collapse: collapse;
border-top: 0;
}
/* Because we must set sticky on th, we have to apply background styles here rather than on thead */
& th {
border-left: 1px dotted rgba(200, 209, 224, 0.6);
border-bottom: 1px solid #ddd;
background: #eee;
text-align: left;
box-shadow: 0px 0px 0 2px #e8e8e8;
&.active {
background: #ddd;
}
&.sortable::after {
font-family: FontAwesome;
content: "\f0dc";
position: absolute;
right: 8px;
color: #999;
}
&.active::after {
position: absolute;
right: 8px;
color: #999;
}
&.active.asc::after {
font-family: FontAwesome;
content: "\f0d8";
}
&.active.desc::after {
font-family: FontAwesome;
content: "\f0d7";
}
}
}

68
task_2_ts/index.html Normal file
View File

@@ -0,0 +1,68 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta content="IE=edge" http-equiv="X-UA-Compatible" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title>Open data explorer</title>
<script src="ts/main.ts" type="module"></script>
</head>
<body>
<nav class="container-fluid">
<ul>
<li>
<h1>Open data explorer</h1>
</li>
</ul>
</nav>
<main class="container-fluid">
<article>
<header>
<h2>Select csv data</h2>
</header>
<form id="select-data-form">
<label for="file-input" class="custom-file-upload">
<i class="fa fa-file-csv"></i> Select csv file to explore
</label>
<input id="file-input" type="file" aria-describedby="fileHelp" accept="text/csv" />
<small id="fileHelp">Please upload a csv file, where the first row is the header. And the values are
comma(,) seperated.</small>
</form>
</article>
<article>
<header>
<h2>Data infos</h2>
</header>
<div id="data-info"></div>
</article>
<article>
<header>
<h2>Selected column infos</h2>
</header>
<div id="column-info"></div>
</article>
<article>
<header>
<h2>Filter active column</h2>
</header>
<label for="filter">Filter column:</label><input type="search" id="filter" name="filter"
placeholder="Filter" disabled>
</article>
<article style="width: 100%">
<header>
<h2>Data table</h2>
</header>
<figure id="table-content"></figure>
</article>
</main>
</body>
</html>

21
task_2_ts/package.json Normal file
View File

@@ -0,0 +1,21 @@
{
"name": "vite-typescript-starter",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"format": "prettier . --write",
"tsc": "tsc"
},
"devDependencies": {
"prettier": "^3.0.1",
"typescript": "^5.1.6",
"vite": "^4.4.9"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^6.4.2",
"@picocss/pico": "^1.5.10",
"json-2-csv": "^4.1.0"
}
}

30
task_2_ts/ts/csv.ts Normal file
View File

@@ -0,0 +1,30 @@
import {
csv2json
} from 'json-2-csv';
export type CSV_Data = Array<Record<string, unknown>>;
const convertCSVtoJSON = async ( csvText: string ) => {
// Type cast OK, as the typing of the external library is not perfect.
return ( await csv2json( csvText ) ) as CSV_Data;
};
/**
* Reads a CSV file and returns the data as JSON.
* @param event The change event of the file input.
*/
export const readCSV = async ( event: Event ): Promise<CSV_Data> => {
if ( !( event.target instanceof HTMLInputElement ) ) {
throw new Error( 'Not an HTMLInputElement' );
}
const file = event.target.files?.[0];
if ( file == null ) {
throw new Error( 'No file selected' );
}
const result = await file.text();
return await convertCSVtoJSON( result );
};

5
task_2_ts/ts/main.ts Normal file
View File

@@ -0,0 +1,5 @@
import "@fortawesome/fontawesome-free/css/all.css";
import "../css/layout.css";
import "@picocss/pico/css/pico.min.css";
// TODO start here with the first entry point

33
task_2_ts/tsconfig.json Normal file
View File

@@ -0,0 +1,33 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"strict": true,
"allowUnusedLabels": false,
"allowUnreachableCode": false,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"allowJs": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
},
"include": ["**/*"],
"exclude": ["tests/**/*", "public/**/*", "build/**/*"]
}

1
task_2_ts/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />

7
task_2_ts/vite.config.js Normal file
View File

@@ -0,0 +1,7 @@
export default {
server: {
host: '0.0.0.0',
port: 5173,
allowedHosts: true,
},
}