Skip to content

Commit

Permalink
Added "Top" btn.
Browse files Browse the repository at this point in the history
Start implementing admin panel.
Refactored security configuration.
BUG FIXED: app is now not throwing errors on client console(css/js file not found).
  • Loading branch information
GeorgeK95 committed Mar 25, 2018
1 parent 2ab3999 commit ad6ecb9
Show file tree
Hide file tree
Showing 33 changed files with 744 additions and 429 deletions.
675 changes: 357 additions & 318 deletions PizzaNationApp/.idea/workspace.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package pizzaNation.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import pizzaNation.util.DirectoryScanner;
import pizzaNation.util.StaticFilesContainer;

import static pizzaNation.util.WebConstants.CSS_PAGE_FILES;
import static pizzaNation.util.WebConstants.JS_PAGE_FILES;

/**
* Created by George-Lenovo on 25/03/2018.
*/
@Configuration
public class PizzaNationConfiguration {

@Bean
public StaticFilesContainer getStaticFilesContainer() {
return new StaticFilesContainer(
DirectoryScanner.getDirectoryFilesNames(CSS_PAGE_FILES),
DirectoryScanner.getDirectoryFilesNames(JS_PAGE_FILES)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package pizzaNation.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import pizzaNation.model.PeshoModel;

@Configuration
@EnableWebSecurity
Expand All @@ -33,20 +31,4 @@ protected void configure(HttpSecurity http) throws Exception {
.csrf()
.disable();*/
}

// @Bean
// public StaticFilesContainer getStaticFilesContainer() {
// StaticFilesContainer filesContainer = new StaticFilesContainer();
// filesContainer.setCssFiles(DirectoryScanner.getDirectoryFilesNames(CSS_PAGE_FILES));
// filesContainer.setJsFiles(DirectoryScanner.getDirectoryFilesNames(JS_PAGE_FILES));
// return filesContainer;
// }

//ako stane,nov config file i tam
@Bean
public PeshoModel getPeshoModel() {
PeshoModel peshoModel = new PeshoModel();
peshoModel.setEmail("[email protected]");
return peshoModel;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package pizzaNation.contoller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
import pizzaNation.model.PeshoModel;
import pizzaNation.util.StaticFilesContainer;

import java.util.List;
import java.util.Map;
Expand All @@ -14,28 +13,10 @@
/**
* Created by George-Lenovo on 15/03/2018.
*/
@Component
public abstract class BaseController {

// private StaticFilesContainer staticFilesContainer;

private PeshoModel peshoModel;

public BaseController() {
}

@Autowired
public BaseController(PeshoModel peshoModel) {
this.peshoModel = peshoModel;
}

// @Autowired
// public BaseController(StaticFilesContainer staticFilesContainer) {
// this.staticFilesContainer = staticFilesContainer;
// }

private static final String CSS_PAGE_DIR = "/css/page/";
private static final String JS_PAGE_DIR = "/js/page/";
private StaticFilesContainer staticFilesContainer;

protected ModelAndView view() {
return this.view(null);
Expand Down Expand Up @@ -67,12 +48,12 @@ private ModelAndView view(String viewName, Object viewModel) {

private void addAttributes(String viewName, ModelAndView modelAndView) {
String viewSimpleName = viewName.split(SLASH_STR)[0];
// if (this.staticFilesContainer.containsCssFile(viewSimpleName))
modelAndView.getModelMap().addAttribute(PAGE_STYLE_STR,
List.of(CSS_PAGE_DIR + viewSimpleName + CSS_EXTENSION));
// if (this.staticFilesContainer.containsJsFile(viewSimpleName))
modelAndView.getModelMap().addAttribute(PAGE_SCRIPT_STR,
List.of(JS_PAGE_DIR + viewSimpleName + JS_EXTENSION));

if (this.staticFilesContainer.containsCssFile(viewSimpleName))
modelAndView.getModelMap().addAttribute(PAGE_STYLE_STR, List.of(CSS_PAGE_DIR + viewSimpleName + CSS_EXTENSION));
if (this.staticFilesContainer.containsJsFile(viewSimpleName))
modelAndView.getModelMap().addAttribute(PAGE_SCRIPT_STR, List.of(JS_PAGE_DIR + viewSimpleName + JS_EXTENSION));

modelAndView.getModelMap().addAttribute(VIEW_STR, viewName);
}
}
19 changes: 0 additions & 19 deletions PizzaNationApp/src/main/java/pizzaNation/model/PeshoModel.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package pizzaNation.util;

import java.io.File;
import java.util.*;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

import static pizzaNation.util.WebConstants.CSS_PAGE_FILES;
import static pizzaNation.util.WebConstants.JS_PAGE_FILES;
import static pizzaNation.util.WebConstants.CSS_EXTENSION;
import static pizzaNation.util.WebConstants.EMPTY_STR;
import static pizzaNation.util.WebConstants.JS_EXTENSION;

/**
* Created by George-Lenovo on 23/03/2018.
Expand All @@ -20,7 +23,10 @@ private static Set<String> listFilesForFolder(File folder, Set<String> filesName
if (fileEntry.isDirectory()) {
listFilesForFolder(fileEntry, filesNames);
} else {
filesNames.add(fileEntry.getName());
filesNames.add(fileEntry.getName()
.replace(CSS_EXTENSION, EMPTY_STR)
.replace(JS_EXTENSION, EMPTY_STR)
);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package pizzaNation.util;

import org.springframework.stereotype.Component;

import java.util.Set;

/**
Expand All @@ -13,19 +11,16 @@ public class StaticFilesContainer {

private Set<String> jsFiles;

public StaticFilesContainer(Set<String> cssFiles, Set<String> jsFiles) {
this.cssFiles = cssFiles;
this.jsFiles = jsFiles;
}

public boolean containsCssFile(String fileName) {
return this.cssFiles.contains(fileName);
}

public boolean containsJsFile(String fileName) {
return this.jsFiles.contains(fileName);
}

public void setCssFiles(Set<String> cssFiles) {
this.cssFiles = cssFiles;
}

public void setJsFiles(Set<String> jsFiles) {
this.jsFiles = jsFiles;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
public final class WebConstants {

//paths
static final String CSS_PAGE_FILES = "E:\\GITHUB\\PizzaNationApp\\PizzaNationApp\\src\\main\\resources\\static\\css\\page";
static final String JS_PAGE_FILES = "E:\\GITHUB\\PizzaNationApp\\PizzaNationApp\\src\\main\\resources\\static\\js\\page";
public static final String CSS_PAGE_FILES = System.getProperty("user.dir").concat("\\src\\main\\resources\\static\\css\\page");
public static final String JS_PAGE_FILES = System.getProperty("user.dir").concat("\\src\\main\\resources\\static\\js\\page");


public static final String CSS_PAGE_DIR = "/css/page/";
public static final String JS_PAGE_DIR = "/js/page/";

//URL-s
public static final String ERROR_URL = "/error";
Expand Down Expand Up @@ -45,6 +49,7 @@ public final class WebConstants {
public static final String PAGE_STYLE_STR = "pageStyle";
public static final String PAGE_SCRIPT_STR = "pageScript";
public static final String VIEW_STR = "view";
public static final String EMPTY_STR = "";

//Extensions
public static final String CSS_EXTENSION = ".css";
Expand Down
18 changes: 18 additions & 0 deletions PizzaNationApp/src/main/resources/static/css/core/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,25 @@ div.form_security img {
float: left;
margin: 0 10px 0 0;
}

/*Tables Padding Style*/
table.padded_table tr td {
padding: 6px;
}

/*GoToTop Btn*/
#gotoTopBtn {
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
font-size: 18px;
border: none;
outline: none;
background-color: #E0121A;
color: white;
cursor: pointer;
padding: 15px;
border-radius: 4px;
}
88 changes: 88 additions & 0 deletions PizzaNationApp/src/main/resources/static/css/page/admin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*Menu Style*/
.menu_item_secondary {
background-image: url('../../img/menu/secondary.jpg');
}

div#menu_page {
padding: 20px 0 20px 0;
}

div.menu_item {
float: left;
}

div.menu_item_third {
width: 33.3%;
}

div.menu_item_pad {
padding: 8px;
padding: 12px;
}

div.menu_inner {
background: #FFFFFF;
position: relative;

background-color: #FFFFFF;
background-repeat: no-repeat;
background-position: top center;
background-size: cover;
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
}

div.menu_item_third div.menu_inner,
div.menu_item_third div.menu_inner_quick,
div.menu_item_third div.menu_inner a {
height: 200px;
}

div.menu_title {
position: absolute;
z-index: 100;
width: 90%;
left: 5%;
height: 46px;

background: #FFFFFF;
background: rgba(255, 255, 255, 0.8);

background: #E0121A;
background: rgba(224, 18, 26, 0.8);

background: #0054A5;
background: rgba(0, 84, 165, 0.8);

background: #333333;
background: rgba(51, 51, 51, 0.6);

-webkit-transition: 0.15s;
transition: 0.25s;

text-align: center;
}

div.menu_hover:hover div.menu_title {
background: rgba(51, 51, 51, 1);
background: #e0121a;
}

div.menu_item_third div.menu_title {
top: 135px;
}

div.menu_title_pad {
padding: 10px;
}

div.menu_title h2,
div.menu_title h3 {
font-size: 26px;
margin: 0;
line-height: 1em;

color: #ec0d0d;
color: #FFFFFF;
}
18 changes: 18 additions & 0 deletions PizzaNationApp/src/main/resources/static/js/page/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function () {
scrollFunction()
};

function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
document.getElementById("gotoTopBtn").style.display = "block";
} else {
document.getElementById("gotoTopBtn").style.display = "none";
}
}

// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
24 changes: 23 additions & 1 deletion PizzaNationApp/src/main/resources/templates/admin/admin.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
<main>
admin panel in process
<div class="page_bckgrnd_img">
<div class="wrapper">
<div id="menu_page">

<th:block th:each="i: ${#numbers.sequence(0, 8)}">
<div class="menu_item menu_item_third">
<div class="menu_item_pad">
<div class="menu_inner menu_hover shadow_element menu_item_secondary">
<div class="menu_title">
<div class="menu_title_pad">
<h3>Desserts</h3>
</div>
</div>
</div>
</div>
</div>
</th:block>

<div class="clear"><!-- clear --></div>

</div>
</div>
</div>
</main>
Loading

0 comments on commit ad6ecb9

Please sign in to comment.