Skip to content
Snippets Groups Projects
Commit 151a2816 authored by ArktikHunter's avatar ArktikHunter
Browse files

commit before pull

parent dce3321d
No related branches found
No related tags found
No related merge requests found
Showing
with 37 additions and 12 deletions
......@@ -21,5 +21,10 @@
<option name="name" value="In Project Repo" />
<option name="url" value="file://C:\Users\trade\IdeaProjects\cmpt-370-group-project\SchedulerApp/lib" />
</remote-repository>
<remote-repository>
<option name="id" value="in-project" />
<option name="name" value="In Project Repo" />
<option name="url" value="file://C:\Users\hunte\Desktop\cmpt-370-group-project\cmpt-370-group-project\SchedulerApp/lib" />
</remote-repository>
</component>
</project>
\ No newline at end of file
......@@ -57,7 +57,7 @@ public class Controller {
Stage popupStage;
Scene popupScene;
Model model = new Model("10.237.93.139" ,8989);
Model model = new Model("localhost" ,8989);
DailyView dailyView;
WeeklyView weeklyView;
BorderPane root;
......@@ -244,8 +244,10 @@ public class Controller {
bottomPanel = bottomLoader.load();
dailyView = new DailyView();
dailyView.setModel(model);
model.addSubscriber(dailyView);
weeklyView = new WeeklyView();
weeklyView.setModel(model);
model.addSubscriber(weeklyView);
root.setTop(header);
root.setLeft(sidePanel);
......
......@@ -13,6 +13,7 @@ public class Model {
private Socket socket;
protected ArrayList<String> shifts;
protected ArrayList<String> employees;
protected ArrayList<ModelSubscriber> subscribers;
static LocalDate date;
private boolean isManager;
......@@ -20,6 +21,8 @@ public class Model {
private int selectedEmployee;
public Model(String hostname, int port) {
selectedEmployee = 1; //testing
subscribers = new ArrayList<>();
if(date == null) {
date = LocalDate.now();
}
......@@ -62,6 +65,7 @@ public class Model {
//for manager only, allows viewing of weekly schedule by employee
public void setSelectedEmployee(int id){
selectedEmployee = id;
notifySubscribers();
}
public int getSelectedEmployee(){
......@@ -70,15 +74,18 @@ public class Model {
public void dateNext(){
date = date.plusDays(1);
notifySubscribers();
}
public void datePrev(){
date = date.minusDays(1);
notifySubscribers();
}
//todo: add calender to fill jump field
public void dateJump(LocalDate date){
this.date = date;
notifySubscribers();
}
//todo
......@@ -129,14 +136,17 @@ public class Model {
void addShift(int id, String date, int start, int end){
writer.println("addShift/"+id+"/"+date+"/"+start+"/"+end);
notifySubscribers();
}
void removeShift(int shiftID){
writer.println("removeShift/"+shiftID);
notifySubscribers();
}
void editShift(int shiftID, String day, int start, int end) {
writer.println("editShift/"+shiftID+"/"+day+"/"+start+"/"+end);
notifySubscribers();
}
void printAllShifts() {
......@@ -216,14 +226,10 @@ public class Model {
start = date.minusDays(today).toString();
end = date.plusDays(6 - today).toString();
}
printAllShifts();
System.out.println("start: " + start + " end: " + end + " shifts returned " + getShiftsByWeek(start, end).size());
return convertToShift(getShiftsByWeek(start, end));
/*
ArrayList<String> test = new ArrayList<>();
test.add("123.2022-03-10.0800.1600");
return convertToShift(test);
*/
}
//for view
......@@ -319,4 +325,15 @@ public class Model {
String[] splitString = tempEmployee.split("\\.");
return Integer.parseInt(splitString[0]);
}
//for publish/subscribe
public void addSubscriber(ModelSubscriber sub){
subscribers.add(sub);
}
public void notifySubscribers(){
for (ModelSubscriber sub : subscribers){
sub.modelChanged();
}
}
}
package com.example.schedulerapp;
public interface ModelSubscriber {
void modelChanged();
}
......@@ -46,7 +46,7 @@ public class ScheduleServer {
public static void main(String[] args) {
//Set "localhost" is working locally. Razer-Blade lan address (NOT static) is "172.16.1.99"
ScheduleServer server = new ScheduleServer("10.237.93.139", 8989,
ScheduleServer server = new ScheduleServer("localhost", 8989,
"jdbc:mysql://localhost:3306/ScheduleApp", "root", "password");
server.execute();
}
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -16,10 +16,10 @@
</HBox>
<HBox prefHeight="25.0" prefWidth="800.0">
<children>
<Button mnemonicParsing="false" prefHeight="25.0" prefWidth="200.0" text="Previous" />
<Label prefHeight="25.0" prefWidth="200.0" text="Current: " />
<Button mnemonicParsing="false" prefHeight="25.0" prefWidth="200.0" text="Jump" />
<Button mnemonicParsing="false" prefHeight="25.0" prefWidth="200.0" text="Next" />
<Button mnemonicParsing="false" onMouseClicked="#prevButtonClicked" prefHeight="25.0" prefWidth="200.0" text="Previous" />
<Label fx:id="currentDateText" prefHeight="25.0" prefWidth="200.0" text="Current: " />
<Button mnemonicParsing="false" onMouseClicked="#jumpButtonClicked" prefHeight="25.0" prefWidth="200.0" text="Jump" />
<Button mnemonicParsing="false" onMouseClicked="#nextButtonClicked" prefHeight="25.0" prefWidth="200.0" text="Next" />
</children>
</HBox>
</children>
......
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