1
0
Fork 0

Fix logout adn dynamic permission view

This commit is contained in:
Ethanell 2021-01-21 11:06:24 +01:00
parent c8e156dc72
commit a9643c7feb
13 changed files with 38 additions and 50 deletions

View file

@ -1,4 +1,3 @@
const socket = io.connect();
const date = document.getElementById("date");
const details = document.getElementById("details");
const marksdetailsbackground = document.getElementById("marksdetailsbackground");

View file

@ -1,5 +1,3 @@
const socket = io.connect();
socket.on("agendaGet", data => {
document.querySelectorAll(".eventName, .eventLocation").forEach(p => p.innerHTML = "");
data.forEach(event => {

View file

@ -1,5 +1,3 @@
let socket = io.connect();
document.getElementById("login").addEventListener("submit", e=>{
e.preventDefault();
let expressionReguliere = /^(([^<>()[]\.,;:s@]+(.[^<>()[]\.,;:s@]+)*)|(.+))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;

View file

@ -1,10 +1,12 @@
let socket = io.connect();
const socket = io.connect();
/*
Front-end Event
*/
// Disconnect
document.getElementById("logout").addEventListener("click", function() {
socket.emit("logout")
document.addEventListener("DOMContentLoaded", () => {
const logout = document.getElementById("logout");
if (logout)
logout.addEventListener("click", () => socket.emit("logout"));
});

View file

@ -1,4 +1,3 @@
const socket = io.connect();
const marks = document.getElementById("marksrow");
const evaluationTemplate = marks.querySelector("#evaluationTemplate");
const gradeTemplate = marks.querySelector("#gradeTemplate");

View file

@ -1,4 +1,3 @@
const socket = io.connect();
const group = document.getElementById("group");
const evaluation = document.getElementById("evaluation");
const marksform = document.getElementById("marksform");

View file

@ -1,5 +1,3 @@
let socket = io.connect();
document.getElementById("editprofil").addEventListener("submit", e=>{
e.preventDefault();
socket.emit("profileEdit", {

View file

@ -1,5 +1,3 @@
let socket = io.connect();
document.getElementById("register").addEventListener("submit", e=>{
e.preventDefault();
let expressionReguliere = /^(([^<>()[]\.,;:s@]+(.[^<>()[]\.,;:s@]+)*)|(.+))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;

View file

@ -247,11 +247,11 @@ h3
div:nth-child(3)
text-align: left
#marksrow
padding: 20px 70px
#logout, #logout>a
cursor: pointer
#marksdetails, #details
z-index: 100001

View file

@ -1,12 +1,6 @@
doctype html
html
head
title= title
link(href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet")
link(rel="stylesheet", href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css")
link(rel="stylesheet", href="/stylesheets/style.css")
script(src="/socket.io/socket.io.js")
body
extends ../template/layout
block content
div(class='row main-form')
div(class='col s12 m8 offset-m2 signinup z-depth-5' id="signin")
h2 Welcome back
@ -37,4 +31,3 @@ html
input(type='submit' value='Send email')
script(src="/javascripts/login.js")
script(src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js")

View file

@ -1,12 +1,6 @@
doctype html
html
head
title= title
link(href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet")
link(rel="stylesheet", href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css")
link(rel="stylesheet", href="/stylesheets/style.css")
script(src="/socket.io/socket.io.js")
body
extends ../template/layout
block content
div(class='row main-form')
div(class='col s12 m8 offset-m2 signinup z-depth-5' id="signup")
h2 Welcome
@ -34,4 +28,3 @@ html
a(class="alreadyregister" href="login") Already registered ?
script(src="/javascripts/register.js")
script(src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js")

View file

@ -14,15 +14,26 @@ html
meta(name="msapplication-TileColor" content="#da532c")
meta(name="theme-color" content="#ffffff")
script(src="/socket.io/socket.io.js")
script(src="/javascripts/main.js")
body
- var student = false;
- var teacher = true;
- var admin = false;
-
var student = false, teacher = false, admin = false;
if (session.user) {
switch (session.user.permissions) {
case 1:
student = true;
break;
case 2:
teacher = true;
break;
case 3:
admin = true;
}
}
div(class="row" id="page")
block navbar
div(class="col s12" id="main")
block content
script(src="/javascripts/main.js")
script(src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js")
script.
M.AutoInit();

View file

@ -2,7 +2,7 @@ extends layout
block navbar
ul#slide-out.sidenav
if session.user.permissions === 1
if student
li
.user-view.student
p
@ -12,8 +12,8 @@ block navbar
span.white-text.name=session.user.Groups[session.user.Groups.length-1].displayName
p
span.white-text.email=session.user.email
a
span.white-text Se déconnecter
a#logout
span.white-text Logout
li
a(href="/" class="waves-effect") Home
@ -28,15 +28,15 @@ block navbar
li
a(href="/viescol" class="waves-effect") School and student life
if session.user.permissions === 2
else if teacher
li
.user-view.teacher
p(href='#name')
span.white-text.name=session.user.firstName + " " + session.user.lastName
p(href='#email')
span.white-text.email=session.user.email
a
span.white-text Se déconnecter
a#logout
span.white-text Logout
li
a(href="/" class="waves-effect") Home
li
@ -50,15 +50,15 @@ block navbar
li
a(href="/viescol" class="waves-effect") School and student life
if session.user.permissions === 3
else if admin
li
.user-view.admin
p(href='#name')
span.white-text.name=session.user.firstName + " " + session.user.lastName
p(href='#email')
span.white-text.email=session.user.email
a
span.white-text Se déconnecter
a#logout
span.white-text Logout
li
a(href="/" class="waves-effect") Home
li(class="active")