-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add experimental trends search output
- Loading branch information
Showing
13 changed files
with
289 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
app/src/main/java/io/xeres/app/service/notification/file/FileTrendNotificationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2024 by David Gerber - https://zapek.com | ||
* | ||
* This file is part of Xeres. | ||
* | ||
* Xeres is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Xeres is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Xeres. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.xeres.app.service.notification.file; | ||
|
||
import io.xeres.app.service.notification.NotificationService; | ||
import io.xeres.common.rest.notification.file.FileTrendNotification; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class FileTrendNotificationService extends NotificationService | ||
{ | ||
public void receivedSearch(String keywords) | ||
{ | ||
sendNotification(new FileTrendNotification(keywords)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
common/src/main/java/io/xeres/common/rest/notification/file/FileTrendNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2024 by David Gerber - https://zapek.com | ||
* | ||
* This file is part of Xeres. | ||
* | ||
* Xeres is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Xeres is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Xeres. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.xeres.common.rest.notification.file; | ||
|
||
import io.xeres.common.rest.notification.Notification; | ||
|
||
public record FileTrendNotification(String keywords) implements Notification | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
ui/src/main/java/io/xeres/ui/controller/file/FileTrendViewController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright (c) 2024 by David Gerber - https://zapek.com | ||
* | ||
* This file is part of Xeres. | ||
* | ||
* Xeres is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Xeres is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Xeres. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.xeres.ui.controller.file; | ||
|
||
import io.xeres.ui.client.NotificationClient; | ||
import io.xeres.ui.controller.Controller; | ||
import io.xeres.ui.controller.TabActivation; | ||
import io.xeres.ui.support.util.UiUtils; | ||
import javafx.application.Platform; | ||
import javafx.beans.property.SimpleStringProperty; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.TableColumn; | ||
import javafx.scene.control.TableView; | ||
import net.rgielen.fxweaver.core.FxmlView; | ||
import org.springframework.context.event.ContextClosedEvent; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
import reactor.core.Disposable; | ||
|
||
import java.io.IOException; | ||
|
||
@Component | ||
@FxmlView(value = "/view/file/trend.fxml") | ||
public class FileTrendViewController implements Controller, TabActivation | ||
{ | ||
private final NotificationClient notificationClient; | ||
private Disposable notificationDisposable; | ||
|
||
@FXML | ||
private TableView<TrendResult> trendTableView; | ||
|
||
// @FXML | ||
// private TableColumn<TrendResult, Integer> tableHits; | ||
// | ||
// @FXML | ||
// private TableColumn<TrendResult, String> tableFrom; | ||
|
||
@FXML | ||
private TableColumn<TrendResult, String> tableTerms; | ||
|
||
public FileTrendViewController(NotificationClient notificationClient) | ||
{ | ||
this.notificationClient = notificationClient; | ||
} | ||
|
||
@Override | ||
public void initialize() throws IOException | ||
{ | ||
tableTerms.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().keywords())); | ||
|
||
setupFileTrendNotifications(); | ||
} | ||
|
||
private void setupFileTrendNotifications() | ||
{ | ||
notificationDisposable = notificationClient.getFileTrendNotifications() | ||
.doOnError(UiUtils::showAlertError) | ||
.doOnNext(sse -> Platform.runLater(() -> { | ||
assert sse.data() != null; | ||
trendTableView.getItems().add(new TrendResult(sse.data().keywords())); | ||
if (trendTableView.getItems().size() > 255) // XXX: maybe not optimal... | ||
{ | ||
trendTableView.getItems().removeFirst(); | ||
} | ||
})) | ||
.subscribe(); | ||
} | ||
|
||
@EventListener | ||
public void onApplicationEvent(ContextClosedEvent ignored) | ||
{ | ||
if (notificationDisposable != null && !notificationDisposable.isDisposed()) | ||
{ | ||
notificationDisposable.dispose(); | ||
} | ||
} | ||
|
||
@Override | ||
public void activate() | ||
{ | ||
|
||
} | ||
|
||
@Override | ||
public void deactivate() | ||
{ | ||
|
||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
ui/src/main/java/io/xeres/ui/controller/file/TrendResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024 by David Gerber - https://zapek.com | ||
* | ||
* This file is part of Xeres. | ||
* | ||
* Xeres is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Xeres is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Xeres. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.xeres.ui.controller.file; | ||
|
||
public record TrendResult(String keywords) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.