parent
f6b2adce48
commit
173489a29a
Binary file not shown.
@ -0,0 +1,73 @@
|
||||
package com.rotanareg.skolan.AssociatedPersist;
|
||||
|
||||
import com.rotanareg.skolan.coursePersist.CourseEntity;
|
||||
import com.rotanareg.skolan.userPersist.UserEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* Created by Nils Gerstner on 2017-08-31.
|
||||
*/
|
||||
|
||||
@Entity
|
||||
@Table(name="COURSE_USER")
|
||||
@IdClass(CourseUserAssociationId.class)
|
||||
public class CourseUserAssociation {
|
||||
|
||||
@Id
|
||||
private long courseId;
|
||||
@Id
|
||||
private long personId;
|
||||
|
||||
@Column(name="IS_TEACHER")
|
||||
private boolean isTeacher;
|
||||
|
||||
@ManyToOne
|
||||
@PrimaryKeyJoinColumn(name="COURSEID", referencedColumnName = "ID")
|
||||
private CourseEntity course;
|
||||
@ManyToOne
|
||||
@PrimaryKeyJoinColumn(name="PERSONID", referencedColumnName = "ID")
|
||||
|
||||
private UserEntity person;
|
||||
|
||||
public long getCourseId() {
|
||||
return courseId;
|
||||
}
|
||||
|
||||
public void setCourseId(Long courseId) {
|
||||
this.courseId = courseId;
|
||||
}
|
||||
|
||||
public long getPersonId() {
|
||||
return personId;
|
||||
}
|
||||
|
||||
public void setPersonId(Long personId) {
|
||||
this.personId = personId;
|
||||
}
|
||||
|
||||
public boolean isTeacher() {
|
||||
return isTeacher;
|
||||
}
|
||||
|
||||
public void setTeacher(boolean teacher) {
|
||||
isTeacher = teacher;
|
||||
}
|
||||
|
||||
public CourseEntity getCourse() {
|
||||
return course;
|
||||
}
|
||||
|
||||
public void setCourse(CourseEntity course) {
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public UserEntity getPerson() {
|
||||
return person;
|
||||
}
|
||||
|
||||
public void setPerson(UserEntity person) {
|
||||
this.person = person;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.rotanareg.skolan.AssociatedPersist;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by Nils Gerstner on 2017-08-31.
|
||||
*/
|
||||
public class CourseUserAssociationId implements Serializable {
|
||||
private long personId;
|
||||
private long courseId;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) (personId + courseId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof CourseUserAssociationId) {
|
||||
CourseUserAssociationId otherId = (CourseUserAssociationId) o;
|
||||
return (otherId.personId == this.personId) && (otherId.courseId == this.courseId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
/******************************
|
||||
* JSF - Managed-Bean, hämta info till/från xhtml filen. (Mellan Back och Front -end.)
|
||||
******************************/
|
||||
|
||||
//TODO: inkludera logik
|
||||
|
||||
package com.rotanareg.skolan;
|
||||
|
||||
import com.rotanareg.skolan.attendancePersist.*;
|
||||
import com.rotanareg.skolan.domains.*;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.RequestScoped;
|
||||
import java.sql.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Marko K. Seppänen.
|
||||
*/
|
||||
@ManagedBean
|
||||
@RequestScoped
|
||||
public class AttendanceBean {
|
||||
private Long id;
|
||||
// private Course course;
|
||||
// private User user;
|
||||
private Date sqlDate; //yyyy-mm-dd
|
||||
private boolean hasAttended;
|
||||
|
||||
@EJB
|
||||
AttendanceService aService;
|
||||
|
||||
public String addCourse() {
|
||||
if (getId() == null) {
|
||||
aService.addAttendance(new AttendanceDomain(getDate(), isHasAttended()));
|
||||
}else {
|
||||
// Update
|
||||
// aService.updateCourse(new AttendanceDomain(getId(), getDate(), isHasAttended()));
|
||||
}
|
||||
|
||||
setId(null);
|
||||
setDate(null);
|
||||
setHasAttended(false);
|
||||
return "stats_test";
|
||||
}
|
||||
/*
|
||||
public String editCourse(Long id) {
|
||||
CourseDomain courseDomain = courseService.getCourse(id);
|
||||
setId(courseDomain.getId());
|
||||
setName(courseDomain.getName());
|
||||
setCode(courseDomain.getCode());
|
||||
return "course";
|
||||
}
|
||||
|
||||
public String removeCourse(Long id) {
|
||||
courseService.removeCourse(id);
|
||||
return "course";
|
||||
}
|
||||
*/
|
||||
public List<AttendanceDomain> getAttendances() {
|
||||
return aService.getAttendances();
|
||||
}
|
||||
/*
|
||||
public List<CourseDomain> getCoursesFilter() {
|
||||
if (myFilter == null || myFilter.equals(""))
|
||||
return courseService.getCourses();
|
||||
else
|
||||
return courseService.getCoursesNameContain(myFilter);
|
||||
}
|
||||
*/
|
||||
public String getSubmitButton() {
|
||||
if (id == null)
|
||||
return "Add";
|
||||
else
|
||||
return "Update";
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return sqlDate;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.sqlDate = date;
|
||||
}
|
||||
|
||||
public boolean isHasAttended() {
|
||||
return hasAttended;
|
||||
}
|
||||
|
||||
public void setHasAttended(boolean hasAttended) {
|
||||
this.hasAttended = hasAttended;
|
||||
}
|
||||
|
||||
public AttendanceService getCourseService() {
|
||||
return aService;
|
||||
}
|
||||
|
||||
public void setCourseService(AttendanceService courseService) {
|
||||
this.aService = courseService;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.rotanareg.skolan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rotanareg.skolan.domains.User;
|
||||
import com.rotanareg.skolan.userPersist.*;
|
||||
import javax.ejb.EJB;
|
||||
import javax.faces.bean.ManagedBean;
|
||||
import javax.faces.bean.RequestScoped;
|
||||
|
||||
|
||||
@ManagedBean
|
||||
@RequestScoped
|
||||
public class UserBean {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String lastName;
|
||||
private Role role;
|
||||
private String passWord;
|
||||
@EJB
|
||||
UserService userService;
|
||||
|
||||
public String addUser(){
|
||||
if (getId()==null)
|
||||
userService.addUser(new User(name,lastName,role));
|
||||
else
|
||||
userService.addUser(new User(getId(),getName(),getLastName(),getRole(),getPassWord()));
|
||||
|
||||
setId(null);
|
||||
setName("");
|
||||
setLastName("");
|
||||
setRole(null);
|
||||
setPassWord("");
|
||||
return "user";
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public Role getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(Role role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getPassWord() {
|
||||
return passWord;
|
||||
}
|
||||
|
||||
public void setPassWord(String passWord) {
|
||||
this.passWord = passWord;
|
||||
}
|
||||
|
||||
public UserService getUserService() {
|
||||
return userService;
|
||||
}
|
||||
|
||||
public void setUserService(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
public UserService getUsers(){
|
||||
return userService;
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/******************************
|
||||
* JPA Entity class defines whose instances can be stored in the database.
|
||||
* The Entity represents your Data Object Model.
|
||||
******************************/
|
||||
|
||||
package com.rotanareg.skolan.attendancePersist;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
//import java.util.*;
|
||||
import java.sql.Date;
|
||||
import java.text.DateFormat.*;
|
||||
import java.text.*;
|
||||
|
||||
/**
|
||||
* Created by Marko K. Seppänen.
|
||||
*/
|
||||
/*@NamedQueries({
|
||||
@NamedQuery(name = "selectAll", query = "SELECT p FROM Course p"),
|
||||
@NamedQuery(name = "selectSome", query = "SELECT t FROM Course t WHERE LOCATE(:filt,t.name) >0 ")
|
||||
})*/
|
||||
@Entity
|
||||
@Table(name = "Attendance")
|
||||
@NamedQueries({
|
||||
@NamedQuery(name = "selectAll", query = "SELECT p FROM AttendanceEntity p"),
|
||||
//@NamedQuery(name = "selectSome", query = "SELECT t FROM AttendanceEntity t WHERE LOCATE(:filt,t.name) >0 ")
|
||||
})
|
||||
public class AttendanceEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
//@NotNull
|
||||
//private Long courseId;
|
||||
/* private CourseEntity course;
|
||||
|
||||
//@NotNull
|
||||
//private Long userId;
|
||||
private UserEntity user;
|
||||
*/
|
||||
////@Temporal(TemporalType.DATE)
|
||||
////@DateFormat(format = "yyyy-MM-dd")
|
||||
//@NotNull
|
||||
private Date sqlDate; //yyyy-mm-dd
|
||||
private boolean hasAttended;
|
||||
|
||||
public AttendanceEntity() {
|
||||
}
|
||||
|
||||
public AttendanceEntity(Date date, boolean hasAttended) {
|
||||
this.sqlDate = date;
|
||||
this.hasAttended = hasAttended;
|
||||
}
|
||||
|
||||
/* public AttendanceEntity(CourseEntity course, UserEntity user, Date sqlDate, boolean hasAttended) {
|
||||
this.course = course;
|
||||
this.user = user;
|
||||
this.sqlDate = sqlDate;
|
||||
this.hasAttended = hasAttended;
|
||||
}
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/* public CourseEntity getCourse() {
|
||||
return course;
|
||||
}
|
||||
|
||||
public void setCourse(CourseEntity course) {
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public UserEntity getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(UserEntity user) {
|
||||
this.user = user;
|
||||
}
|
||||
*/
|
||||
public Date getDate() {
|
||||
return sqlDate;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.sqlDate = date;
|
||||
}
|
||||
|
||||
public boolean isHasAttended() {
|
||||
return hasAttended;
|
||||
}
|
||||
|
||||
public void setHasAttended(boolean hasAttended) {
|
||||
this.hasAttended = hasAttended;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/******************************
|
||||
* EJB - Interface för våran tjänst ("kontrakt" för varje EJB att följa om den vill stödja tjänsten för Attendance)
|
||||
******************************/
|
||||
|
||||
package com.rotanareg.skolan.attendancePersist;
|
||||
|
||||
import com.rotanareg.skolan.domains.*;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Marko K. Seppänen.
|
||||
*/
|
||||
@Local
|
||||
public interface AttendanceService {
|
||||
|
||||
// (C)reate / add.
|
||||
void addAttendance(AttendanceDomain attendance);
|
||||
/*
|
||||
// (R)ead / get.
|
||||
AttendanceDomain getAttendance(Long id);
|
||||
|
||||
// (U)pdate.
|
||||
void updateAttendance(AttendanceDomain attendance);
|
||||
|
||||
// (D)elete.
|
||||
void deleteAttendance(Long id);
|
||||
*/
|
||||
|
||||
List<AttendanceDomain> getAttendances();
|
||||
/*
|
||||
public List<CourseDomain> getCoursesNameContain(String filter);
|
||||
*/
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
/******************************
|
||||
* EJB - Enterprise bean (EJB), som stödjer tjänsten AttendanceService.
|
||||
******************************/
|
||||
|
||||
package com.rotanareg.skolan.attendancePersist;
|
||||
|
||||
import com.rotanareg.skolan.domains.*;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
import java.sql.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by Marko K. Seppänen.
|
||||
*/
|
||||
@Stateless
|
||||
public class AttendanceServiceImpl implements AttendanceService {
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
// (C)reate / add.
|
||||
@Override
|
||||
public void addAttendance(AttendanceDomain ad){
|
||||
AttendanceEntity dom = new AttendanceEntity(ad.getDate(), ad.isHasAttended()); // Create the Data Object Model
|
||||
em.persist(dom);
|
||||
}
|
||||
|
||||
// (R)ead / get.
|
||||
/* @Override
|
||||
public AttendanceDomain getAttendance(Long id){
|
||||
Course c = em.find(Course.class, id);
|
||||
return new CourseDomain(c.getId(), c.getName(), c.getCode());
|
||||
}
|
||||
|
||||
// (U)pdate.
|
||||
@Override
|
||||
public void updateAttendance(AttendanceDomain attendance){
|
||||
Course c = em.find(Course.class, course.getId());
|
||||
c.setName(course.getName());
|
||||
c.setCode(course.getCode());
|
||||
em.merge(c);
|
||||
|
||||
}
|
||||
|
||||
// (D)elete.
|
||||
@Override
|
||||
public void deleteAttendance(Long id){
|
||||
Course c = em.find(Course.class, id);
|
||||
em.remove(c);
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public List<AttendanceDomain> getAttendances() {
|
||||
/*Query query = em.createQuery("select a from Course a where a.code = :lname and a.name = :fname", Course.class);
|
||||
query.setParameter("lname", "Karlsson");
|
||||
query.setParameter("fname", "Kalle");
|
||||
*/
|
||||
/*Query query = em.createQuery("select a from Attendance a where a.code = :lname and a.name = :fname", AttendanceEntity.class);
|
||||
query.setParameter("lname", "Karlsson");
|
||||
query.setParameter("fname", "Kalle");
|
||||
*/
|
||||
//List<CourseEntity> courseEntityList = em.createNamedQuery("selectAllCourses").getResultList();
|
||||
|
||||
/*
|
||||
List<AttendanceEntity> courseRecords = query.getResultList();
|
||||
System.out.println("course Size " + courseRecords.size());
|
||||
*/
|
||||
|
||||
List<AttendanceEntity> l = em.createNamedQuery("selectAll").getResultList();
|
||||
|
||||
return l.stream().
|
||||
map(a -> new AttendanceDomain(a.getId(), a.getDate(), a.isHasAttended())).
|
||||
collect(Collectors.toList());
|
||||
}
|
||||
/*
|
||||
@Override
|
||||
public List<CourseDomain> getCoursesNameContain(String filter) {
|
||||
|
||||
List<Course> l = em.createNamedQuery("selectSome").setParameter("filt", filter).getResultList();
|
||||
|
||||
return l.stream().
|
||||
map(p -> new CourseDomain(p.getId(), p.getName(), p.getCode())).
|
||||
collect(Collectors.toList());
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/******************************
|
||||
* POJO - Mellanskikt mellan AttendanceBean (vanlig böna) och EJB (Enterprise-böna), samt JPA (transformerings-klass).
|
||||
* Inkapslings-klass (hjälp-klass) för att underlätta transporten av data mellan objekt.
|
||||
******************************/
|
||||
|
||||
package com.rotanareg.skolan.domains;
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
/**
|
||||
* Created by Marko K. Seppänen.
|
||||
*/
|
||||
public class AttendanceDomain {
|
||||
private Long id;
|
||||
// private Course course;
|
||||
// private User user;
|
||||
private Date sqlDate; //yyyy-mm-dd
|
||||
private boolean hasAttended;
|
||||
|
||||
public AttendanceDomain(Date date, boolean hasAttended) {
|
||||
this.sqlDate = date;
|
||||
this.hasAttended = hasAttended;
|
||||
}
|
||||
|
||||
public AttendanceDomain(Long id, Date date, boolean hasAttended) {
|
||||
this.id = id;
|
||||
this.sqlDate = date;
|
||||
this.hasAttended = hasAttended;
|
||||
}
|
||||
|
||||
/* public AttendanceDomain(Long id, Course course, User user, Date date, boolean hasAttended) {
|
||||
this.id = id;
|
||||
this.courseId = courseId;
|
||||
this.userId = userId;
|
||||
this.sqlDate = date;
|
||||
this.hasAttended = hasAttended;
|
||||
}
|
||||
*/
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/* public Course getCourse() {
|
||||
return course;
|
||||
}
|
||||
|
||||
public void setCourse(Course course) {
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
*/
|
||||
public Date getDate() {
|
||||
return sqlDate;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.sqlDate = sqlDate;
|
||||
}
|
||||
|
||||
public boolean isHasAttended() {
|
||||
return hasAttended;
|
||||
}
|
||||
|
||||
public void setHasAttended(boolean hasAttended) {
|
||||
this.hasAttended = hasAttended;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.rotanareg.skolan.signIn;
|
||||
|
||||
import javax.enterprise.context.SessionScoped;
|
||||
import javax.inject.Named;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by Nils Gerstner on 2017-09-01.
|
||||
*/
|
||||
|
||||
@Named
|
||||
@SessionScoped
|
||||
public class LoggedIn implements Serializable {
|
||||
private Long id = null;
|
||||
|
||||
public LoggedIn() {
|
||||
}
|
||||
|
||||
public LoggedIn(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.rotanareg.skolan.signIn;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
import javax.enterprise.context.*;
|
||||
import javax.inject.*;
|
||||
|
||||
import com.rotanareg.skolan.userPersist.UserService;
|
||||
|
||||
@Named
|
||||
@RequestScoped
|
||||
public class SignIn {
|
||||
|
||||
@Inject
|
||||
private LoggedIn loggedIn;
|
||||
|
||||
@EJB
|
||||
private UserService us;
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void submit() {
|
||||
if (us.getUserContaining(username).get(0).getPassWord().equals(password)){
|
||||
this.loggedIn = new LoggedIn(us.getUserContaining(username).get(0).getId());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean loggedIn(){
|
||||
if (loggedIn != null)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void logout(){
|
||||
this.loggedIn = null;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.rotanareg.skolan.user;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
public class DateB {
|
||||
|
||||
public static Date date(String s) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
||||
try {
|
||||
return dateFormat.parse(s);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.admin.admindomain;
|
||||
|
||||
public class AdminDomain {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.admin.adminejb;
|
||||
|
||||
public class AdminService {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.admin.adminejb;
|
||||
|
||||
public class AdminServiceImpl {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.admin.adminjpa;
|
||||
|
||||
public class Admin {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.admin.adminjsf;
|
||||
|
||||
public class AdminBean {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.student.studentdomain;
|
||||
|
||||
public class StudentDomain {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.student.studentejb;
|
||||
|
||||
public class StudentService {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.student.studentejb;
|
||||
|
||||
public class StudentServiceImpl {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.student.studentjpa;
|
||||
|
||||
public class Student {
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package com.rotanareg.skolan.user.student.studentjsf;
|
||||
|
||||
public class StudentBean {
|
||||
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.teacher.teacherdomain;
|
||||
|
||||
public class TeacherDomain {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.teacher.teacherejb;
|
||||
|
||||
public class TeacherServiceImpl {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.teacher.teacherejb;
|
||||
|
||||
public class TeaherService {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.teacher.teacherjpa;
|
||||
|
||||
public class Teacher {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.rotanareg.skolan.user.teacher.teacherjsf;
|
||||
|
||||
public class TeacherBean {
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.rotanareg.skolan.userManager;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
public class EmailAddressValidator implements ConstraintValidator<ValidEmailAddress, String> {
|
||||
|
||||
@Override
|
||||
public void initialize(ValidEmailAddress constraintAnnotation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext context) {
|
||||
return value == null || value.equals("") || value.contains("@");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
package com.rotanareg.skolan.userManager;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class PhoneNumber implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String countryCode;
|
||||
private String subscriberNumber;
|
||||
|
||||
public String getCountryCode() {
|
||||
return countryCode;
|
||||
}
|
||||
|
||||
public void setCountryCode(String countryCode) {
|
||||
this.countryCode = countryCode;
|
||||
}
|
||||
|
||||
|
||||
public String getSubscriberNumber() {
|
||||
return subscriberNumber;
|
||||
}
|
||||
|
||||
public void setSubscriberNumber(String subscriberNumber) {
|
||||
this.subscriberNumber = subscriberNumber;
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package com.rotanareg.skolan.userManager;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
import javax.faces.convert.ConverterException;
|
||||
import javax.faces.convert.FacesConverter;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@FacesConverter(forClass = PhoneNumber.class)
|
||||
public class PhoneNumberConverter implements Converter {
|
||||
|
||||
private static final Pattern PHONE_NUMBER_PATTERN = Pattern.compile("[0-8]{2}-[0-8]{3}-[0-8]{3}");
|
||||
|
||||
@Override
|
||||
public Object getAsObject(FacesContext context, UIComponent component, String value) {
|
||||
if (value == null || value.equals("")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!PHONE_NUMBER_PATTERN.matcher(value).matches()) {
|
||||
throw new ConverterException(
|
||||
new FacesMessage("Fyll i det rätta formen på telefonummer: 00-000-000."));
|
||||
}
|
||||
|
||||
PhoneNumber phoneNumber = new PhoneNumber();
|
||||
phoneNumber.setCountryCode(value.substring(0, 2));
|
||||
phoneNumber.setSubscriberNumber(value.substring(3));
|
||||
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsString(FacesContext context, UIComponent component, Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PhoneNumber phoneNumber = (PhoneNumber) value;
|
||||
|
||||
return phoneNumber.getCountryCode() + "-" + phoneNumber.getSubscriberNumber();
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
package com.rotanareg.skolan.userManager;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.validator.FacesValidator;
|
||||
import javax.faces.validator.Validator;
|
||||
import javax.faces.validator.ValidatorException;
|
||||
|
||||
|
||||
@FacesValidator("com.rotanareg.skolan.user.PhoneNumber")
|
||||
public class PhoneNumberValidator implements Validator {
|
||||
|
||||
@Override
|
||||
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
|
||||
PhoneNumber phoneNumber = (PhoneNumber) value;
|
||||
|
||||
|
||||
|
||||
if (phoneNumber != null) {
|
||||
checkCountryCode(phoneNumber.getCountryCode());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCountryCode(String countryCode) {
|
||||
int firstDigit = Character.digit(countryCode.charAt(0), 10);
|
||||
if (firstDigit == 0 || firstDigit == 1) {
|
||||
throw new ValidatorException(
|
||||
new FacesMessage("Första siffran i ditt tfn får inte vara 0 or 1."));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.rotanareg.skolan.userManager;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Named
|
||||
@RequestScoped
|
||||
public class SignIn {
|
||||
|
||||
@Inject
|
||||
private UserManager userManager;
|
||||
|
||||
@Pattern(regexp = "[A-Za-z0-9]{2,20}", message = "Användarnamnet skall innehålla bara bokstäver och siffror samt vara långt mellan 2 och 20 tecken.")
|
||||
private String username;
|
||||
|
||||
@Size(min = 8, message = "Ditt password måste innehålla minst 8 tecken.")
|
||||
private String password;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String submit() {
|
||||
return userManager.signIn(username, password);
|
||||
}
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
package com.rotanareg.skolan.userManager;
|
||||
|
||||
import com.rotanareg.skolan.Role;
|
||||
|
||||
import javax.validation.constraints.Past;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class User implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Role role;
|
||||
private List<Role> rolesList;
|
||||
|
||||
public User() {
|
||||
rolesList = new ArrayList();
|
||||
rolesList.add(Role.STUDENT);
|
||||
rolesList.add(Role.TEACHER);
|
||||
rolesList.add(Role.ADMIN);
|
||||
role = Role.STUDENT; // set the first role as default
|
||||
}
|
||||
|
||||
@Pattern(regexp = "[A-Za-z0-9]{2,20}", message = "Skriv in ditt användarnamn mellan 2 och 20 tecken långt, innehållande bokstäver och siffror")
|
||||
private String username;
|
||||
|
||||
@Size(min = 8, message = "Ditt pasword måste innehålla minst 8 tecken")
|
||||
private String password;
|
||||
|
||||
@Size(min = 1, max = 30, message = "Skriv in ditt Förnamn mellan 1 och 30 tecken långt.")
|
||||
private String firstName;
|
||||
|
||||
@Size(min = 1, max = 30, message = "Skriv in ditt Efternamn mellan 1 och 30 tecken långt.")
|
||||
private String lastName;
|
||||
|
||||
@ValidEmailAddress
|
||||
private String emailAddress;
|
||||
|
||||
private PhoneNumber phoneNumber;
|
||||
|
||||
@Past(message = "Ditt födelsedatum måste vara i dåtid .")
|
||||
private Date birthDate;
|
||||
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
|
||||
public String getEmailAddress() {
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
public void setEmailAddress(String emailAddress) {
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
|
||||
public PhoneNumber getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(PhoneNumber phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public Date getBirthDate() {
|
||||
return birthDate;
|
||||
}
|
||||
|
||||
public void setBirthDate(Date birthDate) {
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
public Role getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(Role role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public List<Role> getRolesList() {
|
||||
return rolesList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,30 +0,0 @@
|
||||
package com.rotanareg.skolan.userManager;
|
||||
|
||||
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.io.Serializable;
|
||||
@Named
|
||||
@ViewScoped
|
||||
public class UserDetail implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Inject
|
||||
private UserManager userManager;
|
||||
|
||||
private User user;
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void onload() {
|
||||
user = userManager.isSignedIn() ? userManager.getCurrentUser() : new User();
|
||||
}
|
||||
|
||||
public String submit() {
|
||||
return userManager.save(user);
|
||||
}
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package com.rotanareg.skolan.userManager;
|
||||
|
||||
import com.rotanareg.skolan.Role;
|
||||
|
||||
import javax.enterprise.context.SessionScoped;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Named
|
||||
@SessionScoped
|
||||
public class UserManager implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Inject
|
||||
private UserService userService;
|
||||
|
||||
private User currentUser;
|
||||
|
||||
public boolean isSignedIn() {
|
||||
return currentUser != null;
|
||||
}
|
||||
|
||||
public User getCurrentUser() {
|
||||
return currentUser;
|
||||
}
|
||||
|
||||
public String signIn(String username, String password) {
|
||||
User user = userService.getUser(username);
|
||||
if (user == null || !password.equals(user.getPassword())) {
|
||||
return "signIn";
|
||||
}
|
||||
currentUser = user;
|
||||
|
||||
switch (user.getRole()) {
|
||||
case STUDENT:
|
||||
return "student"; // xhtml-page to redirect to when signed in
|
||||
case TEACHER:
|
||||
return "teacher"; // xhtml-page to redirect to when signed in
|
||||
case ADMIN:
|
||||
return "admin"; // xhtml-page to redirect to when signed in
|
||||
}
|
||||
return ""; // should never happen, but redirects to the default xhtml-page
|
||||
}
|
||||
|
||||
public void signOut() {
|
||||
FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
|
||||
}
|
||||
|
||||
public String save(User user) {
|
||||
userService.saveUser(user);
|
||||
currentUser = user;
|
||||
|
||||
return "index";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
package com.rotanareg.skolan.userManager;
|
||||
|
||||
public interface UserService {
|
||||
// get information om användare
|
||||
User getUser(String username);
|
||||
|
||||
// spara information om användare
|
||||
void saveUser(User user);
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.rotanareg.skolan.userManager;
|
||||
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ApplicationScoped // skall stored i databas
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
|
||||
private final Map<String, User> users = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public User getUser(String username) {
|
||||
return users.get(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveUser(User user) {
|
||||
users.put(user.getUsername(), user);
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
package com.rotanareg.skolan.userManager;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Constraint(validatedBy = EmailAddressValidator.class)
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ValidEmailAddress {
|
||||
|
||||
String message() default "Skriv din rätta e-mail adressen.";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
@ -1,7 +1,22 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
|
||||
|
||||
<navigation-rule>
|
||||
<display-name>index.xhtml</display-name>
|
||||
<from-view-id>/index.xhtml</from-view-id>
|
||||
<navigation-case>
|
||||
<from-outcome>success</from-outcome>
|
||||
<to-view-id>/pupil1.xhtml</to-view-id>
|
||||
</navigation-case>
|
||||
</navigation-rule>
|
||||
<navigation-rule>
|
||||
<display-name>index.xhtml</display-name>
|
||||
<from-view-id>/index.xhtml</from-view-id>
|
||||
<navigation-case>
|
||||
<from-outcome>failure</from-outcome>
|
||||
<to-view-id>/index.xhtml</to-view-id>
|
||||
</navigation-case>
|
||||
</navigation-rule>
|
||||
</faces-config>
|
@ -1,24 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
|
||||
<ui:composition template="templates/template_page.xhtml">
|
||||
<ui:param name="pageTitle" value="Admin sidan"/>
|
||||
|
||||
<ui:composition template="/templates/page_template.xhtml">
|
||||
<ui:param name="pageTitle" value="Admin"/>
|
||||
<ui:define name = "panel-top">
|
||||
|
||||
<ui:define name="panel-top">
|
||||
<section>
|
||||
<h:commandButton value="Registrera nya kurser" action="#{course.addCourse()}"/> <!--lägg in inom parantes parameter-->
|
||||
<h:commandButton value="Registrera nya användare" action="#{user.addUser()}"/> <!--lägg in inom parantes parameter-->
|
||||
<h:outputLink value="index.xhtml">Logga ut</h:outputLink>
|
||||
</section>
|
||||
</ui:define>
|
||||
|
||||
|
||||
<ui:define name="panel-main">
|
||||
<section>
|
||||
<h1>Admin</h1>
|
||||
|
||||
<h:outputLink value="user_detail.xhtml">Registrera nya användare</h:outputLink>
|
||||
</section>
|
||||
</ui:define>
|
||||
|
||||
</ui:composition>
|
||||
|
||||
|
||||
</html>
|
||||
|
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
<f:view>
|
||||
<h:outputLabel value="Hello, world"/>
|
||||
</f:view>
|
||||
</html>
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
|
||||
<ui:composition template="templates/page_template.xhtml">
|
||||
<f:metadata>
|
||||
<f:viewParam name ="courseId" value="#{courseDetail.courseId}"/>
|
||||
<f:viewAction action="#{courseDetail.onload}"/>
|
||||
</f:metadata>
|
||||
|
||||
<ui:param name="pageTitle" value="Course Details"/>
|
||||
<ui:define name="panel-main">
|
||||
<section class="course_detail">
|
||||
<h:form>
|
||||
<h1>#{course.name}</h1>
|
||||
<p> </p>
|
||||
</h:form>
|
||||
</section>
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
</html>
|
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
|
||||
<ui:composition template="/templates/page_template.xhtml">
|
||||
<ui:param name="pageTitle" value="Kurs"/>
|
||||
<ui:define name="panel-top">
|
||||
<section>
|
||||
|
||||
<p>Ny kurs panel top</p>
|
||||
|
||||
</section>
|
||||
</ui:define>
|
||||
|
||||
<ui:define name="panel-main">
|
||||
<section class="create_course">
|
||||
<h:form>
|
||||
<p> Kurs kod</p>
|
||||
<p>Kurs namn</p>
|
||||
<p>Kurs deskription</p>
|
||||
<p>Ansvarig lärare</p>
|
||||
</h:form>
|
||||
</section>
|
||||
</ui:define>
|
||||
|
||||
</ui:composition>
|
||||
</html>
|
@ -0,0 +1,28 @@
|
||||
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core"
|
||||
xmlns:c="http://java.sun.com/jsp/jstl/core"
|
||||
xmlns:composite="http://xmlns.jcp.org/jsf/composite">
|
||||
<h:form>
|
||||
<p id="login_form">
|
||||
<label class="text_grey">Login:</label><br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<h:outputLabel>Användarnamn123:</h:outputLabel><br/>
|
||||
<h:inputText id="username" value="#{contactInformation.foreName}"/><br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<h:outputLabel>Lösenord:</h:outputLabel><br/>
|
||||
<h:inputText id="password" value="#{contactInformation.city}"/><br/>
|
||||
|
||||
<br/>
|
||||
|
||||
<h:commandButton action="#{contactInformation.save}" value="Login"/>
|
||||
</p>
|
||||
</h:form>
|
||||
|
||||
</ui:composition>
|
||||
|
@ -1,83 +0,0 @@
|
||||
html {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin: 0 0 8px 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 8px 0 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
input, button,select {
|
||||
font-family: Tahoma, sans-serif;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
body > header {
|
||||
padding: 16px;
|
||||
clear: both;
|
||||
text-align: center;
|
||||
font-size: 200%;
|
||||
}
|
||||
|
||||
body > header > h1 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body > section , body > form > section{
|
||||
margin: 8px 20%;
|
||||
padding: 18px;
|
||||
overflow: hidden;
|
||||
.bild
|
||||
background-image: url("testBild2.jpg");
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
background-position: 100%;
|
||||
}
|
||||
|
||||
body > footer {
|
||||
padding: 8px;
|
||||
clear: both;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
body > footer > p {
|
||||
margin: 0;
|
||||
}
|
||||
.student-table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.student-header {
|
||||
padding: 4px;
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.student-col-name {
|
||||
padding: 4px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.student-col-courseCode, .student-col-courseName, .student-col-teacherName {
|
||||
padding: 4px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.student-footer {
|
||||
padding: 4px;
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
Before Width: | Height: | Size: 91 KiB |
@ -1,62 +0,0 @@
|
||||
body {
|
||||
background-color: rgba(118, 203, 224, 0.1);
|
||||
}
|
||||
|
||||
a:link, a:visited {
|
||||
color: #8d52a0;
|
||||
}
|
||||
|
||||
a:hover, a:active {
|
||||
color: #76cbe0;
|
||||
}
|
||||
|
||||
input, select {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
border: 1px solid #396280;
|
||||
padding: 4px;
|
||||
}
|
||||
option {
|
||||
background-color: white;
|
||||
color: black;
|
||||
}
|
||||
input[readonly] {
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
input[type="submit"], input[type="button"] {
|
||||
border-radius: 4px;
|
||||
padding: 4px 12px;
|
||||
}
|
||||
|
||||
body > header {
|
||||
background-color: #2badca;
|
||||
color: white;
|
||||
}
|
||||
|
||||
body > section, body > form > section {
|
||||
background-color: rgba(114, 207, 179, 0.38);
|
||||
color: black;
|
||||
}
|
||||
|
||||
body > footer {
|
||||
background-color: #2badca;
|
||||
color: #e5e5e5;
|
||||
}
|
||||
.student-header {
|
||||
background-color: #2a17f1;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.student-row-odd {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
.student-row-even {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.student-footer {
|
||||
background-color: #2a17f1;
|
||||
color: white;
|
||||
}
|
@ -1,41 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
|
||||
<ui:composition template="/templates/page_template.xhtml">
|
||||
<ui:param name="pageTitle" value="Logga in"/>
|
||||
<ui:composition template="/templates/template_page.xhtml">
|
||||
<ui:param name="pageTitle" value="Sign In"/>
|
||||
<ui:define name="panel-top">
|
||||
<section>
|
||||
|
||||
<h:outputText value="Välkommen till Rotana Reg skolan!"/>
|
||||
<p> </p>
|
||||
<h:outputText value="Vänligen logga in"/>
|
||||
|
||||
<ui:fragment rendered="#{loggedIn.id == null}">
|
||||
<h1>Logga in</h1>
|
||||
<p>Skriv ditt användarnamn</p>
|
||||
</ui:fragment>
|
||||
|
||||
<ui:fragment rendered="#{loggedIn.id != null}">
|
||||
<h:form>
|
||||
<h1>Välkommen, #{userBean.users.getUser(loggedIn.id).name}!</h1>
|
||||
<p>Du är redan inloggad.
|
||||
Vill du<h:commandLink action="#{signIn.logout}">logga ut</h:commandLink>?</p>
|
||||
</h:form>
|
||||
</ui:fragment>
|
||||
</section>
|
||||
</ui:define>
|
||||
|
||||
<ui:define name="panel-main">
|
||||
<ui:fragment rendered="#{not userManager.signedIn}">
|
||||
<section>
|
||||
<h:form>
|
||||
<h:panelGrid columns="2" styleClass="form-grid" columnClasses="form-column-label,form-column-input">
|
||||
|
||||
<h:outputLabel for="username">Användarnamn</h:outputLabel>
|
||||
<h:inputText id="username" value="#{signIn.username}" size="20"/>
|
||||
|
||||
<h:outputLabel for="password">Password</h:outputLabel>
|
||||
<h:inputSecret id="password" value="#{signIn.password}" size="20"/>
|
||||
|
||||
<h:outputText value=""/>
|
||||
<h:commandButton value="Submit" action="#{signIn.submit}"/> <!--anroppar usermanager-->
|
||||
</h:panelGrid>
|
||||
</h:form>
|
||||
</section>
|
||||
<ui:fragment rendered="#{loggedIn.id == null}">
|
||||
<section>
|
||||
<h:form>
|
||||
<h:panelGrid columns="2" styleClass="form-grid" columnClasses="form-column-label,form-column-input">
|
||||
<h:outputLabel for="username">Användarnamn</h:outputLabel>
|
||||
<h:inputText id="username" value="#{signIn.username}"/>
|
||||
|
||||
<h:outputLabel for="password">Password</h:outputLabel>
|
||||
<h:inputSecret id="password" value="#{signIn.password}"/> <!--anroppar user bean-->
|
||||
|
||||
<h:outputText value=""/>
|
||||
<h:commandButton value="Submit" action="#{signIn.submit}"/> <!--anroppar usermanager-->
|
||||
</h:panelGrid>
|
||||
</h:form>
|
||||
</section>
|
||||
</ui:fragment>
|
||||
</ui:define>
|
||||
|
||||
</ui:composition>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
|
||||
<ui:composition template="templates/template_page.xhtml">
|
||||
<ui:param name="pageTitle" value="Admin sidan"/>
|
||||
|
||||
|
||||
<ui:define name="panel-top">
|
||||
<section>
|
||||
<h:outputLink value="index.xhtml">Logga ut</h:outputLink>
|
||||
</section>
|
||||
</ui:define>
|
||||
|
||||
|
||||
<ui:define name="panel-main">
|
||||
<section>
|
||||
<h1>Statistik</h1>
|
||||
--marko jobbar på statistik-biten...---
|
||||
<br/>
|
||||
<h:link styleClass="menuItem" value="stats_test.xhtml" outcome="stats_test"/>
|
||||
</section>
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
|
||||
|
||||
</html>
|
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
<f:view>
|
||||
<h:form id="form1">
|
||||
<h:panelGrid columns="3">
|
||||
<h:panelGrid columns="2" style="vertical-align: top">
|
||||
<h:outputText value='Enter name'/>
|
||||
<h:inputText value='#{attendanceBean.date}'/>
|
||||
<h:outputText value='Enter code'/>
|
||||
<h:inputText value='#{attendanceBean.hasAttended}'/>
|
||||
<h:commandButton action="#{attendanceBean.addAttendance}" value="#{attendanceBean.submitButton}"/>
|
||||
<h:inputHidden value="#{attendanceBean.id}"/>
|
||||
</h:panelGrid>
|
||||
<h:panelGrid columns="1" style="vertical-align: top">
|
||||
<h:outputText value="Unfilterd List"/>
|
||||
<h:dataTable id="tbl1" value="#{attendanceBean.attendances}" var="aBean">
|
||||
<h:column >
|
||||
<f:facet name="header">Id</f:facet>
|
||||
<h:outputText id="id" value="#{aBean.id}"/>
|
||||
</h:column>
|
||||
<h:column >
|
||||
<f:facet name="header">Datum</f:facet>
|
||||
<h:outputText value="#{aBean.date}"/>
|
||||
</h:column>
|
||||
<h:column >
|
||||
<f:facet name="header">Närvaro</f:facet>
|
||||
<h:outputText value="#{aBean.hasAttended}"/>
|
||||
</h:column>
|
||||
</h:dataTable>
|
||||
</h:panelGrid>
|
||||
<h:panelGrid columns="1" style="vertical-align:text-top">
|
||||
</h:panelGrid>
|
||||
</h:panelGrid>
|
||||
</h:form>
|
||||
</f:view>
|
||||
</html>
|
@ -1,24 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
|
||||
<ui:composition template="/templates/page_template.xhtml">
|
||||
<ui:param name="pageTitel" value="Lärare"/>
|
||||
<ui:define name = "panel-top">
|
||||
<ui:composition template="templates/template_page.xhtml">
|
||||
<ui:param name="pageTitle" value="Lärare sidan"/>
|
||||
<ui:define name="panel-top">
|
||||
<section>
|
||||
<p> lärare sidan panel top</p>
|
||||
<!--TODO vet ej -->
|
||||
<h:outputLink value="index.xhtml">Logga ut</h:outputLink>
|
||||
</section>
|
||||
</ui:define>
|
||||
|
||||
<ui:define name="panel-main">
|
||||
<section>
|
||||
<p> lärare sidan panel main</p>
|
||||
|
||||
<h1>Lärare</h1>
|
||||
<h2>Bla bla bla</h2>
|
||||
</section>
|
||||
</ui:define>
|
||||
|
||||
</ui:composition>
|
||||
</html>
|
||||
|
||||
|
||||
</html>
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||
|
||||
<ui:composition>
|
||||
<footer>
|
||||
<h1>Skolan 2017</h1>
|
||||
</footer>
|
||||
</ui:composition>
|
||||
</html>
|
@ -0,0 +1,28 @@
|
||||
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core"
|
||||
xmlns:c="http://java.sun.com/jsp/jstl/core"
|
||||
xmlns:composite="http://xmlns.jcp.org/jsf/composite">
|
||||
<h:form id="loginForm">
|
||||
<label class="text_grey" value="Login"/>
|
||||
|
||||
<h:outputLabel value="Användarnamn: "/>
|
||||
<h:inputText id="username"
|
||||
value="#{loginBean.username}"
|
||||
required="true"
|
||||
requiredMessage="du måste ange ditt namn!!!"/>
|
||||
<br/>
|
||||
|
||||
<h:outputLabel value="Lösenord: "/>
|
||||
<h:inputSecret id="password"
|
||||
value="#{loginBean.password}"
|
||||
required="true"
|
||||
requiredMessage="mata in ditt lösenord"/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<h:commandButton action="#{loginBean.login}" value="Login"/>
|
||||
</h:form>
|
||||
|
||||
</ui:composition>
|
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||
|
||||
<ui:composition>
|
||||
<header>
|
||||
<h1>Rotana Reg skola</h1>
|
||||
</header>
|
||||
</ui:composition>
|
||||
</html>
|
@ -1,41 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
<f:view contentType="text/html">
|
||||
<h:head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>RotanaReg Skolan #{pageTitel} </title>
|
||||
<h:outputStylesheet library="skolan" name="/css/style.css"/>
|
||||
<h:outputStylesheet library="skolan" name="/theme/blueheven.css"/>
|
||||
</h:head>
|
||||
|
||||
<h:body>
|
||||
<ui:include src="header_template.xhtml"/>
|
||||
<nav>
|
||||
<h:link styleClass="menuItem" value="Home" outcome="index"/>
|
||||
<span class="text_grey"> | </span>
|
||||
<h:link styleClass="menuItem" value="Admin" outcome="admin"/>
|
||||
<span class="text_grey"> | </span>
|
||||
<h:link styleClass="menuItem" value="Student" outcome="student"/>
|
||||
<span class="text_grey"> | </span>
|
||||
<h:link styleClass="menuItem" value="Teacher" outcome="teacher"/>
|
||||
</nav>
|
||||
<ui:insert name="panel-top">
|
||||
<section>
|
||||
<p>Hej<h:outputLink value="signIn.xhtml"></h:outputLink></p>
|
||||
</section>
|
||||
</ui:insert>
|
||||
|
||||
<ui:insert name="panel-main">
|
||||
<section>
|
||||
<h1>Main Panel</h1>
|
||||
<p>Placeholder text.</p> <!--används bara en content för panel main inte är specifierad i relevant page-->
|
||||
</section>
|
||||
</ui:insert>
|
||||
<ui:include src="footer_template.xhtml"/>
|
||||
</h:body>
|
||||
</f:view>
|
||||
</html>
|
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||
|
||||
<f:view>
|
||||
<h:outputLabel value="Hello, world"/>
|
||||
</f:view>
|
||||
</html>
|
Loading…
Reference in new issue