diff --git a/Dockerfile b/Dockerfile
index 5bad607..3044058 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -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
diff --git a/README.md b/README.md
index dbe8bb4..e8e9353 100644
--- a/README.md
+++ b/README.md
@@ -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)
@@ -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.
diff --git a/db/poli.db b/db/poli.db
index 416d099..891155f 100644
Binary files a/db/poli.db and b/db/poli.db differ
diff --git a/db/schema-postgresql.sql b/db/schema-postgresql.sql
index a5f54d3..70f0bf1 100644
--- a/db/schema-postgresql.sql
+++ b/db/schema-postgresql.sql
@@ -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;
diff --git a/db/schema-sqlite.sql b/db/schema-sqlite.sql
index a7c5dd3..40d57d5 100644
--- a/db/schema-sqlite.sql
+++ b/db/schema-sqlite.sql
@@ -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;
diff --git a/docs/_images/screenshots/rls_user_attributes.jpg b/docs/_images/screenshots/rls_user_attributes.jpg
new file mode 100644
index 0000000..c8318bb
Binary files /dev/null and b/docs/_images/screenshots/rls_user_attributes.jpg differ
diff --git a/docs/change-logs.md b/docs/change-logs.md
index 66ccae2..7979d25 100644
--- a/docs/change-logs.md
+++ b/docs/change-logs.md
@@ -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
diff --git a/docs/installation.md b/docs/installation.md
index 5eea789..5e82de8 100644
--- a/docs/installation.md
+++ b/docs/installation.md
@@ -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.
diff --git a/docs/report-component.md b/docs/report-component.md
index 9739ce8..b7d5ca1 100644
--- a/docs/report-component.md
+++ b/docs/report-component.md
@@ -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
diff --git a/pom.xml b/pom.xml
index b4d0684..f964ba6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.shzlw.poli
poli
jar
- 0.8.1
+ 0.9.0
1.8
diff --git a/src/main/java/com/shzlw/poli/dao/UserDao.java b/src/main/java/com/shzlw/poli/dao/UserDao.java
index 75d8e09..3a2bb9a 100644
--- a/src/main/java/com/shzlw/poli/dao/UserDao.java
+++ b/src/main/java/com/shzlw/poli/dao/UserDao.java
@@ -154,6 +154,11 @@ public List findUserGroups(long userId) {
return jt.queryForList(sql, new Object[]{ userId }, Long.class);
}
+ public List 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 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) -> {
diff --git a/src/main/java/com/shzlw/poli/filter/AuthFilter.java b/src/main/java/com/shzlw/poli/filter/AuthFilter.java
index 4b69df2..fccc23d 100644
--- a/src/main/java/com/shzlw/poli/filter/AuthFilter.java
+++ b/src/main/java/com/shzlw/poli/filter/AuthFilter.java
@@ -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)) {
diff --git a/src/main/java/com/shzlw/poli/rest/AuthWs.java b/src/main/java/com/shzlw/poli/rest/AuthWs.java
index e6e29bd..b5b42ab 100644
--- a/src/main/java/com/shzlw/poli/rest/AuthWs.java
+++ b/src/main/java/com/shzlw/poli/rest/AuthWs.java
@@ -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);
}
diff --git a/src/main/java/com/shzlw/poli/rest/GroupWs.java b/src/main/java/com/shzlw/poli/rest/GroupWs.java
index 740e504..53c51ab 100644
--- a/src/main/java/com/shzlw/poli/rest/GroupWs.java
+++ b/src/main/java/com/shzlw/poli/rest/GroupWs.java
@@ -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;
@@ -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 findAll() {
@@ -42,6 +50,11 @@ public Group findOne(@PathVariable("id") long groupId) {
public ResponseEntity add(@RequestBody Group group) {
long groupId = groupDao.insertGroup(group.getName());
groupDao.insertGroupReports(groupId, group.getGroupReports());
+
+ List userIds = userDao.findGroupUsers(groupId);
+ for (Long userId : userIds) {
+ reportService.invalidateCache(userId);
+ }
return new ResponseEntity(groupId, HttpStatus.CREATED);
}
@@ -52,6 +65,11 @@ public ResponseEntity> update(@RequestBody Group group) {
groupDao.updateGroup(group);
groupDao.deleteGroupReports(groupId);
groupDao.insertGroupReports(groupId, group.getGroupReports());
+
+ List userIds = userDao.findGroupUsers(groupId);
+ for (Long userId : userIds) {
+ reportService.invalidateCache(userId);
+ }
return new ResponseEntity(HttpStatus.OK);
}
@@ -61,6 +79,11 @@ public ResponseEntity> delete(@PathVariable("id") long groupId) {
groupDao.deleteGroupUsers(groupId);
groupDao.deleteGroupReports(groupId);
groupDao.deleteGroup(groupId);
+
+ List userIds = userDao.findGroupUsers(groupId);
+ for (Long userId : userIds) {
+ reportService.invalidateCache(userId);
+ }
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/shzlw/poli/rest/JdbcQueryWs.java b/src/main/java/com/shzlw/poli/rest/JdbcQueryWs.java
index 9470c2c..dee1e0b 100644
--- a/src/main/java/com/shzlw/poli/rest/JdbcQueryWs.java
+++ b/src/main/java/com/shzlw/poli/rest/JdbcQueryWs.java
@@ -72,12 +72,6 @@ public ResponseEntity queryComponent(
String sql = component.getSqlQuery();
DataSource dataSource = jdbcDataSourceService.getDataSource(component.getJdbcDataSourceId());
User user = (User) request.getAttribute(Constants.HTTP_REQUEST_ATTR_USER);
-
- List userAttributes = user.getUserAttributes();
- LOGGER.info("userAttributes: {}", userAttributes.size());
- for (UserAttribute attr : userAttributes) {
- LOGGER.info("attr: {}", attr);
- }
List newFilterParams = addUserAttributesToFilterParams(user.getUserAttributes(), filterParams);
QueryResult queryResult = jdbcQueryService.queryComponentByParams(dataSource, sql, newFilterParams);
return new ResponseEntity(queryResult, HttpStatus.OK);
diff --git a/src/main/java/com/shzlw/poli/service/ReportService.java b/src/main/java/com/shzlw/poli/service/ReportService.java
index fa1d015..8f28c29 100644
--- a/src/main/java/com/shzlw/poli/service/ReportService.java
+++ b/src/main/java/com/shzlw/poli/service/ReportService.java
@@ -45,6 +45,7 @@ public List getReportsByUser(User user) {
List 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();
}
diff --git a/src/main/java/com/shzlw/poli/util/Constants.java b/src/main/java/com/shzlw/poli/util/Constants.java
index c08328e..0cc1269 100644
--- a/src/main/java/com/shzlw/poli/util/Constants.java
+++ b/src/main/java/com/shzlw/poli/util/Constants.java
@@ -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 = "";
diff --git a/src/test/java/com/shzlw/poli/filter/AuthFilterTest.java b/src/test/java/com/shzlw/poli/filter/AuthFilterTest.java
index 28e1cc3..3395d60 100644
--- a/src/test/java/com/shzlw/poli/filter/AuthFilterTest.java
+++ b/src/test/java/com/shzlw/poli/filter/AuthFilterTest.java
@@ -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")
);
diff --git a/start.bat b/start.bat
index 6a58a51..a2116eb 100644
--- a/start.bat
+++ b/start.bat
@@ -1 +1 @@
-java -jar poli-0.8.1.jar --spring.config.name=application,poli
\ No newline at end of file
+java -jar poli-0.9.0.jar --spring.config.name=application,poli
\ No newline at end of file
diff --git a/start.sh b/start.sh
index 2649493..4a8cb87 100755
--- a/start.sh
+++ b/start.sh
@@ -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
diff --git a/web-app/package-lock.json b/web-app/package-lock.json
index c9d8151..c981e07 100644
--- a/web-app/package-lock.json
+++ b/web-app/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "poli-web-app",
- "version": "0.8.1",
+ "version": "0.9.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -2480,7 +2480,7 @@
"fill-range": "^4.0.0",
"isobject": "^3.0.1",
"repeat-element": "^1.1.2",
- "snapdragon": "^0.8.1",
+ "snapdragon": "^0.9.0",
"snapdragon-node": "^2.0.1",
"split-string": "^3.0.2",
"to-regex": "^3.0.1"
@@ -4460,7 +4460,7 @@
"esprima": "^3.1.3",
"estraverse": "^4.2.0",
"esutils": "^2.0.2",
- "optionator": "^0.8.1",
+ "optionator": "^0.9.0",
"source-map": "~0.6.1"
},
"dependencies": {
@@ -4963,7 +4963,7 @@
"extend-shallow": "^2.0.1",
"posix-character-classes": "^0.1.0",
"regex-not": "^1.0.0",
- "snapdragon": "^0.8.1",
+ "snapdragon": "^0.9.0",
"to-regex": "^3.0.1"
},
"dependencies": {
@@ -5118,7 +5118,7 @@
"extend-shallow": "^2.0.1",
"fragment-cache": "^0.2.1",
"regex-not": "^1.0.0",
- "snapdragon": "^0.8.1",
+ "snapdragon": "^0.9.0",
"to-regex": "^3.0.1"
},
"dependencies": {
@@ -8089,7 +8089,7 @@
"nanomatch": "^1.2.9",
"object.pick": "^1.3.0",
"regex-not": "^1.0.0",
- "snapdragon": "^0.8.1",
+ "snapdragon": "^0.9.0",
"to-regex": "^3.0.2"
},
"dependencies": {
@@ -8289,7 +8289,7 @@
"kind-of": "^6.0.2",
"object.pick": "^1.3.0",
"regex-not": "^1.0.0",
- "snapdragon": "^0.8.1",
+ "snapdragon": "^0.9.0",
"to-regex": "^3.0.1"
},
"dependencies": {
diff --git a/web-app/package.json b/web-app/package.json
index e492791..19d7e8b 100644
--- a/web-app/package.json
+++ b/web-app/package.json
@@ -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",