Compare commits

..

10 Commits

Author SHA1 Message Date
rxf
b0ee6043fa klick on selectes dates unselects it
.dockerignore added
mongo adapted to newest version
package.json: all debedencies updated
2026-01-18 10:19:10 +01:00
rxf
a24e491257 .gitignore angepasst 2026-01-16 16:27:38 +01:00
rxf
c922a2beea .gitignore auch angepasst 2026-01-16 16:25:02 +01:00
rxf
72c806be24 alles auf Module (import) umgeschrieben 2026-01-16 16:24:41 +01:00
rxf
ec953b0ae6 Position ders Datums angepasst 2023-07-06 15:00:07 +02:00
rxf
ed458b209a Übrnahme der Einheiten
launch.json
   -Port für Mongo

public/javascript/script.js
   - Einheite richtig mit abspeichern

package.json:
  "version": "1.2.1",
  "date": "2023-07-06",
2023-07-06 14:40:51 +02:00
rxf
0b82819524 Einheit mit in die Datenbank 2023-06-08 10:05:02 +02:00
rxf
027d0fd82e Einheiten dazu
routes/index.js
   - Übergabe der Einheiten

views/leayout.pug
   - Übernahme der Einheiten

package.json
   "version": "1.1.0",
   "date": "2023-05-14",

public/javascript/script.js
   - glob. Variable für Einheiten
   - Einheiten einlesen bei Click
   - Anzeige der Einheiten
   - bei init Einheiten auf 0

public/stylesheets/style.css
   - Anpassungen wg. Einheiten
2023-05-14 19:50:10 +02:00
rxf
c51fc0ea0a Einheiten dazu - WIP ** 2023-05-14 13:23:22 +02:00
rxf
61763de397 Favicon dazu, Version und Datum angepasst 2023-05-07 10:27:19 +02:00
38 changed files with 1075 additions and 818 deletions

8
.dockerignore Normal file
View File

@@ -0,0 +1,8 @@
node_modules
npm-debug.log
.git
.gitignore
.env
.DS_Store
log
*.log

3
.gitignore vendored
View File

@@ -1 +1,4 @@
node_modules
.DS_*
log
.env

21
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/bin/www",
"env": {
"MONGOPORT": "27017",
"DEBUG":"spritzschema:server"
}
}
]
}

View File

@@ -1,4 +1,4 @@
FROM node:20-alpine
FROM node:alpine
ADD package.json /tmp
RUN cd /tmp && npm install
@@ -8,12 +8,7 @@ WORKDIR /opt/app
ADD . /opt/app
RUN apk add --no-cache tzdata
ENV TZ Europe/Berlin
ENV TZ=Europe/Berlin
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN touch cmds.sh \
&& echo 'npm start' >>cmds.sh
EXPOSE 3014
CMD sh ./cmds.sh
CMD ["npm", "start"]

22
app.js
View File

@@ -1,13 +1,25 @@
import createError from 'http-errors'
import logger from 'morgan'
import express from 'express'
import cookieParser from 'cookie-parser'
import path from 'path'
import { fileURLToPath } from 'url';
/*
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
*/
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
import indexRouter from './routes/index.js'
// import usersRouter from './routes/users.js'
var app = express();
const app = express();
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// view engine setup
app.set('views', path.join(__dirname, 'views'));
@@ -21,7 +33,7 @@ app.use(express.static(path.join(__dirname, 'public')));
app.use('/', indexRouter);
app.use('/data', indexRouter);
app.use('/users', usersRouter);
// app.use('/users', usersRouter);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
@@ -39,4 +51,4 @@ app.use(function(err, req, res, next) {
res.render('error');
});
module.exports = app;
export default app

View File

@@ -4,15 +4,22 @@
* Module dependencies.
*/
import app from '../app.js'
import Debug from 'debug'
import http from 'http'
const debug = Debug('spritzschema:server')
/*
var app = require('../app');
var debug = require('debug')('Spritzschema:server');
var http = require('http');
*/
/**
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '3100');
var port = normalizePort(process.env.PORT || '3200');
app.set('port', port);
/**
@@ -86,5 +93,6 @@ function onListening() {
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
//debug('Listening on ' + bind);
console.log('Listening on ' + bind);
}

View File

@@ -15,14 +15,16 @@ services:
# command: '--auth'
restart: unless-stopped
# spritzschema:
# image: spritzschema
# volumes:
# - ${PWD}/log:/var/log
# ports:
# - '3100:3100'
# container_name: spritzschema
# environment:
# - MONGOHOST=mongodb
# restart: unless-stopped
#
spritzschema:
build:
context: .
dockerfile: Dockerfile_spritzschema
volumes:
- ${PWD}/log:/var/log
ports:
- '3200:3200'
container_name: spritzschema
environment:
- MONGOHOST=mongodb
restart: unless-stopped

View File

@@ -0,0 +1,30 @@
version: '3.9'
volumes:
mongodata:
services:
mongodb:
image: mongo
volumes:
- mongodata:/data/db
- ${PWD}/log:/var/log
ports:
- "27017:27017"
container_name: mongodb
# command: '--auth'
restart: unless-stopped
#spritzschema:
# build:
# context: .
# dockerfile: Dockerfile_spritzschema
# volumes:
# - ${PWD}/log:/var/log
# #ports:
# # - '3100:3014'
# container_name: spritzschema
# environment:
# - MONGOHOST=mongodb
# restart: unless-stopped

View File

@@ -1,6 +1,6 @@
// all functions to get data from mongodb
const {MongoClient} = require('mongodb')
import { MongoClient } from 'mongodb';
const MONGOHOST = process.env.MONGOHOST || 'localhost'
const MONGOPORT = process.env.MONGOPORT || 27017
@@ -11,12 +11,12 @@ const MONGOBASE = process.env.MONGOBASE || 'medizin'
const MONGO_URL = MONGOAUTH ? 'mongodb://'+MONGOUSRP+'@' + MONGOHOST + ':' + MONGOPORT + '/?authSource=admin' : 'mongodb://'+MONGOHOST+':'+MONGOPORT // URL to mongo database
let COLLECTION = 'spritzschema'
const doMongo = async function(cmd, options) {
export const doMongo = async function(cmd, options) {
let erg = {err: null}
if (options.testing) {
COLLECTION = 'spritzschema_test'
}
const client = new MongoClient(MONGO_URL, { useUnifiedTopology: true })
const client = new MongoClient(MONGO_URL)
try {
await client.connect()
if (cmd === 'getdata') {
@@ -46,7 +46,7 @@ const doMongo = async function(cmd, options) {
// return:
// JSON Dokument mit den angefragten Werten
// *********************************************
async function getAPIdataOne(client, options) {
async function getAPIdataOne(client, options) {
let erg = {err: null}
try {
erg.data = await client.db(MONGOBASE).collection(COLLECTION).findOne({curdata: options.curdata},{ projection:{_id: 0} })
@@ -58,7 +58,7 @@ async function getAPIdataOne(client, options) {
return erg
}
async function getAPIlastDataOne(client, options) {
async function getAPIlastDataOne(client, options) {
let erg = {err: null}
try {
erg.data = await client.db(MONGOBASE).collection(COLLECTION).findOne({},{ projection:{_id: 0}, sort: {$natural: -1}})
@@ -70,7 +70,7 @@ async function getAPIlastDataOne(client, options) {
return erg
}
async function putAPIdataOne(client, options) {
async function putAPIdataOne(client, options) {
let erg = {err: null}
const query = {curdate: options.data.curdate}
const opts = {upsert : true}
@@ -84,7 +84,7 @@ async function putAPIdataOne(client, options) {
return erg
}
async function delAPIdataOne(client, options) {
async function delAPIdataOne(client, options) {
let erg = {err: null}
const query = {curdate: options.curdate}
try {
@@ -95,4 +95,4 @@ async function delAPIdataOne(client, options) {
}
return erg
}
exports.doMongo = doMongo

1552
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,20 @@
{
"name": "Spritzschema",
"version": "0.0.1",
"date": "2023-05-03",
"name": "spritzschema",
"version": "1.3.0",
"date": "2026-01-18",
"type": "module",
"private": true,
"scripts": {
"start": "node ./bin/www >>/var/log/spritzschema.log 2>&1"
"start": "node ./bin/www.js >>/var/log/spritzschema.log 2>&1"
},
"dependencies": {
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"express": "^4.18.2",
"http-errors": "~1.6.3",
"mongodb": "^5.4.0",
"morgan": "~1.9.1",
"pug": "^3.0.2"
"cookie-parser": "~1.4.7",
"debug": "~4.4.3",
"express": "^5.2.1",
"http-errors": "~2.0.1",
"mongodb": "^7.0.0",
"morgan": "^1.10.1",
"pug": "^3.0.3"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

BIN
public/apple-icon-57x57.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
public/apple-icon-60x60.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
public/apple-icon-72x72.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
public/apple-icon-76x76.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

2
public/browserconfig.xml Normal file
View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig><msapplication><tile><square70x70logo src="/ms-icon-70x70.png"/><square150x150logo src="/ms-icon-150x150.png"/><square310x310logo src="/ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>

BIN
public/favicon-16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

BIN
public/favicon-256x256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
public/favicon-32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
public/favicon-96x96.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -2,23 +2,33 @@ document.addEventListener('DOMContentLoaded', async function () {
const DateTime = luxon.DateTime
let curEinheit = sysParams.einheit
if (sysParams.doinit) {
await initSchema('2023-05-01')
}
let ret = await getData()
let schema = ret.data
if(curEinheit === 0) {
curEinheit = schema.einheit
}
fillSchema(schema)
document.querySelector('#sptab').addEventListener('click', markField);
document.querySelector('#einheiten').addEventListener('change', enterEinheit);
async function markField (e) {
let field = e.target;
let d = schema.data[34].day
field.setAttribute('aria-label','x');
field.setAttribute('disabled','disabled');
schema.data[parseInt(field.id.slice(2))-1].status = true
// field.setAttribute('disabled','disabled');
let status = schema.data[parseInt(field.id.slice(2))-1].status
status = !status
schema.data[parseInt(field.id.slice(2))-1].status = status
schema.data[parseInt(field.id.slice(2))-1].einheit = curEinheit
await storeData(schema)
fillSchema(schema)
if (e.srcElement.id === 'bt35') {
let ldt = DateTime.fromISO(d)
ldt = ldt.plus({day: 1})
@@ -26,6 +36,21 @@ document.addEventListener('DOMContentLoaded', async function () {
}
}
async function enterEinheit (e) {
let field = e.target;
curEinheit = parseInt(field.value)
schema.einheit = curEinheit
}
function buildCellHtml(day, einheit) {
let x = `<div id="inner">${day.toFormat('d')}
<div id="lowline" class="small">
<div id="wtg">${day.setLocale('de').toFormat('ccc')}</div>
<div id="eh">${einheit !== 0 ? einheit : ''}</div>
</div></div>`
return x
}
function fillSchema(schema) {
const setArray = schema.data
let months = ''
@@ -43,19 +68,20 @@ document.addEventListener('DOMContentLoaded', async function () {
let sel = '#bt'+(i+1)
let day = DateTime.fromISO(setArray[i].day)
if (setArray[i].day !== '') {
let x = `${day.toFormat('d')}
<br /><span class="small">${day.setLocale('de').toFormat('ccc')}</span>`
document.querySelector(sel).innerHTML = x
document.querySelector(sel).innerHTML = buildCellHtml(day, setArray[i].einheit)
if (setArray[i].status) {
document.querySelector(sel).setAttribute('aria-label', 'x')
document.querySelector(sel).setAttribute('disabled', 'disabled')
// document.querySelector(sel).setAttribute('disabled', 'disabled')
} else {
document.querySelector(sel).setAttribute('aria-label', '')
document.querySelector(sel).removeAttribute('disabled')
// document.querySelector(sel).removeAttribute('disabled')
}
} else {
document.querySelector(sel).setAttribute('disabled', 'disabled')
}
if(setArray[i].einheit !== 0) {
document.getElementById("einheiten").value = setArray[i].einheit
}
}
}
@@ -84,6 +110,7 @@ document.addEventListener('DOMContentLoaded', async function () {
let k = 0
for(let i = 0; i < 35; i++) {
let elem = {status: false}
elem.einheit = 0
if (i === 17) {
elem.day = ''
} else {
@@ -101,7 +128,7 @@ document.addEventListener('DOMContentLoaded', async function () {
}
setArray.push(elem)
}
let schema = {curdate: startdate, months: monthArray, years: yearsArray, data: setArray}
let schema = {curdate: startdate, months: monthArray, years: yearsArray, data: setArray, einheit: curEinheit}
await storeData(schema)
}

41
public/manifest.json Normal file
View File

@@ -0,0 +1,41 @@
{
"name": "App",
"icons": [
{
"src": "\/android-icon-36x36.png",
"sizes": "36x36",
"type": "image\/png",
"density": "0.75"
},
{
"src": "\/android-icon-48x48.png",
"sizes": "48x48",
"type": "image\/png",
"density": "1.0"
},
{
"src": "\/android-icon-72x72.png",
"sizes": "72x72",
"type": "image\/png",
"density": "1.5"
},
{
"src": "\/android-icon-96x96.png",
"sizes": "96x96",
"type": "image\/png",
"density": "2.0"
},
{
"src": "\/android-icon-144x144.png",
"sizes": "144x144",
"type": "image\/png",
"density": "3.0"
},
{
"src": "\/android-icon-192x192.png",
"sizes": "192x192",
"type": "image\/png",
"density": "4.0"
}
]
}

BIN
public/ms-icon-144x144.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
public/ms-icon-150x150.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

BIN
public/ms-icon-310x310.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
public/ms-icon-70x70.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@@ -50,6 +50,17 @@ a {
color: gray;
}
#infeld {
width: 91vmin;
margin: auto;
font-size: 200%;
}
#einheiten {
font-size: 130%;
margin-left: 30px;
}
footer {
width: 91vmin;
margin: auto;
@@ -58,3 +69,22 @@ footer {
text-align: right;
margin-top: 30px;
}
#inner {
margin-top: -45px;
}
#lowline {
width: 100%;
clear: float;
}
#eh {
color: black;
float: right;
margin-right: -20px;
}
#wtg {
float: left;
}

View File

@@ -1,13 +1,15 @@
const express = require('express');
import express from 'express'
import { doMongo } from '../modules/mongointerface.js'
import pkg from '../package.json' with { type: "json" }
const router = express.Router();
const domongo = require('../modules/mongointerface')
const pkg = require('../package.json')
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', {
test: req.query.test === 'true',
doinit: req.query.doinit === 'true',
einheit: req.query.einheit === undefined ? 0 : req.query.einheit,
version: pkg.version,
title: pkg.name,
date: pkg.date
@@ -18,7 +20,7 @@ router.get('/data', async function(req, res, next) {
const options = {}
options.curdate = req.query.curdate
options.testing = req.query.test
let erg = await domongo.doMongo('getlastdata', options)
let erg = await doMongo('getlastdata', options)
res.json(erg)
})
@@ -26,8 +28,8 @@ router.post('/data', async function (req, res, next) {
const options = {}
options.data = req.body
options.testing = req.query.test
let erg = await domongo.doMongo('putdata', options)
let erg = await doMongo('putdata', options)
res.json(erg)
})
module.exports = router;
export default router

View File

@@ -1,9 +0,0 @@
var express = require('express');
var router = express.Router();
/* GET users listing. */
router.get('/', function(req, res, next) {
res.send('respond with a resource');
});
module.exports = router;

View File

@@ -44,3 +44,6 @@ block content
button#bt33
button#bt34
button#bt35
#infeld
label(for="einheiten") Einheiten:
input#einheiten(type="number" min="0" max="100" value="0")

View File

@@ -2,6 +2,25 @@ doctype html
html
head
title= 'Spritzschema'
link(rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png")
link(rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png")
link(rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png")
link(rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png")
link(rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png")
link(rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png")
link(rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png")
link(rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png")
link(rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png")
link(rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png")
link(rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png")
link(rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png")
link(rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png")
link(rel="manifest" href="/manifest.json")
meta(name="msapplication-TileColor" content="#ffffff")
meta(name="msapplication-TileImage" content="/ms-icon-144x144.png")
meta(name="theme-color" content="#ffffff")
link(rel='stylesheet', href='/stylesheets/style.css')
script(src="https://cdn.jsdelivr.net/npm/luxon@3.3.0/build/global/luxon.min.js")
script(src="/javascripts/script.js")
@@ -11,7 +30,8 @@ html
testing: '#{test}' === 'true',
version: '#{version}',
date: '#{date}',
doinit: '#{doinit}' === 'true'
doinit: '#{doinit}' === 'true',
einheit: parseInt('#{einheit}')
}