Skip to content

Commit

Permalink
Bump version to v0.9.0 & fix two issues
Browse files Browse the repository at this point in the history
  • Loading branch information
shzlw committed Jul 21, 2019
1 parent 440c481 commit 569922d
Show file tree
Hide file tree
Showing 22 changed files with 58 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM openjdk:8-jre-alpine

WORKDIR /app

COPY target/poli-0.8.1.jar /app/poli-0.8.1.jar
COPY target/poli-0.9.0.jar /app/poli-0.9.0.jar
COPY db/poli.db /app/db/poli.db
COPY start.sh /app/start.sh
COPY config/poli.docker.properties /app/config/poli.properties
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# **Poli**

[![Version](https://img.shields.io/badge/Version-0.8.1-0065FF.svg)](#)
[![Version](https://img.shields.io/badge/Version-0.9.0-0065FF.svg)](#)
[![license: MIT](https://img.shields.io/badge/license-MIT-FF5630.svg)](https://opensource.org/licenses/MIT)
[![Download](https://img.shields.io/github/downloads/shzlw/poli/total.svg?color=6554C0)](https://github.com/shzlw/poli/releases)
[![Docker Pulls](https://img.shields.io/docker/pulls/zhonglu/poli.svg)](https://cloud.docker.com/u/zhonglu/repository/docker/zhonglu/poli)
Expand Down Expand Up @@ -56,13 +56,13 @@ Auto refresh, drill through, fullscreen, embeds, color themes + more features in
Windows/Linux

```sh
java -jar poli-0.8.1.jar
java -jar poli-0.9.0.jar
```

Docker

```sh
docker run -d -p 6688:6688 --name poli zhonglu/poli:0.8.1
docker run -d -p 6688:6688 --name poli zhonglu/poli:0.9.0
```

Check [installation guide](https://shzlw.github.io/poli/#/installation) for more details.
Expand Down
Binary file modified db/poli.db
Binary file not shown.
2 changes: 1 addition & 1 deletion db/schema-postgresql.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- v0.8.1 for PostgreSQL
-- v0.9.0 for PostgreSQL
DROP TABLE IF EXISTS p_group_report;
DROP TABLE IF EXISTS p_component;
DROP TABLE IF EXISTS p_report;
Expand Down
2 changes: 1 addition & 1 deletion db/schema-sqlite.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- v0.8.1 for SQLite
-- v0.9.0 for SQLite
DROP TABLE IF EXISTS p_group_report;
DROP TABLE IF EXISTS p_component;
DROP TABLE IF EXISTS p_report;
Expand Down
Binary file added docs/_images/screenshots/rls_user_attributes.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/change-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
- When filters are modified, the color of the "apply filters" button will be changed to show indication.
- When the report view is loaded with url parameters from drill through, the filter values will be applied immediately.

### Bug Fixes
- Fix an issue that the report group modification doesn't update the user report cache.
- Fix an issue that the user with viewer role cannot save canned report.
## v0.8.1
### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
1. Pull and run the Poli image.

```bash
docker run -d -p 6688:6688 --name poli zhonglu/poli:0.8.1
docker run -d -p 6688:6688 --name poli zhonglu/poli:0.9.0
```
2. Add JDBC drivers.

Expand Down
2 changes: 2 additions & 0 deletions docs/report-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ Assume that we have a table: department_data. The goal here is to have user1 who
1. Create a new user: user1. Define a user attribute on the User page.


![rls user attributes](_images/screenshots/rls_user_attributes.jpg)

2. Create a table chart using

```sql
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.shzlw.poli</groupId>
<artifactId>poli</artifactId>
<packaging>jar</packaging>
<version>0.8.1</version>
<version>0.9.0</version>

<properties>
<java.version>1.8</java.version>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/shzlw/poli/dao/UserDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ public List<Long> findUserGroups(long userId) {
return jt.queryForList(sql, new Object[]{ userId }, Long.class);
}

public List<Long> findGroupUsers(long groupId) {
String sql = "SELECT user_id FROM p_group_user WHERE group_id = ?";
return jt.queryForList(sql, new Object[]{ groupId }, Long.class);
}

public List<UserAttribute> findUserAttributes(long userId) {
String sql = "SELECT attr_key, attr_value FROM p_user_attribute WHERE user_id = ?";
return jt.query(sql, new Object[]{ userId }, (rs, i) -> {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/shzlw/poli/filter/AuthFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ private static boolean validateViewer(String requestMethod, String path) {
isValid = true;
}
} else if (Constants.HTTP_METHOD_POST.equals(requestMethod)) {
if (path.startsWith("/ws/jdbcquery")) {
if (path.startsWith("/ws/jdbcquery")
|| path.startsWith("/ws/cannedreport")) {
isValid = true;
}
} else if (Constants.HTTP_METHOD_DELETE.equals(requestMethod)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/shzlw/poli/rest/AuthWs.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public LoginResponse loginBySessionKey(@CookieValue(value = Constants.SESSION_KE
}

User user = userDao.findBySessionKey(sessionKey);
user.setUserAttributes(userDao.findUserAttributes(user.getId()));
if (user == null) {
return LoginResponse.ofError(INVALID_USERNAME_PASSWORD);
}

user.setUserAttributes(userDao.findUserAttributes(user.getId()));
userService.newOrUpdateUser(user, user.getSessionKey(), sessionKey);
return LoginResponse.ofSucess(user.getUsername(), user.getSysRole(), false);
}
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/shzlw/poli/rest/GroupWs.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.shzlw.poli.rest;

import com.shzlw.poli.dao.GroupDao;
import com.shzlw.poli.dao.UserDao;
import com.shzlw.poli.model.Group;
import com.shzlw.poli.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand All @@ -18,6 +20,12 @@ public class GroupWs {
@Autowired
GroupDao groupDao;

@Autowired
ReportService reportService;

@Autowired
UserDao userDao;

@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@Transactional(readOnly = true)
public List<Group> findAll() {
Expand All @@ -42,6 +50,11 @@ public Group findOne(@PathVariable("id") long groupId) {
public ResponseEntity<Long> add(@RequestBody Group group) {
long groupId = groupDao.insertGroup(group.getName());
groupDao.insertGroupReports(groupId, group.getGroupReports());

List<Long> userIds = userDao.findGroupUsers(groupId);
for (Long userId : userIds) {
reportService.invalidateCache(userId);
}
return new ResponseEntity<Long>(groupId, HttpStatus.CREATED);
}

Expand All @@ -52,6 +65,11 @@ public ResponseEntity<?> update(@RequestBody Group group) {
groupDao.updateGroup(group);
groupDao.deleteGroupReports(groupId);
groupDao.insertGroupReports(groupId, group.getGroupReports());

List<Long> userIds = userDao.findGroupUsers(groupId);
for (Long userId : userIds) {
reportService.invalidateCache(userId);
}
return new ResponseEntity<String>(HttpStatus.OK);
}

Expand All @@ -61,6 +79,11 @@ public ResponseEntity<?> delete(@PathVariable("id") long groupId) {
groupDao.deleteGroupUsers(groupId);
groupDao.deleteGroupReports(groupId);
groupDao.deleteGroup(groupId);

List<Long> userIds = userDao.findGroupUsers(groupId);
for (Long userId : userIds) {
reportService.invalidateCache(userId);
}
return new ResponseEntity<String>(HttpStatus.NO_CONTENT);
}
}
6 changes: 0 additions & 6 deletions src/main/java/com/shzlw/poli/rest/JdbcQueryWs.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ public ResponseEntity<QueryResult> queryComponent(
String sql = component.getSqlQuery();
DataSource dataSource = jdbcDataSourceService.getDataSource(component.getJdbcDataSourceId());
User user = (User) request.getAttribute(Constants.HTTP_REQUEST_ATTR_USER);

List<UserAttribute> userAttributes = user.getUserAttributes();
LOGGER.info("userAttributes: {}", userAttributes.size());
for (UserAttribute attr : userAttributes) {
LOGGER.info("attr: {}", attr);
}
List<FilterParameter> newFilterParams = addUserAttributesToFilterParams(user.getUserAttributes(), filterParams);
QueryResult queryResult = jdbcQueryService.queryComponentByParams(dataSource, sql, newFilterParams);
return new ResponseEntity(queryResult, HttpStatus.OK);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/shzlw/poli/service/ReportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public List<Report> getReportsByUser(User user) {
List<Report> reports = new ArrayList<>();
if (Constants.SYS_ROLE_VIEWER.equals(user.getSysRole())) {
reports = reportDao.findByViewer(user.getId());
LOGGER.info("reports: {}", reports.size());
} else {
reports = reportDao.findAll();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/shzlw/poli/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public final class Constants {

private Constants() {}

public static final String CURRENT_VERSION = "0.8.1";
public static final String CURRENT_VERSION = "0.9.0";

public static final String SUCCESS = "success";
public static final String GOOD = "";
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/shzlw/poli/filter/AuthFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public void testViewerValidAccess() throws IOException, ServletException {
new AccessRule(Constants.HTTP_METHOD_GET, "/ws/user/account"),
new AccessRule(Constants.HTTP_METHOD_PUT, "/ws/user/account"),
new AccessRule(Constants.HTTP_METHOD_POST, "/ws/jdbcquery"),
new AccessRule(Constants.HTTP_METHOD_POST, "/ws/cannedreport"),
new AccessRule(Constants.HTTP_METHOD_DELETE, "/ws/cannedreport")
);

Expand Down
2 changes: 1 addition & 1 deletion start.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java -jar poli-0.8.1.jar --spring.config.name=application,poli
java -jar poli-0.9.0.jar --spring.config.name=application,poli
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
set -e

java -jar poli-0.8.1.jar --spring.config.name=application,poli
java -jar poli-0.9.0.jar --spring.config.name=application,poli
14 changes: 7 additions & 7 deletions web-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "poli-web-app",
"version": "0.8.1",
"version": "0.9.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.17",
Expand Down

0 comments on commit 569922d

Please sign in to comment.