Skip to content

Commit 53352e9

Browse files
committed
Update client
1 parent 8b54b1f commit 53352e9

File tree

7 files changed

+41
-25
lines changed

7 files changed

+41
-25
lines changed

rss-dashboard-client/src/main/java/rss_dashboard/client/controller/MainController.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ private CompletableFuture<Void> saveDashboardModificationAsync(int page, int row
147147

148148
private void renderCategories() {
149149
categoryTreeView.setRoot(new TreeItem<String>("Categories"));
150+
150151
rssChannelMappings.values().forEach(rssItemIds -> {
151152
rssItemIds.stream().map(rssItems::get).forEach(rssItem -> {
152153
List<String> categories = rssItem.getCategories();
@@ -163,12 +164,13 @@ private void renderCategories() {
163164

164165
if (nextItem == null) {
165166
String category = categories.get(0);
166-
nextItem = new TreeItem<>(categories.get(0));
167+
nextItem = new TreeItem<>(category);
167168

168169
int index = 0;
169170
List<TreeItem<String>> children = item.getChildren();
170171
for (; index < children.size(); index++) {
171-
if (children.get(index).getValue().compareTo(category) > 0) {
172+
if (children.get(index).getValue().toLowerCase()
173+
.compareTo(category.toLowerCase()) > 0) {
172174
break;
173175
}
174176
}
@@ -204,7 +206,7 @@ private void renderRssChannel(int pageId, int rowId, int columnId, String rssCha
204206
rssGridPane.add(pane, columnId, rowId);
205207

206208
RssChannelController controller = loader.getController();
207-
rssChannelControllers.put(rssChannel.getId(), controller);
209+
rssChannelControllers.put(rssChannelId, controller);
208210
controller.setDeleteCallback(() -> {
209211
rssGridPane.getChildren().remove(pane);
210212
renderEmptyRssChannel(pageId, rowId, columnId);
@@ -289,9 +291,11 @@ private void renderMapping(String rssChannelId, List<String> categories, List<St
289291
.filter(rssItem -> {
290292
return (categories.isEmpty()
291293
|| categories.stream().anyMatch(category -> {
292-
return rssItem.getCategories().stream().anyMatch(category::equalsIgnoreCase);
294+
return rssItem.getCategories().stream()
295+
.anyMatch(category::equalsIgnoreCase);
293296
})) && (keywords.isEmpty() || keywords.stream().anyMatch(keyword -> {
294-
return rssItem.getDescription().toLowerCase().contains(keyword.toLowerCase())
297+
return rssItem.getDescription().toLowerCase()
298+
.contains(keyword.toLowerCase())
295299
|| rssItem.getTitle().toLowerCase().contains(keyword.toLowerCase());
296300
}));
297301
})

rss-dashboard-client/src/main/java/rss_dashboard/client/controller/RssChannelController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.IOException;
44
import java.util.List;
5+
import java.util.stream.Collectors;
56

67
import javafx.application.HostServices;
78
import javafx.event.ActionEvent;
@@ -45,7 +46,11 @@ public void setHostServices(HostServices hostServices) {
4546
public void setRssChannel(IRssChannel rssChannel) {
4647
titleLabel.setText(rssChannel.getTitle());
4748
hyperlink.setText(rssChannel.getLink());
48-
descriptionLabel.setText(rssChannel.getDescription());
49+
50+
String description = rssChannel.getDescription();
51+
descriptionLabel.setText(description == null || description.isEmpty()
52+
? "No description given."
53+
: description);
4954
}
5055

5156
public void setRssItems(List<IRssItem> rssItems) {

rss-dashboard-client/src/main/java/rss_dashboard/client/controller/RssItemController.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package rss_dashboard.client.controller;
22

3+
import java.nio.charset.StandardCharsets;
4+
35
import javafx.application.HostServices;
46
import javafx.fxml.FXML;
57
import javafx.scene.control.Hyperlink;
@@ -16,16 +18,25 @@ public class RssItemController {
1618
@FXML
1719
protected Label pubDateLabel;
1820

21+
private String url;
22+
1923
public void setRssItem(IRssItem rssItem) {
2024
titleLabel.setText(rssItem.getTitle());
21-
hyperlink.setText(rssItem.getLink());
22-
descriptionLabel.setText(rssItem.getDescription());
25+
hyperlink.setText("link");
26+
27+
String description = rssItem.getDescription();
28+
new String(description.getBytes(), StandardCharsets.UTF_8);
29+
descriptionLabel.setText(description == null || description.isEmpty()
30+
? "No description given."
31+
: description);
32+
2333
pubDateLabel.setText(rssItem.getPubDate());
34+
this.url = rssItem.getLink();
2435
}
2536

2637
public void setHostServices(HostServices hostServices) {
2738
hyperlink.setOnAction(event -> {
28-
hostServices.showDocument(hyperlink.getText());
39+
hostServices.showDocument(url);
2940
});
3041
}
3142
}

rss-dashboard-client/src/main/java/rss_dashboard/client/model/rss/RssChannelMapping.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.util.List;
44

5+
import com.google.api.client.util.Key;
6+
57
import lombok.AllArgsConstructor;
68
import lombok.Builder;
79
import lombok.Getter;
@@ -13,5 +15,6 @@
1315
@AllArgsConstructor
1416
@Builder
1517
public class RssChannelMapping implements IRssChannelMapping {
18+
@Key
1619
private List<String> rssItemIds;
1720
}

rss-dashboard-client/src/main/java/rss_dashboard/client/network/HttpClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class HttpClient implements INetworkClient {
4141
public void initialize(HttpRequest request) {
4242
request.setParser(objectParser);
4343
request.getHeaders().setAccept("application/json");
44-
request.getHeaders().setContentType("application/json");
44+
request.getHeaders().setContentType("application/json; charset=utf-8");
4545
request.getHeaders().set("keepalive", true);
4646
}
4747
});
@@ -59,7 +59,7 @@ public HttpClient(String baseUrlString) throws MalformedURLException {
5959
miscLogoutUrl = new GenericUrl(new URL(baseUrlString + "/misc/logout"));
6060
rssChannelUrl = new GenericUrl(new URL(baseUrlString + "/rss/channels"));
6161
rssItemUrl = new GenericUrl(new URL(baseUrlString + "/rss/items"));
62-
rssChannelMappingUrl = new GenericUrl(new URL(baseUrlString + "/rss/channel_mapping"));
62+
rssChannelMappingUrl = new GenericUrl(new URL(baseUrlString + "/rss/mapping"));
6363
dashboardLayoutUrl = new GenericUrl(new URL(baseUrlString + "/dashboard/layout"));
6464
}
6565

rss-dashboard-client/src/main/resources/fxml/RssChannelView.fxml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
<?import javafx.scene.layout.VBox?>
1111
<?import javafx.scene.text.Font?>
1212

13-
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308"
14-
minWidth="0.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1"
15-
fx:controller="rss_dashboard.client.controller.RssChannelController">
13+
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="0.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="rss_dashboard.client.controller.RssChannelController">
1614
<children>
1715
<BorderPane minWidth="0.0">
1816
<left>
@@ -44,20 +42,17 @@
4442
</HBox>
4543
</left>
4644
<right>
47-
<VBox alignment="TOP_RIGHT" minWidth="0.0"
48-
BorderPane.alignment="CENTER">
45+
<VBox alignment="TOP_RIGHT" minWidth="0.0" BorderPane.alignment="CENTER">
4946
<children>
50-
<Button fx:id="deleteButton" mnemonicParsing="false"
51-
onAction="#handleDeleteButtonPressed" text="Delete" />
47+
<Button fx:id="deleteButton" mnemonicParsing="false" onAction="#handleDeleteButtonPressed" text="Delete" />
5248
</children>
5349
<padding>
5450
<Insets right="10.0" top="10.0" />
5551
</padding>
5652
</VBox>
5753
</right>
5854
</BorderPane>
59-
<ListView fx:id="itemListView" maxHeight="1.7976931348623157E308"
60-
maxWidth="1.7976931348623157E308" VBox.vgrow="ALWAYS" />
55+
<ListView fx:id="itemListView" VBox.vgrow="ALWAYS" />
6156
</children>
6257
<padding>
6358
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />

rss-dashboard-client/src/main/resources/fxml/RssItemView.fxml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@
77
<?import javafx.scene.layout.VBox?>
88
<?import javafx.scene.text.Font?>
99

10-
<VBox maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0"
11-
xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1"
12-
fx:controller="rss_dashboard.client.controller.RssItemController">
10+
<VBox minHeight="0.0" minWidth="0.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="rss_dashboard.client.controller.RssItemController">
1311
<children>
1412
<BorderPane>
1513
<left>
1614
<HBox BorderPane.alignment="CENTER">
1715
<children>
1816
<Label fx:id="titleLabel" text="Label" wrapText="true">
1917
<font>
20-
<Font name="System Bold" size="18.0" />
18+
<Font name="System Bold" size="14.0" />
2119
</font>
2220
</Label>
2321
</children>
@@ -36,6 +34,6 @@
3634
</VBox>
3735
</right>
3836
</BorderPane>
39-
<Label fx:id="descriptionLabel" text="Label" />
37+
<Label fx:id="descriptionLabel" text="Label" wrapText="true" />
4038
</children>
4139
</VBox>

0 commit comments

Comments
 (0)