diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml
index 8558ad6..1b05273 100644
--- a/.github/workflows/prettier.yml
+++ b/.github/workflows/prettier.yml
@@ -1,25 +1,17 @@
-name: Continuous Integration
+name: Prettier
on:
pull_request:
- branches: [main]
+ branches: [master]
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- - name: Checkout
- uses: actions/checkout@v3
+ - uses: actions/checkout@v2
+ - uses: actions/setup-node@v3
with:
- # Make sure the actual branch is checked out when running on pull requests
- ref: ${{ github.head_ref }}
- # This is important to fetch the changes to the previous commit
- fetch-depth: 0
-
- - name: Prettify code
- uses: creyD/prettier_action@v4.3
- with:
- # This part is also where you can pass other options, for example:
- prettier_options: --check **/*
- dry: True
+ node-version: 17
+ - run: npm install
+ - run: npm run prettier:check
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
deleted file mode 100644
index 90e0b52..0000000
--- a/.github/workflows/tests.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-name: Tests
-
-on:
- push:
- branches: [master]
-
-jobs:
- deploy:
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-node@v3
- with:
- node-version: 17
- - run: npm install
- - run: npm run test
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 711f4c4..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "esversion": 11
-}
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..b0b2994
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,5 @@
+Dockerfile
+LICENSE
+fakelog.conf
+fakelog.nginx
+bin
diff --git a/.prettierrc b/.prettierrc
index 23b8710..fc56e31 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -1,7 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
- "semi": false,
+ "semi": true,
"singleQuote": true,
"printWidth": 120
}
diff --git a/app.js b/app.js
index 91b7568..022ea84 100644
--- a/app.js
+++ b/app.js
@@ -1,98 +1,102 @@
-const express = require('express')
-const path = require('path')
-const logger = require('morgan')
-const cookieParser = require('cookie-parser')
-const bodyParser = require('body-parser')
-const cors = require('cors')
-const protocol = require('./src/utils/connection')
+const express = require('express');
+const path = require('path');
+const logger = require('morgan');
+const cookieParser = require('cookie-parser');
+const bodyParser = require('body-parser');
+const cors = require('cors');
+const protocol = require('./src/utils/connection');
// const favicon = require('serve-favicon');
-const subdomain = require('express-subdomain')
-const index = require('./src/routes/index')
-const api = require('./src/routes/api')
-const cufs = require('./src/routes/cufs')
-const uonetplus = require('./src/routes/uonetplus')
-const uonetplusOpiekun = require('./src/routes/uonetplus-opiekun')
-const uonetplusUczen = require('./src/routes/uonetplus-uczen')
-const uonetplusUczenplus = require('./src/routes/uonetplus-uczenplus/index')
-const uonetplusUzytkownik = require('./src/routes/uonetplus-uzytkownik')
-const uonetplusWiadomosciplus = require('./src/routes/uonetplus-wiadomosciplus')
+const subdomain = require('express-subdomain');
+const index = require('./src/routes/index');
+const api = require('./src/routes/api');
+const cufs = require('./src/routes/cufs');
+const uonetplus = require('./src/routes/uonetplus');
+const uonetplusOpiekun = require('./src/routes/uonetplus-opiekun');
+const uonetplusUczen = require('./src/routes/uonetplus-uczen');
+const uonetplusUczenplus = require('./src/routes/uonetplus-uczenplus/index');
+const uonetplusUzytkownik = require('./src/routes/uonetplus-uzytkownik');
+const uonetplusWiadomosciplus = require('./src/routes/uonetplus-wiadomosciplus');
-const app = express()
+const app = express();
// view engine setup
-app.set('views', path.join(__dirname, 'src/views'))
-app.set('view engine', 'pug')
+app.set('views', path.join(__dirname, 'src/views'));
+app.set('view engine', 'pug');
// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
-app.use(logger('dev'))
-app.use(bodyParser.json())
-app.use(bodyParser.urlencoded({ extended: false }))
-app.use(cookieParser())
-app.use(express.static(path.join(__dirname, 'public')))
+app.use(logger('dev'));
+app.use(bodyParser.json());
+app.use(bodyParser.urlencoded({ extended: false }));
+app.use(cookieParser());
+app.use(express.static(path.join(__dirname, 'public')));
app.use((req, res, next) => {
- res.locals.userInfo = require('./data/api/ListaUczniow')[1]
- res.locals.uonetplusUrl = protocol(req) + '://' + req.get('host').replace('uonetplus-opiekun', 'uonetplus')
- res.locals.currentHost = protocol(req) + '://' + req.get('host')
- res.locals.proto = protocol(req)
- res.locals.host = req.get('host').replace(/(api|cufs|uonetplus|uonetplus-opiekun|uonetplus-uzytkownik)\./, '')
+ res.locals.userInfo = require('./data/api/ListaUczniow')[1];
+ res.locals.uonetplusUrl = protocol(req) + '://' + req.get('host').replace('uonetplus-opiekun', 'uonetplus');
+ res.locals.currentHost = protocol(req) + '://' + req.get('host');
+ res.locals.proto = protocol(req);
+ res.locals.host = req.get('host').replace(/(api|cufs|uonetplus|uonetplus-opiekun|uonetplus-uzytkownik)\./, '');
res.cookie('UonetPlus_ASP.NET_SessionId', '', {
httpOnly: true,
domain: req.get('host'),
- })
+ });
res.cookie('ARR_DS_ARR301302', '', {
httpOnly: true,
domain: req.get('host'),
- })
+ });
res.cookie('ARR_' + req.get('host'), '1234567891012131314151617181920212223242526272829303132333435363', {
httpOnly: true,
domain: req.get('host'),
- })
- next()
-})
+ });
+ next();
+});
const corsOpt = {
origin: process.env.CORS_ALLOW_ORIGIN || '*',
-}
-app.use(cors(corsOpt))
-app.options('*', cors(corsOpt))
+};
+app.use(cors(corsOpt));
+app.options('*', cors(corsOpt));
-app.set('subdomain offset', +process.env.SUBDOMAIN_OFFSET || 2)
-app.use(subdomain('api', api))
-app.use(subdomain('cufs', cufs))
-app.use(subdomain('uonetplus', uonetplus))
-app.use(subdomain('uonetplus-opiekun', uonetplusOpiekun.use('/powiatwulkanowy/123456', uonetplusOpiekun)))
-app.use(subdomain('uonetplus-opiekun', uonetplusOpiekun.use('/powiatwulkanowy/123457', uonetplusOpiekun)))
-app.use(subdomain('uonetplus-opiekun', uonetplusOpiekun.use('/powiatwulkanowy/123458', uonetplusOpiekun)))
-app.use(subdomain('uonetplus-uczen', uonetplusUczen.use('/powiatwulkanowy/:customerSymbol', uonetplusUczen)))
-app.use(subdomain('uonetplus-uczenplus', uonetplusUczenplus.use('/powiatwulkanowy/:customerSymbol', uonetplusUczenplus)))
-app.use(subdomain('uonetplus-uzytkownik', uonetplusUzytkownik.use('/powiatwulkanowy', uonetplusUzytkownik)))
-app.use(subdomain('uonetplus-wiadomosciplus', uonetplusWiadomosciplus.use('/powiatwulkanowy', uonetplusWiadomosciplus)))
-app.use('/', index)
+app.set('subdomain offset', +process.env.SUBDOMAIN_OFFSET || 2);
+app.use(subdomain('api', api));
+app.use(subdomain('cufs', cufs));
+app.use(subdomain('uonetplus', uonetplus));
+app.use(subdomain('uonetplus-opiekun', uonetplusOpiekun.use('/powiatwulkanowy/123456', uonetplusOpiekun)));
+app.use(subdomain('uonetplus-opiekun', uonetplusOpiekun.use('/powiatwulkanowy/123457', uonetplusOpiekun)));
+app.use(subdomain('uonetplus-opiekun', uonetplusOpiekun.use('/powiatwulkanowy/123458', uonetplusOpiekun)));
+app.use(subdomain('uonetplus-uczen', uonetplusUczen.use('/powiatwulkanowy/:customerSymbol', uonetplusUczen)));
+app.use(
+ subdomain('uonetplus-uczenplus', uonetplusUczenplus.use('/powiatwulkanowy/:customerSymbol', uonetplusUczenplus))
+);
+app.use(subdomain('uonetplus-uzytkownik', uonetplusUzytkownik.use('/powiatwulkanowy', uonetplusUzytkownik)));
+app.use(
+ subdomain('uonetplus-wiadomosciplus', uonetplusWiadomosciplus.use('/powiatwulkanowy', uonetplusWiadomosciplus))
+);
+app.use('/', index);
// catch 404 and forward to error handler
app.use((req, res, next) => {
- const err = new Error('Not Found')
- err.status = 404
- next(err)
-})
+ const err = new Error('Not Found');
+ err.status = 404;
+ next(err);
+});
// error handler
app.use((err, req, res, next) => {
// set locals, only providing error in development
- res.locals.message = err.message
- res.locals.error = req.app.get('env') === 'development' ? err : {}
+ res.locals.message = err.message;
+ res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
- res.status(err.status || 500)
- res.render('error')
-})
+ res.status(err.status || 500);
+ res.render('error');
+});
if (typeof PhusionPassenger !== 'undefined') {
- app.listen('passenger')
+ app.listen('passenger');
}
-module.exports = app
+module.exports = app;
diff --git a/data/uonetplus-uczenplus/FrekwencjaStatystyki.json b/data/uonetplus-uczenplus/FrekwencjaStatystyki.json
index 5572f07..1f24b2f 100644
--- a/data/uonetplus-uczenplus/FrekwencjaStatystyki.json
+++ b/data/uonetplus-uczenplus/FrekwencjaStatystyki.json
@@ -9,10 +9,7 @@
"wartosc": 1
}
],
- "okresy": [
- 0,
- 1
- ],
+ "okresy": [0, 1],
"razem": 1
},
{
@@ -23,10 +20,7 @@
"wartosc": 2
}
],
- "okresy": [
- 0,
- 2
- ],
+ "okresy": [0, 2],
"razem": 2
},
{
@@ -37,10 +31,7 @@
"wartosc": 3
}
],
- "okresy": [
- 0,
- 3
- ],
+ "okresy": [0, 3],
"razem": 3
},
{
@@ -51,10 +42,7 @@
"wartosc": 6
}
],
- "okresy": [
- 0,
- 6
- ],
+ "okresy": [0, 6],
"razem": 6
},
{
@@ -65,10 +53,7 @@
"wartosc": 4
}
],
- "okresy": [
- 0,
- 4
- ],
+ "okresy": [0, 4],
"razem": 4
},
{
@@ -79,10 +64,7 @@
"wartosc": 5
}
],
- "okresy": [
- 0,
- 5
- ],
+ "okresy": [0, 5],
"razem": 5
},
{
@@ -93,11 +75,8 @@
"wartosc": 2
}
],
- "okresy": [
- 0,
- 2
- ],
+ "okresy": [0, 2],
"razem": 2
}
]
-}
\ No newline at end of file
+}
diff --git a/package.json b/package.json
index fc87120..fdcb4ba 100644
--- a/package.json
+++ b/package.json
@@ -5,9 +5,9 @@
"scripts": {
"start": "node ./bin/www & npm run scss",
"watch": "nodemon ./bin/www & npm run scss",
- "test": "jshint src/ app.js --verbose",
"scss": "sass --watch public/stylesheets",
- "prettier": "prettier . --write"
+ "prettier:write": "prettier . --write",
+ "prettier:check": "prettier . --check"
},
"dependencies": {
"@types/express": "^4.17.21",
@@ -30,7 +30,6 @@
"validate-polish": "^2.1.40"
},
"devDependencies": {
- "jshint": "^2.13.6",
"nodemon": "^3.1.0"
},
"engines": {
diff --git a/src/routes/api.js b/src/routes/api.js
index e39007e..dbb2f06 100644
--- a/src/routes/api.js
+++ b/src/routes/api.js
@@ -1,11 +1,11 @@
-const router = require('express').Router()
-const protocol = require('../utils/connection')
-const { format } = require('date-fns')
+const router = require('express').Router();
+const protocol = require('../utils/connection');
+const { format } = require('date-fns');
router.all('/', (req, res) => {
- const today = format(new Date(), 'yyyy-MM-dd')
+ const today = format(new Date(), 'yyyy-MM-dd');
- let base = protocol(req) + '://' + req.get('host')
+ let base = protocol(req) + '://' + req.get('host');
res.json({
status: 'success',
start: base.replace('api.', ''),
@@ -41,26 +41,26 @@ router.all('/', (req, res) => {
base + '/powiatwulkanowy/123456/mobile-api/Uczen.v3.Uczen/WiadomosciUsuniete',
base + '/powiatwulkanowy/123456/mobile-api/Uczen.v3.Uczen/DodajWiadomosc',
],
- })
-})
+ });
+});
// v3
-router.use('/powiatwulkanowy/mobile-api/Uczen.v3.UczenStart', require('./mobile-api/register'))
-router.use('/powiatwulkanowy/123456/mobile-api/Uczen.v3.Uczen', require('./mobile-api/student'))
-router.use('/powiatwulkanowy/123456/mobile-api/Uczen.v3.Uczen', require('./mobile-api/messages'))
-router.use('/powiatwulkanowy/123456/mobile-api/Push.v1.Push', require('./mobile-api/push'))
+router.use('/powiatwulkanowy/mobile-api/Uczen.v3.UczenStart', require('./mobile-api/register'));
+router.use('/powiatwulkanowy/123456/mobile-api/Uczen.v3.Uczen', require('./mobile-api/student'));
+router.use('/powiatwulkanowy/123456/mobile-api/Uczen.v3.Uczen', require('./mobile-api/messages'));
+router.use('/powiatwulkanowy/123456/mobile-api/Push.v1.Push', require('./mobile-api/push'));
// hebe
-router.use('/powiatwulkanowy/api/mobile/register', require('./api/register'))
-router.use('/powiatwulkanowy/123456/api/mobile/register', require('./api/register'))
-router.use('/powiatwulkanowy/123456/api/mobile', require('./api/student'))
-router.use('/powiatwulkanowy/123456/api/mobile/school', require('./api/school'))
+router.use('/powiatwulkanowy/api/mobile/register', require('./api/register'));
+router.use('/powiatwulkanowy/123456/api/mobile/register', require('./api/register'));
+router.use('/powiatwulkanowy/123456/api/mobile', require('./api/student'));
+router.use('/powiatwulkanowy/123456/api/mobile/school', require('./api/school'));
router.all('/*', (req, res) => {
res.status(404).json({
status: 'error',
message: 'Not implemented yet',
- })
-})
+ });
+});
-module.exports = router
+module.exports = router;
diff --git a/src/routes/api/register.js b/src/routes/api/register.js
index 35cffdb..7978861 100644
--- a/src/routes/api/register.js
+++ b/src/routes/api/register.js
@@ -1,9 +1,9 @@
-const router = require('express').Router({})
-const protocol = require('../../utils/connection')
-const { createEnvelope } = require('./utils')
+const router = require('express').Router({});
+const protocol = require('../../utils/connection');
+const { createEnvelope } = require('./utils');
router.all('/new', (req, res) => {
- const base = protocol(req) + '://' + req.get('host')
+ const base = protocol(req) + '://' + req.get('host');
res.json(
createEnvelope(0, 'OK', 'AccountPayload', {
@@ -12,8 +12,8 @@ router.all('/new', (req, res) => {
UserLogin: 'jan@fakelog.cf',
UserName: 'jan@fakelog.cf',
})
- )
-})
+ );
+});
router.all('/hebe', (req, res) => {
res.json(
@@ -223,7 +223,7 @@ router.all('/hebe', (req, res) => {
},
},
])
- )
-})
+ );
+});
-module.exports = router
+module.exports = router;
diff --git a/src/routes/api/school.js b/src/routes/api/school.js
index a56f605..99fb4ea 100644
--- a/src/routes/api/school.js
+++ b/src/routes/api/school.js
@@ -1,13 +1,13 @@
-const router = require('express').Router({})
-const { createEnvelope } = require('./utils')
-const { format } = require('date-fns')
-const { uuid } = require('uuidv4')
-const { getByValue } = require('./../../utils/dictMap')
+const router = require('express').Router({});
+const { createEnvelope } = require('./utils');
+const { format } = require('date-fns');
+const { uuid } = require('uuidv4');
+const { getByValue } = require('./../../utils/dictMap');
router.get('/grade/byPupil', (req, res) => {
- const subjects = require('../../../data/api/dictionaries/Przedmioty')
- const categories = require('../../../data/api/dictionaries/KategorieOcen')
- const teachers = require('../../../data/api/dictionaries/Nauczyciele')
+ const subjects = require('../../../data/api/dictionaries/Przedmioty');
+ const categories = require('../../../data/api/dictionaries/KategorieOcen');
+ const teachers = require('../../../data/api/dictionaries/Nauczyciele');
res.json(
createEnvelope(
@@ -71,11 +71,11 @@ router.get('/grade/byPupil', (req, res) => {
Denominator: item.Mianownik,
PupilId: 111,
Value: item.Wartosc,
- }
+ };
})
)
- )
-})
+ );
+});
router.all('/lucky', (req, res) => {
res.json(
@@ -83,7 +83,7 @@ router.all('/lucky', (req, res) => {
Day: format(new Date(), 'yyyy-MM-dd'),
Number: format(new Date(), 'd'),
})
- )
-})
+ );
+});
-module.exports = router
+module.exports = router;
diff --git a/src/routes/api/student.js b/src/routes/api/student.js
index 6c87e3a..a887a20 100644
--- a/src/routes/api/student.js
+++ b/src/routes/api/student.js
@@ -1,10 +1,10 @@
-const router = require('express').Router({})
-const { createEnvelope } = require('./utils')
-const { getTime, format } = require('date-fns')
+const router = require('express').Router({});
+const { createEnvelope } = require('./utils');
+const { getTime, format } = require('date-fns');
router.all('/version', (req, res) => {
- res.json(createEnvelope(105, 'Podany czas jest nieprawidłowy', 'Object', null))
-})
+ res.json(createEnvelope(105, 'Podany czas jest nieprawidłowy', 'Object', null));
+});
router.all('/internal/time', (req, res) => {
res.json(
@@ -14,11 +14,11 @@ router.all('/internal/time', (req, res) => {
Time: format(new Date(), 'HH:mm:ss'),
Timestamp: getTime(new Date()),
})
- )
-})
+ );
+});
router.all('/heartbeat', (req, res) => {
- res.json(createEnvelope(0, 'OK', 'Boolean', true))
-})
+ res.json(createEnvelope(0, 'OK', 'Boolean', true));
+});
-module.exports = router
+module.exports = router;
diff --git a/src/routes/api/utils.js b/src/routes/api/utils.js
index 6377383..8c73798 100644
--- a/src/routes/api/utils.js
+++ b/src/routes/api/utils.js
@@ -1,5 +1,5 @@
-const { uuid } = require('uuidv4')
-const { getTime, format } = require('date-fns')
+const { uuid } = require('uuidv4');
+const { getTime, format } = require('date-fns');
exports.createEnvelope = (statusCode, statusMessage, type, body) => {
return {
@@ -13,5 +13,5 @@ exports.createEnvelope = (statusCode, statusMessage, type, body) => {
},
Timestamp: getTime(new Date()),
TimestampFormatted: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
- }
-}
+ };
+};
diff --git a/src/routes/cufs.js b/src/routes/cufs.js
index 99f0300..dd5f307 100644
--- a/src/routes/cufs.js
+++ b/src/routes/cufs.js
@@ -1,28 +1,28 @@
-const express = require('express')
-const fs = require('fs')
-const router = express.Router()
-const protocol = require('../utils/connection')
+const express = require('express');
+const fs = require('fs');
+const router = express.Router();
+const protocol = require('../utils/connection');
router.get('/', (req, res) => {
- res.redirect('/powiatwulkanowy/Account/LogOn')
-})
+ res.redirect('/powiatwulkanowy/Account/LogOn');
+});
router.get('/powiatwulkanowy(/)?', (req, res) => {
- res.redirect('/powiatwulkanowy/Account/LogOn')
-})
+ res.redirect('/powiatwulkanowy/Account/LogOn');
+});
// GET login page
router.get('/:symbol/Account/LogOn', (req, res) => {
res.render('login-form', {
title: 'Logowanie (' + req.param('symbol') + ')',
- })
-})
+ });
+});
// POST login
router.post('/:symbol/Account/LogOn', (req, res) => {
if ('jan@fakelog.cf' === req.body.LoginName && 'jan123' === req.body.Password) {
- res.cookie('Vulcan.CUFS.WebFrontEndCookie', '1234567891012131314151617181920212223242526+')
- res.cookie('ARR_cufs.vulcan.net.pl', '1234567891012131314151617181920212223242526272829303132333435363')
+ res.cookie('Vulcan.CUFS.WebFrontEndCookie', '1234567891012131314151617181920212223242526+');
+ res.cookie('ARR_cufs.vulcan.net.pl', '1234567891012131314151617181920212223242526272829303132333435363');
return res.redirect(
'/' +
req.param('symbol') +
@@ -38,37 +38,37 @@ router.post('/:symbol/Account/LogOn', (req, res) => {
'%3a%2f%2fuonetplus.fakelog.localhost%3A300%2f' +
req.param('symbol') +
'%2fLoginEndpoint.aspx'
- )
+ );
}
res.render('login-form', {
title: 'Logowanie (' + req.param('symbol') + ')',
message: 'Zła nazwa użytkownika lub hasło',
- })
-})
+ });
+});
router.get('/:symbol/FS/LS', (req, res) => {
res.render('login-cert', {
symbol: req.param('symbol'),
cert: fs.readFileSync('public/cert.xml', 'utf8'),
uonetplusOpiekun: protocol(req) + '://' + req.get('host').replace('cufs.', 'uonetplus.'),
- })
-})
+ });
+});
router.get('/:symbol/AccountManage/UnlockAccount', (req, res) => {
- res.render('login-recover', { title: 'Przywracanie dostępu' })
-})
+ res.render('login-recover', { title: 'Przywracanie dostępu' });
+});
router.post('/:symbol/AccountManage/UnlockAccount', (req, res) => {
if (req.body['g-recaptcha-response']) {
- return res.render('summary', { title: 'Podsumowanie operacji' })
+ return res.render('summary', { title: 'Podsumowanie operacji' });
}
res.render('login-recover', {
title: 'Przywracanie dostępu',
message:
'Mechanizm zabezpieczający przeciw robotom i robakom internetowym sygnalizuje, że żądanie nie zostało poprawnie autoryzowane',
- })
-})
+ });
+});
-module.exports = router
+module.exports = router;
diff --git a/src/routes/index.js b/src/routes/index.js
index 7775874..ffa9806 100644
--- a/src/routes/index.js
+++ b/src/routes/index.js
@@ -1,6 +1,6 @@
-const express = require('express')
-const router = express.Router()
-const protocol = require('../utils/connection')
+const express = require('express');
+const router = express.Router();
+const protocol = require('../utils/connection');
/* GET home page. */
router.get('/', (req, res) => {
@@ -8,7 +8,7 @@ router.get('/', (req, res) => {
title: 'fake-log',
proto: protocol(req),
domain: req.get('host'),
- })
-})
+ });
+});
-module.exports = router
+module.exports = router;
diff --git a/src/routes/mobile-api/messages.js b/src/routes/mobile-api/messages.js
index 3ca8e24..ec81a97 100644
--- a/src/routes/mobile-api/messages.js
+++ b/src/routes/mobile-api/messages.js
@@ -1,24 +1,24 @@
-const router = require('express').Router({})
-const api = require('../../utils/api')
+const router = require('express').Router({});
+const api = require('../../utils/api');
router.all('/ZmienStatusWiadomosci', (req, res) => {
- res.json(api.createResponse('Zmiana statusu wiadomości.'))
-})
+ res.json(api.createResponse('Zmiana statusu wiadomości.'));
+});
router.all('/WiadomosciOdebrane', (req, res) => {
- res.json(api.createResponse(require('../../../data/api/messages/WiadomosciOdebrane')))
-})
+ res.json(api.createResponse(require('../../../data/api/messages/WiadomosciOdebrane')));
+});
router.all('/WiadomosciWyslane', (req, res) => {
- res.json(api.createResponse(require('../../../data/api/messages/WiadomosciWyslane')))
-})
+ res.json(api.createResponse(require('../../../data/api/messages/WiadomosciWyslane')));
+});
router.all('/WiadomosciUsuniete', (req, res) => {
- res.json(api.createResponse(require('../../../data/api/messages/WiadomosciUsuniete')))
-})
+ res.json(api.createResponse(require('../../../data/api/messages/WiadomosciUsuniete')));
+});
router.all('/DodajWiadomosc', (req, res) => {
- res.json(api.createResponse(require('../../../data/api/messages/DodajWiadomosc')))
-})
+ res.json(api.createResponse(require('../../../data/api/messages/DodajWiadomosc')));
+});
-module.exports = router
+module.exports = router;
diff --git a/src/routes/mobile-api/push.js b/src/routes/mobile-api/push.js
index e929d67..19d5f43 100644
--- a/src/routes/mobile-api/push.js
+++ b/src/routes/mobile-api/push.js
@@ -1,8 +1,8 @@
-const router = require('express').Router({})
-const api = require('../../utils/api')
+const router = require('express').Router({});
+const api = require('../../utils/api');
router.all('/GetCertificatePushConfig', (req, res) => {
- res.json(api.createResponse('not implemented')) //TODO
-})
+ res.json(api.createResponse('not implemented')); //TODO
+});
-module.exports = router
+module.exports = router;
diff --git a/src/routes/mobile-api/register.js b/src/routes/mobile-api/register.js
index c0c8729..e0d17ab 100644
--- a/src/routes/mobile-api/register.js
+++ b/src/routes/mobile-api/register.js
@@ -1,10 +1,10 @@
-const router = require('express').Router({})
-const protocol = require('../../utils/connection')
-const { getUnixTime, format } = require('date-fns')
-const api = require('../../utils/api')
+const router = require('express').Router({});
+const protocol = require('../../utils/connection');
+const { getUnixTime, format } = require('date-fns');
+const api = require('../../utils/api');
router.all('/Certyfikat', (req, res) => {
- const base = protocol(req) + '://' + req.get('host')
+ const base = protocol(req) + '://' + req.get('host');
// key gen
// keytool -genkeypair -keystore myKeystore.p12 -storetype PKCS12 -storepass 012345678901234567890123456789AB -alias LoginCert -keyalg RSA -keysize 2048 -sigalg SHA1WithRSA -validity 99999 -dname "CN=Wulkanowy, OU=Wulkanowy, O=Wulkanowy, L=Jaroslaw, ST=podkarpackie, C=WLKNW" -ext san=dns:fakelog.cf,dns:localhost,ip:127.0.0.1
@@ -28,23 +28,23 @@ router.all('/Certyfikat', (req, res) => {
UzytkownikNazwa: 'admin',
TypKonta: null,
},
- })
-})
+ });
+});
router.all('/ListaUczniow', (req, res) => {
- const currDate = new Date()
+ const currDate = new Date();
- let semesterNumber
- let semesterStart
- let semesterEnd
+ let semesterNumber;
+ let semesterStart;
+ let semesterEnd;
if (currDate.getMonth() >= 8) {
- semesterNumber = 1
- semesterStart = new Date(currDate.getFullYear(), 8, 1)
- semesterEnd = new Date(currDate.getFullYear() + 1, 0, 30)
+ semesterNumber = 1;
+ semesterStart = new Date(currDate.getFullYear(), 8, 1);
+ semesterEnd = new Date(currDate.getFullYear() + 1, 0, 30);
} else {
- semesterNumber = 2
- semesterStart = new Date(currDate.getFullYear(), 0, 30)
- semesterEnd = new Date(currDate.getFullYear(), 7, 31)
+ semesterNumber = 2;
+ semesterStart = new Date(currDate.getFullYear(), 0, 30);
+ semesterEnd = new Date(currDate.getFullYear(), 7, 31);
}
res.json(
@@ -57,10 +57,10 @@ router.all('/ListaUczniow', (req, res) => {
OkresDataDo: getUnixTime(semesterEnd),
OkresDataOdTekst: format(semesterStart, 'yyyy-MM-dd'),
OkresDataDoTekst: format(semesterEnd, 'yyyy-MM-dd'),
- }
+ };
})
)
- )
-})
+ );
+});
-module.exports = router
+module.exports = router;
diff --git a/src/routes/mobile-api/student.js b/src/routes/mobile-api/student.js
index 03be891..6f4f923 100644
--- a/src/routes/mobile-api/student.js
+++ b/src/routes/mobile-api/student.js
@@ -1,15 +1,15 @@
-const router = require('express').Router({})
-const api = require('../../utils/api')
-const converter = require('../../utils/converter')
-const { addDays, differenceInDays, parseISO, startOfWeek, getTime } = require('date-fns')
+const router = require('express').Router({});
+const api = require('../../utils/api');
+const converter = require('../../utils/converter');
+const { addDays, differenceInDays, parseISO, startOfWeek, getTime } = require('date-fns');
router.all('/LogAppStart', (req, res) => {
- res.json(api.createResponse('Log'))
-})
+ res.json(api.createResponse('Log'));
+});
router.all('/UstawPushToken', (req, res) => {
- res.json(api.createResponse('Zapisano tokenId dla powiadomien PUSH'))
-})
+ res.json(api.createResponse('Zapisano tokenId dla powiadomien PUSH'));
+});
router.all('/Slowniki', (req, res) => {
res.json(
@@ -24,69 +24,69 @@ router.all('/Slowniki', (req, res) => {
KategorieFrekwencji: require('../../../data/api/dictionaries/KategorieFrekwencji'),
TypyFrekwencji: require('../../../data/api/dictionaries/TypyFrekwencji'),
})
- )
-})
+ );
+});
router.all('/PlanLekcjiZeZmianami', (req, res) => {
- const timetable = require('../../../data/api/student/PlanLekcjiZeZmianami')
+ const timetable = require('../../../data/api/student/PlanLekcjiZeZmianami');
const requestDate = req.body.DataPoczatkowa
? parseISO(req.body.DataPoczatkowa)
- : startOfWeek(new Date(), { weekStartsOn: 1 })
- const baseOffset = differenceInDays(requestDate, parseISO(timetable[0].DzienTekst))
+ : startOfWeek(new Date(), { weekStartsOn: 1 });
+ const baseOffset = differenceInDays(requestDate, parseISO(timetable[0].DzienTekst));
res.json(
api.createResponse(
timetable.map((item) => {
- const date = addDays(parseISO(item.DzienTekst), baseOffset)
+ const date = addDays(parseISO(item.DzienTekst), baseOffset);
return {
...item,
Dzien: getTime(date) / 1000,
DzienTekst: converter.formatDate(date, true),
- }
+ };
})
)
- )
-})
+ );
+});
router.all('/Oceny', (req, res) => {
- res.json(api.createResponse(require('../../../data/api/student/Oceny')))
-})
+ res.json(api.createResponse(require('../../../data/api/student/Oceny')));
+});
router.all('/OcenyPodsumowanie', (req, res) => {
- res.json(api.createResponse(require('../../../data/api/student/OcenyPodsumowanie')))
-})
+ res.json(api.createResponse(require('../../../data/api/student/OcenyPodsumowanie')));
+});
router.all('/Sprawdziany', (req, res) => {
- const exams = require('../../../data/api/student/Sprawdziany')
+ const exams = require('../../../data/api/student/Sprawdziany');
const requestDate = req.body.DataPoczatkowa
? parseISO(req.body.DataPoczatkowa)
- : startOfWeek(new Date(), { weekStartsOn: 1 })
- const baseOffset = differenceInDays(requestDate, parseISO(exams[0].DataTekst))
+ : startOfWeek(new Date(), { weekStartsOn: 1 });
+ const baseOffset = differenceInDays(requestDate, parseISO(exams[0].DataTekst));
res.json(
api.createResponse(
exams.map((item) => {
- const date = addDays(parseISO(item.DataTekst), baseOffset)
+ const date = addDays(parseISO(item.DataTekst), baseOffset);
return {
...item,
Data: getTime(date) / 1000,
DataTekst: converter.formatDate(date, true),
- }
+ };
})
)
- )
-})
+ );
+});
router.all('/UwagiUcznia', (req, res) => {
- res.json(api.createResponse(require('../../../data/api/student/UwagiUcznia')))
-})
+ res.json(api.createResponse(require('../../../data/api/student/UwagiUcznia')));
+});
router.all('/Frekwencje', (req, res) => {
- const attendance = require('../../../data/api/student/Frekwencje')
+ const attendance = require('../../../data/api/student/Frekwencje');
const requestDate = req.body.DataPoczatkowa
? parseISO(req.body.DataPoczatkowa)
- : startOfWeek(new Date(), { weekStartsOn: 1 })
- const baseOffset = differenceInDays(requestDate, parseISO(attendance[0].DzienTekst))
+ : startOfWeek(new Date(), { weekStartsOn: 1 });
+ const baseOffset = differenceInDays(requestDate, parseISO(attendance[0].DzienTekst));
res.json(
api.createResponse({
@@ -95,40 +95,40 @@ router.all('/Frekwencje', (req, res) => {
DataPoczatkowaTekst: req.body.DataPoczatkowa,
DataKoncowaTekst: req.body.DataKoncowa,
Frekwencje: attendance.map((item) => {
- const date = addDays(parseISO(item.DzienTekst), baseOffset)
+ const date = addDays(parseISO(item.DzienTekst), baseOffset);
return {
...item,
Dzien: getTime(date) / 1000,
DzienTekst: converter.formatDate(date, true),
- }
+ };
}),
})
- )
-})
+ );
+});
router.all('/ZadaniaDomowe', (req, res) => {
- const homework = require('../../../data/api/student/ZadaniaDomowe')
+ const homework = require('../../../data/api/student/ZadaniaDomowe');
const requestDate = req.body.DataPoczatkowa
? parseISO(req.body.DataPoczatkowa)
- : startOfWeek(new Date(), { weekStartsOn: 1 })
- const baseOffset = differenceInDays(requestDate, parseISO(homework[0].DataTekst))
+ : startOfWeek(new Date(), { weekStartsOn: 1 });
+ const baseOffset = differenceInDays(requestDate, parseISO(homework[0].DataTekst));
res.json(
api.createResponse(
homework.map((item) => {
- const date = addDays(parseISO(item.DataTekst), baseOffset)
+ const date = addDays(parseISO(item.DataTekst), baseOffset);
return {
...item,
Data: getTime(date) / 1000,
DataTekst: converter.formatDate(date, true),
- }
+ };
})
)
- )
-})
+ );
+});
router.all('/Nauczyciele', (req, res) => {
- res.json(api.createResponse(require('../../../data/api/student/Nauczyciele')))
-})
+ res.json(api.createResponse(require('../../../data/api/student/Nauczyciele')));
+});
-module.exports = router
+module.exports = router;
diff --git a/src/routes/uonetplus-opiekun.js b/src/routes/uonetplus-opiekun.js
index ca9a5f9..1778288 100644
--- a/src/routes/uonetplus-opiekun.js
+++ b/src/routes/uonetplus-opiekun.js
@@ -1,75 +1,75 @@
-const express = require('express')
-const router = express.Router()
-const converter = require('../utils/converter')
-const dictMap = require('../utils/dictMap')
-const { getGradeColorByCategoryName } = require('../utils/gradeColor')
-const _ = require('lodash')
+const express = require('express');
+const router = express.Router();
+const converter = require('../utils/converter');
+const dictMap = require('../utils/dictMap');
+const { getGradeColorByCategoryName } = require('../utils/gradeColor');
+const _ = require('lodash');
-global.opiekunRoot = '/powiatwulkanowy/123456'
+global.opiekunRoot = '/powiatwulkanowy/123456';
router.all('/', (req, res) => {
res.render('log-exception', {
title: 'Dziennik FakeUONET+',
message: 'Podany identyfikator klienta jest niepoprawny.',
- })
-})
+ });
+});
router.all('/powiatwulkanowy(/12345[678])?', (req, res) => {
if (req.header('Referer') || 'true' === req.query.login) {
- return res.redirect('/powiatwulkanowy/123456/Start/Index/')
+ return res.redirect('/powiatwulkanowy/123456/Start/Index/');
}
res.render('login', {
title: 'Uczeń',
- })
-})
+ });
+});
router.get('/Start/Index/', (req, res) => {
res.cookie('EfebSsoAuthCookie', 'asdfasdfasdfasdfasdfasdfas', {
domain: req.get('host').replace('uonetplus-opiekun', ''),
path: '/',
httpOnly: true,
- })
- res.cookie('idBiezacyDziennik', '1234')
+ });
+ res.cookie('idBiezacyDziennik', '1234');
res.render('opiekun/start', {
title: 'Witryna ucznia i rodzica – Strona główna',
- })
-})
+ });
+});
router.get('/Uczen/UczenOnChange', (req, res) => {
- res.cookie('idBiezacyUczen', req.query.id)
+ res.cookie('idBiezacyUczen', req.query.id);
- res.redirect(req.header('Referer') ? req.header('Referer') : '../?login=true')
-})
+ res.redirect(req.header('Referer') ? req.header('Referer') : '../?login=true');
+});
router.get('/Dziennik/DziennikOnChange', (req, res) => {
- res.cookie('idBiezacyDziennik', req.query.id)
+ res.cookie('idBiezacyDziennik', req.query.id);
- res.redirect(req.header('Referer') ? req.header('Referer') : '../')
-})
+ res.redirect(req.header('Referer') ? req.header('Referer') : '../');
+});
router.get('/Uczen.mvc/DanePodstawowe', (req, res) => {
res.render('opiekun/dane', {
title: 'Witryna ucznia i rodzica – Dane ucznia',
data: require('../../data/opiekun/dane.json'),
- })
-})
+ });
+});
router.get('/Oceny(.mvc|)/Wszystkie', (req, res) => {
- let data
- let viewPath
+ let data;
+ let viewPath;
- const teachers = require('../../data/api/dictionaries/Nauczyciele')
- const subjects = require('../../data/api/dictionaries/Przedmioty')
- const details = require('../../data/api/student/Oceny')
- const subjectCategories = require('../../data/api/dictionaries/KategorieOcen')
- const summary = require('../../data/api/student/OcenyPodsumowanie')
- const descriptiveGrades = require('../../data/api/student/OcenyOpisowe')
+ const teachers = require('../../data/api/dictionaries/Nauczyciele');
+ const subjects = require('../../data/api/dictionaries/Przedmioty');
+ const details = require('../../data/api/student/Oceny');
+ const subjectCategories = require('../../data/api/dictionaries/KategorieOcen');
+ const summary = require('../../data/api/student/OcenyPodsumowanie');
+ const descriptiveGrades = require('../../data/api/student/OcenyOpisowe');
if (req.query.details === '2') {
data = details.map((item) => {
- const teacher = dictMap.getByValue(teachers, 'Id', item.IdPracownikD)
- const category = dictMap.getByValue(subjectCategories, 'Id', item.IdKategoria)
+ const teacher = dictMap.getByValue(teachers, 'Id', item.IdPracownikD);
+ const category = dictMap.getByValue(subjectCategories, 'Id', item.IdKategoria);
return {
subject: dictMap.getByValue(subjects, 'Id', item.IdPrzedmiot).Nazwa,
value: item.Wpis === '' ? item.Komentarz : item.Wpis,
@@ -79,11 +79,11 @@ router.get('/Oceny(.mvc|)/Wszystkie', (req, res) => {
weight: item.Waga,
date: converter.formatDate(new Date(item.DataUtworzenia * 1000)),
teacher: teacher.Imie + ' ' + teacher.Nazwisko,
- }
- })
- viewPath = 'opiekun/oceny-szczegolowy'
+ };
+ });
+ viewPath = 'opiekun/oceny-szczegolowy';
} else {
- viewPath = 'opiekun/oceny-skrocony'
+ viewPath = 'opiekun/oceny-skrocony';
data = {
normalGrades: subjects.map((item) => {
return {
@@ -91,24 +91,24 @@ router.get('/Oceny(.mvc|)/Wszystkie', (req, res) => {
average: dictMap.getByValue(summary.SrednieOcen, 'IdPrzedmiot', item.Id).SredniaOcen,
predictedRating: dictMap.getByValue(summary.OcenyPrzewidywane, 'IdPrzedmiot', item.Id).Wpis,
finalRating: dictMap.getByValue(summary.OcenyPrzewidywane, 'IdPrzedmiot', item.Id).Wpis,
- }
+ };
}),
descriptiveGrades,
- }
+ };
}
res.render(viewPath, {
title: 'Witryna ucznia i rodzica – Oceny',
data: data,
- })
-})
+ });
+});
router.get('/Statystyki.mvc/Uczen', (req, res) => {
- let data
- let viewPath
+ let data;
+ let viewPath;
if (req.query.rodzajWidoku === '1') {
- viewPath = 'opiekun/oceny-statystyki-czastkowe'
+ viewPath = 'opiekun/oceny-statystyki-czastkowe';
data = require('../../data/opiekun/oceny-statystyki-czastkowe').map((item) => {
return {
subject: item.subject,
@@ -117,25 +117,25 @@ router.get('/Statystyki.mvc/Uczen', (req, res) => {
pupilPercent: item.pupilAmount !== 0 ? 25.000003 : 0,
classAmount: item.classAmount,
classPercent: item.classAmount !== 0 ? 25.000003 : 0,
- }
- })
+ };
+ });
} else {
- viewPath = 'opiekun/oceny-statystyki-roczne'
+ viewPath = 'opiekun/oceny-statystyki-roczne';
data = require('../../data/opiekun/oceny-statystyki-roczne').map((item) => {
return {
subject: item.subject,
grade: item.grade,
amount: item.amount,
percent: item.amount !== 0 ? 25.000003 : 0,
- }
- })
+ };
+ });
}
res.render(viewPath, {
title: 'Witryna ucznia i rodzica – Statystyki ucznia',
data: data,
- })
-})
+ });
+});
router.get('/Frekwencja.mvc', (req, res) => {
const sumStats = require('../../data/opiekun/frekwencja-statystyki').reduce((prev, current) => {
@@ -147,8 +147,8 @@ router.get('/Frekwencja.mvc', (req, res) => {
lateness: prev.lateness + current.lateness,
latenessExcused: prev.latenessExcused + current.latenessExcused,
exemption: prev.exemption + current.exemption,
- }
- })
+ };
+ });
res.render('opiekun/frekwencja', {
title: 'Witryna ucznia i rodzica – Frekwencja',
subjects: require('../../data/api/dictionaries/Przedmioty'),
@@ -158,7 +158,7 @@ router.get('/Frekwencja.mvc', (req, res) => {
require('../../data/api/dictionaries/KategorieFrekwencji'),
'Id',
item.IdKategoria
- )
+ );
return {
number: item.Numer,
subject: item.PrzedmiotNazwa,
@@ -170,7 +170,7 @@ router.get('/Frekwencja.mvc', (req, res) => {
excused: category.Usprawiedliwione,
deleted: category.Usuniete,
attendanceInfo: _.capitalize(category.Nazwa),
- }
+ };
}),
'number'
),
@@ -190,35 +190,37 @@ router.get('/Frekwencja.mvc', (req, res) => {
prev: converter.getPrevWeekTick(req.query.data),
next: converter.getNextWeekTick(req.query.data),
},
- })
-})
+ });
+});
router.get('/UwagiOsiagniecia.mvc/Wszystkie', (req, res) => {
- const teachers = require('../../data/api/dictionaries/Nauczyciele')
- const categories = require('../../data/api/dictionaries/KategorieUwag')
+ const teachers = require('../../data/api/dictionaries/Nauczyciele');
+ const categories = require('../../data/api/dictionaries/KategorieUwag');
res.render('opiekun/uwagi', {
title: 'Witryna ucznia i rodzica – Uwagi i osiągnięcia',
notes: require('../../data/api/student/UwagiUcznia').map((item) => {
return {
date: converter.formatDate(new Date(item.DataWpisuTekst)),
- teacher: `${item.PracownikImie} ${item.PracownikNazwisko} [${dictMap.getByValue(teachers, 'Id', item.IdPracownik).Kod}]`,
+ teacher: `${item.PracownikImie} ${item.PracownikNazwisko} [${
+ dictMap.getByValue(teachers, 'Id', item.IdPracownik).Kod
+ }]`,
category: dictMap.getByValue(categories, 'Id', item.IdKategoriaUwag).Nazwa,
content: item.TrescUwagi,
- }
+ };
}),
- })
-})
+ });
+});
router.get('/Lekcja(.mvc|)/PlanZajec', (req, res) => {
- const teachers = require('../../data/api/dictionaries/Nauczyciele')
+ const teachers = require('../../data/api/dictionaries/Nauczyciele');
const days = _.groupBy(
require('../../data/api/student/PlanLekcjiZeZmianami')
.filter((item) => item.PlanUcznia)
.map((item) => {
- const teacher = dictMap.getByValue(teachers, 'Id', item.IdPracownik)
- const oldTeacher = dictMap.getByValue(teachers, 'Id', item.IdPracownikOld)
- const times = dictMap.getByValue(require('../../data/api/dictionaries/PoryLekcji'), 'Id', item.IdPoraLekcji)
+ const teacher = dictMap.getByValue(teachers, 'Id', item.IdPracownik);
+ const oldTeacher = dictMap.getByValue(teachers, 'Id', item.IdPracownikOld);
+ const times = dictMap.getByValue(require('../../data/api/dictionaries/PoryLekcji'), 'Id', item.IdPoraLekcji);
return {
number: item.NumerLekcji,
id: item.IdPoraLekcji,
@@ -234,70 +236,70 @@ router.get('/Lekcja(.mvc|)/PlanZajec', (req, res) => {
changes: item.PogrubionaNazwa,
canceled: item.PrzekreslonaNazwa,
date: converter.formatDate(new Date(item.DzienTekst)),
- }
+ };
}),
'date'
- )
+ );
- const firstLesson = _.min(_.flatten(_.values(days)).map((e) => e.number))
- const lastLesson = _.max(_.flatten(_.values(days)).map((e) => e.number))
+ const firstLesson = _.min(_.flatten(_.values(days)).map((e) => e.number));
+ const lastLesson = _.max(_.flatten(_.values(days)).map((e) => e.number));
const daysWithGaps = _.mapValues(days, (day) => {
- const dayWithGaps = []
- let prevNumber = null
+ const dayWithGaps = [];
+ let prevNumber = null;
- const beforeGap = day[0].number - firstLesson
+ const beforeGap = day[0].number - firstLesson;
for (i = 0; i < beforeGap; i++) {
- const number = firstLesson + i
- const times = dictMap.getByValue(require('../../data/api/dictionaries/PoryLekcji'), 'Numer', number)
+ const number = firstLesson + i;
+ const times = dictMap.getByValue(require('../../data/api/dictionaries/PoryLekcji'), 'Numer', number);
dayWithGaps.push({
number,
gap: true,
start: times.PoczatekTekst,
end: times.KoniecTekst,
- })
+ });
}
day.forEach((lesson) => {
- let gap = 0
+ let gap = 0;
if (prevNumber !== null) {
- gap = lesson.number - prevNumber - 1
+ gap = lesson.number - prevNumber - 1;
}
for (i = 0; i < gap; i++) {
- const number = prevNumber + i + 1
- const times = dictMap.getByValue(require('../../data/api/dictionaries/PoryLekcji'), 'Numer', number)
+ const number = prevNumber + i + 1;
+ const times = dictMap.getByValue(require('../../data/api/dictionaries/PoryLekcji'), 'Numer', number);
dayWithGaps.push({
number,
gap: true,
start: times.PoczatekTekst,
end: times.KoniecTekst,
- })
+ });
}
- prevNumber = lesson.number
+ prevNumber = lesson.number;
- dayWithGaps.push(lesson)
- })
+ dayWithGaps.push(lesson);
+ });
- const afterGap = lastLesson - prevNumber
+ const afterGap = lastLesson - prevNumber;
for (i = 0; i < afterGap; i++) {
- const number = prevNumber + i + 1
- const times = dictMap.getByValue(require('../../data/api/dictionaries/PoryLekcji'), 'Numer', number)
+ const number = prevNumber + i + 1;
+ const times = dictMap.getByValue(require('../../data/api/dictionaries/PoryLekcji'), 'Numer', number);
dayWithGaps.push({
number,
gap: true,
start: times.PoczatekTekst,
end: times.KoniecTekst,
- })
+ });
}
- return dayWithGaps
- })
+ return dayWithGaps;
+ });
- const data = _.groupBy(_.flatten(_.values(daysWithGaps)), 'number')
+ const data = _.groupBy(_.flatten(_.values(daysWithGaps)), 'number');
res.render('opiekun/plan-zajec', {
title: 'Witryna ucznia i rodzica – Plan lekcji',
@@ -307,8 +309,8 @@ router.get('/Lekcja(.mvc|)/PlanZajec', (req, res) => {
prev: converter.getPrevWeekTick(req.query.data),
next: converter.getNextWeekTick(req.query.data),
},
- })
-})
+ });
+});
router.get('/Lekcja(.mvc|)/Zrealizowane', (req, res) => {
res.render('opiekun/plan-zrealizowane', {
@@ -321,36 +323,36 @@ router.get('/Lekcja(.mvc|)/Zrealizowane', (req, res) => {
...item,
// jshint ignore:end
date: converter.formatDate(new Date(item.date)),
- }
+ };
}),
'date'
),
- })
-})
+ });
+});
router.get('/Sprawdziany.mvc/Terminarz', (req, res) => {
- const subjects = require('../../data/api/dictionaries/Przedmioty')
- const teachers = require('../../data/api/dictionaries/Nauczyciele')
- const days = converter.getWeekDaysFrom(req.query.data)
+ const subjects = require('../../data/api/dictionaries/Przedmioty');
+ const teachers = require('../../data/api/dictionaries/Nauczyciele');
+ const days = converter.getWeekDaysFrom(req.query.data);
res.render('opiekun/sprawdziany', {
title: 'Witryna ucznia i rodzica – Terminarz sprawdzianów',
data: _.groupBy(
require('../../data/api/student/Sprawdziany').map((item, index) => {
- const subject = dictMap.getByValue(subjects, 'Id', item.IdPrzedmiot)
- const teacher = dictMap.getByValue(teachers, 'Id', item.IdPracownik)
- let examType
+ const subject = dictMap.getByValue(subjects, 'Id', item.IdPrzedmiot);
+ const teacher = dictMap.getByValue(teachers, 'Id', item.IdPracownik);
+ let examType;
switch (item.RodzajNumer) {
case 1:
- examType = 'Sprawdzian'
- break
+ examType = 'Sprawdzian';
+ break;
case 2:
- examType = 'Kartkówka'
- break
+ examType = 'Kartkówka';
+ break;
case 3:
- examType = 'Praca klasowa'
- break
+ examType = 'Praca klasowa';
+ break;
default:
- examType = 'Nieznany'
+ examType = 'Nieznany';
}
return {
entryDate: '01.01.1970',
@@ -358,12 +360,14 @@ router.get('/Sprawdziany.mvc/Terminarz', (req, res) => {
// date: converter.formatDate(new Date(item.DataTekst)),
// dayName: converter.getDayName(item.DataTekst),
dayName: days[index][0],
- subject: `${subject.Nazwa} ${res.locals.userInfo.OddzialKod}${item.PodzialSkrot ? '|' + item.PodzialSkrot : ''}`,
+ subject: `${subject.Nazwa} ${res.locals.userInfo.OddzialKod}${
+ item.PodzialSkrot ? '|' + item.PodzialSkrot : ''
+ }`,
type: examType,
description: item.Opis,
teacher: `${teacher.Imie} ${teacher.Nazwisko}`,
teacherSymbol: teacher.Kod,
- }
+ };
}),
'date'
),
@@ -372,16 +376,16 @@ router.get('/Sprawdziany.mvc/Terminarz', (req, res) => {
prev: converter.getPrevWeekTick(req.query.data),
next: converter.getNextWeekTick(req.query.data),
},
- })
-})
+ });
+});
router.get('/ZadaniaDomowe.mvc', (req, res) => {
- const subjects = require('../../data/api/dictionaries/Przedmioty')
+ const subjects = require('../../data/api/dictionaries/Przedmioty');
res.render('opiekun/zadania', {
title: 'Witryna ucznia i rodzica – Zadania domowe',
homework: require('../../data/api/student/ZadaniaDomowe').map((item) => {
- const teacher = dictMap.getByValue(require('../../data/api/dictionaries/Nauczyciele'), 'Id', item.IdPracownik)
- const date = converter.getDateString(req.query.data)
+ const teacher = dictMap.getByValue(require('../../data/api/dictionaries/Nauczyciele'), 'Id', item.IdPracownik);
+ const date = converter.getDateString(req.query.data);
return {
date: converter.formatDate(date),
dayName: converter.getDayName(date),
@@ -390,68 +394,68 @@ router.get('/ZadaniaDomowe.mvc', (req, res) => {
teacherSymbol: teacher.Kod,
subject: dictMap.getByValue(subjects, 'Id', item.IdPrzedmiot).Nazwa,
content: item.Opis,
- }
+ };
}),
tics: {
prev: converter.getPrevDayTick(req.query.data),
next: converter.getNextDayTick(req.query.data),
},
- })
-})
+ });
+});
router.get('/Szkola.mvc/Nauczyciele', (req, res) => {
- const teachers = require('../../data/api/student/Nauczyciele')
- const subjectsDict = require('../../data/api/dictionaries/Przedmioty')
- const teachersDict = require('../../data/api/dictionaries/Pracownicy')
+ const teachers = require('../../data/api/student/Nauczyciele');
+ const subjectsDict = require('../../data/api/dictionaries/Przedmioty');
+ const teachersDict = require('../../data/api/dictionaries/Pracownicy');
- const headmaster = dictMap.getByValue(teachersDict, 'Id', teachers.NauczycieleSzkola[0].IdPracownik)
- const tutor = dictMap.getByValue(teachersDict, 'Id', teachers.NauczycieleSzkola[3].IdPracownik)
+ const headmaster = dictMap.getByValue(teachersDict, 'Id', teachers.NauczycieleSzkola[0].IdPracownik);
+ const tutor = dictMap.getByValue(teachersDict, 'Id', teachers.NauczycieleSzkola[3].IdPracownik);
res.render('opiekun/szkola', {
title: 'Witryna ucznia i rodzica – Szkoła i nauczyciele',
headMaster: `${headmaster.Imie} ${headmaster.Nazwisko}`,
tutor: `${tutor.Imie} ${tutor.Nazwisko}`,
teachers: teachers.NauczycielePrzedmioty.map((item) => {
- const teacher = dictMap.getByValue(teachersDict, 'Id', item.IdPracownik)
+ const teacher = dictMap.getByValue(teachersDict, 'Id', item.IdPracownik);
return {
subject: dictMap.getByValue(subjectsDict, 'Id', item.IdPrzedmiot).Nazwa,
name: `${teacher.Imie} ${teacher.Nazwisko} [${teacher.Kod}]`,
- }
+ };
}),
- })
-})
+ });
+});
router.get('/DostepMobilny.mvc', (req, res) => {
res.render('opiekun/mobilny', {
title: 'Witryna ucznia i rodzica – Dostęp mobilny',
devices: require('../../data/opiekun/zarejestrowane-urzadzenia').map((item) => {
- const created = item.DataUtworzenia.split(' ')
+ const created = item.DataUtworzenia.split(' ');
return {
// jshint ignore:start
...item,
// jshint ignore:end
DataUtworzenia: `${converter.formatDate(new Date(created[0]))} godz: ${created[1]}`,
- }
+ };
}),
- })
-})
+ });
+});
router.get('/DostepMobilny.mvc/Rejestruj', (req, res) => {
- res.render('opiekun/mobilny-rejestruj')
-})
+ res.render('opiekun/mobilny-rejestruj');
+});
router.all('/DostepMobilny.mvc/PingForCertGeneratedToken', (req, res) => {
res.json({
success: true,
data: req.body.idToken % 2 === 0,
- })
-})
+ });
+});
router.get('/DostepMobilny.mvc/Wyrejestruj/:id', (req, res) => {
- res.render('opiekun/mobilny-wyrejestruj')
-})
+ res.render('opiekun/mobilny-wyrejestruj');
+});
router.post('/DostepMobilny.mvc/PotwierdzWyrejestrowanie', (req, res) => {
- res.redirect('/DostepMobilny.mvc')
-})
+ res.redirect('/DostepMobilny.mvc');
+});
-module.exports = router
+module.exports = router;
diff --git a/src/routes/uonetplus-uczen.js b/src/routes/uonetplus-uczen.js
index 06cb870..da17efb 100644
--- a/src/routes/uonetplus-uczen.js
+++ b/src/routes/uonetplus-uczen.js
@@ -1,12 +1,12 @@
-const express = require('express')
-const router = express.Router({ mergeParams: true })
-const protocol = require('../utils/connection')
-const dictMap = require('../utils/dictMap')
-const converter = require('../utils/converter')
-const Tokens = require('csrf')
-const _ = require('lodash')
-const { getGradeColorByCategoryName } = require('../utils/gradeColor')
-const { validatePolish } = require('validate-polish')
+const express = require('express');
+const router = express.Router({ mergeParams: true });
+const protocol = require('../utils/connection');
+const dictMap = require('../utils/dictMap');
+const converter = require('../utils/converter');
+const Tokens = require('csrf');
+const _ = require('lodash');
+const { getGradeColorByCategoryName } = require('../utils/gradeColor');
+const { validatePolish } = require('validate-polish');
const {
format,
fromUnixTime,
@@ -18,10 +18,10 @@ const {
differenceInDays,
parseISO,
startOfWeek,
-} = require('date-fns')
+} = require('date-fns');
router.get('/', (req, res) => {
- const base = protocol(req) + '://' + req.get('host') + '/powiatwulkanowy/123456'
+ const base = protocol(req) + '://' + req.get('host') + '/powiatwulkanowy/123456';
res.json({
status: 'sucess',
data: {
@@ -68,19 +68,19 @@ router.get('/', (req, res) => {
'/ZgloszoneNieobecnosci.mvc/Get',
'/ZgloszoneNieobecnosci.mvc/Post',
].map((item) => {
- return base + item
+ return base + item;
}),
},
- })
-})
+ });
+});
router.get('/LoginEndpoint.aspx', (req, res) => {
- res.redirect('/Start')
-})
+ res.redirect('/Start');
+});
router.get('/Start', (req, res) => {
- res.render('uczen/start')
-})
+ res.render('uczen/start');
+});
router.all('/UczenCache.mvc/Get', (req, res) => {
res.json({
@@ -98,14 +98,14 @@ router.all('/UczenCache.mvc/Get', (req, res) => {
IdJednostkaSprawozdawcza: 1,
Nazwa: '' + item.Numer,
OkresDataOd: fromUnixTime(item.OkresDataOd),
- }
+ };
}),
pokazLekcjeZrealizowane: true,
serverDate: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
},
success: true,
- })
-})
+ });
+});
router.all('/UczenDziennik.mvc/Get', (req, res) => {
res.json({
@@ -123,9 +123,9 @@ router.all('/UczenDziennik.mvc/Get', (req, res) => {
year: getYear(parseISO(item.OkresDataOdTekst)) + i - array.length + 1,
OkresDataOd: addYears(parseISO(item.OkresDataOdTekst), i - array.length + 1),
OkresDataDo: addYears(parseISO(item.OkresDataDoTekst), i - array.length + 1),
- }
+ };
})
- .reverse()
+ .reverse();
}, [])
.map((item) => {
return {
@@ -154,7 +154,7 @@ router.all('/UczenDziennik.mvc/Get', (req, res) => {
IdJednostkaSprawozdawcza: item.IdJednostkaSprawozdawcza,
IsLastOkres: i === 1,
Id: semesterId,
- }
+ };
}),
DziennikDataOd: format(addMonths(item.OkresDataOd, 0), 'yyyy-MM-dd HH:mm:ss'),
DziennikDataDo: format(addMonths(item.OkresDataDo, 7), 'yyyy-MM-dd HH:mm:ss'),
@@ -168,11 +168,11 @@ router.all('/UczenDziennik.mvc/Get', (req, res) => {
IsPrzedszkola: false,
IsAuthorized: item.Id !== 1,
UczenPelnaNazwa: `${item.OkresPoziom}${item.OddzialSymbol} ${item.year} - ${item.Imie} ${item.Nazwisko}`,
- }
+ };
}),
success: true,
- })
-})
+ });
+});
router.all('/Autoryzacja.mvc/Post', (req, res) => {
res.json({
@@ -180,88 +180,88 @@ router.all('/Autoryzacja.mvc/Post', (req, res) => {
success: validatePolish.pesel(req.body.data?.Pesel ?? ''),
},
success: true,
- })
-})
+ });
+});
router.all('/Home.mvc/RefreshSession', (req, res) => {
res.json({
data: {},
success: true,
- })
-})
+ });
+});
router.all('/Diety.mvc/Get', (req, res) => {
res.json({
data: {},
success: true,
- })
-})
+ });
+});
router.all('/EgzaminySemestralne.mvc/Get', (req, res) => {
res.json({
data: {},
success: true,
- })
-})
+ });
+});
router.all('/EgzaminyZewnetrzne.mvc/Get', (req, res) => {
res.json({
data: {},
success: true,
- })
-})
+ });
+});
router.all('/EwidencjaObecnosci.mvc/Get', (req, res) => {
res.json({
data: {},
success: true,
- })
-})
+ });
+});
router.all('/FormularzeSzablony.mvc/Get', (req, res) => {
res.json({
data: {},
success: true,
- })
-})
+ });
+});
router.all('/FormularzeSzablonyDownload.mvc/Get', (req, res) => {
res.json({
data: {},
success: true,
- })
-})
+ });
+});
router.all('/FormularzeWysylanie.mvc/Get', (req, res) => {
res.json({
data: {},
success: true,
- })
-})
+ });
+});
router.all('/FormularzeWysylanie.mvc/Post', (req, res) => {
res.json({
data: {},
success: true,
- })
-})
+ });
+});
router.all('/Frekwencja.mvc/Get', (req, res) => {
- const attendance = require('../../data/api/student/Frekwencje')
+ const attendance = require('../../data/api/student/Frekwencje');
res.json({
data: {
UsprawiedliwieniaAktywne: true,
Dni: [],
UsprawiedliwieniaWyslane: [],
Frekwencje: attendance.map((item) => {
- let offset = new Date(item.DzienTekst).getDay() - new Date(attendance[0].DzienTekst).getDay()
- let date
+ let offset = new Date(item.DzienTekst).getDay() - new Date(attendance[0].DzienTekst).getDay();
+ let date;
if (req.body.data) {
date = converter.formatDate(
addDays(new Date(req.body.data.replace(' ', 'T').replace(/Z$/, '') + 'Z'), offset),
true
- )
- } else date = item.DzienTekst
+ );
+ } else date = item.DzienTekst;
return {
IdKategoria: item.IdKategoria,
NrDnia: item.Numer,
@@ -271,15 +271,15 @@ router.all('/Frekwencja.mvc/Get', (req, res) => {
IdPoraLekcji: item.IdPoraLekcji,
Data: `${date} 00:00:00`,
LekcjaOddzialId: item.Dzien * item.Numer,
- }
+ };
}),
},
success: true,
- })
-})
+ });
+});
router.all('/FrekwencjaStatystyki.mvc/Get', (req, res) => {
- const attendance = require('../../data/opiekun/frekwencja-statystyki')
+ const attendance = require('../../data/opiekun/frekwencja-statystyki');
const sumStats = require('../../data/opiekun/frekwencja-statystyki').reduce((prev, current) => {
return {
presence: prev.presence + current.presence,
@@ -289,8 +289,8 @@ router.all('/FrekwencjaStatystyki.mvc/Get', (req, res) => {
lateness: prev.lateness + current.lateness,
latenessExcused: prev.latenessExcused + current.latenessExcused,
exemption: prev.exemption + current.exemption,
- }
- })
+ };
+ });
res.json({
data: {
@@ -309,39 +309,39 @@ router.all('/FrekwencjaStatystyki.mvc/Get', (req, res) => {
const name = (i) => {
switch (i) {
case 0:
- return 'Obecność'
+ return 'Obecność';
case 1:
- return 'Nieobecność nieusprawiedliwiona'
+ return 'Nieobecność nieusprawiedliwiona';
case 2:
- return 'Nieobecność usprawiedliwiona'
+ return 'Nieobecność usprawiedliwiona';
case 3:
- return 'Nieobecność z przyczyn szkolnych'
+ return 'Nieobecność z przyczyn szkolnych';
case 4:
- return 'Spóźnienie nieusprawiedliwione'
+ return 'Spóźnienie nieusprawiedliwione';
case 5:
- return 'Spóźnienie usprawiedliwione'
+ return 'Spóźnienie usprawiedliwione';
case 6:
- return 'Zwolnienie'
+ return 'Zwolnienie';
}
- }
+ };
const value = (month, i) => {
switch (i) {
case 0:
- return attendance[month].presence
+ return attendance[month].presence;
case 1:
- return attendance[month].absence
+ return attendance[month].absence;
case 2:
- return attendance[month].absenceExcused
+ return attendance[month].absenceExcused;
case 3:
- return attendance[month].absenceForSchoolReasons
+ return attendance[month].absenceForSchoolReasons;
case 4:
- return attendance[month].lateness
+ return attendance[month].lateness;
case 5:
- return attendance[month].latenessExcused
+ return attendance[month].latenessExcused;
case 6:
- return attendance[month].exemption
+ return attendance[month].exemption;
}
- }
+ };
return {
Id: j + 1,
NazwaTypuFrekwencji: name(j),
@@ -358,24 +358,24 @@ router.all('/FrekwencjaStatystyki.mvc/Get', (req, res) => {
Lipiec: value(10, j),
Sierpien: value(11, j),
Razem: 0,
- }
+ };
}),
},
success: true,
- })
-})
+ });
+});
router.all('/FrekwencjaStatystykiPrzedmioty.mvc/Get', (req, res) => {
const subjects = require('../../data/api/dictionaries/Przedmioty').map((item) => {
return {
Id: item.Id,
Nazwa: item.Nazwa,
- }
- })
+ };
+ });
subjects.unshift({
Id: -1,
Nazwa: 'Wszystkie',
- })
+ });
subjects.push(
{
Id: 0,
@@ -385,43 +385,43 @@ router.all('/FrekwencjaStatystykiPrzedmioty.mvc/Get', (req, res) => {
Id: 492,
Nazwa: 'Opieka nad uczniami',
}
- )
+ );
res.json({
data: subjects,
success: true,
- })
-})
+ });
+});
router.all('/Jadlospis.mvc/Get', (req, res) => {
res.json({
data: {},
success: true,
- })
-})
+ });
+});
router.all('/LekcjeZrealizowane.mvc/GetPrzedmioty', (req, res) => {
const subjects = require('../../data/api/dictionaries/Przedmioty').map((item) => {
return {
IdPrzedmiot: item.Id,
Nazwa: item.Nazwa,
- }
- })
+ };
+ });
subjects.unshift({
IdPrzedmiot: -1,
Nazwa: 'Wszystkie',
- })
+ });
res.json({
data: subjects,
success: true,
- })
-})
+ });
+});
router.all('/LekcjeZrealizowane.mvc/GetZrealizowane', (req, res) => {
- const realized = require('../../data/opiekun/plan-zrealizowane.json')
+ const realized = require('../../data/opiekun/plan-zrealizowane.json');
const requestDate = req.body.poczatek
? parseISO(req.body.poczatek.replace('T', ' ').replace(/Z$/, ''))
- : parseISO(realized[0].date)
- const baseOffset = differenceInDays(requestDate, parseISO(realized[0].date))
+ : parseISO(realized[0].date);
+ const baseOffset = differenceInDays(requestDate, parseISO(realized[0].date));
res.json({
data: _.groupBy(
@@ -437,19 +437,19 @@ router.all('/LekcjeZrealizowane.mvc/GetZrealizowane', (req, res) => {
PseudonimUcznia: null,
ZasobyPubliczne: '',
PrzedmiotDisplay: item.subject,
- }
+ };
}),
(item) => converter.formatDate(new Date(item.Data))
),
success: true,
- })
-})
+ });
+});
router.all('/Oceny.mvc/Get', (req, res) => {
- const summary = require('../../data/api/student/OcenyPodsumowanie')
- const teachers = require('../../data/api/dictionaries/Nauczyciele')
- const subjectCategories = require('../../data/api/dictionaries/KategorieOcen')
- const descriptiveGrades = require('../../data/api/student/OcenyOpisowe')
+ const summary = require('../../data/api/student/OcenyPodsumowanie');
+ const teachers = require('../../data/api/dictionaries/Nauczyciele');
+ const subjectCategories = require('../../data/api/dictionaries/KategorieOcen');
+ const descriptiveGrades = require('../../data/api/student/OcenyOpisowe');
res.json({
data: {
@@ -462,14 +462,14 @@ router.all('/Oceny.mvc/Get', (req, res) => {
OcenyCzastkowe: require('../../data/api/student/Oceny')
.filter((grade) => grade.IdPrzedmiot === item.Id)
.map((item, index) => {
- const teacher = dictMap.getByValue(teachers, 'Id', item.IdPracownikD)
- const category = dictMap.getByValue(subjectCategories, 'Id', item.IdKategoria)
- let gradeDate
+ const teacher = dictMap.getByValue(teachers, 'Id', item.IdPracownikD);
+ const category = dictMap.getByValue(subjectCategories, 'Id', item.IdKategoria);
+ let gradeDate;
if (index == 0) {
- gradeDate = converter.formatDate(new Date())
+ gradeDate = converter.formatDate(new Date());
} else {
- gradeDate = converter.formatDate(new Date(item.DataUtworzenia * 1000))
+ gradeDate = converter.formatDate(new Date(item.DataUtworzenia * 1000));
}
return {
@@ -480,7 +480,7 @@ router.all('/Oceny.mvc/Get', (req, res) => {
KodKolumny: category.Kod,
DataOceny: gradeDate,
KolorOceny: parseInt(getGradeColorByCategoryName(category.Nazwa), 16),
- }
+ };
}),
ProponowanaOcenaRoczna: dictMap.getByValue(summary.OcenyPrzewidywane, 'IdPrzedmiot', item.Id, {
Wpis: '',
@@ -496,7 +496,7 @@ router.all('/Oceny.mvc/Get', (req, res) => {
SumaPunktow: dictMap.getByValue(summary.SrednieOcen, 'IdPrzedmiot', item.Id, { SumaPunktow: null })
.SumaPunktow,
WidocznyPrzedmiot: false,
- }
+ };
}),
OcenyOpisowe: descriptiveGrades,
TypOcen: 2,
@@ -504,37 +504,37 @@ router.all('/Oceny.mvc/Get', (req, res) => {
IsDlaDoroslych: false,
},
success: true,
- })
-})
+ });
+});
router.all('/OkresyUmowOplat.mvc/Get', (req, res) => {
res.json({
data: {},
success: true,
- })
-})
+ });
+});
router.all('/Oplaty.mvc/Get', (req, res) => {
res.json({
data: {},
success: true,
- })
-})
+ });
+});
router.all('/PlanZajec.mvc/Get', (req, res) => {
const requestDate = req.body.data
? parseISO(req.body.data.replace('T', ' ').replace(/Z$/, ''))
- : startOfWeek(new Date(), { weekStartsOn: 1 })
+ : startOfWeek(new Date(), { weekStartsOn: 1 });
- const teachers = require('../../data/api/dictionaries/Nauczyciele')
+ const teachers = require('../../data/api/dictionaries/Nauczyciele');
const lessons = _.map(
_.groupBy(
require('../../data/api/student/PlanLekcjiZeZmianami')
.filter((item) => item.PlanUcznia)
.map((item) => {
- const teacher = dictMap.getByValue(teachers, 'Id', item.IdPracownik)
- const oldTeacher = dictMap.getByValue(teachers, 'Id', item.IdPracownikOld)
- const times = dictMap.getByValue(require('../../data/api/dictionaries/PoryLekcji'), 'Id', item.IdPoraLekcji)
+ const teacher = dictMap.getByValue(teachers, 'Id', item.IdPracownik);
+ const oldTeacher = dictMap.getByValue(teachers, 'Id', item.IdPracownikOld);
+ const times = dictMap.getByValue(require('../../data/api/dictionaries/PoryLekcji'), 'Id', item.IdPoraLekcji);
return {
number: item.NumerLekcji,
id: item.IdPoraLekcji,
@@ -549,61 +549,65 @@ router.all('/PlanZajec.mvc/Get', (req, res) => {
changes: item.PogrubionaNazwa,
canceled: item.PrzekreslonaNazwa,
date: new Date(item.DzienTekst),
- }
+ };
}),
'number'
),
(number) => number.sort((a, b) => a.date - b.date)
- )
+ );
- const earliestDay = new Date(_.minBy(_.flatten(_.values(lessons)), (i) => new Date(i.date)).date)
- const latestDay = new Date(_.maxBy(_.flatten(_.values(lessons)), (i) => new Date(i.date)).date)
+ const earliestDay = new Date(_.minBy(_.flatten(_.values(lessons)), (i) => new Date(i.date)).date);
+ const latestDay = new Date(_.maxBy(_.flatten(_.values(lessons)), (i) => new Date(i.date)).date);
const rows = _.values(
_.mapValues(lessons, (item) => {
const row = {
times: `${[item[0].number]}
${[item[0].start]}
${[item[0].end]}`,
lessons: [],
- }
- let prevDay = subDays(earliestDay, 1)
+ };
+ let prevDay = subDays(earliestDay, 1);
item.forEach((lesson) => {
- const gapSize = differenceInDays(lesson.date, prevDay) - 1
+ const gapSize = differenceInDays(lesson.date, prevDay) - 1;
for (let i = 0; i < gapSize; i++) {
- row.lessons.push('')
+ row.lessons.push('');
}
- let cell = ''
+ let cell = '';
if (lesson.oldTeacher) {
- cell += `${lesson.subject}`
- cell += `${lesson.room}`
- cell += `${lesson.oldTeacher}`
- cell += `${lesson.subject}`
- cell += `${lesson.room}`
- cell += `${lesson.teacher}`
- cell += `${lesson.info}`
+ cell += `${lesson.subject}`;
+ cell += `${lesson.room}`;
+ cell += `${lesson.oldTeacher}`;
+ cell += `${lesson.subject}`;
+ cell += `${lesson.room}`;
+ cell += `${lesson.teacher}`;
+ cell += `${lesson.info}`;
} else {
if (lesson.group) {
- cell += `${lesson.subject} [${lesson.group}]`
- cell += ``
+ cell += `${lesson.subject} [${
+ lesson.group
+ }]`;
+ cell += ``;
} else {
- cell += `${lesson.subject}`
+ cell += `${
+ lesson.subject
+ }`;
}
- cell += `${lesson.room}`
- cell += `${lesson.teacher}`
+ cell += `${lesson.room}`;
+ cell += `${lesson.teacher}`;
if (lesson.info) {
- cell += `${lesson.info}`
+ cell += `${lesson.info}`;
}
}
- row.lessons.push(`