mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
detailled view of collected data in fabanalytics
This commit is contained in:
parent
6a56f291e5
commit
7929d3b198
@ -278,6 +278,20 @@ Application.Controllers.controller('SettingsController', ['$scope', '$filter', '
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Open a modal showing a sample of the collected data if FabAnalytics is enabled
|
||||
*/
|
||||
$scope.analyticsModal = function() {
|
||||
$uibModal.open({
|
||||
templateUrl: '<%= asset_path "admin/settings/analyticsModal.html" %>',
|
||||
controller: 'AnalyticsModalController',
|
||||
size: 'lg',
|
||||
resolve: {
|
||||
analyticsData: ['FabAnalytics', function (FabAnalytics) { return FabAnalytics.data().$promise; }]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* PRIVATE SCOPE */
|
||||
|
||||
/**
|
||||
@ -363,3 +377,18 @@ Application.Controllers.controller('SavePolicyController', ['$scope', '$uibModal
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
||||
/**
|
||||
* Controller used in the "what do we collect?" modal, about FabAnalytics
|
||||
*/
|
||||
Application.Controllers.controller('AnalyticsModalController', ['$scope', '$uibModalInstance', 'analyticsData',
|
||||
function ($scope,$uibModalInstance, analyticsData) {
|
||||
// analytics data sample
|
||||
$scope.data = analyticsData;
|
||||
|
||||
// callback to close the modal
|
||||
$scope.close = function () {
|
||||
$uibModalInstance.dismiss();
|
||||
}
|
||||
}
|
||||
])
|
||||
|
@ -526,7 +526,9 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco
|
||||
}
|
||||
]);
|
||||
|
||||
|
||||
/**
|
||||
* Controller used in the modal showing details about the version and the upgrades
|
||||
*/
|
||||
Application.Controllers.controller('VersionModalController', ['$scope', '$uibModalInstance', 'version', function ($scope, $uibModalInstance, version) {
|
||||
// version infos (current version + upgrade infos from hub)
|
||||
$scope.version = version;
|
||||
|
10
app/assets/javascripts/services/fab_analytics.js
Normal file
10
app/assets/javascripts/services/fab_analytics.js
Normal file
@ -0,0 +1,10 @@
|
||||
Application.Services.factory('FabAnalytics', ['$resource', function ($resource) {
|
||||
return $resource('/api/analytics',
|
||||
{}, {
|
||||
data: {
|
||||
method: 'GET',
|
||||
url: '/api/analytics/data'
|
||||
}
|
||||
}
|
||||
);
|
||||
}]);
|
25
app/assets/templates/admin/settings/analyticsModal.html
Normal file
25
app/assets/templates/admin/settings/analyticsModal.html
Normal file
@ -0,0 +1,25 @@
|
||||
<div class="modal-header">
|
||||
<h3 class="text-center red" translate>{{ 'app.admin.settings.fab_analytics' }}</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p translate>{{ 'app.admin.settings.privacy.analytics.intro_analytics_html' }}</p>
|
||||
<div>
|
||||
<table class="table table-bordered">
|
||||
<tbody>
|
||||
<tr><td translate>{{ 'app.admin.settings.privacy.analytics.version' }}</td><td>{{ data.version }}</td></tr>
|
||||
<tr><td translate>{{ 'app.admin.settings.privacy.analytics.members' }}</td><td>{{ data.members }}</td></tr>
|
||||
<tr><td translate>{{ 'app.admin.settings.privacy.analytics.admins' }}</td><td>{{ data.admins }}</td></tr>
|
||||
<tr><td translate>{{ 'app.admin.settings.privacy.analytics.availabilities' }}</td><td>{{ data.availabilities }}</td></tr>
|
||||
<tr><td translate>{{ 'app.admin.settings.privacy.analytics.reservations' }}</td><td>{{ data.reservations }}</td></tr>
|
||||
<tr><td translate>{{ 'app.admin.settings.privacy.analytics.plans' }}</td><td>{{ data.plans }}</td></tr>
|
||||
<tr><td translate>{{ 'app.admin.settings.privacy.analytics.spaces' }}</td><td>{{ data.spaces }}</td></tr>
|
||||
<tr><td translate>{{ 'app.admin.settings.privacy.analytics.online_payment' }}</td><td>{{ data.online_payment }}</td></tr>
|
||||
<tr><td translate>{{ 'app.admin.settings.privacy.analytics.invoices' }}</td><td>{{ data.invoices }}</td></tr>
|
||||
<tr><td translate>{{ 'app.admin.settings.privacy.analytics.openlab' }}</td><td>{{ data.openlab }}</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-warning" ng-click="close()" translate>{{ 'app.shared.buttons.close' }}</button>
|
||||
</div>
|
@ -39,7 +39,7 @@
|
||||
switch-animate="true"/>
|
||||
<p>
|
||||
<span translate>{{ 'app.admin.settings.privacy.about_analytics' }}</span>
|
||||
<a href="https://hub.fab-manager.com/privacy" target="_blank" translate>{{ 'app.admin.settings.privacy.read_more' }}</a>
|
||||
<a ng-click="analyticsModal()" class="pointer" translate>{{ 'app.admin.settings.privacy.read_more' }}</a>
|
||||
</p>
|
||||
<button name="button" class="btn btn-warning" ng-click="save(fabAnalytics)" translate>{{ 'app.shared.buttons.save' }}</button>
|
||||
</div>
|
||||
|
10
app/controllers/api/analytics_controller.rb
Normal file
10
app/controllers/api/analytics_controller.rb
Normal file
@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# API Controller for fabAnalytics
|
||||
class API::AnalyticsController < API::ApiController
|
||||
before_action :authenticate_user!
|
||||
|
||||
def data
|
||||
render json: HealthService.row_stats
|
||||
end
|
||||
end
|
@ -31,15 +31,9 @@ class HealthService
|
||||
!ActiveRecord::Migrator.needs_migration?
|
||||
end
|
||||
|
||||
def self.stats
|
||||
enable = Setting.find_by(name: 'fab_analytics')&.value
|
||||
return false if enable == 'false'
|
||||
|
||||
def self.row_stats
|
||||
require 'version'
|
||||
require 'openssl'
|
||||
require 'base64'
|
||||
|
||||
stats = {
|
||||
{
|
||||
version: Version.current,
|
||||
members: User.members.count,
|
||||
admins: User.admins.count,
|
||||
@ -50,7 +44,17 @@ class HealthService
|
||||
online_payment: !Rails.application.secrets.fablab_without_online_payments,
|
||||
invoices: !Rails.application.secrets.fablab_without_invoices,
|
||||
openlab: Rails.application.secrets.openlab_app_secret.present?
|
||||
}.to_json.to_s
|
||||
}
|
||||
end
|
||||
|
||||
def self.stats
|
||||
enable = Setting.find_by(name: 'fab_analytics')&.value
|
||||
return false if enable == 'false'
|
||||
|
||||
require 'openssl'
|
||||
require 'base64'
|
||||
|
||||
row_stats.to_json.to_s
|
||||
|
||||
key = Setting.find_by(name: 'hub_public_key')&.value
|
||||
return false unless key
|
||||
|
@ -964,6 +964,18 @@ en:
|
||||
publish_will_notify: "Publish a new version will send a notification to every users."
|
||||
publish: "Publish"
|
||||
users_notified: "Platform users will be notified of the update."
|
||||
analytics:
|
||||
intro_analytics_html: "You'll find below a detailed view of all the data, Fab-Manager will collect <strong>if permission is granted.</strong>"
|
||||
version: "Application version"
|
||||
members: "Number of members"
|
||||
admins: "Number of administrators"
|
||||
availabilities: "Number of availabilities of the last 7 days"
|
||||
reservations: "Number of reservations during the last 7 days"
|
||||
plans: "Is the subscription module active?"
|
||||
spaces: "Is the space management module active?"
|
||||
online_payment: "Is the online payment module active?"
|
||||
invoices: "Is the invoicing module active?"
|
||||
openlab: "Is the project sharing module (OpenLab) active?"
|
||||
|
||||
open_api_clients:
|
||||
add_new_client: "Create new API client"
|
||||
|
@ -964,6 +964,18 @@ es:
|
||||
publish_will_notify: "Publish a new version will send a notification to every users."
|
||||
publish: "Publish"
|
||||
users_notified: "Platform users will be notified of the update."
|
||||
analytics:
|
||||
intro_analytics_html: "You'll find below a detailed view of all the data, Fab-Manager will collect <strong>if permission is granted.</strong>"
|
||||
version: "Application version"
|
||||
members: "Number of members"
|
||||
admins: "Number of administrators"
|
||||
availabilities: "Number of availabilities of the last 7 days"
|
||||
reservations: "Number of reservations during the last 7 days"
|
||||
plans: "Is the subscription module active?"
|
||||
spaces: "Is the space management module active?"
|
||||
online_payment: "Is the online payment module active?"
|
||||
invoices: "Is the invoicing module active?"
|
||||
openlab: "Is the project sharing module (OpenLab) active?"
|
||||
|
||||
open_api_clients:
|
||||
add_new_client: "Crear un nuevo cliente de API"
|
||||
|
@ -967,6 +967,18 @@ fr:
|
||||
users_notified: "Les utilisateurs de la plateforme seront notifiés de la mise à jour."
|
||||
about_analytics: "J'accepte de partager des données anonymes avec l'équipe de développement pour aider à améliorer Fab-Manager."
|
||||
read_more: "Quelles informations collectons-nous ?"
|
||||
analytics:
|
||||
intro_analytics_html: "Vous trouverez ci-dessous une vue détaillée de toutes les données de Fab-Manager collectera <strong>si l'autorisation lui est accordée.</strong>"
|
||||
version: "Version de l'application"
|
||||
members: "Nombre de membres"
|
||||
admins: "Nombre d'administrateurs"
|
||||
availabilities: "Nombre de disponibilités les 7 dernier jours"
|
||||
reservations: "Nombre de réservations durant 7 dernier jours"
|
||||
plans: "Le module d'abonnements est-il actif ?"
|
||||
spaces: "Le module d'espaces est-il actif ?"
|
||||
online_payment: "Le module de paiement par carte bancaire est-il actif ?"
|
||||
invoices: "Le module est facturation est-il actif ?"
|
||||
openlab: "Le module de partage de projets (OpenLab) est-il actif ?"
|
||||
|
||||
open_api_clients:
|
||||
add_new_client: "Créer un compte client"
|
||||
|
@ -964,6 +964,18 @@ pt:
|
||||
publish_will_notify: "Publish a new version will send a notification to every users."
|
||||
publish: "Publish"
|
||||
users_notified: "Platform users will be notified of the update."
|
||||
analytics:
|
||||
intro_analytics_html: "You'll find below a detailed view of all the data, Fab-Manager will collect <strong>if permission is granted.</strong>"
|
||||
version: "Application version"
|
||||
members: "Number of members"
|
||||
admins: "Number of administrators"
|
||||
availabilities: "Number of availabilities of the last 7 days"
|
||||
reservations: "Number of reservations during the last 7 days"
|
||||
plans: "Is the subscription module active?"
|
||||
spaces: "Is the space management module active?"
|
||||
online_payment: "Is the online payment module active?"
|
||||
invoices: "Is the invoicing module active?"
|
||||
openlab: "Is the project sharing module (OpenLab) active?"
|
||||
|
||||
open_api_clients:
|
||||
add_new_client: "Criar novo cliente de API"
|
||||
|
@ -166,6 +166,9 @@ Rails.application.routes.draw do
|
||||
|
||||
# payments handling
|
||||
post 'payments/confirm_payment' => 'payments/confirm_payment'
|
||||
|
||||
# FabAnalytics
|
||||
get 'analytics/data' => 'analytics#data'
|
||||
end
|
||||
|
||||
# rss
|
||||
|
Loading…
x
Reference in New Issue
Block a user