Fix FXML errors and make Analytics accessible to all users

This commit is contained in:
2026-02-28 14:34:11 -07:00
parent f503a7e2b6
commit 2f653acac6
5 changed files with 27 additions and 26 deletions

11
log.txt Normal file
View File

@@ -0,0 +1,11 @@
[2026-02-25 11:54:59] [INSERT] DB_INSERT | Table: sale | ID: Sale ID: 22 | Details: Created sale with 1 items, total: $240.00
[2026-02-25 11:55:37] [INSERT] DB_INSERT | Table: sale | ID: Sale ID: 23 | Details: Created sale with 1 items, total: $240.00
[2026-02-28 14:29:17] [ERROR] EXCEPTION | Location: ConnectionDB.getConnection | Type: CommunicationsException | Message: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. | Context: Establishing database connection
[2026-02-28 14:29:17] [ERROR] EXCEPTION | Location: ConnectionDB.getConnection | Type: CommunicationsException | Message: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. | Context: Establishing database connection
[2026-02-28 14:30:29] [ERROR] EXCEPTION | Location: MainLayoutController.loadView | Type: LoadException | Message:
/home/user/Documents/SAIT/Winter%202026/intellij/group-2-threaded-project-petshop-desktop/target/classes/org/example/petshopdesktop/modelviews/analytics-view.fxml:58
| Context: Loading view: analytics-view.fxml

View File

@@ -55,13 +55,6 @@ public class AnalyticsController {
@FXML
public void initialize() {
if (!UserSession.getInstance().isAdmin()) {
lblError.setText("Access restricted to administrators only.");
lblError.setVisible(true);
disableAllCharts();
return;
}
configureCharts();
loadAnalyticsData();
}

View File

@@ -174,8 +174,8 @@ public class MainLayoutController {
public void initialize() {
applyRBAC();
loadView("pet-view.fxml");
updateButtons(btnPets);
loadView("analytics-view.fxml");
updateButtons(btnAnalytics);
}
private void applyRBAC() {
@@ -204,11 +204,6 @@ public class MainLayoutController {
btnStaffAccounts.setManaged(isAdmin);
}
if (btnAnalytics != null) {
btnAnalytics.setVisible(isAdmin);
btnAnalytics.setManaged(isAdmin);
}
btnSalesHistory.setText(isAdmin ? "Sales History" : "Sales");

View File

@@ -32,6 +32,17 @@
</Label>
<Separator prefWidth="200.0" style="-fx-background-color: #444444; -fx-opacity: 0.35;" />
<Button fx:id="btnAnalytics" alignment="CENTER_LEFT" mnemonicParsing="false" onAction="#btnAnalyticsClicked" prefWidth="250.0" style="-fx-background-color: transparent; -fx-background-radius: 10; -fx-cursor: hand; -fx-focus-color: transparent; -fx-faint-focus-color: transparent;" text="Analytics" textFill="#cbd5e1">
<font>
<Font name="System" size="13.0" />
</font>
<padding>
<Insets bottom="10.0" left="14.0" right="14.0" top="10.0" />
</padding>
</Button>
<Separator prefWidth="200.0" style="-fx-background-color: #444444; -fx-opacity: 0.35;" />
<Label text="PETS" textFill="#94a3b8">
<font>
<Font name="System Bold" size="12.0" />
@@ -143,15 +154,6 @@
</padding>
</Button>
<Button fx:id="btnAnalytics" alignment="CENTER_LEFT" mnemonicParsing="false" onAction="#btnAnalyticsClicked" prefWidth="250.0" style="-fx-background-color: transparent; -fx-background-radius: 10; -fx-cursor: hand; -fx-focus-color: transparent; -fx-faint-focus-color: transparent;" text="Analytics" textFill="#cbd5e1">
<font>
<Font name="System" size="13.0" />
</font>
<padding>
<Insets bottom="10.0" left="14.0" right="14.0" top="10.0" />
</padding>
</Button>
<Region VBox.vgrow="ALWAYS" />
<Button fx:id="btnLogout" alignment="CENTER_LEFT" mnemonicParsing="false" onAction="#btnLogoutClicked" prefWidth="250.0" style="-fx-background-color: rgba(255,255,255,0.08); -fx-background-radius: 10; -fx-cursor: hand; -fx-focus-color: transparent; -fx-faint-focus-color: transparent;" text="Logout" textFill="#e2e8f0">

View File

@@ -121,7 +121,7 @@
<CategoryAxis label="Date" side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis label="Revenue ($)" side="LEFT" />
<NumberAxis label="Revenue" side="LEFT" />
</yAxis>
</LineChart>
</VBox>
@@ -138,7 +138,7 @@
</Label>
<BarChart fx:id="chartTopRevenue" animated="true" legendSide="BOTTOM" prefHeight="300.0">
<xAxis>
<NumberAxis label="Revenue ($)" side="BOTTOM" />
<NumberAxis label="Revenue" side="BOTTOM" />
</xAxis>
<yAxis>
<CategoryAxis label="Product" side="LEFT" />
@@ -193,7 +193,7 @@
<CategoryAxis label="Employee" side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis label="Revenue ($)" side="LEFT" />
<NumberAxis label="Revenue" side="LEFT" />
</yAxis>
</BarChart>
</VBox>