Skip to content

Commit

Permalink
Merge pull request #3 from NINAnor/hierarchical-layers
Browse files Browse the repository at this point in the history
Hierarchical layers
  • Loading branch information
frafra authored Nov 28, 2023
2 parents f3f705d + 2a26fd6 commit 30fe5a9
Show file tree
Hide file tree
Showing 24 changed files with 5,251 additions and 209 deletions.
24 changes: 24 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'react/prop-types': [
'warn',
],
},
}

25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
datasets/*/
!datasets/example-*

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
18 changes: 15 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
FROM node:18 as frontend
WORKDIR /app
COPY package.json package-lock.json .
RUN npm i
COPY src src/
COPY public public/
COPY vite.config.js index.html .

CMD ["npm", "run", "dev"]

FROM frontend as build
RUN npm run build

FROM nginx

COPY nginx/default.conf.template /etc/nginx/templates/
COPY viewer.html /var/www/
COPY assets/map.js assets/style.css /var/www/assets/

COPY --from=build /app/dist /var/www/
RUN mv /var/www/index.html /var/www/viewer.html
102 changes: 0 additions & 102 deletions assets/map.js

This file was deleted.

53 changes: 0 additions & 53 deletions assets/style.css

This file was deleted.

32 changes: 29 additions & 3 deletions datasets/example-nina-offices/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
{
"style": "style.json",
"source": "nina.geojson",
"style": "/datasets/example-nina-offices/style.json",
"subtitle": "NINA offices across Norway",
"description": "<p>NINA offices across Norway. This is a test dataset.</p>"
"description": "<p>NINA offices across Norway. This is a test dataset.</p>",
"layers": [
{
"type": "group",
"id": "id1",
"name": "Test",
"download": "/datasets/example-nina-offices/data.geojson",
"children": [
{
"id": "id2",
"name": "Foo",
"children": [
{
"type": "layer",
"id": "osm",
"name": "osm"
}
]
},
{
"type": "layer",
"name": "data",
"id": "data-layer",
"download": "/datasets/example-nina-offices/data.geojson"
}
]
}
]
}
13 changes: 10 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ services:
image: nginx
volumes:
- ./datasets:/var/www/datasets:ro
- ./nginx/default.conf.template:/etc/nginx/templates/default.conf.template:ro
- ./viewer.html:/var/www/viewer.html:ro
- ./assets:/var/www/assets/:ro
- ./nginx/dev.conf.template:/etc/nginx/templates/default.conf.template:ro
vite:
build:
target: frontend
volumes:
- ./src:/app/src
ports:
- "3000:3000"
profiles:
- dev
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Viewer</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
39 changes: 39 additions & 0 deletions nginx/dev.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
server {
listen 80;
server_name localhost;
root /var/www;
absolute_redirect off;
autoindex on;

location = / {
return 307 /datasets/;
}
location = /datasets/ {
}

location ~* ^/datasets/(.+)/$ {
return 307 /viewer.html#$1;
}

location ~* ^/datasets/(.+)/(.+)$ {
try_files $uri $uri/;
}

location = /viewer.html {
proxy_pass http://vite:3000/index.html;
}

location / {
proxy_pass http://vite:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

Loading

0 comments on commit 30fe5a9

Please sign in to comment.