diff --git a/app/assets/javascripts/controllers/admin/members.coffee.erb b/app/assets/javascripts/controllers/admin/members.coffee.erb index 2c243e738..1873bd046 100644 --- a/app/assets/javascripts/controllers/admin/members.coffee.erb +++ b/app/assets/javascripts/controllers/admin/members.coffee.erb @@ -105,8 +105,8 @@ class MembersController ## # Controller used in the members/groups management page ## -Application.Controllers.controller "AdminMembersController", ["$scope", 'membersPromise', 'adminsPromise', 'growl', 'Admin', 'dialogs', '_t', 'Member' -, ($scope, membersPromise, adminsPromise, growl, Admin, dialogs, _t, Member) -> +Application.Controllers.controller "AdminMembersController", ["$scope", 'membersPromise', 'adminsPromise', 'growl', 'Admin', 'dialogs', '_t', 'Member', 'Export' +, ($scope, membersPromise, adminsPromise, growl, Admin, dialogs, _t, Member, Export) -> @@ -204,6 +204,16 @@ Application.Controllers.controller "AdminMembersController", ["$scope", 'members resetSearchMember() memberSearch() + ## + # Callback to alert the admin that the export request was acknowledged and is + # processing right now. + ## + $scope.alertExport = (type) -> + Export.status({category: 'users', type: type}).then (res) -> + unless (res.data.exists) + growl.success _t('export_is_running_you_ll_be_notified_when_its_ready') + + ### PRIVATE SCOPE ### diff --git a/app/assets/templates/admin/members/index.html.erb b/app/assets/templates/admin/members/index.html.erb index 8277b85e6..0d5085228 100644 --- a/app/assets/templates/admin/members/index.html.erb +++ b/app/assets/templates/admin/members/index.html.erb @@ -31,13 +31,13 @@
- + {{ 'members' | translate }} - + {{ 'subscriptions' | translate }} - + {{ 'reservations' | translate }} diff --git a/app/assets/templates/shared/valid_reservation_modal.html.erb b/app/assets/templates/shared/valid_reservation_modal.html.erb index 89d28df19..73318045a 100644 --- a/app/assets/templates/shared/valid_reservation_modal.html.erb +++ b/app/assets/templates/shared/valid_reservation_modal.html.erb @@ -11,6 +11,6 @@
diff --git a/app/controllers/api/exports_controller.rb b/app/controllers/api/exports_controller.rb index 2735c54b7..0ec8dff1c 100644 --- a/app/controllers/api/exports_controller.rb +++ b/app/controllers/api/exports_controller.rb @@ -11,7 +11,22 @@ class API::ExportsController < API::ApiController def status authorize Export - export = Export.where({category: params[:category], export_type: params[:type], query: params[:query], key: params[:key]}).last + export = Export.where({category: params[:category], export_type: params[:type], query: params[:query], key: params[:key]}) + + if params[:category] === 'users' + case params[:type] + when 'subscriptions' + export = export.where('created_at > ?', Subscription.maximum('updated_at')) + when 'reservations' + export = export.where('created_at > ?', Reservation.maximum('updated_at')) + when 'members' + export = export.where('created_at > ?', User.with_role(:member).maximum('updated_at')) + else + raise ArgumentError, "Unknown type #{params[:type]}" + end + end + export = export.last + if export.nil? || !FileTest.exist?(export.file) render json: {exists: false, id: nil}, status: :ok else diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index d3adc33fa..df0d6cadd 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -409,7 +409,6 @@ en: export_all_statistics: "Export all statistics" export_the_current_search_results: "Export the current search results" export: "Export" - export_is_running_you_ll_be_notified_when_its_ready: "Export is running. You'll be notified when it's ready." stats_graphs: # statistics graphs diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index 8113367b7..7bf6309d8 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -409,7 +409,6 @@ fr: export_all_statistics: "Exporter toutes les statistiques" export_the_current_search_results: "Exporter les résultats de la recherche courante" export: "Exporter" - export_is_running_you_ll_be_notified_when_its_ready: "L'export est en cours. Vous serez notifié lorsqu'il sera prêt." stats_graphs: # graphiques de statistiques diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml index 4a9f40174..ac9f5bdb3 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -97,6 +97,7 @@ en: all_themes: "All themes" filter: 'Filter' confirm_payment_of_html: "{ROLE, select, admin{Payment on site} other{Pay}}: {AMOUNT}" # messageFormat interpolation (context: confirm my payment of $20.00) + export_is_running_you_ll_be_notified_when_its_ready: "Export is running. You'll be notified when it's ready." messages: you_will_lose_any_unsaved_modification_if_you_quit_this_page: "You will lose any unsaved modification if you quit this page" diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml index 119deb195..2b3768182 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -97,6 +97,7 @@ fr: all_themes: "Toutes les thématiques" filter: 'Filtre' confirm_payment_of_html: "{ROLE, select, admin{Paiement sur place} other{Payer}} : {AMOUNT}" # messageFormat interpolation (contexte : valider mon paiement de 20,00 €) + export_is_running_you_ll_be_notified_when_its_ready: "L'export est en cours. Vous serez notifié lorsqu'il sera prêt." messages: you_will_lose_any_unsaved_modification_if_you_quit_this_page: "Vous perdrez les modifications non enregistrées si vous quittez cette page"