Skip to content

Commit b5c248d

Browse files
committed
Update advanced search to use server side levels data
1 parent 96fd1df commit b5c248d

File tree

10 files changed

+203
-74
lines changed

10 files changed

+203
-74
lines changed

app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogHttpClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.phoebus.logbook.LogClient;
1414
import org.phoebus.logbook.LogEntry;
1515
import org.phoebus.logbook.LogEntryChangeHandler;
16+
import org.phoebus.logbook.LogEntryLevel;
1617
import org.phoebus.logbook.LogTemplate;
1718
import org.phoebus.logbook.Logbook;
1819
import org.phoebus.logbook.LogbookException;
@@ -551,7 +552,7 @@ public LogTemplate saveTemplate(LogTemplate template) throws LogbookException {
551552
}
552553

553554
@Override
554-
public Collection<org.phoebus.logbook.Level> getLevels(){
555+
public Collection<LogEntryLevel> getLogEntryLevels(){
555556
HttpRequest request = HttpRequest.newBuilder()
556557
.uri(URI.create(Preferences.olog_url + "/levels"))
557558
.GET()
@@ -560,7 +561,7 @@ public Collection<org.phoebus.logbook.Level> getLevels(){
560561
try {
561562
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
562563
return OlogObjectMappers.logEntryDeserializer.readValue(
563-
response.body(), new TypeReference<Set<org.phoebus.logbook.Level>>() {
564+
response.body(), new TypeReference<Set<LogEntryLevel>>() {
564565
});
565566
} catch (Exception e) {
566567
LOGGER.log(Level.WARNING, "Unable to get templates from service", e);

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/AdvancedSearchViewController.java

Lines changed: 166 additions & 52 deletions
Large diffs are not rendered by default.

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTableViewController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ public void initialize() {
165165
configureComboBox();
166166
ologQueries.setAll(ologQueryManager.getQueries());
167167

168-
searchParameters.addListener((observable, oldValue, newValue) -> query.getEditor().setText(newValue));
168+
searchParameters.addListener((observable, oldValue, newValue) -> {
169+
query.getEditor().setText(newValue);
170+
});
169171

170172
tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
171173

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/SearchParameters.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class SearchParameters implements ObservableValue<String> {
4343
private SimpleStringProperty title = new SimpleStringProperty();
4444
private SimpleStringProperty text = new SimpleStringProperty();
4545
private SimpleStringProperty author = new SimpleStringProperty();
46-
private SimpleStringProperty level = new SimpleStringProperty();
46+
private SimpleStringProperty levels = new SimpleStringProperty();
4747
private SimpleStringProperty tags = new SimpleStringProperty();
4848
private SimpleStringProperty logbooks = new SimpleStringProperty();
4949
private SimpleStringProperty startTime = new SimpleStringProperty();
@@ -74,7 +74,7 @@ public SearchParameters() {
7474
updateMap(Keys.OWNER, newValue);
7575
notifyListeners();
7676
});
77-
level.addListener((observable, oldValue, newValue) -> {
77+
levels.addListener((observable, oldValue, newValue) -> {
7878
updateMap(Keys.LEVEL, newValue);
7979
notifyListeners();
8080
});
@@ -106,7 +106,7 @@ private void updateMap(Keys key, String newValue) {
106106
} else {
107107
searchParameters.put(key, newValue);
108108
}
109-
notifyListeners();
109+
//notifyListeners();
110110
}
111111

112112
public void addListener(InvalidationListener listener) {
@@ -149,8 +149,8 @@ public SimpleStringProperty authorProperty() {
149149
return author;
150150
}
151151

152-
public SimpleStringProperty levelProperty() {
153-
return level;
152+
public SimpleStringProperty levelsProperty() {
153+
return levels;
154154
}
155155

156156
public SimpleStringProperty tagsProperty() {
@@ -203,9 +203,9 @@ public void setQuery(String query) {
203203
textProperty().setValue(null);
204204
}
205205
if (map.containsKey(Keys.LEVEL.getName())) {
206-
levelProperty().setValue(map.get(Keys.LEVEL.getName()));
206+
levelsProperty().setValue(map.get(Keys.LEVEL.getName()));
207207
} else {
208-
levelProperty().setValue(null);
208+
levelsProperty().setValue(null);
209209
}
210210
if (map.containsKey(Keys.TAGS.getName())) {
211211
tagsProperty().setValue(map.get(Keys.TAGS.getName()));

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import org.phoebus.framework.selection.SelectionService;
6262
import org.phoebus.logbook.LogClient;
6363
import org.phoebus.logbook.LogEntry;
64+
import org.phoebus.logbook.LogEntryLevel;
6465
import org.phoebus.logbook.LogFactory;
6566
import org.phoebus.logbook.LogService;
6667
import org.phoebus.logbook.LogTemplate;
@@ -824,9 +825,9 @@ private void getServerSideStaticData() {
824825

825826
templatesProperty.setAll(logClient.getTemplates().stream().toList());
826827

827-
Collection<org.phoebus.logbook.Level> levels = logClient.getLevels();
828-
availableLevels.setAll(levels.stream().map(org.phoebus.logbook.Level::name).sorted().toList());
829-
Optional<org.phoebus.logbook.Level> optionalLevel = levels.stream().filter(org.phoebus.logbook.Level::defaultLevel).findFirst();
828+
Collection<LogEntryLevel> levels = logClient.getLogEntryLevels();
829+
availableLevels.setAll(levels.stream().map(LogEntryLevel::name).sorted().toList());
830+
Optional<LogEntryLevel> optionalLevel = levels.stream().filter(LogEntryLevel::defaultLevel).findFirst();
830831
String defaultLevel = null;
831832
if(optionalLevel.isPresent()){
832833
// One level value should be the default level
@@ -906,7 +907,7 @@ public Optional<LogEntry> getLogEntryResult() {
906907
* Loads template to configure UI elements.
907908
*
908909
* @param logTemplate A {@link LogTemplate} selected by user. If <code>null</code>, all log entry elements
909-
* will be cleared, except the Level selector, which will be set to the top-most item.
910+
* will be cleared, except the LogEntryLevel selector, which will be set to the top-most item.
910911
*/
911912
private void loadTemplate(LogTemplate logTemplate) {
912913
if (logTemplate != null) {

app/logbook/olog/ui/src/main/resources/log_olog_ui_preferences.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ default_logbook_query=desc=*&start=12 hours&end=now
1111
# Stylesheet for the items in the log calendar view
1212
calendar_view_item_stylesheet=Agenda.css
1313

14-
# Text to render for the "Level" field of a log entry. Sites may wish to customize this with respect to
14+
# Text to render for the "LogEntryLevel" field of a log entry. Sites may wish to customize this with respect to
1515
# its wording and its implied purpose.
1616
level_field_name=Level:
1717

app/logbook/olog/ui/src/main/resources/org/phoebus/logbook/olog/ui/AdvancedSearchView.fxml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
~ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2424
-->
2525

26-
<AnchorPane fx:id="advancedSearchPane" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.phoebus.logbook.olog.ui.AdvancedSearchViewController">
26+
<AnchorPane fx:id="advancedSearchPane" xmlns="http://javafx.com/javafx/17.0.12" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.phoebus.logbook.olog.ui.AdvancedSearchViewController">
2727

2828
<children>
29-
<GridPane layoutX="18.0" layoutY="95.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
29+
<GridPane fx:id="gridPane" layoutX="18.0" layoutY="95.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
3030
<columnConstraints>
3131
<ColumnConstraints hgrow="NEVER" minWidth="10.0" prefWidth="100.0" />
3232
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
@@ -67,7 +67,16 @@
6767
<Label text="%Text" GridPane.rowIndex="3" />
6868
<TextField fx:id="searchText" GridPane.columnSpan="2" GridPane.rowIndex="4" />
6969
<Label fx:id="levelLabel" text="Level:" GridPane.rowIndex="5" />
70-
<ComboBox fx:id="levelSelector" prefWidth="150.0" GridPane.columnSpan="2" GridPane.rowIndex="6" />
70+
<!--<ComboBox fx:id="levelSelector" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" GridPane.columnSpan="2" GridPane.rowIndex="6" />-->
71+
<HBox maxWidth="1.7976931348623157E308" GridPane.columnSpan="2" GridPane.rowIndex="6">
72+
<children>
73+
<TextField fx:id="selectedLevelsField" editable="false" HBox.hgrow="ALWAYS">
74+
<HBox.margin>
75+
<Insets right="5.0" />
76+
</HBox.margin></TextField>
77+
<ToggleButton fx:id="levelsToggleButton" onAction="#selectLevels" />
78+
</children>
79+
</HBox>
7180
<Label text="%Logbooks" GridPane.rowIndex="7" />
7281
<TextField fx:id="searchLogbooks" editable="false" GridPane.columnSpan="2" GridPane.rowIndex="8" />
7382
<Label text="%Tags" GridPane.rowIndex="9" />

app/logbook/ui/src/main/resources/log_ui_preferences.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ default_logbook_query=search=*&start=12 hours&end=now
1111
# Stylesheet for the items in the log calendar view
1212
calendar_view_item_stylesheet=Agenda.css
1313

14-
# Text to render for the "Level" field of a log entry. Sites may wish to customize this with respect to
14+
# Text to render for the "LogEntryLevel" field of a log entry. Sites may wish to customize this with respect to
1515
# its wording and its implied purpose.
1616
level_field_name=Level:

core/logbook/src/main/java/org/phoebus/logbook/LogClient.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.util.Collections;
77
import java.util.List;
88
import java.util.Map;
9-
import java.util.Set;
109

1110
/**
1211
* @author Eric Berryman taken from shroffk
@@ -531,7 +530,10 @@ default LogTemplate saveTemplate(LogTemplate logTemplate) throws LogbookExceptio
531530
return null;
532531
}
533532

534-
default Collection<Level> getLevels(){
533+
/**
534+
* @return List of {@link LogEntryLevel}s maintained in the service
535+
*/
536+
default Collection<LogEntryLevel> getLogEntryLevels(){
535537
return Collections.emptySet();
536538
}
537539
}

core/logbook/src/main/java/org/phoebus/logbook/Level.java renamed to core/logbook/src/main/java/org/phoebus/logbook/LogEntryLevel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
* default level. Server will ensure only one single
1212
* level is maintained as the default level.
1313
*/
14-
public record Level(String name, boolean defaultLevel) {
14+
public record LogEntryLevel(String name, boolean defaultLevel) {
1515
}

0 commit comments

Comments
 (0)