Skip to content
Snippets Groups Projects
Commit 21a7ec7a authored by joalhelk's avatar joalhelk
Browse files

updates to ui

parent c7dc5dea
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ public class Nodes { ...@@ -11,6 +11,7 @@ public class Nodes {
// Add a list of nodes // Add a list of nodes
public static void AddNodes(List<Node> list) { public static void AddNodes(List<Node> list) {
if(list == null) return;
for(Node n : list) { for(Node n : list) {
AddNode(n); AddNode(n);
} }
......
...@@ -86,6 +86,7 @@ public class LoginPage implements ActionListener, MouseListener { ...@@ -86,6 +86,7 @@ public class LoginPage implements ActionListener, MouseListener {
actionButton.addActionListener(this); actionButton.addActionListener(this);
actionButton.addMouseListener(this); actionButton.addMouseListener(this);
actionButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); actionButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
frame.getRootPane().setDefaultButton(actionButton);
bottomPanel.setBackground(Color.black); bottomPanel.setBackground(Color.black);
bottomPanel.setBounds(0,0,width, height); bottomPanel.setBounds(0,0,width, height);
...@@ -177,6 +178,11 @@ public class LoginPage implements ActionListener, MouseListener { ...@@ -177,6 +178,11 @@ public class LoginPage implements ActionListener, MouseListener {
loginSwitch = !loginSwitch; loginSwitch = !loginSwitch;
} }
/*
* Sends login information to the server
* if the credentials are valid, save the user information and token
* and open welcomepage
*/
private boolean handleLogin() { private boolean handleLogin() {
Map<String, String> credentials = loginPanel.getCredentials(); Map<String, String> credentials = loginPanel.getCredentials();
if(credentials.get("email").equals("") || credentials.get("password").equals("")) return false; if(credentials.get("email").equals("") || credentials.get("password").equals("")) return false;
...@@ -184,7 +190,7 @@ public class LoginPage implements ActionListener, MouseListener { ...@@ -184,7 +190,7 @@ public class LoginPage implements ActionListener, MouseListener {
boolean valid = HttpRequests.LoginRequest(credentials.get("email"), credentials.get("password")); boolean valid = HttpRequests.LoginRequest(credentials.get("email"), credentials.get("password"));
if (valid) { if (valid) {
frame.dispose(); frame.dispose();
WelcomePage welcomePage = new WelcomePage(); new WelcomePage();
} else { } else {
messageLabel.setText("Invalid username or password"); messageLabel.setText("Invalid username or password");
loginPanel.ClearFields(); loginPanel.ClearFields();
...@@ -192,6 +198,9 @@ public class LoginPage implements ActionListener, MouseListener { ...@@ -192,6 +198,9 @@ public class LoginPage implements ActionListener, MouseListener {
return valid; return valid;
} }
/*
* Sends the registration info to the server
*/
private boolean handleRegister() { private boolean handleRegister() {
if (registerPanel.validateForm()) { if (registerPanel.validateForm()) {
Map<String, String> userInfo = registerPanel.getUserInfo(); Map<String, String> userInfo = registerPanel.getUserInfo();
......
...@@ -52,7 +52,7 @@ public class WelcomePage implements MouseListener, ActionListener { ...@@ -52,7 +52,7 @@ public class WelcomePage implements MouseListener, ActionListener {
private static JFrame frame; private static JFrame frame;
private static JLabel chosen_label; private static JLabel chosen_label;
private static final Timer timer = new Timer(); private static Timer timer;
private static NodeDataFrame nodeDataFrame = new NodeDataFrame(leftPanelWidth, topPanelHeight, width-leftPanelWidth, height-topPanelHeight-bottomPanelHeight); private static NodeDataFrame nodeDataFrame = new NodeDataFrame(leftPanelWidth, topPanelHeight, width-leftPanelWidth, height-topPanelHeight-bottomPanelHeight);
private static NodeSettingsFrame nodeSettingFrame = new NodeSettingsFrame(width-leftPanelWidth, height-topPanelHeight-bottomPanelHeight); private static NodeSettingsFrame nodeSettingFrame = new NodeSettingsFrame(width-leftPanelWidth, height-topPanelHeight-bottomPanelHeight);
...@@ -203,6 +203,7 @@ public class WelcomePage implements MouseListener, ActionListener { ...@@ -203,6 +203,7 @@ public class WelcomePage implements MouseListener, ActionListener {
* Polls the backend for new data every given interval * Polls the backend for new data every given interval
*/ */
private static void PollData() { private static void PollData() {
timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() { timer.scheduleAtFixedRate(new TimerTask() {
int timeRemaining = pollInterval; int timeRemaining = pollInterval;
public void run() { public void run() {
...@@ -231,9 +232,16 @@ public class WelcomePage implements MouseListener, ActionListener { ...@@ -231,9 +232,16 @@ public class WelcomePage implements MouseListener, ActionListener {
} else if(arg0.getSource() == friendsLabel && arg0.getSource() != chosen_label) { } else if(arg0.getSource() == friendsLabel && arg0.getSource() != chosen_label) {
cl.show(stagePanel, "3"); cl.show(stagePanel, "3");
setActiveScene(friendsLabel); setActiveScene(friendsLabel);
} else if(arg0.getSource() == helpLabel) {
showHelpDialog();
} else if(arg0.getSource() == settingsLabel) {
// TODO: make settings for user information updating
} }
} }
private static void showHelpDialog() {
// TODO:
}
/* /*
* Sets a navbar item as chosen and changes its colors accordingly * Sets a navbar item as chosen and changes its colors accordingly
......
...@@ -221,6 +221,11 @@ public class HttpRequests { ...@@ -221,6 +221,11 @@ public class HttpRequests {
response.append(responseLine.trim()); response.append(responseLine.trim());
} }
} }
/*if (con.getResponseCode() == 403) {
WelcomePage.TimedOutSession();
// Set success to true so error dialog wont be shown
return null;
}*/
data = new JSONArray(response.toString()); data = new JSONArray(response.toString());
con.disconnect(); con.disconnect();
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
......
...@@ -44,6 +44,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -44,6 +44,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http.authorizeRequests().antMatchers("/api/v*/registration/**").permitAll(); http.authorizeRequests().antMatchers("/api/v*/registration/**").permitAll();
// --------------------------- // ---------------------------
http.authorizeRequests().antMatchers("/api/v*/nodeData").permitAll();
http.authorizeRequests().antMatchers("/api/v*/nodeData/**").permitAll();
// GET requests to appuser endpoint should have ADMIN roles // GET requests to appuser endpoint should have ADMIN roles
// TODO: This does not work I think // TODO: This does not work I think
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment