1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

privacy option for fab-analytics

This commit is contained in:
Sylvain 2020-01-15 10:46:04 +01:00
parent e7ec69e49e
commit 059096c2dd
8 changed files with 50 additions and 32 deletions

View File

@ -123,6 +123,11 @@ Application.Controllers.controller('SettingsController', ['$scope', '$filter', '
value: (settingsPromise.display_name_enable === 'true')
};
$scope.fabAnalytics = {
name: 'fab_analytics',
value: (settingsPromise.fab_analytics === 'true')
};
// By default, we display the currently published privacy policy
$scope.privacyPolicy = {
version: null,

View File

@ -996,35 +996,16 @@ angular.module('application.router', ['ui.router'])
resolve: {
settingsPromise: ['Setting', function (Setting) {
return Setting.query({
names: `['twitter_name', \
'about_title', \
'about_body', \
'privacy_body', \
'privacy_dpo', \
'about_contacts', \
'home_blogpost', \
'machine_explications_alert', \
'training_explications_alert', \
'training_information_message', \
'subscription_explications_alert', \
'event_explications_alert', \
'space_explications_alert', \
'booking_window_start', \
'booking_window_end', \
'booking_move_enable', \
'booking_move_delay', \
'booking_cancel_enable', \
'booking_cancel_delay', \
'main_color', \
'secondary_color', \
'fablab_name', \
'name_genre', \
'reminder_enable', \
'reminder_delay', \
'visibility_yearly', \
'visibility_others', \
'display_name_enable', \
'machines_sort_by']` }).$promise;
names: `['twitter_name', 'about_title', 'about_body', \
'privacy_body', 'privacy_dpo', 'about_contacts', \
'home_blogpost', 'machine_explications_alert', 'training_explications_alert', \
'training_information_message', 'subscription_explications_alert', 'event_explications_alert', \
'space_explications_alert', 'booking_window_start', 'booking_window_end', \
'booking_move_enable', 'booking_move_delay', 'booking_cancel_enable', \
'booking_cancel_delay', 'main_color', 'secondary_color', \
'fablab_name', 'name_genre', 'reminder_enable', \
'reminder_delay', 'visibility_yearly', 'visibility_others', \
'display_name_enable', 'machines_sort_by', 'fab_analytics']` }).$promise;
}],
privacyDraftsPromise: ['Setting', function (Setting) { return Setting.get({ name: 'privacy_draft', history: true }).$promise; }],
cguFile: ['CustomAsset', function (CustomAsset) { return CustomAsset.get({ name: 'cgu-file' }).$promise; }],

View File

@ -26,5 +26,24 @@
</div>
<div class="row">
<div class="col-md-10 col-md-offset-1 m-t-lg">
<label for="is_recurrent" translate>{{ 'app.admin.settings.fab_analytics' }}</label>
<input bs-switch
ng-model="fabAnalytics.value"
id="is_recurrent"
type="checkbox"
class="form-control"
switch-on-text="{{ 'app.shared.buttons.yes' | translate }}"
switch-off-text="{{ 'app.shared.buttons.no' | translate }}"
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>
</p>
<button name="button" class="btn btn-warning" ng-click="save(fabAnalytics)" translate>{{ 'app.shared.buttons.save' }}</button>
</div>
</div>
</div>
</div>

View File

@ -63,7 +63,8 @@ class Setting < ActiveRecord::Base
accounting_Space_code
accounting_Space_label
hub_last_version
hub_public_key] }
hub_public_key
fab_analytics] }
after_update :update_stylesheet, :notify_privacy_policy_changed if :value_changed?

View File

@ -32,6 +32,9 @@ class HealthService
end
def self.stats
enable = Setting.find_by(name: 'fab_analytics')&.value
return false if enable == 'false'
require 'version'
require 'openssl'
require 'base64'
@ -50,7 +53,7 @@ class HealthService
}.to_json.to_s
key = Setting.find_by(name: 'hub_public_key')&.value
return 'disabled' unless key
return false unless key
public_key = OpenSSL::PKey::RSA.new(key)
Base64.encode64(public_key.public_encrypt(stats))

View File

@ -946,6 +946,7 @@ fr:
display_name: "Afficher le nom"
display_name_enable: "l'affichage du nom"
machines_sort_by: "l'odre d'affichage des machines"
fab_analytics: "Fab Analytics"
elements_ordering: "Ordre d'affichage des éléments"
machines_order: "Ordre des machines"
display_machines_sorted_by: "Afficher les machines triées par"
@ -964,6 +965,8 @@ fr:
publish_will_notify: "Publier une nouvelle version enverra une notification à l'ensemble des utilisateurs."
publish: "Publier"
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 ?"
open_api_clients:
add_new_client: "Créer un compte client"

View File

@ -630,6 +630,12 @@ unless Setting.find_by(name: 'privacy_draft').try(:value)
setting.save
end
unless Setting.find_by(name: 'fab_analytics').try(:value)
setting = Setting.find_or_initialize_by(name: 'fab_analytics')
setting.value = 'true'
setting.save
end
if StatisticCustomAggregation.count.zero?
# available reservations hours for machines
machine_hours = StatisticType.find_by(key: 'hour', statistic_index_id: 2)

View File

@ -16,7 +16,7 @@ class Version
end
def self.check_and_schedule
return if Rails.env.development? && !ENV['FORCE_VERSION_CHECK']
return if (Rails.env.development? || Rails.env.test?) && ENV['FORCE_VERSION_CHECK'] != 'true'
VersionCheckWorker.perform_async
# every sunday at 1:15am