Merge pull request #48 from wulkanowy/feature/drawer

drawer
This commit is contained in:
Zaptyp 2021-02-06 13:40:19 +01:00 committed by GitHub
commit 740ee5fa2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 194 additions and 22523 deletions

4
.gitignore vendored
View file

@ -17,6 +17,10 @@ __pycache__/
# C extensions
*.so
frontend/static/frontend/login.js
frontend/static/frontend/content.js
frontend/static/frontend/accountManager.js
# Distribution / packaging
.Python
build/

View file

@ -1,7 +1,22 @@
import React, { Component } from "react";
import { render } from 'react-dom';
import { Button, ListItemText, ListItemIcon, ListItem } from '@material-ui/core';
import { Drawer } from '@material-ui/core';
import React, { Component } from 'react';
import clsx from 'clsx';
import ReactDOM from 'react-dom';
import { createStyles, makeStyles, useTheme, Theme } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import List from '@material-ui/core/List';
import CssBaseline from '@material-ui/core/CssBaseline';
import Typography from '@material-ui/core/Typography';
import Divider from '@material-ui/core/Divider';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import InboxIcon from '@material-ui/icons/MoveToInbox';
import Filter6Icon from '@material-ui/icons/Filter6';
import Dashboard from '@material-ui/icons/Dashboard';
import EventNote from '@material-ui/icons/EventNote';
@ -13,39 +28,174 @@ import EmojiEvents from '@material-ui/icons/EmojiEvents';
import Devices from '@material-ui/icons/Devices';
import Business from '@material-ui/icons/Business'
import AssignmentInd from '@material-ui/icons/AssignmentInd';
import InboxIcon from '@material-ui/icons/MoveToInbox';
import Divider from '@material-ui/core/Divider';
import Forward from '@material-ui/icons/Forward';
import Send from '@material-ui/icons/Send';
import Delete from '@material-ui/icons/Delete';
const drawerWidth = 240;
const useStyles = makeStyles((theme: Theme) =>
createStyles({
root: {
display: 'flex',
},
appBar: {
zIndex: theme.zIndex.drawer + 1,
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
},
appBarShift: {
marginLeft: drawerWidth,
width: `calc(100% - ${drawerWidth}px)`,
transition: theme.transitions.create(['width', 'margin'], {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.enteringScreen,
}),
},
menuButton: {
marginRight: 36,
},
hide: {
display: 'none',
},
drawer: {
width: drawerWidth,
flexShrink: 0,
whiteSpace: 'nowrap',
},
drawerOpen: {
width: drawerWidth,
transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.enteringScreen,
}),
},
drawerClose: {
transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
overflowX: 'hidden',
width: theme.spacing(7) + 1,
[theme.breakpoints.up('sm')]: {
width: theme.spacing(9) + 1,
},
},
toolbar: {
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
padding: theme.spacing(0, 1),
// necessary for content to be below app bar
...theme.mixins.toolbar,
},
content: {
flexGrow: 1,
padding: theme.spacing(3),
},
}),
);
function MiniDrawer() {
const classes = useStyles();
const theme = useTheme();
const [open, setOpen] = React.useState(false);
const handleDrawerOpen = () => {
setOpen(true);
};
const handleDrawerClose = () => {
setOpen(false);
};
const iconsList = [<Dashboard />, <Filter6Icon />, <EventNote />, <Event />, <Class />, <DateRange />, <InsertChart />, <EmojiEvents />, <Devices />, <Business />, <AssignmentInd />];
const iconsListMessages = [<InboxIcon />, <Forward />, <Send />, <Delete />]
return (
<div className={classes.root}>
<CssBaseline />
<AppBar id="bar"
position="fixed"
className={clsx(classes.appBar, {
[classes.appBarShift]: open,
})}
>
<Toolbar>
<IconButton
color="inherit"
aria-label="open drawer"
onClick={handleDrawerOpen}
edge="start"
className={clsx(classes.menuButton, {
[classes.hide]: open,
})}
>
<MenuIcon />
</IconButton>
<Typography variant="h6" noWrap>
Wulkanowy web early access insider preview pre-alpha pre-beta alpha beta release canditate v. 0.0.1
</Typography>
</Toolbar>
</AppBar>
<Drawer anchor="left"
variant="permanent"
className={clsx(classes.drawer, {
[classes.drawerOpen]: open,
[classes.drawerClose]: !open,
})}
classes={{
paper: clsx({
[classes.drawerOpen]: open,
[classes.drawerClose]: !open,
}),
}}>
<div className={classes.toolbar}>
<IconButton onClick={handleDrawerClose}>
{theme.direction === 'rtl' ? <ChevronRightIcon /> : <ChevronLeftIcon />}
</IconButton>
</div>
<Divider />
<List>
{['Start', 'Oceny', 'Plan Lekcji', 'Sprawdziany', 'Zadania Domowe', 'Frekwencja', 'Uczeń na Tle Klasy', 'Uwagi i Osiągnięcia', 'Dostęp Mobilny', 'Szkoła i Nauczyciele', 'Dane Ucznia'].map((text, index) => (
<ListItem button key={text}>
<ListItemIcon>{iconsList[index]}</ListItemIcon>
<ListItemText primary={text} />
</ListItem>
))}
</List>
<Divider />
<List>
{['Odebrane', 'Wysłane', 'Wyślij Wiadomość', 'Usunięte'].map((text, index) => (
<ListItem button key={text}>
<ListItemIcon>{iconsListMessages[index]}</ListItemIcon>
<ListItemText primary={text} />
</ListItem>
))}
</List>
</Drawer>
<main className={classes.content}>
<div className={classes.toolbar} />
<Typography paragraph>
Here is content (in my imagination)
</Typography>
</main>
</div>
);
}
class Content extends Component {
iconsList = [<Dashboard />, <Filter6Icon />, <EventNote />, <Event />, <Class />, <DateRange />, <InsertChart />, <EmojiEvents />, <Devices />, <Business />, <AssignmentInd />];
iconsListMessages = [<InboxIcon />, <Forward />, <Send />, <Delete />]
render() {
return (
<div>
<Drawer anchor="left" variant="permanent">
{['Start', 'Oceny', 'Plan Lekcji', 'Sprawdziany', 'Zadania Domowe', 'Frekwencja', 'Uczeń na Tle Klasy', 'Uwagi i Osiągnięcia', 'Dostęp Mobilny', 'Szkoła i Nauczyciele', 'Dane Ucznia'].map((text, index) => (
<ListItem button key={text}>
<ListItemIcon>{this.iconsList[index]}</ListItemIcon>
<ListItemText primary={text} />
</ListItem>
))}
<Divider />
{['Odebrane', 'Wysłane', 'Wyślij Wiadomość', 'Usunięte'].map((text, index) => (
<ListItem button key={text}>
<ListItemIcon>{this.iconsListMessages[index]}</ListItemIcon>
<ListItemText primary={text} />
</ListItem>
))}
</Drawer>
</div>
<MiniDrawer />
)
}
};
}
export default Content;
export default Content
const content = document.getElementById("content");
render(<Content />, content);
ReactDOM.render(<Content />, content);

View file

@ -1,66 +0,0 @@
/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
/******/ (function() { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/AccountManager.js":
/*!*******************************!*\
!*** ./src/AccountManager.js ***!
\*******************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
eval("__webpack_require__.r(__webpack_exports__);\nObject(function webpackMissingModule() { var e = new Error(\"Cannot find module './components/AccountManager'\"); e.code = 'MODULE_NOT_FOUND'; throw e; }());\n\n\n//# sourceURL=webpack://wulkanowy-web/./src/AccountManager.js?");
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/make namespace object */
/******/ !function() {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ }();
/******/
/************************************************************************/
/******/ // startup
/******/ // Load entry module
/******/ __webpack_require__("./src/AccountManager.js");
/******/ // This entry module used 'exports' so it can't be inlined
/******/ })()
;

View file

@ -1,66 +0,0 @@
/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
/******/ (function() { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/content.js":
/*!************************!*\
!*** ./src/content.js ***!
\************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
eval("__webpack_require__.r(__webpack_exports__);\nObject(function webpackMissingModule() { var e = new Error(\"Cannot find module './components/Content'\"); e.code = 'MODULE_NOT_FOUND'; throw e; }());\n\n\n//# sourceURL=webpack://wulkanowy-web/./src/content.js?");
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/make namespace object */
/******/ !function() {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ }();
/******/
/************************************************************************/
/******/ // startup
/******/ // Load entry module
/******/ __webpack_require__("./src/content.js");
/******/ // This entry module used 'exports' so it can't be inlined
/******/ })()
;

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -76,4 +76,13 @@ body {
margin-right: 10px;
color: blue;
cursor: pointer;
}
}
#bar {
background-color: #d32f2f;
}
.MuiTouchRipple-rippleVisible {
color: #d32f2f !important;
opacity: 100% !important;
}

View file

@ -1,40 +0,0 @@
var cookies_data = JSON.parse(sessionStorage.getItem('cookies_data'));
students = cookies_data.data.students.data;
const displayData = () => {
var primary = '';
students.forEach((student) => {
if (student.UczenNazwisko + ' ' + student.UczenImie2 + ' ' + student.UczenImie + ' ' + student.UczenSymbol != primary) {
primary = student.UczenNazwisko + ' ' + student.UczenImie2 + ' ' + student.UczenImie + ' ' + student.UczenSymbol;
document.querySelector("#content").innerHTML += `<p>
<label>
<input class="with-gap" name="group1" value='`+ student.UczenPelnaNazwa + `' type="radio" checked />
<span>`+ student.UczenPelnaNazwa + `</span>
</label>
</p>`;
}
})
document.querySelector("#content").innerHTML += `<button id="button" class="waves-light waves-effect btn red darken-1">LOGIN</button>`;
const button_ = document.querySelector("#button");
button_.addEventListener('click', logIn);
}
const logIn = () => {
var ele = document.getElementsByName('group1');
for (i = 0; i < ele.length; i++) {
if (ele[i].checked) {
studentName = ele[i].value;
students.forEach((student) => {
if (student.UczenPelnaNazwa == studentName) {
cookies_data.data.students.data = [student];
sessionStorage.setItem('cookies_data', JSON.stringify(cookies_data));
window.location.href = '/content/';
}
})
}
}
}
window.addEventListener('load', displayData)

View file

@ -1,34 +0,0 @@
const attendance_ = document.querySelector('#attendance_');
myStorage = window.sessionStorage;
weekAttendance = 0
const getAttendance = (event) => {
if (event.target.id == 'previous-attendance' || event.target.id == 'previous-attendance_i') {
weekAttendance -= 1
}
else if (event.target.id == 'next-attendance' || event.target.id == 'next-attendance_i') {
weekAttendance += 1
}
document.querySelector('#content').innerHTML = 'Here is attendance (in my imagination)';
document.querySelector('#content').innerHTML += '<button id="previous-attendance" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="previous-attendance_i">keyboard_arrow_left</i></button>';
document.querySelector('#content').innerHTML += '<button id="next-attendance" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="next-attendance_i">keyboard_arrow_right</i></button>';
const left_attendance_ = document.querySelector('#previous-attendance');
const right_attendance_ = document.querySelector('#next-attendance');
left_attendance_.addEventListener('click', getAttendance);
right_attendance_.addEventListener('click', getAttendance);
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/attendance', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: JSON.stringify({"cookies": cookies_data, "week": weekAttendance})
}).then(response => response.json()).then(data => {
console.log(data);
})
}
attendance_.addEventListener('click', getAttendance);

View file

@ -1,22 +0,0 @@
const start_ = document.querySelector('#dashboard_');
const getDashboard = () => {
document.querySelector('#content').innerHTML = 'Dashboard';
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/dashboard', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
console.log(data);
})
}
window.addEventListener('load', getDashboard);
start_.addEventListener('click', getDashboard);

View file

@ -1,35 +0,0 @@
const exams_ = document.querySelector('#exams_');
myStorage = window.sessionStorage;
weekExams = 0
const getExams = (event) => {
if (event.target.id == 'previous-exams' || event.target.id == 'previous-exams_i') {
weekExams -= 1
}
else if (event.target.id == 'next-exams' || event.target.id == 'next-exams_i') {
weekExams += 1
}
document.querySelector('#content').innerHTML = 'Here is exams (in my imagination)';
document.querySelector('#content').innerHTML += '<button id="previous-exams" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="previous-exams_i">keyboard_arrow_left</i></button>';
document.querySelector('#content').innerHTML += '<button id="next-exams" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="next-exams_i">keyboard_arrow_right</i></button>';
const left_exams_ = document.querySelector('#previous-exams');
const right_exams_ = document.querySelector('#next-exams');
left_exams_.addEventListener('click', getExams);
right_exams_.addEventListener('click', getExams);
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/exams', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: JSON.stringify({"cookies": cookies_data, "week": weekExams})
}).then(response => response.json()).then(data => {
console.log(data)
})
}
exams_.addEventListener('click', getExams);

View file

@ -1,101 +0,0 @@
var hash = require('object-hash');
const grades_ = document.querySelector('#grades_');
myStorage = window.sessionStorage;
const getGrades = () => {
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/grades', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
const allGrades = data.data.Oceny
const content = document.getElementById("content")
content.innerHTML = ""
const container = document.getElementsByClassName("gradeModals")[0]
allGrades.forEach((grade) => {
const czastkowe = grade.OcenyCzastkowe
czastkowe.forEach((czastkowa) => {
const gradeDiv = document.createElement("div")
gradeDiv.classList = "grade modal-trigger"
gradeDiv.dataset.target = `${hash.MD5(czastkowa)}`
gradeDiv.innerHTML = `${czastkowa.Wpis}`
switch (czastkowa.Wpis) {
case "6" || "6-":
czastkowa.Kolor = "#3dbbf5"
gradeDiv.style.background = "#3dbbf5"
break;
case "5" || "5-" || "5+":
czastkowa.Kolor = "#4caf50"
gradeDiv.style.background = "#4caf50"
break;
case "4" || "4-" || "4+":
czastkowa.Kolor = "#a0c431"
gradeDiv.style.background = "#a0c431"
break;
case "3" || "3-" || "3+":
czastkowa.Kolor = "#ffb940"
gradeDiv.style.background = "#ffb940"
break;
case "2" || "2-" || "2+":
czastkowa.Kolor = "#ff774d"
gradeDiv.style.background = "#ff774d"
break;
case "1" || "1+":
czastkowa.Kolor = "#d43f3f"
gradeDiv.style.background = "#d43f3f"
break;
default:
czastkowa.Kolor = "#607d8b"
gradeDiv.style.background = "#607d8b"
}
const gradeModal = document.createElement("div")
gradeModal.id = `${hash.MD5(czastkowa)}`
gradeModal.classList = "modal"
gradeModal.style.marginTop = "15rem"
gradeModal.innerHTML = `<div class="modal-content">
<h4>${grade.Przedmiot}</h4>
<h5>${czastkowa.KodKolumny} - ${czastkowa.NazwaKolumny}</h5>
<div style="float: right; background: ${czastkowa.Kolor}; width: 60px; height: 70px; text-align: center;"><h1>${czastkowa.Wpis}</h1></div>
<span class="teacher" style="font-size: 16px;">Nauczyciel</span>
<p>${czastkowa.Nauczyciel}</p>
<span class="weight" style="font-size: 16px;">Waga</span>
<p>${czastkowa.Waga}</p>
<span class="date" style="font-size: 16px;">Data</span>
<p>${czastkowa.DataOceny}</p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-close${hash.MD5(czastkowa)} waves-effect waves-white btn materialize-red">Zamknij</a>
</div>`
gradeDiv.addEventListener('click', () => {
console.log(czastkowa)
gradeModal.style.display = 'block'
})
container.append(gradeModal)
document.getElementsByClassName(`modal-close${hash.MD5(czastkowa)}`)[0].addEventListener('click', () => {
gradeModal.style.display = 'none'
})
content.append(gradeDiv)
})
})
})
}
grades_.addEventListener('click', getGrades);

View file

@ -1,35 +0,0 @@
const homeworks_ = document.querySelector('#homeworks_');
myStorage = window.sessionStorage;
weekHomeworks = 0
const getHomeworks = (event) => {
if (event.target.id == 'previous-homeworks' || event.target.id == 'previous-homeworks_i') {
weekHomeworks -= 1
}
else if (event.target.id == 'next-homeworks' || event.target.id == 'next-homeworks_i') {
weekHomeworks += 1
}
document.querySelector('#content').innerHTML = 'Here is homeworks (in my imagination)';
document.querySelector('#content').innerHTML += '<button id="previous-homeworks" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="previous-homeworks_i">keyboard_arrow_left</i></button>';
document.querySelector('#content').innerHTML += '<button id="next-homeworks" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="next-homeworks_i">keyboard_arrow_right</i></button>';
const left_homeworks_ = document.querySelector('#previous-homeworks');
const right_homeworks_ = document.querySelector('#next-homeworks');
left_homeworks_.addEventListener('click', getHomeworks);
right_homeworks_.addEventListener('click', getHomeworks);
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/homeworks', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: JSON.stringify({"cookies": cookies_data, "week": weekHomeworks})
}).then(response => response.json()).then(data => {
console.log(data);
})
}
homeworks_.addEventListener('click', getHomeworks);

View file

@ -1,20 +0,0 @@
const log_out_ = document.querySelector('#log_out_');
myStorage = window.sessionStorage;
const logOut = () => {
fetch(url = '../api/log_out', {
method: 'GET',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
}
}).then(response => response.json()).then(data => {
sessionStorage.clear();
console.log(data)
window.location.href = '../'
})
}
log_out_.addEventListener('click', logOut)

View file

@ -1,68 +0,0 @@
const button = document.querySelector('#button');
const login = () => {
const loginName = document.querySelector('#id_loginName').value;
const Password = document.querySelector('#id_Password').value;
const symbol = document.querySelector('#id_Symbol').value;
const diary = document.querySelector('#id_diary').value;
button.removeEventListener('click', login)
if(loginName != '' && Password != '' && symbol != ''){
switch(diary){
case 'Fakelog':
var diaryUrl = 'http://cufs.fakelog.cf/';
sessionStorage.setItem('diary_url', 'http://cufs.fakelog.cf/');
break;
case 'Vulcan UONET+':
var diaryUrl = 'https://cufs.vulcan.net.pl/';
sessionStorage.setItem('diary_url', 'https://cufs.vulcan.net.pl/');
break;
}
data = {
'loginName': loginName,
'Password': Password,
'Symbol': symbol,
'diaryUrl': diaryUrl
}
fetch(url = 'api/login', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie()
},
body: JSON.stringify(data)
}).then(response => response.json()).then(data => {
if(data['success']){
myStorage = window.sessionStorage;
sessionStorage.setItem('cookies_data', JSON.stringify(data));
sessionStorage.setItem('csrfcookie', csrfcookie());
sessionStorage.setItem('email', document.querySelector('#id_loginName').value);
sessionStorage.setItem('symbol', document.querySelector('#id_Symbol').value);
window.location.href = "/account-manager/";
}
else{
document.querySelector('#error').innerHTML = 'Nieprawidłowy login, hasło lub symbol';
}
button.addEventListener('click', login);
});
}
};
var csrfcookie = function() {
var cookieValue = null,
name = 'csrftoken';
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
};
button.addEventListener('click', login);

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,257 +0,0 @@
const received_ = document.querySelector('#received_');
const sent_ = document.querySelector('#sent_');
const deleted_ = document.querySelector('#deleted_');
const content = document.getElementById("content");
const send_ = document.querySelector('#send_')
var hash = require('object-hash');
const getReceivedMessages = () => {
content.innerHTML = ""
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/messages/received', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
const wiadomosci = data.data
table = document.createElement("table")
table.className = "striped"
table.innerHTML = "<thead>\n" +
" <tr>\n" +
" <th>Temat</th>\n" +
" <th>Nadawca</th>\n" +
" <th>Data</th>\n" +
" </tr>\n" +
" </thead>" +
" <tbody>" +
" " +
" </tbody>"
content.append(table)
wiadomosci.forEach((wiadomosc) => {
const tbody = document.getElementsByTagName("tbody")[0]
wiadomoscRow = tbody.insertRow()
temat = wiadomoscRow.insertCell()
temat.innerHTML = `<span id="${wiadomosc.Id}">${wiadomosc.Temat}</span>`
wiadomoscRow.appendChild(temat)
nadawca = wiadomoscRow.insertCell()
nadawca.innerHTML = `<span>${wiadomosc.Nadawca.Name}</span>`
wiadomoscRow.appendChild(nadawca)
dataWyslania = wiadomoscRow.insertCell()
dataWyslania.innerHTML = `<span>${wiadomosc.Data}</span>`
wiadomoscRow.appendChild(dataWyslania)
document.getElementById(wiadomosc.Id).addEventListener('click', getMessageContent);
})
})
}
const getSentMessages = () => {
content.innerHTML = ""
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/messages/sent', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
const wiadomosci = data.data // haha spaghetti code goes brrr
table = document.createElement("table")
table.className = "striped"
table.innerHTML = "<thead>\n" +
" <tr>\n" +
" <th>Temat</th>\n" +
" <th>Adresat</th>\n" +
" <th>Data</th>\n" +
" </tr>\n" +
" </thead>" +
" <tbody>" +
" " +
" </tbody>"
content.append(table)
wiadomosci.forEach((wiadomosc) => {
const tbody = document.getElementsByTagName("tbody")[0]
wiadomoscRow = tbody.insertRow()
temat = wiadomoscRow.insertCell()
temat.innerHTML = `<span id="${wiadomosc.Id}">${wiadomosc.Temat}</span>`
wiadomoscRow.appendChild(temat)
nadawca = wiadomoscRow.insertCell()
nadawca.innerHTML = `<span>${wiadomosc.Adresaci[0]}</span>`
wiadomoscRow.appendChild(nadawca)
dataWyslania = wiadomoscRow.insertCell()
dataWyslania.innerHTML = `<span>${wiadomosc.Data}</span>`
wiadomoscRow.appendChild(dataWyslania)
document.getElementById(wiadomosc.Id).addEventListener('click', getMessageContent);
})
})
}
const getDeletedMessages = () => {
content.innerHTML = ""
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/messages/deleted', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
const wiadomosci = data.data
table = document.createElement("table")
table.className = "striped"
table.innerHTML = "<thead>\n" +
" <tr>\n" +
" <th>Temat</th>\n" +
" <th>Nadawca</th>\n" +
" <th>Data</th>\n" +
" </tr>\n" +
" </thead>" +
" <tbody>" +
" " +
" </tbody>"
content.append(table)
wiadomosci.forEach((wiadomosc) => {
const tbody = document.getElementsByTagName("tbody")[0]
wiadomoscRow = tbody.insertRow()
temat = wiadomoscRow.insertCell()
temat.innerHTML = `<span id="${wiadomosc.Id}">${wiadomosc.Temat}</span>`
wiadomoscRow.appendChild(temat)
nadawca = wiadomoscRow.insertCell()
nadawca.innerHTML = `<span>${wiadomosc.Nadawca.Name}</span>`
wiadomoscRow.appendChild(nadawca)
dataWyslania = wiadomoscRow.insertCell()
dataWyslania.innerHTML = `<span>${wiadomosc.Data}</span>`
wiadomoscRow.appendChild(dataWyslania)
document.getElementById(wiadomosc.Id).addEventListener('click', getMessageContent);
})
})
}
const getAddressee = () => {
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/messages/recipients', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
console.log(data);
document.querySelector('#content').innerHTML = `
<form action="javascript:void(0);">
<div class="input-field">
<select id='recipients' style='display: inline !important;'>
</select>
</div>
<div class="input-field">
<input required="" placeholder="Temat" id="subject" class="input-field">
</div>
<div class="input-field">
<input required="" placeholder="Treść" id="message-content" class="input-field">
</div>
<button id="button" class="waves-light waves-effect btn red darken-1">WYŚLIJ</button>
</form>`
data.addressee.data.forEach((recipient) => {
const recipient_hash = `${hash.MD5(recipient)}`
document.querySelector('#recipients').insertAdjacentHTML('beforeend', '<option value="'+recipient_hash+'">'+recipient.Name+'</option>');
sessionStorage.setItem(recipient_hash, JSON.stringify(recipient));
const button_ = document.querySelector('#button');
button_.addEventListener('click', sendMessage);
})
})
}
const sendMessage = () => {
const recipient_hash_ = document.querySelector('#recipients').value;
const subject_ = document.querySelector('#subject').value;
const content_ = document.querySelector('#message-content').value;
const recipient_ = JSON.parse(sessionStorage.getItem(recipient_hash_));
if(subject_ != '' && content_ != ''){
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
send_data = {
'cookies_data': cookies_data,
'data': recipient_,
'subject': subject_,
'content': content_
}
console.log(cookies_data)
console.log(recipient_)
fetch(url = '../api/messages/send', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: JSON.stringify(send_data)
}).then(response => response.json()).then(data => {
console.log(data)
})
}
}
const getMessageContent = (event) => {
send_data = {
'cookies_data': cookies_data,
'message_id': event.target.id
}
fetch(url = '../api/messages/content', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: JSON.stringify(send_data)
}).then(response => response.json()).then(data => {
console.log(data)
})
}
received_.addEventListener('click', getReceivedMessages);
sent_.addEventListener('click', getSentMessages);
deleted_.addEventListener('click', getDeletedMessages);
send_.addEventListener('click', getAddressee);

View file

@ -1,41 +0,0 @@
const registered_ = document.querySelector('#mobile_access_');
myStorage = window.sessionStorage;
const getRegisteredDevices = () => {
document.querySelector('#content').innerHTML = '<button id="register_device_">ZAJERESTRUJ URZĄDZENIE</button><div id="register_device_data"></div><br />Here is registered mobile devices (in my imagination)';
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/mobile/registered', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
console.log(data);
const register_device_ = document.querySelector('#register_device_');
register_device_.addEventListener('click', registerDevice);
})
}
const registerDevice = () => {
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/mobile/register', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
console.log(data);
document.querySelector('#register_device_data').innerHTML = data.data.QrCodeImage+'<br /> TOKEN:'+data.data.TokenKey+'<br /> PIN:'+data.data.PIN+'<br /> SYMBOL:'+data.data.CustomerGroup;
})
}
registered_.addEventListener('click', getRegisteredDevices);

View file

@ -1,41 +0,0 @@
const notes_ = document.querySelector('#notes_');
content = document.getElementById("content")
myStorage = window.sessionStorage;
const getNotes = () => {
content.innerHTML = ""
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/notes', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
const uwagi = data.data.Uwagi
const osiagniecia = data.data.Osiagniecia
console.log(data);
const uwagiList = document.createElement("ul")
uwagiList.id = "notesList"
content.append(uwagiList)
uwagi.forEach((uwaga) => {
uwagaElement = document.createElement("li")
uwagaElement.innerHTML = `<div class="noteElement"><h6 style="display:block; margin-top: -5px;">${uwaga.Kategoria}</h6><span style="display:block; float: right; margin-top: -25px; font-size: 13px;">${uwaga.Nauczyciel}</span><span style="display:block; width: 50%; font-size: 12px;">${uwaga.TrescUwagi}</span><span style="float:right; font-size: 20px; margin-top: -20px; font-weight: 700;">${uwaga.Punkty}</span></div>`
uwagiList.append(uwagaElement)
})
osiagniecia.forEach((osiagniecie) => {
osiagniecieElement = document.createElement("li")
osiagniecieElement.innerHTML = `<div class="achievementElement"><span>${osiagniecie}</span></div>`
uwagiList.append(osiagniecieElement)
})
})
}
notes_.addEventListener('click', getNotes);

View file

@ -1,22 +0,0 @@
const school_data = document.querySelector('#school_data_');
myStorage = window.sessionStorage;
const getSchoolData = () => {
document.querySelector('#content').innerHTML = 'Here is school data (in my imagination)';
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/school_data', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
console.log(data);
})
}
school_data_.addEventListener('click', getSchoolData);

View file

@ -1,16 +0,0 @@
const name_ = document.querySelector('#name');
const email_ = document.querySelector('#email');
myStorage = window.sessionStorage;
const studentName = () => {
const cookies_data = JSON.parse(sessionStorage.getItem('cookies_data'))
name_.innerHTML = cookies_data['data']['students']['data'][0]['UczenImie']+' '+cookies_data['data']['students']['data'][0]['UczenImie2']+' '+cookies_data['data']['students']['data'][0]['UczenNazwisko']
};
const studentEmail = () => {
email_.innerHTML = sessionStorage.getItem('email')
};
window.addEventListener('load', studentName);
window.addEventListener('load', studentEmail);

View file

@ -1,46 +0,0 @@
const stats_ = document.querySelector('#stats_');
myStorage = window.sessionStorage;
const showMenu = () => {
document.querySelector('#content').innerHTML = '<button id="partial" class="waves-light waves-effect btn red darken-1">OCENY CZĄSTKOWE</button>';
document.querySelector('#content').innerHTML += '<button id="year" class="waves-light waves-effect btn red darken-1">OCENY ROCZNE</button>';
const partial_ = document.querySelector('#partial');
const year_ = document.querySelector('#year');
partial_.addEventListener('click', getPartial);
year_.addEventListener('click', getYear);
}
const getPartial = () => {
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/stats/partial', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
console.log(data)
})
}
const getYear = () => {
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/stats/year', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
console.log(data)
})
}
stats_.addEventListener('click', showMenu);

View file

@ -1,22 +0,0 @@
const student_data_ = document.querySelector('#student_data_');
myStorage = window.sessionStorage;
const getStudentData = () => {
document.querySelector('#content').innerHTML = 'Here is student data (in my imagination)';
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/student_data', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: cookies_data
}).then(response => response.json()).then(data => {
console.log(data)
})
}
student_data_.addEventListener('click', getStudentData)

View file

@ -1,35 +0,0 @@
const timetable_ = document.querySelector('#timetable_');
myStorage = window.sessionStorage;
weekTimetable = 0
const getTimetable = (event) => {
if (event.target.id == 'previous-timetable' || event.target.id == 'previous-timetable_i') {
weekTimetable -= 1
}
else if (event.target.id == 'next-timetable' || event.target.id == 'next-timetable_i') {
weekTimetable += 1
}
document.querySelector('#content').innerHTML = 'Here is timetable (in my imagination)';
document.querySelector('#content').innerHTML += '<button id="previous-timetable" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="previous-timetable_i">keyboard_arrow_left</i></button>';
document.querySelector('#content').innerHTML += '<button id="next-timetable" class="waves-light waves-effect btn red darken-1"><i class="material-icons" id="next-timetable_i">keyboard_arrow_right</i></button>';
const left_timetable_ = document.querySelector('#previous-timetable');
const right_timetable_ = document.querySelector('#next-timetable');
left_timetable_.addEventListener('click', getTimetable);
right_timetable_.addEventListener('click', getTimetable);
cookies_data = sessionStorage.getItem('cookies_data');
csrfcookie_ = sessionStorage.getItem('csrfcookie');
fetch(url = '../api/timetable', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrfcookie_
},
body: JSON.stringify({"cookies": cookies_data, "week": weekTimetable})
}).then(response => response.json()).then(data => {
console.log(data)
})
}
timetable_.addEventListener('click', getTimetable);

View file

@ -1,66 +0,0 @@
/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
/******/ (function() { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/login.js":
/*!**********************!*\
!*** ./src/login.js ***!
\**********************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
eval("__webpack_require__.r(__webpack_exports__);\nObject(function webpackMissingModule() { var e = new Error(\"Cannot find module './components/App'\"); e.code = 'MODULE_NOT_FOUND'; throw e; }());\n\n\n//# sourceURL=webpack://wulkanowy-web/./src/login.js?");
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/make namespace object */
/******/ !function() {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ }();
/******/
/************************************************************************/
/******/ // startup
/******/ // Load entry module
/******/ __webpack_require__("./src/login.js");
/******/ // This entry module used 'exports' so it can't be inlined
/******/ })()
;

View file

@ -5,12 +5,13 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="{% static 'frontend/css/start.css' %}" />
<title>Wulkanowy | Aplikacja ucznia i rodzica</title>
</head>
<body>
<div id="content">
</div>
<script src={% static 'frontend/content.js' %}></script>
<script src="{% static 'frontend/content.js' %}"></script>
</body>
</html>