Skip to content

Commit

Permalink
Merge pull request #3170 from jeonghanlee/alarm-log-table-refactor
Browse files Browse the repository at this point in the history
Alarm log table refactor
  • Loading branch information
shroffk authored Oct 21, 2024
2 parents 64d7db5 + 2a92aa6 commit 72b8cc9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public AlarmLogTableController(WebResource client) {
public void initialize() {
resize.setText("<");
tableView.getColumns().clear();
configCol = new TableColumn<>("Config");

configCol.setCellValueFactory(
alarmMessage -> new SimpleStringProperty(alarmMessage.getValue().getConfig()));
tableView.getColumns().add(configCol);
Expand All @@ -159,7 +159,6 @@ public void initialize() {
pvCol.setCellValueFactory(alarmMessage -> new SimpleStringProperty(alarmMessage.getValue().getPv()));
tableView.getColumns().add(pvCol);

severityCol = new TableColumn<>("Severity");
severityCol.setCellValueFactory(
alarmMessage -> new SimpleStringProperty(alarmMessage.getValue().getSeverity()));
severityCol.setCellFactory(alarmLogTableTypeStringTableColumn -> new TableCell<>() {
Expand All @@ -179,12 +178,17 @@ protected void updateItem(String item, boolean empty) {
});
tableView.getColumns().add(severityCol);

messageCol = new TableColumn<>("Message");
messageCol.setCellValueFactory(
alarmMessage -> new SimpleStringProperty(alarmMessage.getValue().getMessage()));
tableView.getColumns().add(messageCol);

timeCol = new TableColumn<>("Time");
valueCol.setCellValueFactory(
alarmMessage -> {
String value = alarmMessage.getValue().getValue();
return new SimpleStringProperty(value);
});
tableView.getColumns().add(valueCol);

timeCol.setCellValueFactory(
alarmMessage -> {
if (alarmMessage.getValue().getTime() != null) {
Expand All @@ -195,25 +199,21 @@ protected void updateItem(String item, boolean empty) {
});
tableView.getColumns().add(timeCol);

msgTimeCol = new TableColumn<>("Message Time");
msgTimeCol.setCellValueFactory(
alarmMessage -> {
String time = TimestampFormats.MILLI_FORMAT.format(alarmMessage.getValue().getMessage_time());
return new SimpleStringProperty(time);
});
tableView.getColumns().add(msgTimeCol);

deltaTimeCol = new TableColumn<>("Time Delta");
deltaTimeCol.setCellValueFactory(
alarmMessage -> {
java.time.Duration delta = java.time.Duration.between(alarmMessage.getValue().getMessage_time(), Instant.now());
return new SimpleStringProperty(delta.toHours() + ":" + delta.toMinutesPart() + ":" + delta.toSecondsPart()
+ "." + delta.toMillisPart());
});
deltaTimeCol.setVisible(false);
tableView.getColumns().add(deltaTimeCol);

currentSeverityCol = new TableColumn<>("Current Severity");
currentSeverityCol.setCellValueFactory(
alarmMessage -> new SimpleStringProperty(alarmMessage.getValue().getCurrent_severity()));
currentSeverityCol.setCellFactory(alarmLogTableTypeStringTableColumn -> new TableCell<>() {
Expand All @@ -234,12 +234,10 @@ protected void updateItem(String item, boolean empty) {
});
tableView.getColumns().add(currentSeverityCol);

currentMessageCol = new TableColumn<>("Current Message");
currentMessageCol.setCellValueFactory(
alarmMessage -> new SimpleStringProperty(alarmMessage.getValue().getCurrent_message()));
tableView.getColumns().add(currentMessageCol);

commandCol = new TableColumn<>("Command");
commandCol.setCellValueFactory(
alarmMessage -> {
String action = alarmMessage.getValue().getCommand();
Expand All @@ -258,12 +256,10 @@ protected void updateItem(String item, boolean empty) {
});
tableView.getColumns().add(commandCol);

userCol = new TableColumn<>("User");
userCol.setCellValueFactory(
alarmMessage -> new SimpleStringProperty(alarmMessage.getValue().getUser()));
tableView.getColumns().add(userCol);

hostCol = new TableColumn<>("Host");
hostCol.setCellValueFactory(
alarmMessage -> new SimpleStringProperty(alarmMessage.getValue().getHost()));
tableView.getColumns().add(hostCol);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<TextField fx:id="searchHost" GridPane.columnSpan="2" GridPane.rowIndex="13" />
<Label text="%Command" GridPane.rowIndex="14" />
<TextField fx:id="searchCommand" GridPane.columnSpan="2" GridPane.rowIndex="15" />
<Label text="%Time" GridPane.columnSpan="2" GridPane.rowIndex="16">
<Label text="%MessageTime" GridPane.columnSpan="2" GridPane.rowIndex="16">
<GridPane.margin>
<Insets top="5.0" />
</GridPane.margin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,20 @@
</VBox>
<TableView fx:id="tableView" onContextMenuRequested="#createContextMenu" prefHeight="591.0" prefWidth="1000.0" tableMenuButtonVisible="true">
<columns>
<TableColumn fx:id="configCol" minWidth="50.0" prefWidth="75.0" text="%Config" />
<TableColumn fx:id="configCol" minWidth="50.0" prefWidth="75.0" text="%Config" visible="%ConfigVisible" />
<TableColumn fx:id="pvCol" minWidth="50.0" prefWidth="75.0" text="PV" />
<TableColumn fx:id="severityCol" minWidth="50.0" prefWidth="75.0" text="%Severity" />
<TableColumn fx:id="messageCol" minWidth="50.0" prefWidth="75.0" text="%Message" />
<TableColumn fx:id="valueCol" minWidth="50.0" prefWidth="75.0" text="%Value" />
<TableColumn fx:id="valueCol" minWidth="50.0" prefWidth="75.0" text="%Value" visible="%ValueVisible" />
<TableColumn fx:id="timeCol" minWidth="50.0" prefWidth="75.0" text="%Time" />
<TableColumn fx:id="msgTimeCol" minWidth="50.0" prefWidth="75.0" text="%MessageTime" />
<TableColumn fx:id="currentSeverityCol" minWidth="50.0" prefWidth="75.0" text="%CurrentSeverity" />
<TableColumn fx:id="currentMessageCol" minWidth="50.0" prefWidth="75.0" text="%CurrentMessage" />
<TableColumn fx:id="msgTimeCol" minWidth="50.0" prefWidth="75.0" text="%MessageTime" visible="%MTimeVisible"/>
<TableColumn fx:id="deltaTimeCol" minWidth="50.0" prefWidth="75.0" text="%TimeDelta" visible="%TimeDeltaVisible"/>
<TableColumn fx:id="currentSeverityCol" minWidth="50.0" prefWidth="75.0" text="%CurrentSeverity" visible="%CSeverityVisible" />
<TableColumn fx:id="currentMessageCol" minWidth="50.0" prefWidth="75.0" text="%CurrentMessage" visible="%CMessageVisible" />
<TableColumn fx:id="mode" minWidth="50.0" prefWidth="75.0" text="%Mode" />
<TableColumn fx:id="commandCol" minWidth="50.0" prefWidth="75.0" text="%Command" />
<TableColumn fx:id="userCol" minWidth="50.0" prefWidth="75.0" text="%User" />
<TableColumn fx:id="hostCol" minWidth="50.0" prefWidth="75.0" text="%Host" />
<TableColumn fx:id="commandCol" minWidth="50.0" prefWidth="75.0" text="%Command" visible="%CommandVisible" />
<TableColumn fx:id="userCol" minWidth="50.0" prefWidth="75.0" text="%User" visible="%UserVisible" />
<TableColumn fx:id="hostCol" minWidth="50.0" prefWidth="75.0" text="%Host" visible="%HostVisible" />
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,15 @@ Severity=Severity
StartTime=Start Time
Time=Time
User=User
Value=Value
Value=Value
TimeDelta=Time Delta
ConfigVisible=true
ValueVisible=false
MTimeVisible=true
TimeDeltaVisible=false
CSeverityVisible=true
CMessageVisible=true
CommandVisible=true
UserVisible=true
HostVisible=true

Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,14 @@ StartTime=Heure de début
Time=Heure
User=Utilisateur
Value=Valeur
TimeDelta=Heure Delta
ConfigVisible=true
ValueVisible=false
MTimeVisible=true
TimeDeltaVisible=false
CSeverityVisible=true
CMessageVisible=true
CommandVisible=true
UserVisible=true
HostVisible=true

0 comments on commit 72b8cc9

Please sign in to comment.