ADD:: Added dashboard
added controller class and functionality to switch between sections
This commit is contained in:
13
build.gradle
13
build.gradle
@@ -1,11 +1,18 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")
|
||||
classpath("org.openjfx:javafx-plugin:0.0.7")
|
||||
}
|
||||
}
|
||||
//plugins {
|
||||
// id "org.openjfx.javafxplugin" version "0.0.7"
|
||||
//}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
@@ -15,9 +22,11 @@ apply plugin: 'io.spring.dependency-management'
|
||||
apply plugin: 'jacoco'
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
//apply plugin: 'org.openjfx.javafxplugin'
|
||||
|
||||
tasks.withType(Checkstyle) {
|
||||
reports {
|
||||
html.destination rootProject.file("reports/checkstyle.html")
|
||||
html.destination rootProject.file("build/reports/checkstyle.html")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,3 +90,5 @@ jacocoTestReport {
|
||||
bootJar {
|
||||
mainClassName = 'Client.Application'
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ dependencies {
|
||||
}
|
||||
|
||||
jacoco {
|
||||
toolVersion = "0.8.2"
|
||||
toolVersion = "0.8.3"
|
||||
reportsDir = file("$buildDir/customJacocoReportDir")
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,9 @@ import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application extends javafx.application.Application {
|
||||
@@ -40,12 +36,19 @@ public class Application extends javafx.application.Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception{
|
||||
fxmlLoader.setLocation(this.getClass().getClassLoader().getResource("fxml/sample.fxml"));
|
||||
|
||||
// fxmlLoader.setLocation(this.getClass().getClassLoader().getResource("fxml/dashboard.fxml"));
|
||||
|
||||
|
||||
rootNode = fxmlLoader.load();
|
||||
|
||||
// rootNode = FXMLLoader.load(this.getClass().getClassLoader().getResource("fxml/sample.fxml"));
|
||||
|
||||
primaryStage.setTitle("GoGreen");
|
||||
Scene scene = new Scene(rootNode);
|
||||
|
||||
// scene.getStylesheets().add(getClass().getResource("stylesheets/dashboardStyle.css").toExternalForm());
|
||||
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package gogreen.client.controller;
|
||||
|
||||
import gogreen.client.rest.UserService;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.effect.DropShadow;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class DashBoardController {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@FXML
|
||||
public AnchorPane menuBar;
|
||||
public AnchorPane dashboardPane;
|
||||
public AnchorPane userPane;
|
||||
public AnchorPane activitiesPane;
|
||||
public Label welcomebacktext;
|
||||
// public Button addActivityButton;
|
||||
// public ComboBox addActivity;
|
||||
|
||||
@FXML
|
||||
public Label dashboardText;
|
||||
public Label activitiesText;
|
||||
public Label userText;
|
||||
public Button dashboardButton;
|
||||
public Button activitiesButton;
|
||||
public Button userButton;
|
||||
|
||||
DropShadow shadow = new DropShadow();
|
||||
|
||||
public void handleClickAction(MouseEvent event) {
|
||||
if (event.getTarget() == dashboardButton) {
|
||||
dashboardPane.setVisible(true);
|
||||
userPane.setVisible(false);
|
||||
activitiesPane.setVisible(false);
|
||||
} else if (event.getTarget() == activitiesButton){
|
||||
dashboardPane.setVisible(false);
|
||||
userPane.setVisible(false);
|
||||
activitiesPane.setVisible(true);
|
||||
} else if (event.getTarget() == userButton) {
|
||||
dashboardPane.setVisible(false);
|
||||
userPane.setVisible(true);
|
||||
activitiesPane.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void displayDashboard(ActionEvent event) {
|
||||
dashboardPane.setVisible(true);
|
||||
userPane.setVisible(false);
|
||||
activitiesPane.setVisible(false);
|
||||
}
|
||||
|
||||
public void displayActivities(ActionEvent event) {
|
||||
dashboardPane.setVisible(false);
|
||||
userPane.setVisible(false);
|
||||
activitiesPane.setVisible(true);
|
||||
}
|
||||
|
||||
public void displayUser(ActionEvent event) {
|
||||
dashboardPane.setVisible(false);
|
||||
userPane.setVisible(true);
|
||||
activitiesPane.setVisible(false);
|
||||
}
|
||||
public void addShadow(MouseEvent event) {
|
||||
userButton.setEffect(shadow);
|
||||
}
|
||||
|
||||
public void removeShadow(MouseEvent event) {
|
||||
userButton.setEffect(null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import gogreen.client.rest.UserService;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
@@ -35,6 +34,8 @@ public class UserController {
|
||||
@FXML
|
||||
private Button signupButton;
|
||||
|
||||
|
||||
|
||||
// @Value("${my.url}")
|
||||
// private String myUrl;
|
||||
|
||||
@@ -68,11 +69,28 @@ public class UserController {
|
||||
}
|
||||
|
||||
userService.registerUser(usernameField.getText(), passwordField.getText());
|
||||
|
||||
// load the dashboard stage
|
||||
// Parent parent = FXMLLoader.load(this.getClass().getClassLoader().getResource("/fxml/dashboard.fxml"));
|
||||
//
|
||||
// Scene scene = new Scene(parent);
|
||||
// Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
||||
// app_stage.setScene(scene);
|
||||
// app_stage.setFullScreen(true);
|
||||
// app_stage.show();
|
||||
|
||||
//on,y works once, when already logged in once, need to restart client for it to work again
|
||||
openDashboard();
|
||||
|
||||
}
|
||||
|
||||
public void openDashboard() throws IOException {
|
||||
Parent dash = FXMLLoader.load(this.getClass().getClassLoader().getResource("fxml/Dashboard.fxml"));
|
||||
Scene scene = new Scene(dash);
|
||||
Stage app_stage = new Stage();
|
||||
app_stage.setScene(scene);
|
||||
// app_stage.setFullScreen(true);
|
||||
app_stage.show();
|
||||
}
|
||||
|
||||
public static class AlertHelper {
|
||||
|
||||
@@ -1,6 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.collections.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.collections.FXCollections?>
|
||||
|
||||
|
||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" />
|
||||
<AnchorPane prefHeight="602.0" prefWidth="926.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gogreen.client.controller.DashBoardController">
|
||||
<children>
|
||||
<AnchorPane fx:id="menuBar" prefHeight="603.0" prefWidth="216.0" style="-fx-background-color: #545b4f;">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" layoutY="-2.0" prefHeight="90.0" prefWidth="216.0" text="Go Green" textAlignment="CENTER" textFill="#07a11c">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Button fx:id="dashboardButton" layoutY="88.0" mnemonicParsing="false" onAction="#displayDashboard" prefHeight="45.0" prefWidth="216.0" style="-fx-background-color: #5a635c;" text="dashboard">
|
||||
<font>
|
||||
<Font size="21.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<Button fx:id="activitiesButton" layoutY="133.0" mnemonicParsing="false" onAction="#displayActivities" prefHeight="45.0" prefWidth="216.0" style="-fx-background-color: #5a635c;" text="activities">
|
||||
<font>
|
||||
<Font size="21.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<Button fx:id="userButton" layoutY="178.0" mnemonicParsing="false" onAction="#displayUser" prefHeight="45.0" prefWidth="216.0" style="-fx-background-color: #5a635c;" text="you">
|
||||
<font>
|
||||
<Font size="21.0" />
|
||||
</font>
|
||||
</Button>
|
||||
</children></AnchorPane>
|
||||
<AnchorPane fx:id="activitiesPane" layoutX="214.0" prefHeight="603.0" prefWidth="711.0" visible="false" />
|
||||
<AnchorPane fx:id="userPane" layoutX="215.0" layoutY="-1.0" prefHeight="603.0" prefWidth="711.0" visible="false" />
|
||||
<AnchorPane fx:id="dashboardPane" layoutX="215.0" prefHeight="603.0" prefWidth="711.0">
|
||||
<children>
|
||||
<HBox layoutX="97.0" layoutY="124.0" prefHeight="100.0" prefWidth="200.0" />
|
||||
<Label fx:id="welcomebacktext" layoutX="69.0" layoutY="53.0" text="Welcome back user!">
|
||||
<font>
|
||||
<Font size="30.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Button layoutX="583.0" layoutY="41.0" mnemonicParsing="false" style="-fx-background-color: #167526;" text="+" textFill="#e0fcdb">
|
||||
<font>
|
||||
<Font name="Eras Bold ITC" size="28.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<!--<ComboBox fx:id="addActivity" layoutX="532.0" layoutY="28.0" prefWidth="150.0" promptText="Add an Activity" style="-fx-background-color: #1f951f;">-->
|
||||
<!--<items>-->
|
||||
<!--<FXCollections fx:factory="observableArrayList">-->
|
||||
<!--<String fx:value="Ate a vegetarian meal" />-->
|
||||
<!--</FXCollections>-->
|
||||
<!--</items>-->
|
||||
<!--</ComboBox>-->
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
.button {
|
||||
-fx-border-width: 0px 0px 1px 0px;
|
||||
-fx-border-color: #f9f9f9;
|
||||
-fx-border-radius: 0%;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ dependencies {
|
||||
}
|
||||
|
||||
jacoco {
|
||||
toolVersion = "0.8.2"
|
||||
toolVersion = "0.8.3"
|
||||
reportsDir = file("$buildDir/customJacocoReportDir")
|
||||
}
|
||||
|
||||
@@ -70,4 +70,8 @@ jacocoTestReport {
|
||||
}
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "7.6.1"
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user