Skip to content

Commit

Permalink
Setup webpack and typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
berrydenhartog committed Aug 26, 2024
1 parent f655982 commit 555c9b8
Show file tree
Hide file tree
Showing 20 changed files with 7,434 additions and 40 deletions.
7 changes: 5 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
},
"remoteUser": "root",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/node:1": {}
},
"forwardPorts": [
8000,
Expand All @@ -29,7 +30,9 @@
"markis.code-coverage",
"qwtel.sqlite-viewer",
"ms-vsliveshare.vsliveshare",
"wholroyd.jinja"
"wholroyd.jinja",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
],
"settings": {
"editor.formatOnPaste": false,
Expand Down
3 changes: 3 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

. ${NVM_DIR}/nvm.sh && nvm install
npm install

pipx install poetry
poetry install
poetry run playwright install --with-deps
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ trim_trailing_whitespace = false
[*.{yml,yaml,json,js,html}]
indent_size = 2

[*.ts]
indent_size = 2


[LICENSE]
insert_final_newline = false
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,17 @@ updates:
alldevcontainers:
patterns:
- "*"

- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "08:00"
timezone: "Europe/Amsterdam"
labels:
- "dependencies"
groups:
allnpm:
patterns:
- "*"
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ output/

# ignore playwright
test-results/

# ignore npm
node_modules/


# ignore tsc generated files
amt/site/static/js/*
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
()v22.6.0
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repos:
- id: check-yaml
exclude: example/
- id: check-json
exclude: 'tsconfig\.json'
- id: check-added-large-files
- id: check-merge-conflict
- id: check-toml
Expand Down
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ignore artifacts:
amt/site/static/js

webpack.config.js
webpack.config.prod.js
tsconfig.json
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"markis.code-coverage",
"qwtel.sqlite-viewer",
"ms-vsliveshare.vsliveshare",
"wholroyd.jinja"
"wholroyd.jinja",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
37 changes: 0 additions & 37 deletions amt/site/static/js/amt.js

This file was deleted.

65 changes: 65 additions & 0 deletions amt/site/static/ts/amt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import Sortable from "sortablejs";
import "htmx.org";

window.onload = function () {
// TODO (robbert): we need (better) event handling and displaying of server errors
document.body.addEventListener("htmx:sendError", function () {
document.getElementById("errorContainer")!.innerHTML =
"<h1>Placeholder: Error while connecting to server</h1";
});

const columns = document.getElementsByClassName(
"progress_cards_container",
) as HTMLCollectionOf<HTMLDivElement>;
for (let i = 0; i < columns.length; i++) {
new Sortable(columns[i], {
//NOSONAR
group: "shared", // set both lists to same group
animation: 150,
onEnd: function (evt) {
if (evt.oldIndex !== evt.newIndex || evt.from !== evt.to) {
let previousSiblingId = evt.item.previousElementSibling
? evt.item.previousElementSibling.getAttribute("data-id")
: "-1";
let nextSiblingId = evt.item.nextElementSibling
? evt.item.nextElementSibling.getAttribute("data-id")
: "-1";
let targetId = "#" + evt.item.getAttribute("data-target-id");
let toStatusId = evt.to.getAttribute("data-id");
let form = document.getElementById("cardMovedForm");

(document.getElementsByName("taskId")[0] as HTMLInputElement).value =
evt.item.getAttribute("data-id") ?? "";
(
document.getElementsByName("statusId")[0] as HTMLInputElement
).value = toStatusId ?? "";
(
document.getElementsByName(
"previousSiblingId",
)[0] as HTMLInputElement
).value = previousSiblingId ?? "";
(
document.getElementsByName("nextSiblingId")[0] as HTMLInputElement
).value = nextSiblingId ?? "";
form!.setAttribute("hx-target", targetId);

// @ts-expect-error"
htmx.trigger("#cardMovedForm", "cardmoved");
}
},
});
}
};

// @ts-expect-error"
function setCookie(
cookieName: string,
cookieValue: string,
expirationDays: number,
) {
const date = new Date();
date.setTime(date.getTime() + expirationDays * 24 * 60 * 60 * 1000); // Set expiration time
const expires = "expires=" + date.toUTCString();
document.cookie =
cookieName + "=" + cookieValue + ";" + expires + ";path=/;SameSite=Strict";
}
13 changes: 13 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";

export default [
{ files: ["**/*.ts"] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
eslintConfigPrettier,
];
Loading

0 comments on commit 555c9b8

Please sign in to comment.