1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

notify admin when users exports are running

This commit is contained in:
Sylvain 2016-07-28 10:28:43 +02:00
parent 4eca6e9dbb
commit 5cacb1d34a
8 changed files with 34 additions and 9 deletions

View File

@ -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 ###

View File

@ -31,13 +31,13 @@
<div class="col-md-12">
<button type="button" class="btn btn-warning m-t m-b" ui-sref="app.admin.members_new" translate>{{ 'add_a_new_member' }}</button>
<div class="pull-right">
<a class="btn btn-default" ng-href="api/members/export_members.xlsx" target="export-frame">
<a class="btn btn-default" ng-href="api/members/export_members.xlsx" target="export-frame" ng-click="alertExport('members')">
<i class="fa fa-file-excel-o"></i> {{ 'members' | translate }}
</a>
<a class="btn btn-default" ng-href="api/members/export_subscriptions.xlsx" target="export-frame" ng-if="!fablabWithoutPlans">
<a class="btn btn-default" ng-href="api/members/export_subscriptions.xlsx" target="export-frame" ng-if="!fablabWithoutPlans" ng-click="alertExport('subscriptions')">
<i class="fa fa-file-excel-o"></i> {{ 'subscriptions' | translate }}
</a>
<a class="btn btn-default" ng-href="api/members/export_reservations.xlsx" target="export-frame">
<a class="btn btn-default" ng-href="api/members/export_reservations.xlsx" target="export-frame" ng-click="alertExport('reservations')">
<i class="fa fa-file-excel-o"></i> {{ 'reservations' | translate }}
</a>
<iframe name="export-frame" height="0" width="0" class="none"></iframe>

View File

@ -11,6 +11,6 @@
</ul>
</div>
<div class="modal-footer">
<button class="btn btn-info" ng-click="ok()" ng-disabled="attempting">{{validButtonName}}</button>
<button class="btn btn-info" ng-click="ok()" ng-disabled="attempting" ng-bind-html="validButtonName"></button>
<button class="btn btn-default" ng-click="cancel()" translate>{{ 'cancel' }}</button>
</div>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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"