From 033a6bc3fcd6e530f2d4ef51c08b6c6d1c45453f Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Mon, 6 May 2024 23:55:38 +0200 Subject: [PATCH 1/7] [New #84] Add ava-analytics --- .env.internal-auth | 1 + .env.keycloak-auth | 1 + config/index.js | 1 + src/components/dashboard/Dashboard.jsx | 5 +++-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.env.internal-auth b/.env.internal-auth index 6a1124c7..16f548b8 100644 --- a/.env.internal-auth +++ b/.env.internal-auth @@ -6,3 +6,4 @@ RECORD_MANAGER_NAVIGATOR_LANGUAGE=true RECORD_MANAGER_BASENAME=/ RECORD_MANAGER_EXTENSIONS=supplier RECORD_MANAGER_AUTHENTICATION=internal +RECORD_MANAGER_ANALYTICS_URL=http://localhost:8081 \ No newline at end of file diff --git a/.env.keycloak-auth b/.env.keycloak-auth index 7673b0b3..20d5db42 100644 --- a/.env.keycloak-auth +++ b/.env.keycloak-auth @@ -8,3 +8,4 @@ RECORD_MANAGER_EXTENSIONS=supplier RECORD_MANAGER_AUTHENTICATION=oidc RECORD_MANAGER_AUTH_SERVER_URL=http://localhost:1235/services/auth/realms/record-manager RECORD_MANAGER_AUTH_CLIENT_ID=record-manager +RECORD_MANAGER_ANALYTICS_URL=http://localhost:8081 diff --git a/config/index.js b/config/index.js index f20e8c67..b6b7a912 100644 --- a/config/index.js +++ b/config/index.js @@ -33,3 +33,4 @@ export const NAVIGATOR_LANGUAGE = JSON.parse(getEnv("NAVIGATOR_LANGUAGE", "true" export const BASENAME = getEnv("BASENAME", ""); export const EXTENSIONS = getEnv("EXTENSIONS", ""); export const APP_INFO = getEnv("APP_INFO", "© KBSS at FEE CTU in Prague, 2024"); +export const ANALYTICS_URL = getEnv("ANALYTICS_URL", ""); diff --git a/src/components/dashboard/Dashboard.jsx b/src/components/dashboard/Dashboard.jsx index f6666de9..2342f379 100644 --- a/src/components/dashboard/Dashboard.jsx +++ b/src/components/dashboard/Dashboard.jsx @@ -9,6 +9,7 @@ import ImportRecordsDialog from "../record/ImportRecordsDialog"; import { isAdmin } from "../../utils/SecurityUtils"; import { trackPromise } from "react-promise-tracker"; import PromiseTrackingMask from "../misc/PromiseTrackingMask"; +import { ANALYTICS_URL } from "../../../config/index.js"; class Dashboard extends React.Component { static propTypes = { @@ -141,8 +142,8 @@ class Dashboard extends React.Component { _renderStatisticsTile() { return this._isAdmin() ? ( - - {this.i18n("dashboard.statistics-tile")} + + {this.i18n("dashboard.statistics-tile")} ) : null; From 358f8e69aa13d6573683a642fe1dc3f94b38e997 Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Tue, 7 May 2024 00:01:06 +0200 Subject: [PATCH 2/7] [New #84] Add ava-analytics to docker compose --- deploy/internal-auth/docker-compose.yml | 10 ++++++++-- deploy/keycloak-auth/docker-compose.yml | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/deploy/internal-auth/docker-compose.yml b/deploy/internal-auth/docker-compose.yml index 1aaa22b0..d8a38584 100644 --- a/deploy/internal-auth/docker-compose.yml +++ b/deploy/internal-auth/docker-compose.yml @@ -10,8 +10,8 @@ x-logging-java-application: &logging-java # Expose port to access db-server directly, bypassing nginx x-access-db-server-development-port: &db-server-dev-port - ports: - - "127.0.0.1:${DB_SERVER_DEV_PORT:-7205}:7200" + ports: + - "127.0.0.1:${DB_SERVER_DEV_PORT:-7205}:7200" services: nginx: @@ -25,6 +25,7 @@ services: - record-manager-server - s-pipes-engine - db-server + - ava-analytics-ui environment: NGINX_ENVSUBST_OUTPUT_DIR: /etc/nginx APP_ORIGIN: "${PUBLIC_ORIGIN:-http://localhost:${INTERNAL_HOST_PORT:-1235}}" @@ -97,5 +98,10 @@ services: - ../shared/db-server/import:/root/graphdb-import:ro - db-server:/opt/graphdb/home + ava-analytics-ui: + image: ghcr.io/kbss-cvut/ava-analytics-ui:latest + expose: + - "8081:80" + volumes: db-server: diff --git a/deploy/keycloak-auth/docker-compose.yml b/deploy/keycloak-auth/docker-compose.yml index 39db2169..6810a4af 100644 --- a/deploy/keycloak-auth/docker-compose.yml +++ b/deploy/keycloak-auth/docker-compose.yml @@ -25,6 +25,7 @@ services: - record-manager-server - s-pipes-engine - db-server + - ava-analytics-ui environment: NGINX_ENVSUBST_OUTPUT_DIR: /etc/nginx APP_ORIGIN: "${PUBLIC_ORIGIN:-http://localhost:${INTERNAL_HOST_PORT:-1235}}" @@ -149,6 +150,11 @@ services: depends_on: - auth-server-db + ava-analytics-ui: + image: ghcr.io/kbss-cvut/ava-analytics-ui:latest + expose: + - "8081:80" + volumes: db-server: auth-server: From 97ebf6142516819692e64eac7e7390cd0e7f9719 Mon Sep 17 00:00:00 2001 From: Max Chopart <57750426+LaChope@users.noreply.github.com> Date: Tue, 7 May 2024 00:12:52 +0200 Subject: [PATCH 3/7] Update .env.keycloak-auth MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Miroslav Blaško --- .env.keycloak-auth | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.keycloak-auth b/.env.keycloak-auth index 20d5db42..ed3ba0a6 100644 --- a/.env.keycloak-auth +++ b/.env.keycloak-auth @@ -8,4 +8,4 @@ RECORD_MANAGER_EXTENSIONS=supplier RECORD_MANAGER_AUTHENTICATION=oidc RECORD_MANAGER_AUTH_SERVER_URL=http://localhost:1235/services/auth/realms/record-manager RECORD_MANAGER_AUTH_CLIENT_ID=record-manager -RECORD_MANAGER_ANALYTICS_URL=http://localhost:8081 +RECORD_MANAGER_ANALYTICS_URL=http://localhost:1235/statistics From d12e43b951fd3a8c15201b464178402f9e6872db Mon Sep 17 00:00:00 2001 From: Max Chopart <57750426+LaChope@users.noreply.github.com> Date: Tue, 7 May 2024 00:12:59 +0200 Subject: [PATCH 4/7] Update .env.internal-auth MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Miroslav Blaško --- .env.internal-auth | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.internal-auth b/.env.internal-auth index 16f548b8..ff59a53e 100644 --- a/.env.internal-auth +++ b/.env.internal-auth @@ -6,4 +6,4 @@ RECORD_MANAGER_NAVIGATOR_LANGUAGE=true RECORD_MANAGER_BASENAME=/ RECORD_MANAGER_EXTENSIONS=supplier RECORD_MANAGER_AUTHENTICATION=internal -RECORD_MANAGER_ANALYTICS_URL=http://localhost:8081 \ No newline at end of file +RECORD_MANAGER_ANALYTICS_URL=http://localhost:1235/statistics \ No newline at end of file From 5fc73aa15db5812d0a2b66f13336685e15467f04 Mon Sep 17 00:00:00 2001 From: Max Chopart <57750426+LaChope@users.noreply.github.com> Date: Tue, 7 May 2024 00:13:16 +0200 Subject: [PATCH 5/7] Update deploy/internal-auth/docker-compose.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Miroslav Blaško --- deploy/internal-auth/docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/deploy/internal-auth/docker-compose.yml b/deploy/internal-auth/docker-compose.yml index d8a38584..1c2b4a87 100644 --- a/deploy/internal-auth/docker-compose.yml +++ b/deploy/internal-auth/docker-compose.yml @@ -100,8 +100,6 @@ services: ava-analytics-ui: image: ghcr.io/kbss-cvut/ava-analytics-ui:latest - expose: - - "8081:80" volumes: db-server: From a429a5c15036870b7aadbd1ee78617e97c4b1c84 Mon Sep 17 00:00:00 2001 From: Max Chopart <57750426+LaChope@users.noreply.github.com> Date: Tue, 7 May 2024 00:13:24 +0200 Subject: [PATCH 6/7] Update deploy/keycloak-auth/docker-compose.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Miroslav Blaško --- deploy/keycloak-auth/docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/deploy/keycloak-auth/docker-compose.yml b/deploy/keycloak-auth/docker-compose.yml index 6810a4af..fa3f92c5 100644 --- a/deploy/keycloak-auth/docker-compose.yml +++ b/deploy/keycloak-auth/docker-compose.yml @@ -152,8 +152,6 @@ services: ava-analytics-ui: image: ghcr.io/kbss-cvut/ava-analytics-ui:latest - expose: - - "8081:80" volumes: db-server: From e8435191b734ef876dceff6fecd3952503c0858f Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Tue, 7 May 2024 00:19:41 +0200 Subject: [PATCH 7/7] [Upd #84] Redirect to standard statistics if ava-analytics env is not provided --- src/components/dashboard/Dashboard.jsx | 5 ++--- src/components/dashboard/DashboardController.jsx | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/dashboard/Dashboard.jsx b/src/components/dashboard/Dashboard.jsx index 2342f379..f6666de9 100644 --- a/src/components/dashboard/Dashboard.jsx +++ b/src/components/dashboard/Dashboard.jsx @@ -9,7 +9,6 @@ import ImportRecordsDialog from "../record/ImportRecordsDialog"; import { isAdmin } from "../../utils/SecurityUtils"; import { trackPromise } from "react-promise-tracker"; import PromiseTrackingMask from "../misc/PromiseTrackingMask"; -import { ANALYTICS_URL } from "../../../config/index.js"; class Dashboard extends React.Component { static propTypes = { @@ -142,8 +141,8 @@ class Dashboard extends React.Component { _renderStatisticsTile() { return this._isAdmin() ? ( - - {this.i18n("dashboard.statistics-tile")} + + {this.i18n("dashboard.statistics-tile")} ) : null; diff --git a/src/components/dashboard/DashboardController.jsx b/src/components/dashboard/DashboardController.jsx index 77b7962a..ed68bad1 100644 --- a/src/components/dashboard/DashboardController.jsx +++ b/src/components/dashboard/DashboardController.jsx @@ -11,6 +11,8 @@ import withI18n from "../../i18n/withI18n"; import { loadFormTemplates } from "../../actions/FormTemplatesActions"; import { importRecords } from "../../actions/RecordsActions"; import PropTypes from "prop-types"; +import { ANALYTICS_URL } from "../../../config/index.js"; +import routes from "../../constants/RoutesConstants"; class DashboardController extends React.Component { constructor(props) { @@ -46,7 +48,11 @@ class DashboardController extends React.Component { }; _showStatistics = () => { - transitionTo(Routes.statistics); + if (ANALYTICS_URL === "") { + transitionTo(routes.statistics); + } else { + window.location.href = ANALYTICS_URL; + } }; _createRecord = () => {