Skip to content
Snippets Groups Projects
Commit 33c08caf authored by ArktikHunter's avatar ArktikHunter
Browse files

commit

parent 5b62b663
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,7 @@ public class Controller {
Stage popupStage;
Scene popupScene;
RafisWeirdClass rafisWeirdClass = new RafisWeirdClass();
Model model = new Model("localhost",8989);
Model model = new Model("127.0.0.1" ,3306);
public void scheduleButtonClicked() throws IOException {
System.out.println("schedule button clicked");
......@@ -131,18 +131,23 @@ public class Controller {
// Login Page
public void managerLoginClicked(MouseEvent mouseEvent) throws IOException {
BorderPane root = new BorderPane();
FXMLLoader gridLoader = new FXMLLoader(this.getClass().getResource("dailySchedManager.fxml"));
Parent grid = gridLoader.load();
//FXMLLoader gridLoader = new FXMLLoader(this.getClass().getResource("dailySchedManager.fxml"));
//Parent grid = gridLoader.load();
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
Parent header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("schedSidePanel.fxml"));
Parent sidePanel = sideLoader.load();
FXMLLoader bottomLoader = new FXMLLoader(this.getClass().getResource("schedBottomPanelManager.fxml"));
Parent bottomPanel = bottomLoader.load();
DailyView dailyView = new DailyView();
dailyView.setModel(model);
WeeklyView weeklyView = new WeeklyView();
weeklyView.setModel(model);
root.setTop(header);
root.setLeft(sidePanel);
root.setBottom(bottomPanel);
root.setCenter(new DailyView());
root.setCenter(weeklyView);
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App");
......
package com.example.schedulerapp;
import java.lang.reflect.Array;
import java.net.*;
import java.io.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
......@@ -13,9 +14,10 @@ public class Model {
protected ArrayList<String> shifts;
protected ArrayList<String> employees;
public LocalDate currentDate;
public LocalDate date;
public Model(String hostname, int port) {
date = LocalDate.now();
this.shifts = new ArrayList<>();
this.employees = new ArrayList<>();
try {
......@@ -81,8 +83,8 @@ public class Model {
return "No Employees";
}
void addShift(int id, String date, int start, int end, String shiftType){
writer.println("addShift/"+id+"/"+date+"/"+start+"/"+end+"/"+shiftType);
void addShift(int id, String date, int start, int end){
writer.println("addShift/"+id+"/"+date+"/"+start+"/"+end);
}
void removeShift(int id, String date, int start, int end){
......@@ -167,18 +169,32 @@ public class Model {
end = date.plusDays(6 - today).toString();
}
return convertToShift(getShiftsByWeek(start, end));
//return convertToShift(getShiftsByWeek(start, end));
ArrayList<String> test = new ArrayList<>();
test.add("123.2022-03-10.0800.1600");
return convertToShift(test);
}
//for view
public ArrayList<Shift> getDailySchedule(){
return new ArrayList<>();
}
//format id.yyyy-mm-dd.start.end
//convert ArrayList<String> to ArrayList<Shift>
protected ArrayList<Shift> convertToShift(ArrayList<String> input){
System.out.println(input.get(0)); //debug
return new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-ddHHmm");
ArrayList<Shift> output = new ArrayList<>();
for (String dbShift : input){
String[] strings = dbShift.split("\\.");
int id = Integer.parseInt(strings[0]);
LocalDateTime start = LocalDateTime.parse(strings[1] + strings[2], formatter);
LocalDateTime end = LocalDateTime.parse(strings[1] + strings[3], formatter);
output.add(new Shift(id, start, end));
}
return output;
}
ArrayList<String> getEmployeeShifts(String id){
......
......@@ -11,11 +11,6 @@ public class ScheduleApp extends Application {
@Override
public void start(Stage stage) throws Exception {
// just for now, not sure if using fxml or not?
BorderPane root = new BorderPane();
Label hello = new Label("Testing again :)");
root.setCenter(hello);
FXMLLoader fxmlLoader = new FXMLLoader(ScheduleApp.class.getResource("login.fxml"));
Scene scene = new Scene(fxmlLoader.load(),800,600);
......
......@@ -47,11 +47,11 @@ public class WeeklyView extends ScheduleView{
int col; //depends on day of week
//get updated schedule
/* ArrayList<Shift> schedule = model.getWeeklySchedule();
ArrayList<Shift> schedule = model.getWeeklySchedule();
for (Shift shift : schedule){
col = (shift.getStart().getDayOfWeek().getValue() % 7) + 1; //need Sunday=7 to be 1
this.add(this.formatShiftButton(shift), col, this.shiftGetRow(shift), 1, this.shiftGetLength(shift));
}*/
}
}
}
No preview for this file type
No preview for this file type
No preview for this file type
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