-
-
-
-
-
- | Title |
- Description |
- Author |
- ISBN |
- PrintYear |
- isRead |
- Edit |
- Delete |
- Read |
-
-
-
- | ${book.title} |
- ${book.description} |
- ${book.author} |
- ${book.isbn} |
- ${book.printYear} |
- ${book.readAlready} |
-
-
-
-
-
-
-
- |
-
-
-
-
- |
-
-
-
- |
-
-
-
-
-
- Your bookList is empty. Add a book.
-
-
+
+ <%@include file="parts/navigation.jsp" %>
+
+
+
+
+
+
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
- <%@include file="parts/pagination.jsp" %>
+
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/exception/exception.jsp b/src/main/webapp/WEB-INF/jsp/exception/exception.jsp
new file mode 100644
index 0000000..4e789a7
--- /dev/null
+++ b/src/main/webapp/WEB-INF/jsp/exception/exception.jsp
@@ -0,0 +1,16 @@
+<%--
+ Created by IntelliJ IDEA.
+ User: GVP
+ Date: 31.07.2018
+ Time: 14:23
+ To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+
+
Title
+
+
+
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/login.jsp b/src/main/webapp/WEB-INF/jsp/login.jsp
new file mode 100644
index 0000000..a3ec40b
--- /dev/null
+++ b/src/main/webapp/WEB-INF/jsp/login.jsp
@@ -0,0 +1,46 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
+<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
+
+
+
+
+
+
+
+
+ <%@include file="parts/navigation.jsp" %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/jsp/parts/header.jsp b/src/main/webapp/WEB-INF/jsp/parts/header.jsp
index efd4cc7..babf07f 100644
--- a/src/main/webapp/WEB-INF/jsp/parts/header.jsp
+++ b/src/main/webapp/WEB-INF/jsp/parts/header.jsp
@@ -1,11 +1,15 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+
+
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/parts/i18n.jsp b/src/main/webapp/WEB-INF/jsp/parts/i18n.jsp
new file mode 100644
index 0000000..c5df986
--- /dev/null
+++ b/src/main/webapp/WEB-INF/jsp/parts/i18n.jsp
@@ -0,0 +1,13 @@
+<%@ page contentType="text/html" pageEncoding="UTF-8" %>
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+
+
\ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/jsp/parts/navigation.jsp b/src/main/webapp/WEB-INF/jsp/parts/navigation.jsp
index 619b9a5..b35f45e 100644
--- a/src/main/webapp/WEB-INF/jsp/parts/navigation.jsp
+++ b/src/main/webapp/WEB-INF/jsp/parts/navigation.jsp
@@ -1,24 +1,55 @@
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/jsp/parts/pagination.jsp b/src/main/webapp/WEB-INF/jsp/parts/pagination.jsp
deleted file mode 100644
index 3abb1cd..0000000
--- a/src/main/webapp/WEB-INF/jsp/parts/pagination.jsp
+++ /dev/null
@@ -1,39 +0,0 @@
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-
diff --git a/src/main/webapp/WEB-INF/jsp/profile.jsp b/src/main/webapp/WEB-INF/jsp/profile.jsp
new file mode 100644
index 0000000..6488e85
--- /dev/null
+++ b/src/main/webapp/WEB-INF/jsp/profile.jsp
@@ -0,0 +1,44 @@
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+
+
+
+ <%@include file="parts/header.jsp" %>
+
+
+
+ <%@include file="parts/navigation.jsp" %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/webapp/WEB-INF/jsp/search.jsp b/src/main/webapp/WEB-INF/jsp/search.jsp
deleted file mode 100644
index c9ea256..0000000
--- a/src/main/webapp/WEB-INF/jsp/search.jsp
+++ /dev/null
@@ -1,67 +0,0 @@
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
-<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
-<%@ page session="false" %>
-<%@ page contentType="text/html;charset=UTF-8" %>
-
-
-
-
Search Result
- <%@include file="parts/header.jsp" %>
-
-
-
-
- <%@include file="parts/navigation.jsp" %>
-
-
-
-
-
-
- | Title |
- Description |
- Author |
- ISBN |
- PrintYear |
- isRead |
- Edit |
- Delete |
- Read |
-
-
-
- | ${book.title} |
- ${book.description} |
- ${book.author} |
- ${book.isbn} |
- ${book.printYear} |
- ${book.readAlready} |
-
-
-
-
-
-
-
- |
-
-
-
-
- |
-
-
-
- |
-
-
-
-
-
-
-
- <%@include file="parts/pagination.jsp"%>
-
-
-
\ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/jsp/users.jsp b/src/main/webapp/WEB-INF/jsp/users.jsp
new file mode 100644
index 0000000..891c137
--- /dev/null
+++ b/src/main/webapp/WEB-INF/jsp/users.jsp
@@ -0,0 +1,88 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
+<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
+<%@ taglib prefix="from" uri="http://www.springframework.org/tags/form" %>
+<%@ page session="false" %>
+<%@ page contentType="text/html;charset=UTF-8" %>
+
+
+
+
+
+ <%@include file="parts/header.jsp" %>
+
+
+
+
+
+ <%@include file="parts/navigation.jsp" %>
+
+
+
+
+
+
+
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index 72ea58f..70b3a79 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -4,6 +4,7 @@
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
Book Manager
+
org.springframework.web.context.ContextLoaderListener
@@ -13,7 +14,7 @@
contextConfigLocation
- /WEB-INF/appconfig-root.xml
+ classpath:/spring/appconfig-root.xml
@@ -37,4 +38,32 @@
*.css
+
+ encodingFilter
+ org.springframework.web.filter.CharacterEncodingFilter
+
+ encoding
+ UTF-8
+
+
+ forceEncoding
+ true
+
+
+
+ encodingFilter
+ /*
+
+
+
+ springSecurityFilterChain
+ org.springframework.web.filter.DelegatingFilterProxy
+
+
+ springSecurityFilterChain
+ /*
+
+
+
+
\ No newline at end of file
diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp
deleted file mode 100644
index 52e7a99..0000000
--- a/src/main/webapp/index.jsp
+++ /dev/null
@@ -1,3 +0,0 @@
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-
\ No newline at end of file
diff --git a/src/main/webapp/resources/css/style.css b/src/main/webapp/resources/css/style.css
new file mode 100644
index 0000000..bf1fa0a
--- /dev/null
+++ b/src/main/webapp/resources/css/style.css
@@ -0,0 +1,6 @@
+tr[book-readAlready="true"] {
+ color: green;
+}
+tr[data-userEnabled="false"] {
+ opacity: 0.3;
+}
diff --git a/src/main/webapp/resources/js/booksDatatables.js b/src/main/webapp/resources/js/booksDatatables.js
new file mode 100644
index 0000000..9173530
--- /dev/null
+++ b/src/main/webapp/resources/js/booksDatatables.js
@@ -0,0 +1,81 @@
+var ajaxUrl = "/bookmanager/books/";
+var datatableApi;
+
+function updateTable() {
+ $.get(ajaxUrl, updateTableByData);
+}
+
+function makeRead(chkbox, id) {
+ var readAlready = chkbox.is(":checked");
+ $.ajax({
+ url: ajaxUrl + id,
+ type: "POST",
+ data: "readAlready=" + readAlready
+ }).done(function () {
+ chkbox.closest("tr").attr("book-readAlready", readAlready);
+ if(readAlready) {
+ successNoty(i18n["read"]);
+ }
+ }).fail(function () {
+ $(chkbox).prop("checked", !readAlready);
+ });
+}
+
+$(function () {
+ datatableApi = $("#bookTable").DataTable({
+ "ajax": {
+ "url": ajaxUrl,
+ "dataSrc": "",
+ },
+ "info": true,
+ "language": {
+ "search": i18n["common.search"]
+ },
+ "columns": [
+ {
+ "data": "title",
+ },
+ {
+ "data": "description"
+ },
+ {
+ "data": "author"
+ },
+ {
+ "data": "isbn"
+ },
+ {
+ "data": "printYear"
+ },
+ {
+ "data": "readAlready",
+ "render": function (data, type, row) {
+ if (type === "display") {
+ return "";
+ }
+ return data;
+ }
+ },
+ {
+ "render": renderEditBtn,
+ "defaultContent": "",
+ "orderable": false
+ },
+ {
+ "render": renderDeleteBtn,
+ "defaultContent": "",
+ "orderable": false
+ }
+ ],
+ "order": [
+ [
+ 0,
+ "asc"
+ ]
+ ],
+ "createdRow": function (row, data, dataIndex) {
+ $(row).attr("book-readAlready", data.readAlready);
+ },
+ "initComplete": makeEditable
+ });
+});
\ No newline at end of file
diff --git a/src/main/webapp/resources/js/datatablesUtil.js b/src/main/webapp/resources/js/datatablesUtil.js
new file mode 100644
index 0000000..c210f71
--- /dev/null
+++ b/src/main/webapp/resources/js/datatablesUtil.js
@@ -0,0 +1,103 @@
+var form;
+
+function makeEditable() {
+ form = $('#detailsForm');
+ $(document).ajaxError(function (event, jqXHR, options, jsExc) {
+ failNoty(jqXHR);
+ });
+ $.ajaxSetup({cache: false});
+ var token = $("meta[name='_csrf']").attr("content");
+ var header = $("meta[name='_csrf_header']").attr("content");
+ $(document).ajaxSend(function (e, xhr, options) {
+ xhr.setRequestHeader(header, token);
+ });
+}
+
+function add() {
+ $("#modalTitle").html(i18n["addTitle"]);
+ form.find(":input").val("");
+ form.find("input[name='readAlready']").val('false');
+ $("#editRow").modal();
+}
+
+
+function updateRow(id) {
+ $("#modalTitle").html(i18n["editTitle"]);
+ $.get(ajaxUrl + id, function (data) {
+ $.each(data, function (key, value) {
+ if (key === "description") {
+ form.find("textarea[name='" + key + "']").val(value);
+ }
+ form.find("input[name='" + key + "']").val(value);
+ });
+ $('#editRow').modal();
+ });
+}
+
+function deleteRow(id) {
+ $.ajax({
+ url: ajaxUrl + id,
+ type: "DELETE"
+ }).done(function () {
+ updateTable();
+ successNoty(i18n["common.deleted"]);
+
+ });
+}
+
+function updateTableByData(data) {
+ datatableApi.clear().rows.add(data).draw();
+}
+
+function save() {
+ $.ajax({
+ type: "POST",
+ url: ajaxUrl,
+ data: form.serialize()
+ }).done(function () {
+ $("#editRow").modal("hide");
+ updateTable();
+ successNoty(i18n["common.saved"]);
+ });
+}
+
+var failedNote;
+
+function closeNoty() {
+ if (failedNote) {
+ failedNote.close();
+ failedNote = undefined;
+ }
+}
+
+function successNoty(key) {
+ closeNoty();
+ new Noty({
+ text: " " + [key],
+ type: 'success',
+ layout: "bottomRight",
+ timeout: 1000
+ }).show();
+}
+
+function failNoty(jqXHR) {
+ closeNoty();
+ failedNote = new Noty({
+ text: " " + errorInfo.typeMessage + "
" + errorInfo.details.join("
"),
+ type: "error",
+ layout: "bottomRight",
+ timeout: 1000
+ }).show();
+}
+
+function renderEditBtn(data, type, row) {
+ if (type === "display") {
+ return "";
+ }
+}
+
+function renderDeleteBtn(data, type, row) {
+ if (type === "display") {
+ return "";
+ }
+}
\ No newline at end of file
diff --git a/src/main/webapp/resources/js/userDatatables.js b/src/main/webapp/resources/js/userDatatables.js
new file mode 100644
index 0000000..daccdc4
--- /dev/null
+++ b/src/main/webapp/resources/js/userDatatables.js
@@ -0,0 +1,92 @@
+var ajaxUrl = "/bookmanager/users/";
+var datatableApi;
+
+function updateTable() {
+ $.get(ajaxUrl, updateTableByData);
+}
+
+function enable(chkbox, id) {
+ var enabled = chkbox.is(":checked");
+ $.ajax({
+ url: ajaxUrl + id,
+ type: "POST",
+ data: "enabled=" + enabled
+ }).done(function () {
+ chkbox.closest("tr").attr("data-userEnabled", enabled);
+ successNoty(enabled ? i18n["common.enabled"] : i18n["common.disabled"]);
+ }).fail(function () {
+ $(chkbox).prop("checked", !enabled);
+ });
+}
+
+// $(document).ready(function () {
+$(function () {
+ datatableApi = $("#userTable").DataTable({
+ "ajax": {
+ "url": ajaxUrl,
+ "dataSrc": ""
+ },
+ "info": true,
+ "language": {
+ "search": i18n["common.search"]
+ },
+ "columns": [
+ {
+ "data": "name"
+ },
+ {
+ "data": "email",
+ "render": function (data, type, row) {
+ if (type === "display") {
+ return "" + data + "";
+ }
+ return data;
+ }
+ },
+ {
+ "data": "roles"
+ },
+ {
+ "data": "enabled",
+ "render": function (data, type, row) {
+ if (type === "display") {
+ return "";
+ }
+ return data;
+ }
+ },
+ {
+ "data": "registered",
+ "render": function (date, type, row) {
+ if (type === "display") {
+ var momentDate = moment(date);
+ return momentDate.format("DD-MM-YYYY");
+ }
+ return date;
+ }
+ },
+ {
+ "orderable": false,
+ "defaultContent": "",
+ "render": renderEditBtn
+ },
+ {
+ "orderable": false,
+ "defaultContent": "",
+ "render": renderDeleteBtn
+ }
+ ],
+ "order": [
+ [
+ 0,
+ "asc"
+ ]
+ ],
+ "createdRow": function (row, data, dataIndex) {
+ if (!data.enabled) {
+ $(row).attr("data-userEnabled", false);
+ }
+ },
+ "initComplete": makeEditable
+ });
+});
\ No newline at end of file