1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

superadmin + fixed free space notification

This commit is contained in:
Sylvain 2019-03-20 16:49:38 +01:00
parent bf526458b4
commit 8530a6f655
14 changed files with 27 additions and 8 deletions

View File

@ -150,7 +150,7 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
};
// admins list
$scope.admins = adminsPromise.admins;
$scope.admins = adminsPromise.admins.filter(function(m) { return m.id != Fablab.superadminId; });
// Admins ordering/sorting. Default: not sorted
$scope.orderAdmin = null;

View File

@ -93,6 +93,12 @@ class User < ActiveRecord::Base
User.with_role(:admin)
end
def self.superadmin
return unless Rails.application.secrets.superadmin_email.present?
User.find_by(email: Rails.application.secrets.superadmin_email)
end
def training_machine?(machine)
return true if admin?

View File

@ -1,3 +1,3 @@
json.title notification.notification_type
json.description t('warning_disk_space_under_threshold', THRESHOLD: notification.meta_data.threshold)
json.description t('.warning_free_disk_space', AVAILABLE: number_with_delimiter(notification.meta_data['mb_available']))
json.url notification_url(notification, format: :json)

View File

@ -28,6 +28,7 @@
Fablab.disqusShortname = "<%= Rails.application.secrets.disqus_shortname %>";
Fablab.defaultHost = "<%= Rails.application.secrets.default_host %>";
Fablab.gaId = "<%= Rails.application.secrets.google_analytics_id %>";
Fablab.superadminId = parseInt("<%= User.superadmin&.id %>", 10);
// i18n stuff
Fablab.locale = "<%= Rails.application.secrets.app_locale %>";

View File

@ -1,4 +1,4 @@
<%= render 'notifications_mailer/shared/hello', recipient: @recipient %>
<p><%= t('.body', THRESHOLD: @notification.get_meta_data(:threshold), AVAILABLE: @notification.get_meta_data(:mb_available)) %></p>
<p><%= t('.body', THRESHOLD: number_with_delimiter(@notification.get_meta_data(:threshold)), AVAILABLE: number_with_delimiter(@notification.get_meta_data(:mb_available))) %></p>

View File

@ -13,7 +13,7 @@ class FreeDiskSpaceWorker
return if mb_available > Rails.application.secrets.disk_space_mb_alert
NotificationCenter.call type: 'notify_admin_free_disk_space',
receiver: User.admins,
receiver: User.superadmin || User.admins,
attached_object: Role.first,
meta_data: {
mb_available: mb_available,

View File

@ -62,6 +62,7 @@ OPENLAB_BASE_URI: 'https://openprojects.fab-manager.com'
LOG_LEVEL: 'debug'
DISK_SPACE_MB_ALERT: '100'
SUPERADMIN_EMAIL: 'admin@sleede.com'
ALLOWED_EXTENSIONS: pdf ai eps cad math svg stl dxf dwg obj step iges igs 3dm 3dmf doc docx png ino scad fcad skp sldprt sldasm slddrw slddrt tex latex ps
ALLOWED_MIME_TYPES: application/pdf application/postscript application/illustrator image/x-eps image/svg+xml application/sla application/dxf application/acad application/dwg application/octet-stream application/step application/iges model/iges x-world/x-3dmf application/vnd.openxmlformats-officedocument.wordprocessingml.document image/png text/x-arduino text/plain application/scad application/vnd.sketchup.skp application/x-koan application/vnd-koan koan/x-skm application/vnd.koan application/x-tex application/x-latex

View File

@ -310,7 +310,7 @@ en:
enjoy_a_discount_of_PERCENT_with_code_CODE: "Enjoy a discount of %{PERCENT}% with code %{CODE}"
enjoy_a_discount_of_AMOUNT_with_code_CODE: "Enjoy a discount of %{AMOUNT} with code %{CODE}"
notify_admin_free_disk_space:
warning_disk_space_under_threshold: "Warning: the server's available disk space is now %{AVAILABLE} MiB"
warning_free_disk_space: "Warning: the server's available disk space is now %{AVAILABLE} MiB"
notify_admin_close_period_reminder:
warning_last_closed_period_over_1_year: "Please remind to periodically close your accounting periods. Last closed period ended at %{LAST_END}"
warning_no_closed_periods: "Please remind to periodically close your accounting periods. You have to close periods from %{FIRST_DATE}"

View File

@ -310,7 +310,7 @@ es:
enjoy_a_discount_of_PERCENT_with_code_CODE: "Disfruta de un descuento de %{PERCENT}% con el código %{CODE}"
enjoy_a_discount_of_AMOUNT_with_code_CODE: "Disfruta de un descuento de %{AMOUNT} con el código %{CODE}"
notify_admin_free_disk_space:
warning_disk_space_under_threshold: "Warning: the server's available disk space is now %{AVAILABLE} MiB" # missing translation
warning_free_disk_space: "Warning: the server's available disk space is now %{AVAILABLE} MiB" # missing translation
notify_admin_close_period_reminder:
warning_last_closed_period_over_1_year: "Please remind to periodically close your accounting periods. Last closed period ended at %{LAST_END}" # missing translation
warning_no_closed_periods: "Please remind to periodically close your accounting periods. You have to close periods from %{FIRST_DATE}" # missing translation

View File

@ -310,7 +310,7 @@ fr:
enjoy_a_discount_of_PERCENT_with_code_CODE: "Bénéficiez d'une remise de %{PERCENT} % avec le code %{CODE}"
enjoy_a_discount_of_AMOUNT_with_code_CODE: "Bénéficiez d'une remise de %{AMOUNT} avec le code %{CODE}"
notify_admin_free_disk_space:
warning_disk_space_under_threshold: "Attention: l'espace disque disponible sur le serveur est désormais de %{AVAILABLE} MiO"
warning_free_disk_space: "Attention: l'espace disque disponible sur le serveur est désormais de %{AVAILABLE} MiO"
notify_admin_close_period_reminder:
warning_last_closed_period_over_1_year: "Pensez à clôturer régulièrement vos périodes comptables. Les comptes sont actuellement clôturés jusqu'au %{LAST_END}"
warning_no_closed_periods: "Pensez à clôturer régulièrement vos périodes comptables. Vous devez clôturer des périodes depuis le %{FIRST_DATE}"

View File

@ -310,7 +310,7 @@ pt:
enjoy_a_discount_of_PERCENT_with_code_CODE: "Desfrute de um desconto de %{PERCENT}% com o código %{CODE}"
enjoy_a_discount_of_AMOUNT_with_code_CODE: "Desfrute de um desconto de %{AMOUNT} com o código %{CODE}"
notify_admin_free_disk_space:
warning_disk_space_under_threshold: "Warning: the server's available disk space is now %{AVAILABLE} MiB" # missing translation
warning_free_disk_space: "Warning: the server's available disk space is now %{AVAILABLE} MiB" # missing translation
notify_admin_close_period_reminder:
warning_last_closed_period_over_1_year: "Please remind to periodically close your accounting periods. Last closed period ended at %{LAST_END}" # missing translation
warning_no_closed_periods: "Please remind to periodically close your accounting periods. You have to close periods from %{FIRST_DATE}" # missing translation

View File

@ -43,6 +43,7 @@ development:
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %>
disk_space_mb_alert: <%= ENV["DISK_SPACE_MB_ALERT"] %>
superadmin_email: <%= ENV["SUPERADMIN_EMAIL"] %>
test:
secret_key_base: 83daf5e7b80d990f037407bab78dff9904aaf3c195a50f84fa8695a22287e707dfbd9524b403b1dcf116ae1d8c06844c3d7ed942564e5b46be6ae3ead93a9d30
@ -77,6 +78,7 @@ test:
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %>
disk_space_mb_alert: <%= ENV["DISK_SPACE_MB_ALERT"] %>
superadmin_email: <%= ENV["SUPERADMIN_EMAIL"] %>
staging:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@ -119,6 +121,7 @@ staging:
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %>
disk_space_mb_alert: <%= ENV["DISK_SPACE_MB_ALERT"] %>
superadmin_email: <%= ENV["SUPERADMIN_EMAIL"] %>
# Do not keep production secrets in the repository,
# instead read values from the environment.
@ -164,3 +167,4 @@ production:
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %>
disk_space_mb_alert: <%= ENV["DISK_SPACE_MB_ALERT"] %>
superadmin_email: <%= ENV["SUPERADMIN_EMAIL"] %>

View File

@ -152,6 +152,11 @@ The check will run every weeks and if the threshold is exceeded, an alert will b
Credentials for the first admin user created when seeding the project. (not present in application.yml because they are only used once when running the database seed with the command `rake db:seed`)
SUPERADMIN_EMAIL
Optional email of the administrator account in charge of the system administration.
If specified, it will be hidden from the administrators list and he will exclusively receive the notifications related to the system administration.
If not specified, every admins will receive system administration notifications.
<a name="internationalization-settings"></a>
## Internationalization settings

View File

@ -61,6 +61,8 @@ NAVINUM_API_LOGIN=
NAVINUM_API_PASSWORD=
LOG_LEVEL=debug
DISK_SPACE_MB_ALERT='100'
SUPERADMIN_EMAIL='admin@sleede.com'
ALLOWED_EXTENSIONS=pdf ai eps cad math svg stl dxf dwg obj step iges igs 3dm 3dmf doc docx png ino scad fcad skp sldprt sldasm slddrw slddrt tex latex ps