Update prettier workflow (#64)

This commit is contained in:
Marioneq 4958 2024-03-28 10:47:46 +01:00 committed by GitHub
parent c097154a80
commit 9f634d719c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 1051 additions and 1106 deletions

View file

@ -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

View file

@ -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

View file

@ -1,3 +0,0 @@
{
"esversion": 11
}

5
.prettierignore Normal file
View file

@ -0,0 +1,5 @@
Dockerfile
LICENSE
fakelog.conf
fakelog.nginx
bin

View file

@ -1,7 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"semi": true,
"singleQuote": true,
"printWidth": 120
}

126
app.js
View file

@ -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;

View file

@ -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
}
]
}
}

View file

@ -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": {

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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'),
}
}
};
};

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,10 @@
const { Router } = require('express')
const protocol = require('../utils/connection')
const { Router } = require('express');
const protocol = require('../utils/connection');
const router = Router()
const router = Router();
router.get('/', (req, res) => {
const base = protocol(req) + '://' + req.get('host') + '/powiatwulkanowy/123456'
const base = protocol(req) + '://' + req.get('host') + '/powiatwulkanowy/123456';
res.json({
loginEndpoint: base + '/LoginEndpoint.aspx',
app: base + '/App',
@ -32,121 +32,121 @@ router.get('/', (req, res) => {
base + '/api/PlanZajec',
base + '/api/DniWolne',
].sort(),
})
})
});
});
router.all('/LoginEndpoint.aspx', (req, res) => {
res.redirect(protocol(req) + '://' + req.get('host') + '/powiatwulkanowy/123456/App')
})
res.redirect(protocol(req) + '://' + req.get('host') + '/powiatwulkanowy/123456/App');
});
router.all('/App', (_req, res) => {
res.render('uczenplus/app')
})
res.render('uczenplus/app');
});
router.all('/api/Context', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/Context.json'))
})
res.json(require('../../data/uonetplus-uczenplus/Context.json'));
});
router.all('/api/Cache', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/Cache.json'))
})
res.json(require('../../data/uonetplus-uczenplus/Cache.json'));
});
router.all('/api/OkresyKlasyfikacyjne', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/OkresyKlasyfikacyjne.json'))
})
res.json(require('../../data/uonetplus-uczenplus/OkresyKlasyfikacyjne.json'));
});
router.all('/api/Zebrania', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/Zebrania.json'))
})
res.json(require('../../data/uonetplus-uczenplus/Zebrania.json'));
});
router.all('/api/SprawdzianyZadaniaDomowe', (_req, res) => {
res.json(
require('../../data/uonetplus-uczenplus/SprawdzianyZadaniaDomowe.json').map((event) => {
event.data = new Date().toISOString()
return event
event.data = new Date().toISOString();
return event;
})
)
})
);
});
router.all('/api/SprawdzianSzczegoly', (_req, res) => {
const data = require('../../data/uonetplus-uczenplus/SprawdzianSzczegoly.json')
data.data = new Date().toISOString()
res.json(data)
})
const data = require('../../data/uonetplus-uczenplus/SprawdzianSzczegoly.json');
data.data = new Date().toISOString();
res.json(data);
});
router.all('/api/ZadanieDomoweSzczegoly', (_req, res) => {
const data = require('../../data/uonetplus-uczenplus/ZadanieDomoweSzczegoly.json')
data.data = new Date().toISOString()
res.json(data)
})
const data = require('../../data/uonetplus-uczenplus/ZadanieDomoweSzczegoly.json');
data.data = new Date().toISOString();
res.json(data);
});
router.all('/api/Oceny', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/Oceny.json'))
})
res.json(require('../../data/uonetplus-uczenplus/Oceny.json'));
});
router.all('/api/Frekwencja', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/Frekwencja.json'))
})
res.json(require('../../data/uonetplus-uczenplus/Frekwencja.json'));
});
router.all('/api/Uwagi', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/Uwagi.json'))
})
res.json(require('../../data/uonetplus-uczenplus/Uwagi.json'));
});
router.all('/api/Nauczyciele', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/Nauczyciele.json'))
})
res.json(require('../../data/uonetplus-uczenplus/Nauczyciele.json'));
});
router.all('/api/Informacje', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/Informacje.json'))
})
res.json(require('../../data/uonetplus-uczenplus/Informacje.json'));
});
router.all('/api/WiadomosciNieodczytane', (_req, res) => {
res.json({ liczbaNieodczytanychWiadomosci: 2 })
})
res.json({ liczbaNieodczytanychWiadomosci: 2 });
});
router.all('/api/DostepOffice', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/DostepOffice.json'))
})
res.json(require('../../data/uonetplus-uczenplus/DostepOffice.json'));
});
router.all('/api/ZarejestrowaneUrzadzenia', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/ZarejestrowaneUrzadzenia.json'))
})
res.json(require('../../data/uonetplus-uczenplus/ZarejestrowaneUrzadzenia.json'));
});
router.all('/api/PodrecznikiLataSzkolne', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/PodrecznikiLataSzkolne.json'))
})
res.json(require('../../data/uonetplus-uczenplus/PodrecznikiLataSzkolne.json'));
});
router.all('/api/SzczesliwyNumerTablica', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/SzczesliwyNumerTablica.json'))
})
res.json(require('../../data/uonetplus-uczenplus/SzczesliwyNumerTablica.json'));
});
router.all('/api/WazneDzisiajTablica', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/WazneDzisiajTablica.json'))
})
res.json(require('../../data/uonetplus-uczenplus/WazneDzisiajTablica.json'));
});
router.all('/api/WychowawcyTablica', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/WychowawcyTablica.json'))
})
res.json(require('../../data/uonetplus-uczenplus/WychowawcyTablica.json'));
});
router.all('/api/RealizacjaZajec', (_req, res) => {
res.json(
require('../../data/uonetplus-uczenplus/RealizacjaZajec.json').map((lesson) => {
lesson.data = new Date().toISOString()
return lesson
lesson.data = new Date().toISOString();
return lesson;
})
)
})
);
});
router.all('/api/PlanZajec', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/PlanZajec.json'))
})
res.json(require('../../data/uonetplus-uczenplus/PlanZajec.json'));
});
router.all('/api/DniWolne', (_req, res) => {
res.json(require('../../data/uonetplus-uczenplus/DniWolne.json'))
})
res.json(require('../../data/uonetplus-uczenplus/DniWolne.json'));
});
router.all('/api/*', (_req, res) => {
res.status(404).send({ message: 'Nie odnaleziono zasobu.' })
})
res.status(404).send({ message: 'Nie odnaleziono zasobu.' });
});
module.exports = router
module.exports = router;

View file

@ -1,135 +1,124 @@
const { Router } = require("express");
const { Router } = require('express');
const router = Router({ mergeParams: true });
router.use((req, res, next) => {
if (req.params.customerSymbol !== "123456")
res.status(409).json({ message: "Brak uprawnień." });
if (req.params.customerSymbol !== '123456') res.status(409).json({ message: 'Brak uprawnień.' });
next();
});
router.all("/Context", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/Context.json"));
router.all('/Context', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/Context.json'));
});
router.all("/Cache", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/Cache.json"));
router.all('/Cache', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/Cache.json'));
});
router.all("/OkresyKlasyfikacyjne", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/OkresyKlasyfikacyjne.json"));
router.all('/OkresyKlasyfikacyjne', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/OkresyKlasyfikacyjne.json'));
});
router.all("/Zebrania", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/Zebrania.json"));
router.all('/Zebrania', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/Zebrania.json'));
});
router.all("/SprawdzianyZadaniaDomowe", (_req, res) => {
router.all('/SprawdzianyZadaniaDomowe', (_req, res) => {
res.json(
require("../../../data/uonetplus-uczenplus/SprawdzianyZadaniaDomowe.json").map(
(event) => {
event.data = new Date().toISOString();
return event;
}
)
require('../../../data/uonetplus-uczenplus/SprawdzianyZadaniaDomowe.json').map((event) => {
event.data = new Date().toISOString();
return event;
})
);
});
router.all("/SprawdzianSzczegoly", (_req, res) => {
const data = require("../../../data/uonetplus-uczenplus/SprawdzianSzczegoly.json");
router.all('/SprawdzianSzczegoly', (_req, res) => {
const data = require('../../../data/uonetplus-uczenplus/SprawdzianSzczegoly.json');
data.data = new Date().toISOString();
res.json(data);
});
router.all("/ZadanieDomoweSzczegoly", (_req, res) => {
const data = require("../../../data/uonetplus-uczenplus/ZadanieDomoweSzczegoly.json");
router.all('/ZadanieDomoweSzczegoly', (_req, res) => {
const data = require('../../../data/uonetplus-uczenplus/ZadanieDomoweSzczegoly.json');
data.data = new Date().toISOString();
res.json(data);
});
router.all("/Oceny", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/Oceny.json"));
router.all('/Oceny', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/Oceny.json'));
});
router.all("/Frekwencja", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/Frekwencja.json"));
router.all('/Frekwencja', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/Frekwencja.json'));
});
router.all("/FrekwencjaStatystyki", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/FrekwencjaStatystyki.json"));
router.all('/FrekwencjaStatystyki', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/FrekwencjaStatystyki.json'));
});
router.all("/Usprawiedliwienia", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/Usprawiedliwienia.json"));
router.all('/Usprawiedliwienia', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/Usprawiedliwienia.json'));
});
router.all("/Uwagi", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/Uwagi.json"));
router.all('/Uwagi', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/Uwagi.json'));
});
router.all("/Nauczyciele", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/Nauczyciele.json"));
router.all('/Nauczyciele', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/Nauczyciele.json'));
});
router.all("/Informacje", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/Informacje.json"));
router.all('/Informacje', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/Informacje.json'));
});
router.all("/WiadomosciNieodczytane", (_req, res) => {
router.all('/WiadomosciNieodczytane', (_req, res) => {
res.json({ liczbaNieodczytanychWiadomosci: 2 });
});
router.all("/DostepOffice", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/DostepOffice.json"));
router.all('/DostepOffice', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/DostepOffice.json'));
});
router.all("/ZarejestrowaneUrzadzenia", (_req, res) => {
router.all('/ZarejestrowaneUrzadzenia', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/ZarejestrowaneUrzadzenia.json'));
});
router.all('/PodrecznikiLataSzkolne', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/PodrecznikiLataSzkolne.json'));
});
router.all('/SzczesliwyNumerTablica', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/SzczesliwyNumerTablica.json'));
});
router.all('/WazneDzisiajTablica', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/WazneDzisiajTablica.json'));
});
router.all('/WychowawcyTablica', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/WychowawcyTablica.json'));
});
router.all('/RealizacjaZajec', (_req, res) => {
res.json(
require("../../../data/uonetplus-uczenplus/ZarejestrowaneUrzadzenia.json")
require('../../../data/uonetplus-uczenplus/RealizacjaZajec.json').map((lesson) => {
lesson.data = new Date().toISOString();
return lesson;
})
);
});
router.all("/PodrecznikiLataSzkolne", (_req, res) => {
res.json(
require("../../../data/uonetplus-uczenplus/PodrecznikiLataSzkolne.json")
);
router.all('/PlanZajec', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/PlanZajec.json'));
});
router.all("/SzczesliwyNumerTablica", (_req, res) => {
res.json(
require("../../../data/uonetplus-uczenplus/SzczesliwyNumerTablica.json")
);
router.all('/DniWolne', (_req, res) => {
res.json(require('../../../data/uonetplus-uczenplus/DniWolne.json'));
});
router.all("/WazneDzisiajTablica", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/WazneDzisiajTablica.json"));
});
router.all("/WychowawcyTablica", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/WychowawcyTablica.json"));
});
router.all("/RealizacjaZajec", (_req, res) => {
res.json(
require("../../../data/uonetplus-uczenplus/RealizacjaZajec.json").map(
(lesson) => {
lesson.data = new Date().toISOString();
return lesson;
}
)
);
});
router.all("/PlanZajec", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/PlanZajec.json"));
});
router.all("/DniWolne", (_req, res) => {
res.json(require("../../../data/uonetplus-uczenplus/DniWolne.json"));
});
router.all("/*", (_req, res) => {
res.status(404).send({ message: "Nie odnaleziono zasobu." });
router.all('/*', (_req, res) => {
res.status(404).send({ message: 'Nie odnaleziono zasobu.' });
});
module.exports = router;

View file

@ -1,68 +1,65 @@
const { Router } = require("express");
const protocol = require("../../utils/connection");
const apiRouter = require("./api");
const { Router } = require('express');
const protocol = require('../../utils/connection');
const apiRouter = require('./api');
const router = Router({ mergeParams: true });
router.use("/api", apiRouter);
router.use('/api', apiRouter);
router.get("/", (req, res) => {
const base =
protocol(req) + "://" + req.get("host") + "/powiatwulkanowy/123456";
router.get('/', (req, res) => {
const base = protocol(req) + '://' + req.get('host') + '/powiatwulkanowy/123456';
res.json({
loginEndpoint: base + "/LoginEndpoint.aspx",
app: base + "/App",
loginEndpoint: base + '/LoginEndpoint.aspx',
app: base + '/App',
api: [
base + "/api/Context",
base + "/api/Cache",
base + "/api/OkresyKlasyfikacyjne",
base + "/api/Zebrania",
base + "/api/SprawdzianyZadaniaDomowe",
base + "/api/SprawdzianSzczegoly",
base + "/api/ZadanieDomoweSzczegoly",
base + "/api/Uwagi",
base + "/api/Frekwencja",
base + "/api/FrekwencjaStatystyki",
base + "/api/Usprawiedliwienia",
base + "/api/Oceny",
base + "/api/Nauczyciele",
base + "/api/Informacje",
base + "/api/NieprzeczytaneWiadomosci",
base + "/api/DostepOffice",
base + "/api/ZarejestrowaneUrzadzenia",
base + "/api/PodrecznikiLataSzkolne",
base + "/api/SzczesliwyNumerTablica",
base + "/api/WazneDzisiajTablica",
base + "/api/WychowawcyTablica",
base + "/api/RealizacjaZajec",
base + "/api/PlanZajec",
base + "/api/DniWolne",
base + '/api/Context',
base + '/api/Cache',
base + '/api/OkresyKlasyfikacyjne',
base + '/api/Zebrania',
base + '/api/SprawdzianyZadaniaDomowe',
base + '/api/SprawdzianSzczegoly',
base + '/api/ZadanieDomoweSzczegoly',
base + '/api/Uwagi',
base + '/api/Frekwencja',
base + '/api/FrekwencjaStatystyki',
base + '/api/Usprawiedliwienia',
base + '/api/Oceny',
base + '/api/Nauczyciele',
base + '/api/Informacje',
base + '/api/NieprzeczytaneWiadomosci',
base + '/api/DostepOffice',
base + '/api/ZarejestrowaneUrzadzenia',
base + '/api/PodrecznikiLataSzkolne',
base + '/api/SzczesliwyNumerTablica',
base + '/api/WazneDzisiajTablica',
base + '/api/WychowawcyTablica',
base + '/api/RealizacjaZajec',
base + '/api/PlanZajec',
base + '/api/DniWolne',
].sort(),
});
});
router.all("/LoginEndpoint.aspx", (req, res) => {
if (req.params.customerSymbol !== "123456")
router.all('/LoginEndpoint.aspx', (req, res) => {
if (req.params.customerSymbol !== '123456')
res.redirect(
protocol(req) +
"://" +
req.get("host").replace("uczenplus", "uczen") +
'://' +
req.get('host').replace('uczenplus', 'uczen') +
`/powiatwulkanowy/${req.params.customerSymbol}/LoginEndpoint.aspx`
);
res.redirect(
protocol(req) + "://" + req.get("host") + "/powiatwulkanowy/123456/App"
);
res.redirect(protocol(req) + '://' + req.get('host') + '/powiatwulkanowy/123456/App');
});
router.all("/App", (req, res) => {
if (req.params.customerSymbol !== "123456")
router.all('/App', (req, res) => {
if (req.params.customerSymbol !== '123456')
res.redirect(
protocol(req) +
"://" +
req.get("host").replace("uczenplus", "uczen") +
'://' +
req.get('host').replace('uczenplus', 'uczen') +
`/powiatwulkanowy/${req.params.customerSymbol}/LoginEndpoint.aspx`
);
res.render("uczenplus/app");
res.render('uczenplus/app');
});
module.exports = router;

View file

@ -1,16 +1,16 @@
const express = require('express')
const router = express.Router()
const protocol = require('../utils/connection')
const converter = require('../utils/converter')
const { getRandomInt } = require('../utils/api')
const md5 = require('md5')
const express = require('express');
const router = express.Router();
const protocol = require('../utils/connection');
const converter = require('../utils/converter');
const { getRandomInt } = require('../utils/api');
const md5 = require('md5');
router.get('/', (req, res) => {
res.render('messages')
})
res.render('messages');
});
router.get('/-endpoints', (req, res) => {
const base = protocol(req) + '://' + req.get('host') + '/powiatwulkanowy'
const base = protocol(req) + '://' + req.get('host') + '/powiatwulkanowy';
res.json({
status: 'sucess',
data: {
@ -33,19 +33,19 @@ router.get('/-endpoints', (req, res) => {
'/NowaWiadomosc.mvc/GetJednostkiUzytkownika',
'/NowaWiadomosc.mvc/InsertWiadomosc',
].map((item) => {
return base + item
return base + item;
}),
},
})
})
});
});
router.get('/Wiadomosc.mvc/GetInboxMessages', (req, res) => {
res.json({
success: true,
data: require('../../data/api/messages/WiadomosciOdebrane').map((item) => {
const recipientsNumber = getRandomInt(60, 100)
const readBy = getRandomInt(20, 60)
const unreadBy = recipientsNumber - readBy
const recipientsNumber = getRandomInt(60, 100);
const readBy = getRandomInt(20, 60);
const unreadBy = recipientsNumber - readBy;
return {
Id: item.WiadomoscId * 2,
Nieprzeczytana: !item.GodzinaPrzeczytania,
@ -69,10 +69,10 @@ router.get('/Wiadomosc.mvc/GetInboxMessages', (req, res) => {
HasZalaczniki: true,
FolderWiadomosci: 1,
Adresaci: [],
}
};
}),
})
})
});
});
router.get('/Wiadomosc.mvc/GetOutboxMessages', (req, res) => {
res.json({
@ -101,10 +101,10 @@ router.get('/Wiadomosc.mvc/GetOutboxMessages', (req, res) => {
HasZalaczniki: false,
FolderWiadomosci: 2,
Adresaci: [],
}
};
}),
})
})
});
});
router.get('/Wiadomosc.mvc/GetTrashboxMessages', (req, res) => {
res.json({
@ -133,13 +133,13 @@ router.get('/Wiadomosc.mvc/GetTrashboxMessages', (req, res) => {
HasZalaczniki: false,
FolderWiadomosci: 3,
Adresaci: [],
}
};
}),
})
})
});
});
router.get('/NowaWiadomosc.mvc/GetJednostkiUzytkownika', (req, res) => {
const user = require('../../data/api/ListaUczniow')[1]
const user = require('../../data/api/ListaUczniow')[1];
res.json({
success: true,
data: [
@ -152,11 +152,11 @@ router.get('/NowaWiadomosc.mvc/GetJednostkiUzytkownika', (req, res) => {
Id: user.Id,
},
],
})
})
});
});
router.all('/Adresaci.mvc/GetAddressee', (req, res) => {
const user = require('../../data/api/ListaUczniow')[1]
const user = require('../../data/api/ListaUczniow')[1];
res.json({
success: true,
data: require('../../data/api/dictionaries/Pracownicy').map((item) => {
@ -168,13 +168,13 @@ router.all('/Adresaci.mvc/GetAddressee', (req, res) => {
Role: 2,
PushMessage: null,
Hash: Buffer.from(md5(item.Id)).toString('base64'),
}
};
}),
})
})
});
});
router.get(['/Wiadomosc.mvc/GetAdresaciWiadomosci', '/Wiadomosc.mvc/GetMessageSenderRoles'], (req, res) => {
const user = require('../../data/api/ListaUczniow')[1]
const user = require('../../data/api/ListaUczniow')[1];
res.json({
success: true,
data: require('../../data/api/dictionaries/Pracownicy')
@ -188,10 +188,10 @@ router.get(['/Wiadomosc.mvc/GetAdresaciWiadomosci', '/Wiadomosc.mvc/GetMessageSe
Role: 2,
PushMessage: null,
Hash: Buffer.from(md5(item.Id)).toString('base64'),
}
};
}),
})
})
});
});
router.all(
[
@ -200,7 +200,7 @@ router.all(
'/Wiadomosc.mvc/GetTrashboxMessageDetails',
],
(req, res) => {
const message = require('../../data/api/messages/WiadomosciOdebrane')[0]
const message = require('../../data/api/messages/WiadomosciOdebrane')[0];
res.json({
success: true,
data: {
@ -230,13 +230,13 @@ router.all(
},
],
},
})
});
}
)
);
router.all('/Wiadomosc.mvc/GetAdresaciNiePrzeczytaliWiadomosci', (req, res) => {
const user = require('../../data/api/ListaUczniow')[1]
const recipient = require('../../data/api/dictionaries/Pracownicy')[0]
const user = require('../../data/api/ListaUczniow')[1];
const recipient = require('../../data/api/dictionaries/Pracownicy')[0];
res.json({
success: true,
data: [
@ -250,12 +250,12 @@ router.all('/Wiadomosc.mvc/GetAdresaciNiePrzeczytaliWiadomosci', (req, res) => {
Hash: Buffer.from(md5(recipient.Id)).toString('base64'),
},
],
})
})
});
});
router.all('/Wiadomosc.mvc/GetAdresaciPrzeczytaliWiadomosc', (req, res) => {
const user = require('../../data/api/ListaUczniow')[1]
const recipient = require('../../data/api/dictionaries/Pracownicy')[1]
const user = require('../../data/api/ListaUczniow')[1];
const recipient = require('../../data/api/dictionaries/Pracownicy')[1];
res.json({
success: true,
data: [
@ -265,12 +265,12 @@ router.all('/Wiadomosc.mvc/GetAdresaciPrzeczytaliWiadomosc', (req, res) => {
Id: recipient.Id * 8, // ¯\_(ツ)_/¯
},
],
})
})
});
});
router.all('/Wiadomosc.mvc/GetMessageAddressee', (req, res) => {
const user = require('../../data/api/ListaUczniow')[1]
const recipient = require('../../data/api/dictionaries/Pracownicy')[1]
const user = require('../../data/api/ListaUczniow')[1];
const recipient = require('../../data/api/dictionaries/Pracownicy')[1];
res.json({
success: true,
data: [
@ -282,8 +282,8 @@ router.all('/Wiadomosc.mvc/GetMessageAddressee', (req, res) => {
Hash: 'abcd==',
},
],
})
})
});
});
router.all(
[
@ -294,18 +294,18 @@ router.all(
(req, res) => {
res.json({
success: true,
})
});
}
)
);
router.all('/NowaWiadomosc.mvc/InsertWiadomosc', (req, res) => {
let data = req.body.incomming
let data = req.body.incomming;
res.json({
success: true,
data: {
Adresaci: data.Adresaci.map((item) => {
item.PushMessage = false
return item
item.PushMessage = false;
return item;
}),
Temat: data.Temat,
Tresc: data.Tresc,
@ -321,7 +321,7 @@ router.all('/NowaWiadomosc.mvc/InsertWiadomosc', (req, res) => {
WiadomoscPowitalna: false,
Id: data.Id,
},
})
})
});
});
module.exports = router
module.exports = router;

View file

@ -1,19 +1,19 @@
const express = require('express')
const router = express.Router()
const protocol = require('../utils/connection')
const { timestampToIsoTzFormat, dateToTimestamp } = require('../utils/converter')
const { fromString } = require('uuidv4')
const express = require('express');
const router = express.Router();
const protocol = require('../utils/connection');
const { timestampToIsoTzFormat, dateToTimestamp } = require('../utils/converter');
const { fromString } = require('uuidv4');
router.get('/', (req, res) => {
res.render('messages')
})
res.render('messages');
});
router.get('/LoginEndpoint.aspx', (req, res) => {
res.redirect('/')
})
res.redirect('/');
});
router.get('/-endpoints', (req, res) => {
const base = protocol(req) + '://' + req.get('host') + '/powiatwulkanowy'
const base = protocol(req) + '://' + req.get('host') + '/powiatwulkanowy';
res.json({
status: 'sucess',
data: {
@ -32,19 +32,19 @@ router.get('/-endpoints', (req, res) => {
'/api/MoveTrash',
'/api/Delete',
].map((item) => {
return base + item
return base + item;
}),
},
})
})
});
});
router.get(['/api/Odebrane', '/api/OdebraneSkrzynka'], (req, res) => {
const currentTimestamp = dateToTimestamp(new Date())
const currentTimestamp = dateToTimestamp(new Date());
res.json(
require('../../data/api/messages/WiadomosciOdebrane').map((item, i) => {
let itemTimestamp = item.DataWyslaniaUnixEpoch
let itemTimestamp = item.DataWyslaniaUnixEpoch;
if (i < 7) {
itemTimestamp = currentTimestamp - i * i * 3600 * 6
itemTimestamp = currentTimestamp - i * i * 3600 * 6;
}
return {
apiGlobalKey: fromString(item.WiadomoscId.toString()),
@ -58,10 +58,10 @@ router.get(['/api/Odebrane', '/api/OdebraneSkrzynka'], (req, res) => {
wazna: false,
uzytkownikRola: 2,
id: item.WiadomoscId,
}
};
})
)
})
);
});
router.get(['/api/Wyslane', '/api/WyslaneSkrzynka'], (req, res) => {
res.json(
@ -78,10 +78,10 @@ router.get(['/api/Wyslane', '/api/WyslaneSkrzynka'], (req, res) => {
wazna: false,
uzytkownikRola: 2,
id: item.WiadomoscId,
}
};
})
)
})
);
});
router.get(['/api/Usuniete', '/api/UsunieteSkrzynka'], (req, res) => {
res.json(
@ -98,26 +98,26 @@ router.get(['/api/Usuniete', '/api/UsunieteSkrzynka'], (req, res) => {
wazna: false,
uzytkownikRola: 2,
id: item.WiadomoscId,
}
};
})
)
})
);
});
router.get('/api/Skrzynki', (req, res) => {
const users = require('../../data/api/ListaUczniow')
const users = require('../../data/api/ListaUczniow');
res.json(
users.map((user) => {
return {
globalKey: fromString(user.UzytkownikLoginId.toString()),
nazwa: `${user.Imie} ${user.Nazwisko} - U - (${user.JednostkaSprawozdawczaSkrot})`,
typUzytkownika: 3,
}
};
})
)
})
);
});
router.all('/api/WiadomoscSzczegoly', (req, res) => {
const message = require('../../data/api/messages/WiadomosciOdebrane')[0]
const message = require('../../data/api/messages/WiadomosciOdebrane')[0];
res.json({
data: timestampToIsoTzFormat(message.DataWyslaniaUnixEpoch),
apiGlobalKey: fromString(message.WiadomoscId.toString()),
@ -141,12 +141,12 @@ router.all('/api/WiadomoscSzczegoly', (req, res) => {
},
],
id: message.WiadomoscId,
})
})
});
});
router.all('/api/WiadomoscOdpowiedzPrzekaz', (req, res) => {
const user = require('../../data/api/ListaUczniow')[1]
const message = require('../../data/api/messages/WiadomosciOdebrane')[0]
const user = require('../../data/api/ListaUczniow')[1];
const message = require('../../data/api/messages/WiadomosciOdebrane')[0];
res.json({
data: timestampToIsoTzFormat(message.DataWyslaniaUnixEpoch),
apiGlobalKey: fromString(message.WiadomoscId.toString()),
@ -168,28 +168,28 @@ router.all('/api/WiadomoscOdpowiedzPrzekaz', (req, res) => {
},
],
id: message.WiadomoscId,
})
})
});
});
router.all('/api/Pracownicy', (req, res) => {
const user = require('../../data/api/ListaUczniow')[1]
const recipients = require('../../data/api/dictionaries/Pracownicy')
const user = require('../../data/api/ListaUczniow')[1];
const recipients = require('../../data/api/dictionaries/Pracownicy');
res.json(
recipients.map((item) => {
return {
skrzynkaGlobalKey: fromString(item.Id.toString()),
nazwa: `${item.Nazwisko} ${item.Imie} - P - (${user.JednostkaSprawozdawczaSkrot})`,
}
};
})
)
})
);
});
router.all(['/api/MoveTrash', '/api/Delete'], (req, res) => {
res.status(204).send()
})
res.status(204).send();
});
router.all('/api/WiadomoscNowa', (req, res) => {
res.status(204).send()
})
res.status(204).send();
});
module.exports = router
module.exports = router;

View file

@ -1,9 +1,9 @@
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');
router.get('/powiatwulkanowy/Start.mvc/Endpoints', (req, res) => {
const base = protocol(req) + '://' + req.get('host') + '/powiatwulkanowy/Start.mvc'
const base = protocol(req) + '://' + req.get('host') + '/powiatwulkanowy/Start.mvc';
res.json({
status: 'success',
data: {
@ -22,11 +22,11 @@ router.get('/powiatwulkanowy/Start.mvc/Endpoints', (req, res) => {
'/GetLastAnnouncements',
'/GetStudentDirectorInformations',
].map((item) => {
return base + item
return base + item;
}),
},
})
})
});
});
router.all('/powiatwulkanowy/Start.mvc/GetSelfGovernments', (req, res) => {
res.json({
@ -34,8 +34,8 @@ router.all('/powiatwulkanowy/Start.mvc/GetSelfGovernments', (req, res) => {
success: true,
errorMessage: null,
feedback: null,
})
})
});
});
router.all('/powiatwulkanowy/Start.mvc/GetStudentTrips', (req, res) => {
res.json({
@ -43,20 +43,20 @@ router.all('/powiatwulkanowy/Start.mvc/GetStudentTrips', (req, res) => {
success: true,
errorMessage: null,
feedback: null,
})
})
});
});
router.all('/powiatwulkanowy/Start.mvc/GetLastNotes', (req, res) => {
res.json(require('../../data/uonetplus/GetLastNotes'))
})
res.json(require('../../data/uonetplus/GetLastNotes'));
});
router.all('/powiatwulkanowy/Start.mvc/GetFreeDays', (req, res) => {
res.json(require('../../data/uonetplus/GetFreeDays'))
})
res.json(require('../../data/uonetplus/GetFreeDays'));
});
router.all('/powiatwulkanowy/Start.mvc/GetKidsLuckyNumbers', (req, res) => {
res.json(require('../../data/uonetplus/GetKidsLuckyNumbers'))
})
res.json(require('../../data/uonetplus/GetKidsLuckyNumbers'));
});
router.all('/powiatwulkanowy/Start.mvc/GetKidsLessonPlan', (req, res) => {
res.json({
@ -64,8 +64,8 @@ router.all('/powiatwulkanowy/Start.mvc/GetKidsLessonPlan', (req, res) => {
success: true,
errorMessage: null,
feedback: null,
})
})
});
});
router.all('/powiatwulkanowy/Start.mvc/GetNumberOfUnreadMessages', (req, res) => {
res.json({
@ -73,8 +73,8 @@ router.all('/powiatwulkanowy/Start.mvc/GetNumberOfUnreadMessages', (req, res) =>
success: false,
errorMessage: 'Not implemented yet',
feedback: null,
})
})
});
});
router.all('/powiatwulkanowy/Start.mvc/GetLastHomeworks', (req, res) => {
res.json({
@ -82,8 +82,8 @@ router.all('/powiatwulkanowy/Start.mvc/GetLastHomeworks', (req, res) => {
success: true,
errorMessage: null,
feedback: null,
})
})
});
});
router.all('/powiatwulkanowy/Start.mvc/GetLastTests', (req, res) => {
res.json({
@ -91,8 +91,8 @@ router.all('/powiatwulkanowy/Start.mvc/GetLastTests', (req, res) => {
success: true,
errorMessage: null,
feedback: null,
})
})
});
});
router.all('/powiatwulkanowy/Start.mvc/GetStudentConferences', (req, res) => {
res.json({
@ -100,8 +100,8 @@ router.all('/powiatwulkanowy/Start.mvc/GetStudentConferences', (req, res) => {
success: false,
errorMessage: 'Not implemented yet',
feedback: null,
})
})
});
});
router.all('/powiatwulkanowy/Start.mvc/GetLastStudentLessons', (req, res) => {
res.json({
@ -109,8 +109,8 @@ router.all('/powiatwulkanowy/Start.mvc/GetLastStudentLessons', (req, res) => {
success: true,
errorMessage: null,
feedback: null,
})
})
});
});
router.all('/powiatwulkanowy/Start.mvc/GetStudentDirectorInformations', (req, res) => {
res.json({
@ -118,8 +118,8 @@ router.all('/powiatwulkanowy/Start.mvc/GetStudentDirectorInformations', (req, re
errorMessage: null,
feedback: null,
success: true,
})
})
});
});
router.all('/powiatwulkanowy/Start.mvc/GetLastAnnouncements', (req, res) => {
res.json({
@ -127,58 +127,46 @@ router.all('/powiatwulkanowy/Start.mvc/GetLastAnnouncements', (req, res) => {
errorMessage: null,
feedback: null,
success: true,
})
})
});
});
router.get('/', (req, res) => {
res.render('log-exception', {
title: 'Dziennik FakeUONET+',
message: 'Podany identyfikator klienta jest niepoprawny.',
})
})
});
});
router.all(/^\/([a-z0-9]+)(?:\/LoginEndpoint\.aspx|\/)?$/i, (req, res) => {
let hasCert = req.body.wa && req.body.wresult
let hasCert = req.body.wa && req.body.wresult;
if (req.params[0] != 'powiatwulkanowy') {
if (hasCert)
res.render('permission-error', {
title: 'Logowanie',
})
});
else
res.render('log-exception', {
title: 'Dziennik FakeUONET+',
message: 'Podany identyfikator klienta jest niepoprawny.',
})
});
return
return;
} else if (hasCert) {
return res.redirect('/powiatwulkanowy/Start.mvc/Index')
return res.redirect('/powiatwulkanowy/Start.mvc/Index');
}
res.redirect(protocol(req) + '://' + req.get('host').replace('uonetplus', 'cufs') + '/powiatwulkanowy/Account/LogOn')
})
res.redirect(protocol(req) + '://' + req.get('host').replace('uonetplus', 'cufs') + '/powiatwulkanowy/Account/LogOn');
});
router.get(["/powiatwulkanowy/Start.mvc", "/powiatwulkanowy/Start.mvc/Index"], (req, res) => {
res.render("homepage", {
title: "Uonet+",
uonetplusOpiekun:
protocol(req) +
"://" +
req.get("host").replace("uonetplus", "uonetplus-opiekun"),
uonetplusUczen:
protocol(req) +
"://" +
req.get("host").replace("uonetplus", "uonetplus-uczen"),
uonetplusUczenplus:
protocol(req) +
"://" +
req.get("host").replace("uonetplus", "uonetplus-uczenplus"),
uonetplusWiadomosciplus:
protocol(req) +
"://" +
req.get("host").replace("uonetplus", "uonetplus-wiadomosciplus"),
})
})
router.get(['/powiatwulkanowy/Start.mvc', '/powiatwulkanowy/Start.mvc/Index'], (req, res) => {
res.render('homepage', {
title: 'Uonet+',
uonetplusOpiekun: protocol(req) + '://' + req.get('host').replace('uonetplus', 'uonetplus-opiekun'),
uonetplusUczen: protocol(req) + '://' + req.get('host').replace('uonetplus', 'uonetplus-uczen'),
uonetplusUczenplus: protocol(req) + '://' + req.get('host').replace('uonetplus', 'uonetplus-uczenplus'),
uonetplusWiadomosciplus: protocol(req) + '://' + req.get('host').replace('uonetplus', 'uonetplus-wiadomosciplus'),
});
});
module.exports = router
module.exports = router;

View file

@ -1,4 +1,4 @@
const { uuid } = require('uuidv4')
const { uuid } = require('uuidv4');
function createResponse(data) {
return {
@ -9,14 +9,14 @@ function createResponse(data) {
DayOfWeek: new Date().getDay(),
AppVersion: '17.09.0009.26859',
Data: data,
}
};
}
function getRandomInt(min, max) {
min = Math.ceil(min)
max = Math.floor(max)
return Math.floor(Math.random() * (max - min)) + min
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
exports.createResponse = createResponse
exports.getRandomInt = getRandomInt
exports.createResponse = createResponse;
exports.getRandomInt = getRandomInt;

View file

@ -1,9 +1,9 @@
module.exports = function (req) {
const isConnectionEncrypted = req.connection.encrypted
const isSslEnvSet = process.env.SSL === 'true'
const isHeaderSsl = req.header('x-forwarded-proto') === 'https'
const isConnectionEncrypted = req.connection.encrypted;
const isSslEnvSet = process.env.SSL === 'true';
const isHeaderSsl = req.header('x-forwarded-proto') === 'https';
const proto = isConnectionEncrypted || isSslEnvSet || isHeaderSsl ? 'https' : 'http'
const proto = isConnectionEncrypted || isSslEnvSet || isHeaderSsl ? 'https' : 'http';
return proto.split(/\s*,\s*/)[0]
}
return proto.split(/\s*,\s*/)[0];
};

View file

@ -1,99 +1,99 @@
const { addDays, toDate, format, getTime } = require('date-fns')
const WEEK_TICK = 6048000000000
const DAY_TICK = 864000000000
const { addDays, toDate, format, getTime } = require('date-fns');
const WEEK_TICK = 6048000000000;
const DAY_TICK = 864000000000;
function getDateFromTick(tick) {
if (tick === '' || tick === undefined) {
return getMonday(new Date())
return getMonday(new Date());
}
return new Date((tick - 621355968000000000) / 10000)
return new Date((tick - 621355968000000000) / 10000);
}
function getTickFromDate(date) {
return date.getTime() * 10000 + 621355968000000000
return date.getTime() * 10000 + 621355968000000000;
}
function formatDate(today, iso = false) {
let dd = today.getDate()
let mm = today.getMonth() + 1 //January is 0!
let dd = today.getDate();
let mm = today.getMonth() + 1; //January is 0!
let yyyy = today.getFullYear()
let yyyy = today.getFullYear();
if (dd < 10) {
dd = '0' + dd
dd = '0' + dd;
}
if (mm < 10) {
mm = '0' + mm
mm = '0' + mm;
}
if (iso) return `${yyyy}-${mm}-${dd}`
if (iso) return `${yyyy}-${mm}-${dd}`;
return `${dd}.${mm}.${yyyy}`
return `${dd}.${mm}.${yyyy}`;
}
function timestampToIsoTzFormat(timestamp) {
return format(new Date(timestamp * 1000), "yyyy-MM-dd'T'HH:mm:ss.SSXXX")
return format(new Date(timestamp * 1000), "yyyy-MM-dd'T'HH:mm:ss.SSXXX");
}
function dateToTimestamp(date) {
return getTime(date) / 1000
return getTime(date) / 1000;
}
function getMonday(date) {
let day = date.getDate() - date.getDay() + 1
return new Date(date.getFullYear(), date.getMonth(), day)
let day = date.getDate() - date.getDay() + 1;
return new Date(date.getFullYear(), date.getMonth(), day);
}
function getDayName(dateStr) {
return new Date(dateStr).toLocaleDateString('pl', { weekday: 'long' })
return new Date(dateStr).toLocaleDateString('pl', { weekday: 'long' });
}
function getWeekDaysFrom(startDate, number = 5) {
if (!(startDate instanceof Date)) startDate = getDateFromTick(startDate)
if (!(startDate instanceof Date)) startDate = getDateFromTick(startDate);
const days = []
const days = [];
for (let i = 0; i < number; i++) {
let date = addDays(startDate, i)
days.push([getDayName(date), formatDate(toDate(date)), date])
let date = addDays(startDate, i);
days.push([getDayName(date), formatDate(toDate(date)), date]);
}
return days
return days;
}
function getPrevWeekTick(tick) {
return getPrevTick(tick, WEEK_TICK)
return getPrevTick(tick, WEEK_TICK);
}
function getPrevDayTick(tick) {
return getPrevTick(tick, DAY_TICK)
return getPrevTick(tick, DAY_TICK);
}
function getNextWeekTick(tick) {
return getNextTick(tick, WEEK_TICK)
return getNextTick(tick, WEEK_TICK);
}
function getNextDayTick(tick) {
return getNextTick(tick, DAY_TICK)
return getNextTick(tick, DAY_TICK);
}
function getNextTick(tick, plus) {
tick = tick ? tick : getTickFromDate(new Date())
return parseInt(tick) + plus
tick = tick ? tick : getTickFromDate(new Date());
return parseInt(tick) + plus;
}
function getPrevTick(tick, minus) {
tick = tick ? tick : getTickFromDate(new Date())
return parseInt(tick) - minus
tick = tick ? tick : getTickFromDate(new Date());
return parseInt(tick) - minus;
}
exports.getDateString = getDateFromTick
exports.getWeekDaysFrom = getWeekDaysFrom
exports.getDayName = getDayName
exports.getPrevDayTick = getPrevDayTick
exports.getNextDayTick = getNextDayTick
exports.getPrevWeekTick = getPrevWeekTick
exports.getNextWeekTick = getNextWeekTick
exports.formatDate = formatDate
exports.timestampToIsoTzFormat = timestampToIsoTzFormat
exports.dateToTimestamp = dateToTimestamp
exports.getDateString = getDateFromTick;
exports.getWeekDaysFrom = getWeekDaysFrom;
exports.getDayName = getDayName;
exports.getPrevDayTick = getPrevDayTick;
exports.getNextDayTick = getNextDayTick;
exports.getPrevWeekTick = getPrevWeekTick;
exports.getNextWeekTick = getNextWeekTick;
exports.formatDate = formatDate;
exports.timestampToIsoTzFormat = timestampToIsoTzFormat;
exports.dateToTimestamp = dateToTimestamp;

View file

@ -1,10 +1,10 @@
function getByValue(dictionary, index, value, def = {}) {
const val = dictionary.filter((obj) => {
return obj[index] === value
})[0]
return obj[index] === value;
})[0];
if (!val) return def
return val
if (!val) return def;
return val;
}
exports.getByValue = getByValue
exports.getByValue = getByValue;

View file

@ -1,14 +1,14 @@
exports.getGradeColorByCategoryName = (name) => {
switch (true) {
case name.includes('czarny'):
return '000000'
return '000000';
case name.includes('czerw'):
return 'F04C4C'
return 'F04C4C';
case name.includes('fiol'):
return 'B16CF1'
return 'B16CF1';
case name.includes('nieb'):
return '20A4F7'
return '20A4F7';
case name.includes('zielony'):
return '6ECD07'
return '6ECD07';
}
}
};