From c1f08ba38a1a08e1feadba2f03256b5235ba47f6 Mon Sep 17 00:00:00 2001 From: geepara Date: Wed, 20 Oct 2021 23:06:43 -0400 Subject: [PATCH 1/9] create matomo and matomo database container --- .docker/.env | 4 ++++ .docker/docker-compose.yml | 26 ++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.docker/.env b/.docker/.env index c5e08fd23..6a74fd810 100644 --- a/.docker/.env +++ b/.docker/.env @@ -84,3 +84,7 @@ DOWNLOAD_SERVICE_PORT=6502 DOWNLOAD_SERVICE_DEST=http://fcrepo:8080/fcrepo/rest/files UNPAYWALL_REQUEST_EMAIL=admin@oa-pass.org UNPAYWALL_BASEURI=https://api.unpaywall.org/v2 + +# mariadb +MYSQL_DATABASE=matomo +MYSQL_ROOT_PASSWORD=hello diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index a9e5f4249..444fdc509 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.1' +version: "3.1" services: ember: @@ -11,7 +11,7 @@ services: - ../:/app:Z - /app/node_modules ports: - - '${EMBER_PORT}:${EMBER_PORT}' + - "${EMBER_PORT}:${EMBER_PORT}" networks: - back @@ -178,6 +178,28 @@ services: - front - back + matomo: + image: matomo + container_name: matomo + env_file: .env + ports: + - 3299:80 + networks: + - front + - back + + db: + image: mariadb + container_name: mariadb + env_file: .env + ports: + - 3306:3306 + networks: + - back + volumes: + - /Users/georgepara/PASS/mariadb:/var/lib/mysql + + volumes: passdata: driver: local From d050c75890980a14a1787342fe4f658c95424e25 Mon Sep 17 00:00:00 2001 From: geepara Date: Wed, 20 Oct 2021 23:07:02 -0400 Subject: [PATCH 2/9] add matomo tracking code in index.html --- app/index.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/index.html b/app/index.html index c2fb528a4..f261e6e27 100644 --- a/app/index.html +++ b/app/index.html @@ -12,6 +12,21 @@ {{content-for "head-footer"}} + + +
From 0d124682bb7f6f92c2751ae8fe168eeb52a8c6b0 Mon Sep 17 00:00:00 2001 From: geepara Date: Fri, 22 Oct 2021 15:21:06 -0400 Subject: [PATCH 3/9] config.ini.php overlays file in matomo container --- .docker/config.ini.php | 82 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .docker/config.ini.php diff --git a/.docker/config.ini.php b/.docker/config.ini.php new file mode 100644 index 000000000..65db5340b --- /dev/null +++ b/.docker/config.ini.php @@ -0,0 +1,82 @@ +; DO NOT REMOVE THIS LINE +; file automatically generated or modified by Matomo; you can manually override the default values in global.ini.php by redefining them in this file. +[database] +host = "db" +username = "root" +password = "hello" +dbname = "matomo" +tables_prefix = "matomo_" +charset = "utf8mb4" + +[General] +salt = "acc08f58025c33e0780767b669f9d236" +assume_secure_protocol = 1 +force_ssl = 1 +proxy_client_headers[] = HTTP_X_FORWARDED_FOR +proxy_host_headers[] = HTTP_X_FORWARDED_HOST +proxy_uri_header = 1 + +[PluginsInstalled] +PluginsInstalled[] = "Diagnostics" +PluginsInstalled[] = "Login" +PluginsInstalled[] = "CoreAdminHome" +PluginsInstalled[] = "UsersManager" +PluginsInstalled[] = "SitesManager" +PluginsInstalled[] = "Installation" +PluginsInstalled[] = "Monolog" +PluginsInstalled[] = "Intl" +PluginsInstalled[] = "CorePluginsAdmin" +PluginsInstalled[] = "CoreHome" +PluginsInstalled[] = "WebsiteMeasurable" +PluginsInstalled[] = "IntranetMeasurable" +PluginsInstalled[] = "CoreVisualizations" +PluginsInstalled[] = "Proxy" +PluginsInstalled[] = "API" +PluginsInstalled[] = "Widgetize" +PluginsInstalled[] = "Transitions" +PluginsInstalled[] = "LanguagesManager" +PluginsInstalled[] = "Actions" +PluginsInstalled[] = "Dashboard" +PluginsInstalled[] = "MultiSites" +PluginsInstalled[] = "Referrers" +PluginsInstalled[] = "UserLanguage" +PluginsInstalled[] = "DevicesDetection" +PluginsInstalled[] = "Goals" +PluginsInstalled[] = "Ecommerce" +PluginsInstalled[] = "SEO" +PluginsInstalled[] = "Events" +PluginsInstalled[] = "UserCountry" +PluginsInstalled[] = "GeoIp2" +PluginsInstalled[] = "VisitsSummary" +PluginsInstalled[] = "VisitFrequency" +PluginsInstalled[] = "VisitTime" +PluginsInstalled[] = "VisitorInterest" +PluginsInstalled[] = "RssWidget" +PluginsInstalled[] = "Feedback" +PluginsInstalled[] = "TwoFactorAuth" +PluginsInstalled[] = "CoreUpdater" +PluginsInstalled[] = "CoreConsole" +PluginsInstalled[] = "ScheduledReports" +PluginsInstalled[] = "UserCountryMap" +PluginsInstalled[] = "Live" +PluginsInstalled[] = "PrivacyManager" +PluginsInstalled[] = "ImageGraph" +PluginsInstalled[] = "Annotations" +PluginsInstalled[] = "MobileMessaging" +PluginsInstalled[] = "Overlay" +PluginsInstalled[] = "SegmentEditor" +PluginsInstalled[] = "Insights" +PluginsInstalled[] = "Morpheus" +PluginsInstalled[] = "Contents" +PluginsInstalled[] = "BulkTracking" +PluginsInstalled[] = "Resolution" +PluginsInstalled[] = "DevicePlugins" +PluginsInstalled[] = "Heartbeat" +PluginsInstalled[] = "Marketplace" +PluginsInstalled[] = "ProfessionalServices" +PluginsInstalled[] = "UserId" +PluginsInstalled[] = "CustomJsTracker" +PluginsInstalled[] = "Tour" +PluginsInstalled[] = "PagePerformance" +PluginsInstalled[] = "CustomDimensions" + From b52da28b977c95b402a260be8fcb7befc50122f5 Mon Sep 17 00:00:00 2001 From: geepara Date: Fri, 22 Oct 2021 15:21:55 -0400 Subject: [PATCH 4/9] matomo container works with reverse proxy --- .docker/.env | 3 +++ .docker/docker-compose.yml | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.docker/.env b/.docker/.env index 6a74fd810..da0d9b4d0 100644 --- a/.docker/.env +++ b/.docker/.env @@ -88,3 +88,6 @@ UNPAYWALL_BASEURI=https://api.unpaywall.org/v2 # mariadb MYSQL_DATABASE=matomo MYSQL_ROOT_PASSWORD=hello + +# matomo + diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index 444fdc509..66efc7861 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -64,7 +64,7 @@ services: - front proxy: - image: oapass/httpd-proxy:20200507@sha256:e8ad2e759fe270998efc80bdcacbeb3f965b4b83d875478e36b0ce4c104bb2d3 + image: httpd-proxy:george container_name: proxy networks: - front @@ -182,11 +182,13 @@ services: image: matomo container_name: matomo env_file: .env - ports: - - 3299:80 networks: - front - back + ports: + - 3299:80 + volumes: + - /Users/georgepara/PASS/geepara-pass-ember/pass-ember/.docker/config.ini.php:/var/www/html/config/config.ini.php db: image: mariadb From bd0fc786429d078eb15ad9f6c432a7d64dbed75d Mon Sep 17 00:00:00 2001 From: geepara Date: Fri, 22 Oct 2021 15:41:13 -0400 Subject: [PATCH 5/9] copy of proxy config --- .docker/httpd.conf | 162 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 .docker/httpd.conf diff --git a/.docker/httpd.conf b/.docker/httpd.conf new file mode 100644 index 000000000..a56891378 --- /dev/null +++ b/.docker/httpd.conf @@ -0,0 +1,162 @@ +#Rewrite Rules +#Force SSL +RewriteEngine on +ReWriteCond %{SERVER_PORT} !^443$ +RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L] + +ErrorLog /dev/stdout +ErrorLogFormat "httpd-error [%{u}t] [%-m:%l] [pid %P:tid %T] %7F: %E: [client\ %a] %M% ,\ referer\ %{Referer}i" +LogLevel warn + +ServerName pass + + + DocumentRoot "/var/www/html" + AllowEncodedSlashes NoDecode + + RewriteEngine on + RewriteCond %{REQUEST_URI} =/app + RewriteRule ^/(.*) https://%{HTTP_HOST}/$1/ [NC,R,L] + + SSLEngine on + + #Disable CRIME vulernability v2.4+ + SSLCompression off + + #Clean SSL Issues and enable perfect forward secrecy + SSLProtocol all -SSLv2 -SSLv3 -TLSv1 + SSLHonorCipherOrder on + SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 \ +EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 \ +EECDH EDH+aRSA !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4" + + #SSL Cert Stuff + SSLCertificateFile /etc/httpd/ssl/domain.crt + SSLCertificateKeyFile /etc/httpd/ssl/domain.key + #SSLCertificateChainFile /etc/httpd/ssl/serverchain.pem + + SSLProxyEngine on + #Bypassing certicate checking on self-signed client cert + SSLProxyVerify none + SSLProxyCheckPeerCN off + SSLProxyCheckPeerName off + SSLProxyCheckPeerExpire off + + ProxyPreserveHost on + RequestHeader set X-Forwarded-Proto "https" env=HTTPS + RequestHeader set REMOTE-USER %{REMOTE_USER}s + # Upgrade insecure requests, as an alternative to mod_substitute + # for http -> https url rewriting in response bodies. + #Header set Strict-Transport-Security "max-age=300" + #Header set Content-Security-Policy: upgrade-insecure-requests + + Header set Access-Control-Max-Age "300" + # could be 'localhost', , '' + Header set Access-Control-Allow-Origin "*" + # allow cookies to be sent cross origin + Header set Access-Control-Allow-Credentials "true" + Header merge Access-Control-Allow-Methods "PUT, OPTIONS" + Header merge Access-Control-Expose-Headers "authorization" + + #Map /idp to Tomcat + ProxyPass /idp https://idp:4443/idp + ProxyPassReverse /idp https://idp:4443/idp + + ProxyPass /Shibboleth.sso http://sp/Shibboleth.sso + ProxyPassReverse /Shibboleth.sso http://sp/Shibboleth.sso + + ProxyPass /pass-user-service http://sp/pass-user-service + ProxyPassReverse /pass-user-service http://sp/pass-user-service + + ProxyPass /fcrepo http://sp/fcrepo + ProxyPassReverse /fcrepo http://sp/fcrepo + + # Allow the pass Elasticsearch index to be searched as /es + # Convert private Fedora URIs returned by Elasticsearch to public URIs. + + ProxyPass http://sp/es + ProxyPassReverse http://sp/es + + # Needed for Substitute to work. Turns off compression. + RequestHeader unset Accept-Encoding + + AddOutputFilterByType SUBSTITUTE application/json + Substitute "s|http://fcrepo:8080/fcrepo/rest/|https://pass.local/fcrepo/rest/|n" + + + # Allow DSpace to be addressed through the proxy + # Allows RepositoryCopy externalId to be resolved in various docker environments + + ProxyPass http://dspace:8181/xmlui/ + ProxyPassReverse http://dspace:8181/xmlui/ + + # Needed for Substitute to work. Turns off compression. + RequestHeader unset Accept-Encoding + + AddOutputFilterByType SUBSTITUTE application/json + Substitute "s|http://dspace:8181/xmlui/|https://pass.local/xmlui/|n" + + + + Header Set HTTP-X-FORWARDED-URI /matomo + + # Matomo + ProxyPass http://matomo/ + ProxyPassReverse https://pass.local/matomo/ + + + + # Ember app + ProxyPass /app http://sp/app + ProxyPassReverse /app http://sp/app + + # Schema service + ProxyPass /schemaservice http://sp/schemaservice + ProxyPassReverse /schemaservice http://sp/schemaservice + + # policy service + ProxyPass /policyservice http://sp/policyservice + ProxyPassReverse /policyservice http://sp/policyservice + + # DOI service + ProxyPass /doiservice http://sp/doiservice + ProxyPassReverse /doiservice http://sp/doiservice + + # OA Manuscript download service + ProxyPass /downloadservice http://sp/downloadservice + ProxyPassReverse /downloadservice http://sp/downloadservice + + # Static pages + ProxyPass / http://static-html:82/ + ProxyPassReverse / http://static-html:82/ + + + + + # + # The following directives define some format nicknames for use with + # a CustomLog directive (see below). + # + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined + LogFormat "%h %l %u %t \"%r\" %>s %b" common + + + # You need to enable mod_logio.c to use %I and %O + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio + + + # + # The location and format of the access logfile (Common Logfile Format). + # If you do not define any access logfiles within a + # container, they will be logged here. Contrariwise, if you *do* + # define per- access logfiles, transactions will be + # logged therein and *not* in this file. + # + #CustomLog "logs/access_log" common + + # + # If you prefer a logfile with access, agent, and referer information + # (Combined Logfile Format) you can use the following directive. + # + CustomLog /dev/stdout "httpd-combined %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" + From 77ff71d411545bf499a0bbf574ac15d6314478af Mon Sep 17 00:00:00 2001 From: geepara Date: Wed, 3 Nov 2021 22:02:13 -0400 Subject: [PATCH 6/9] CHANGES.md --- CHANGES.md | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 CHANGES.md diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 000000000..f8b062895 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,116 @@ +# Changes + +The goal of this branch is to implement usage statistics for PASS and keep user data safe. + +## Matomo + +Matomo was the data tracking platform of choice to implement this goal. +Matomo was chosen because of it is not linked to Google's analytics platform and the +service can be hosted on one of our own servers. +This ensures that users' information and data stay within the PASS system and has no +contact with the internet or hosting companies. + +### Docker + +(https://hub.docker.com/_/matomo) + +In order to host matomo on our own servers, a matomo docker image is used. +The command to run this docker image is: + +```bash +docker run -d --link some-mysql:db matomo +``` + +The docker image was added to the docker-compose.yml file so that it runs with the +other containers. +It can be found in `.docker/docker-compose.yml` on lines 181-191: + +```yml +matomo: + image: matomo + container_name: matomo + env_file: .env + networks: + - front + - back + ports: + - 3299:80 + volumes: + - /pass-ember/.docker/config.ini.php:/var/www/html/config/config.ini.php +``` + +The container runs on port 80 (matomo specific). +The container currently uses no environment variables but they can be added to `.docker/.env`. + +### Tracking code + +(https://developer.matomo.org/guides/tracking-javascript-guide) + +The matomo tracking code is a script added to the web app in order to integrate matomo. +The matomo tracking code was added to `index.html` on lines 15-29: + +```html + + + +``` + +### Mariadb + +(https://hub.docker.com/_/mariadb) + +A mariadb database is used in order to store the data tracked by matomo. +This database was configured as a docker container. +The docker image was added to the docker-compose.yml file so that it runs with the other +containers. It can be found in `.docker/docker-compose.yml` on lines 193-202: + +```yml +db: + image: mariadb + container_name: mariadb + env_file: .env + ports: + - 3306:3306 + networks: + - back + volumes: + - #path +``` + +The "path" comment can be replaced with the path of the mariadb database. +The environment variables for the mariadb container can be found in `.docker/.env` on lines +88-90: + +```yml +# mariadb +MYSQL_DATABASE=matomo +MYSQL_ROOT_PASSWORD=hello +``` + +These environment variables are used on the matomo setup page in order to link the +database to matomo. + +### Reverse Proxy + +### Matomo Setup + +The matomo setup and dashboard can be accessed by going to `http://pass.local/matomo`. +Upon first installing matomo, a setup page will be displayed. +Complete the setup by creating the matomo account used to access the dashboard and by +linking the mariadb database. From 82da7cd503641165ec034e23b63345f947195f7d Mon Sep 17 00:00:00 2001 From: geepara Date: Sun, 7 Nov 2021 17:19:11 -0500 Subject: [PATCH 7/9] create metrics page --- app/router.js | 39 +++++++++++----------- app/routes/metrics.js | 68 +++++++++++++++++++++++++++++++++++++++ app/templates/metrics.hbs | 13 ++++++++ 3 files changed, 101 insertions(+), 19 deletions(-) create mode 100644 app/routes/metrics.js create mode 100644 app/templates/metrics.hbs diff --git a/app/router.js b/app/router.js index ba14f45b9..3fd801917 100644 --- a/app/router.js +++ b/app/router.js @@ -1,5 +1,5 @@ -import EmberRouter from '@ember/routing/router'; -import config from './config/environment'; +import EmberRouter from "@ember/routing/router"; +import config from "./config/environment"; class Router extends EmberRouter { location = config.locationType; @@ -8,26 +8,27 @@ class Router extends EmberRouter { } Router.map(function () { - this.route('dashboard', { path: '/' }); - this.route('submissions', function () { - this.route('detail', { path: '/*path' }); - this.route('detail', { path: '/:submission_id' }); - this.route('new', function () { - this.route('grants'); - this.route('policies'); - this.route('repositories'); - this.route('metadata'); - this.route('files'); - this.route('review'); - this.route('basics'); + this.route("dashboard", { path: "/" }); + this.route("metrics", { path: "/metrics" }); + this.route("submissions", function () { + this.route("detail", { path: "/*path" }); + this.route("detail", { path: "/:submission_id" }); + this.route("new", function () { + this.route("grants"); + this.route("policies"); + this.route("repositories"); + this.route("metadata"); + this.route("files"); + this.route("review"); + this.route("basics"); }); }); - this.route('grants', function () { - this.route('detail', { path: '/*path' }); - this.route('detail', { path: '/:grant_id' }); + this.route("grants", function () { + this.route("detail", { path: "/*path" }); + this.route("detail", { path: "/:grant_id" }); }); - this.route('not-found-error', { path: '/*path' }); - this.route('thanks'); + this.route("not-found-error", { path: "/*path" }); + this.route("thanks"); }); export default Router; diff --git a/app/routes/metrics.js b/app/routes/metrics.js new file mode 100644 index 000000000..304edbcd8 --- /dev/null +++ b/app/routes/metrics.js @@ -0,0 +1,68 @@ +import CheckSessionRoute from "./check-session-route"; +// import ENV from "pass-ember/config/environment"; +import { inject as service } from "@ember/service"; +// import { get } from "@ember/object"; + +export default class DashboardRoute extends CheckSessionRoute { + @service("current-user") currentUser; + @service("ajax") ajax; + + headers = { "Content-Type": "application/json; charset=utf-8" }; + + async model() { + // const query = { + // bool: { + // must: [ + // { term: { submissionStatus: "approval-requested" } }, + // { term: { submitter: get(this, "currentUser.user.id") } }, + // ], + // filter: { term: { "@type": "Submission" } }, + // }, + // }; + + // const query = { + // bool: { + // must: + // } + // } + + // let approvalResults = await this.ajax.post(ENV.fedora.elasticsearch, { + // data: { + // size: 500, + // from: 0, + // query, + // _source: { excludes: "*_suggest" }, + // }, + // headers: this.headers, + // xhrFields: { withCredentials: true }, + // }); + + // let journalFrequency = await this.ajax.post(ENV.fedora.elasticsearch, { + + // }) + + // const secondQuery = { + // bool: { + // must: [ + // { term: { submissionStatus: "changes-requested" } }, + // { term: { preparers: get(this, "currentUser.user.id") } }, + // ], + // filter: { term: { "@type": "Submission" } }, + // }, + // }; + // let editsResults = await this.ajax.post(ENV.fedora.elasticsearch, { + // data: { + // size: 500, + // from: 0, + // query: secondQuery, + // _source: { excludes: "*_suggest" }, + // }, + // headers: this.headers, + // xhrFields: { withCredentials: true }, + // }); + // const numberAwaitingEdits = editsResults.hits.total; + // const numberAwaitingApproval = approvalResults.hits.total; + + return {}; + } +} diff --git a/app/templates/metrics.hbs b/app/templates/metrics.hbs new file mode 100644 index 000000000..db1fd891a --- /dev/null +++ b/app/templates/metrics.hbs @@ -0,0 +1,13 @@ +
+
+
+

+ Welcome to the Metrics Page! +

+

+ Here, you'll find some metrics on different information from PASS +

+
+
+
+ From e03b7f43f7cd758639042c86c0b0dfb2e8e62eeb Mon Sep 17 00:00:00 2001 From: geepara Date: Sun, 7 Nov 2021 20:17:19 -0500 Subject: [PATCH 8/9] metrics controller --- app/controllers/metrics.js | 95 ++++++++++++++++++++++++++++++++++++++ app/routes/metrics.js | 66 +++----------------------- app/templates/metrics.hbs | 19 +++++++- 3 files changed, 120 insertions(+), 60 deletions(-) create mode 100644 app/controllers/metrics.js diff --git a/app/controllers/metrics.js b/app/controllers/metrics.js new file mode 100644 index 000000000..7f92ec98e --- /dev/null +++ b/app/controllers/metrics.js @@ -0,0 +1,95 @@ +import Controller from "@ember/controller"; +import { tracked } from "@glimmer/tracking"; +import Bootstrap4Theme from "ember-models-table/themes/bootstrap4"; +import { inject as service } from "@ember/service"; + +export default class GrantsIndexController extends Controller { + @service currentUser; + @service("app-static-config") configurator; + + constructor() { + super(...arguments); + + this.configurator + .getStaticConfig() + .then((config) => this.set("assetsUri", config.assetsUri)); + } + + themeInstance = Bootstrap4Theme.create(); + // TODO Reduce duplication in column definitions + adminColumns = [ + { + propertyName: "grant.projectName", + title: "Project Name", + className: "projectname-column", + component: "grant-link-cell", + }, + { + propertyName: "grant.primaryFunder.name", + title: "Funder", + className: "funder-column", + filterWithSelect: true, + predefinedFilterOptions: ["NIH", "DOE", "NSF"], + }, + { + propertyName: "grant.awardNumber", + title: "Award Number", + className: "awardnum-column", + disableFiltering: true, + component: "grant-link-cell", + }, + { + title: "PI", + propertyName: "grant.pi", + component: "pi-list-cell", + }, + { + propertyName: "grant.startDate", + title: "Start", + disableFiltering: true, + className: "date-column", + component: "date-cell", + }, + { + propertyName: "grant.endDate", + title: "End", + disableFiltering: true, + className: "date-column", + component: "date-cell", + }, + { + propertyName: "grant.awardStatus", + title: "Status", + filterWithSelect: true, + predefinedFilterOptions: ["Active", "Ended"], + }, + { + propertyName: "submissions.length", + title: "Submissions count", + disableFiltering: true, + component: "grant-link-cell", + }, + { + propertyName: "grant.oapCompliance", + title: "OAP Compliance", + component: "oap-compliance-cell", + filterWithSelect: true, + predefinedFilterOptions: ["No", "Yes"], + }, + ]; + + @tracked assetsUri = null; + // Bound to message dialog. + @tracked messageShow = false; + @tracked messageTo = ""; + @tracked messageSubject = ""; + @tracked messageText = ""; + @tracked tablePageSize = 50; + @tracked tablePageSizeValues = [10, 25, 50]; + @tracked user = this.currentUser.user; + + // Columns displayed depend on the user role + get columns() { + return this.adminColumns; + } +} diff --git a/app/routes/metrics.js b/app/routes/metrics.js index 304edbcd8..686076389 100644 --- a/app/routes/metrics.js +++ b/app/routes/metrics.js @@ -1,68 +1,16 @@ import CheckSessionRoute from "./check-session-route"; -// import ENV from "pass-ember/config/environment"; +import ENV from "pass-ember/config/environment"; import { inject as service } from "@ember/service"; -// import { get } from "@ember/object"; export default class DashboardRoute extends CheckSessionRoute { @service("current-user") currentUser; - @service("ajax") ajax; - - headers = { "Content-Type": "application/json; charset=utf-8" }; async model() { - // const query = { - // bool: { - // must: [ - // { term: { submissionStatus: "approval-requested" } }, - // { term: { submitter: get(this, "currentUser.user.id") } }, - // ], - // filter: { term: { "@type": "Submission" } }, - // }, - // }; - - // const query = { - // bool: { - // must: - // } - // } - - // let approvalResults = await this.ajax.post(ENV.fedora.elasticsearch, { - // data: { - // size: 500, - // from: 0, - // query, - // _source: { excludes: "*_suggest" }, - // }, - // headers: this.headers, - // xhrFields: { withCredentials: true }, - // }); - - // let journalFrequency = await this.ajax.post(ENV.fedora.elasticsearch, { - - // }) - - // const secondQuery = { - // bool: { - // must: [ - // { term: { submissionStatus: "changes-requested" } }, - // { term: { preparers: get(this, "currentUser.user.id") } }, - // ], - // filter: { term: { "@type": "Submission" } }, - // }, - // }; - // let editsResults = await this.ajax.post(ENV.fedora.elasticsearch, { - // data: { - // size: 500, - // from: 0, - // query: secondQuery, - // _source: { excludes: "*_suggest" }, - // }, - // headers: this.headers, - // xhrFields: { withCredentials: true }, - // }); - // const numberAwaitingEdits = editsResults.hits.total; - // const numberAwaitingApproval = approvalResults.hits.total; - - return {}; + const url = `${ENV.fedora.elasticsearch}`; + console.log(url); + await fetch(url, { method: "POST" }) + .then((res) => res) + .then((data) => console.log(data)) + .catch((err) => err); } } diff --git a/app/templates/metrics.hbs b/app/templates/metrics.hbs index db1fd891a..75f480b2d 100644 --- a/app/templates/metrics.hbs +++ b/app/templates/metrics.hbs @@ -9,5 +9,22 @@

+
+
+
+ +
+
+
- From 6f349479792911355f9b33879d8057d7a860d9c1 Mon Sep 17 00:00:00 2001 From: geepara Date: Sun, 5 Dec 2021 16:37:30 -0500 Subject: [PATCH 9/9] git syncing issue fixed --- CHANGES.md | 35 ++++++++++++- app/components/nav-bar/index.hbs | 3 ++ app/controllers/metrics.js | 86 ++++++++------------------------ app/router.js | 40 +++++++-------- app/routes/metrics.js | 45 +++++++++++++---- app/templates/application.hbs | 4 ++ app/templates/metrics.hbs | 34 +++++++++---- 7 files changed, 139 insertions(+), 108 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f8b062895..7063bb276 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,7 +5,7 @@ The goal of this branch is to implement usage statistics for PASS and keep user ## Matomo Matomo was the data tracking platform of choice to implement this goal. -Matomo was chosen because of it is not linked to Google's analytics platform and the +Matomo was chosen because it is not linked to Google's analytics platform and the service can be hosted on one of our own servers. This ensures that users' information and data stay within the PASS system and has no contact with the internet or hosting companies. @@ -46,7 +46,7 @@ The container currently uses no environment variables but they can be added to ` (https://developer.matomo.org/guides/tracking-javascript-guide) -The matomo tracking code is a script added to the web app in order to integrate matomo. +The matomo tracking code is a script added to the PASS web app in order to integrate matomo. The matomo tracking code was added to `index.html` on lines 15-29: ```html @@ -108,9 +108,40 @@ database to matomo. ### Reverse Proxy +When configuring the matomo docker container and attempting to access the matomo dashboard, +we ran into a roadblock. Matomo, by default, uses `http` in order to access the login/dashboard. +Chrome did not like the fact that matomo uses `http` and wanted it to use `https`. We attempted +to fix this by using a reverse proxy in order to be able to use `https://pass.local/matomo` +instead of `http://pass.local/matomo` to access the login/dashboard. This is the reason for the +`httpd.conf` located in `.docker/`. + ### Matomo Setup The matomo setup and dashboard can be accessed by going to `http://pass.local/matomo`. Upon first installing matomo, a setup page will be displayed. Complete the setup by creating the matomo account used to access the dashboard and by linking the mariadb database. + +## Metrics Page + +Matomo is a good service for tracking metrics in terms of actual app usage. +However, more specific metrics regarding data within PASS can not be gathered +using Matomo. Therefore, a Metrics page was created within the pass web app +itself. + +The page can be found on the main navigation bar when a user logs into PASS. +It can also be found in the footer of any page in the PASS web app. + +In order to create this page, three files were created: + * `templates/metrics.hbs` + * `routes/metrics.js` + * `controllers/metrics.js` + +Virtually any metric that involves the actual data stored in PASS can be +displayed here. There is one metric that is already implemented which is a +list of the Journals and how many Submissions have been made per Journal. +The metric is calculated in `routes/metrics.js`. I was unable to actually +calculate the metric because the actual PASS data is inaccessible from my +local copy of pass-ember. The test data does not have enough data in order +to determine whether the calculation of the metric is working correctly or +not. \ No newline at end of file diff --git a/app/components/nav-bar/index.hbs b/app/components/nav-bar/index.hbs index 6564c9d80..647e4accb 100644 --- a/app/components/nav-bar/index.hbs +++ b/app/components/nav-bar/index.hbs @@ -25,6 +25,9 @@ +