Skip to content

Commit

Permalink
Merge branch 'release/0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Nov 19, 2017
2 parents 5e3c3b5 + c7233f4 commit 7cdca8d
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 137 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# FAF Moderator Client
This application enables faforever.com moderators to perform administrative actions. This involves:
- managing of users
- avatars
- map & mod vault
- checking recent activities


# Setting up your environment

## Recommended software
- We recommend [JetBrains IntelliJ](https://www.jetbrains.com/idea) as IDE. The community edition is free and open source.
- For editing the user interface, we strongly recommend [Scene Builder](https://gluonhq.com/products/scene-builder)
- For a simple setup and testing of the dependencies you should use [Docker](https://www.docker.org) and [Docker Compose](https://github.com/docker/compose/releases)

## Boot the dependencies
- Checkout the [FAF Stack](https://github.com/FAForver/faf-stack) and boot the api via `docker-compose up -d faf-java-api`. This will also boot the FAF database.
- Get some [test data](https://github.com/FAForever/db/blob/develop/test-data.sql) and insert it into the MySQL db (user: root & password: banana). A tool like HeidiSQL can help you with this. This also adds a moderator account with username: test & password: test_password

## Run from source

1. Clone the project with git
1. Import the project into IntelliJ as "Maven Project"
1. Make sure you have the IntelliJ [Lombok plugin](https://plugins.jetbrains.com/idea/plugin/6317-lombok-plugin) installed
1. Make sure you have `Enable annotation processing` enabled in the settings
1. Add the dev profile as command line options ("VM options" in IntelliJ) using `-Dspring.profiles.active=dev`
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.faforever</groupId>
<artifactId>faf-moderator-client</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<packaging>jar</packaging>

<name>faf-moderator-client</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("FAF Moderator Client");

UiService uiService = applicationContext.getBean(UiService.class);
MainController mainController = uiService.loadFxml("mainWindow.fxml");
MainController mainController = uiService.loadFxml("ui/mainWindow.fxml");
mainController.display();
primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("/media/favicon.png")));
primaryStage.setScene(new Scene(mainController.getRoot()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import lombok.Getter;
import lombok.Setter;

import java.time.OffsetDateTime;
import java.util.List;

@Getter
Expand All @@ -25,6 +26,10 @@ public class Player {
private String userAgent;
@RestrictedVisibility("IsModerator")
private String steamId;
@RestrictedVisibility("IsModerator")
private String recentIpAddress;
private OffsetDateTime createTime;
private OffsetDateTime updateDateTime;

@Relationship("globalRating")
private GlobalRating globalRating;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public List<Player> findLatestRegistrations() {
.pageSize(50);
addModeratorIncludes(routeBuilder);

List<Player> result = fafApi.getPage(routeBuilder, 50, 1, Collections.emptyMap());
List<Player> result = fafApi.getPage(routeBuilder, 100, 1, Collections.emptyMap());
log.trace("found {} users", result.size());
return result;
}
Expand Down Expand Up @@ -82,6 +82,10 @@ public List<Player> findUserBySteamId(@NotNull String pattern) {
return findUsersByAttribute("steamId", pattern);
}

public List<Player> findUserByIP(@NotNull String pattern) {
return findUsersByAttribute("recentIpAddress", pattern);
}

public Collection<Player> findUsersByPreviousName(@NotNull String pattern) {
log.debug("Searching for user by previous name with pattern: {}", pattern);
ElideRouteBuilder<NameRecord> routeBuilder = ElideRouteBuilder.of(NameRecord.class)
Expand All @@ -103,7 +107,7 @@ public List<Teamkill> findLatestTeamkills() {
.addInclude("victim")
.sort("id", false);

List<Teamkill> result = fafApi.getPage(routeBuilder, 50, 1, Collections.emptyMap());
List<Teamkill> result = fafApi.getPage(routeBuilder, 100, 1, Collections.emptyMap());
log.trace("found {} teamkills", result.size());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class MainController implements Controller<TabPane> {
public RadioButton searchUserByPreviousNamesRadioButton;
public RadioButton searchUserByEmailRadioButton;
public RadioButton searchUserBySteamIdRadioButton;
public RadioButton searchUserByIpRadioButton;
public TextField userSearchTextField;
public Button newBanButton;
public Button editBanButton;
Expand Down Expand Up @@ -138,7 +139,7 @@ private void initRecentActivityTab() {
}

public void display() {
LoginController loginController = uiService.loadFxml("login.fxml");
LoginController loginController = uiService.loadFxml("ui/login.fxml");

Stage loginDialog = new Stage();
loginDialog.setOnCloseRequest(event -> System.exit(0));
Expand Down Expand Up @@ -219,6 +220,8 @@ public void onUserSearch() {
usersFound = userService.findUserByEmail(searchPattern);
} else if (searchUserBySteamIdRadioButton.isSelected()) {
usersFound = userService.findUserBySteamId(searchPattern);
} else if (searchUserByIpRadioButton.isSelected()) {
usersFound = userService.findUserByIP(searchPattern);
}

userSearchTableView.getItems().addAll(usersFound);
Expand Down Expand Up @@ -275,7 +278,7 @@ public void onNewBan() {
Player selectedPlayer = userSearchTableView.getSelectionModel().getSelectedItem();
Assert.notNull(selectedPlayer, "Tou need to select a player to create a ban.");

BanInfoController banInfoController = uiService.loadFxml("banInfo.fxml");
BanInfoController banInfoController = uiService.loadFxml("ui/banInfo.fxml");
banInfoController.setBanInfo(new BanInfo()
.setPlayer(selectedPlayer)
);
Expand All @@ -290,7 +293,7 @@ public void onEditBan() {
BanInfo selectedBan = userBansTableView.getSelectionModel().getSelectedItem();
Assert.notNull(selectedBan, "You need to select a ban to edit it.");

BanInfoController banInfoController = uiService.loadFxml("banInfo.fxml");
BanInfoController banInfoController = uiService.loadFxml("ui/banInfo.fxml");
banInfoController.setBanInfo(selectedBan);

Stage banInfoDialog = new Stage();
Expand Down
74 changes: 69 additions & 5 deletions src/main/java/com/faforever/moderatorclient/ui/ViewHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import javafx.scene.control.cell.TreeItemPropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.text.TextAlignment;
import org.apache.maven.artifact.versioning.ComparableVersion;

import java.net.URL;
Expand Down Expand Up @@ -236,10 +238,52 @@ static void buildTeamkillTableView(javafx.scene.control.TableView<Teamkill> tabl
}

static void buildUserTableView(TableView<Player> tableView) {
TableColumn<Player, String> idColumn = new TableColumn<>("ID");
idColumn.setCellValueFactory(new PropertyValueFactory<>("id"));
idColumn.setComparator(Comparator.comparingInt(Integer::parseInt));
idColumn.setMinWidth(50);
TableColumn<Player, Player> idColumn = new TableColumn<>("ID");
idColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue()));
idColumn.setCellFactory(param -> new TableCell<Player, Player>() {
Tooltip tooltip = new Tooltip();

{
setTooltip(tooltip);
setTextAlignment(TextAlignment.RIGHT);
}

@Override
protected void updateItem(Player item, boolean empty) {
super.updateItem(item, empty);
setTextFill(Color.BLACK);

if (item == null) {
setText("");
setStyle("");
tooltip.setText("");
} else {
setText(item.getId());

if (item.getBans().isEmpty()) {
setStyle("");
tooltip.setText("No bans");
} else {
setStyle("-fx-font-weight: bold");

if (item.getBans().stream()
.anyMatch(banInfo -> banInfo.getBanStatus() == BanStatus.BANNED && banInfo.getDuration() == BanDurationType.PERMANENT)) {
tooltip.setText("Permanent ban");
setTextFill(Color.valueOf("#ca0000"));
} else if (item.getBans().stream()
.allMatch(banInfo -> banInfo.getBanStatus() == BanStatus.EXPIRED)) {
tooltip.setText("Expired ban");
setTextFill(Color.valueOf("#098700"));
} else {
tooltip.setText("Temporary ban");
setTextFill(Color.valueOf("#ff8800"));
}
}
}
}
});
idColumn.setComparator(Comparator.comparingInt(o -> Integer.parseInt(o.getId())));
idColumn.setMinWidth(70);
tableView.getColumns().add(idColumn);

TableColumn<Player, String> nameColumn = new TableColumn<>("Name");
Expand All @@ -254,8 +298,28 @@ static void buildUserTableView(TableView<Player> tableView) {

TableColumn<Player, String> steamIdColumn = new TableColumn<>("Steam ID");
steamIdColumn.setCellValueFactory(new PropertyValueFactory<>("steamId"));
steamIdColumn.setMinWidth(100);
steamIdColumn.setMinWidth(150);
tableView.getColumns().add(steamIdColumn);

TableColumn<Player, String> ipColumn = new TableColumn<>("Recent IP Address");
ipColumn.setCellValueFactory(new PropertyValueFactory<>("recentIpAddress"));
ipColumn.setMinWidth(160);
tableView.getColumns().add(ipColumn);

TableColumn<Player, OffsetDateTime> createTimeColumn = new TableColumn<>("Registration Date");
createTimeColumn.setCellValueFactory(new PropertyValueFactory<>("createTime"));
createTimeColumn.setMinWidth(160);
tableView.getColumns().add(createTimeColumn);

TableColumn<Player, OffsetDateTime> updateTimeColumn = new TableColumn<>("Last lobby login");
updateTimeColumn.setCellValueFactory(new PropertyValueFactory<>("updateTime"));
updateTimeColumn.setMinWidth(160);
tableView.getColumns().add(updateTimeColumn);

TableColumn<Player, String> userAgentColumn = new TableColumn<>("User Agent");
userAgentColumn.setCellValueFactory(new PropertyValueFactory<>("userAgent"));
userAgentColumn.setMinWidth(200);
tableView.getColumns().add(userAgentColumn);
}

static void buildUserAvatarsTableView(TableView<AvatarAssignment> tableView) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<graphic>
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@media/welcome-logo.png"/>
<Image url="@../media/welcome-logo.png"/>
</image>
</ImageView>
</graphic>
Expand Down
Loading

0 comments on commit 7cdca8d

Please sign in to comment.