Skip to content

Commit

Permalink
alfio-event#549 - Waiting queue download button and modal
Browse files Browse the repository at this point in the history
 Get available fields from backend and populate a modal dedicated to
 waiting queue download
  • Loading branch information
Nassim Bounouas committed Nov 24, 2018
1 parent e0431ca commit f9af902
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@
import static alfio.model.system.ConfigurationKeys.STOP_WAITING_QUEUE_SUBSCRIPTIONS;
import static alfio.util.OptionalWrapper.optionally;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.toList;

@RestController
@RequestMapping("/admin/api/event/{eventName}/waiting-queue")
@AllArgsConstructor
public class AdminWaitingQueueApiController {

private final WaitingQueueManager waitingQueueManager;
private final WaitingQueueManager waitingQueueManager;
private final EventManager eventManager;
private final TicketReservationManager ticketReservationManager;
private final ConfigurationManager configurationManager;
Expand All @@ -69,7 +70,7 @@ private Map<String, Boolean> loadStatus(Event event) {
.stream()
.filter(tc -> !tc.isAccessRestricted())
.map(tc -> new SaleableTicketCategory(tc, "", now, event, ticketReservationManager.countAvailableTickets(event, tc), tc.getMaxTickets(), null))
.collect(Collectors.toList());
.collect(toList());
boolean active = EventUtil.checkWaitingQueuePreconditions(event, stcList, configurationManager, eventStatisticsManager.noSeatsAvailable());
boolean paused = active && configurationManager.getBooleanConfigValue(Configuration.from(event.getOrganizationId(), event.getId(), STOP_WAITING_QUEUE_SUBSCRIPTIONS), false);
Map<String, Boolean> result = new HashMap<>();
Expand Down Expand Up @@ -118,11 +119,20 @@ public ResponseEntity<Map<String, Object>> removeSubscriber(@PathVariable("event

@RequestMapping(value = "/subscriber/{subscriberId}/restore", method = RequestMethod.PUT)
public ResponseEntity<Map<String, Object>> restoreSubscriber(@PathVariable("eventName") String eventName,
@PathVariable("subscriberId") int subscriberId,
Principal principal) {
@PathVariable("subscriberId") int subscriberId,
Principal principal) {
return performStatusModification(eventName, subscriberId, principal, WaitingQueueSubscription.Status.WAITING, WaitingQueueSubscription.Status.CANCELLED);
}

private static final List<String> FIXED_FIELDS = Arrays.asList("ID", "Creation", "Event", "Status", "Full Name", "First Name", "Last Name", "E-Mail", "Ticket Reservation Id", "Language", "Selected category", "Subscription type");

@RequestMapping("/fields")
public List<SerializablePair<String, String>> getAllFields(@PathVariable("eventName") String eventName) {
List<SerializablePair<String, String>> fields = new ArrayList<>();
fields.addAll(FIXED_FIELDS.stream().map(f -> SerializablePair.of(f, f)).collect(toList()));
return fields;
}

private ResponseEntity<Map<String, Object>> performStatusModification(String eventName, int subscriberId,
Principal principal, WaitingQueueSubscription.Status newStatus,
WaitingQueueSubscription.Status currentStatus) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="modal-header">
<h3>Download waiting queue : select fields</h3>
</div>
<div class="modal-body">
<ul style="list-style-type:none;padding:0">
<li data-ng-repeat="field in fields"><label><input type="checkbox" ng-model="selected[field.key]"> {{field.value}}</label></li>
</ul>
<hr>
<p>
<label><input type="radio" name="format" value="excel" ng-model="format"> Excel</label>
<label><input type="radio" name="format" value="csv" ng-model="format"> csv</label>
</p>
</div>
<div class="modal-footer">
<div class="pull-left">
<button class="btn btn-default" data-ng-click="selectAll()">Select all</button>
<button class="btn btn-default" data-ng-click="deselectAll()">Deselect all</button>
</div>
<div class="pull-right">
<button class="btn btn-primary" type="button" data-ng-click="download()" ><i class="fa fa-download"></i> download waiting queue</button>
<button class="btn btn-default" type="button" data-ng-click="$dismiss()"><i class="fa fa-times"></i> close</button>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<a data-uib-dropdown-toggle id="download-dpdwn" class="btn btn-default"><i class="fa fa-download"></i> Download <span class="caret"></span></a>
<ul class="dropdown-menu" data-uib-dropdown-menu role="menu" aria-labelledby="download-dpdwn">
<li role="menuitem"><a data-ng-click="ctrl.openFieldSelectionModal()"><i class="fa fa-users"></i> attendees' data</a></li>
<li role="menuitem"><a data-ng-click="ctrl.waitingQueueDownloadFieldsSelectionModal()"><i class="fa fa-users"></i> waiting queue</a></li>
<li role="menuitem"><a data-ng-click="ctrl.downloadSponsorsScan()" ><i class="fa fa-barcode"></i> sponsors scan</a></li>
<li role="menuitem"><a data-ng-click="ctrl.downloadInvoices()" ><i class="fa fa-file-o"></i> all invoices</a></li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,11 @@
ctrl.openFieldSelectionModal = function() {
EventService.exportAttendees(ctrl.event);
};

ctrl.waitingQueueDownloadFieldsSelectionModal = function() {
EventService.waitingQueueDownloadFieldsSelection(ctrl.event);
};

ctrl.downloadSponsorsScan = function() {
var pathName = $window.location.pathname;
if(!pathName.endsWith("/")) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/resources/js/admin/service/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@
getFields : function(eventName) {
return $http['get']('/admin/api/events/'+eventName+'/fields');
},
getWaitingQueueFields : function(eventName) {
return $http['get']('/admin/api/event/'+eventName+'/waiting-queue/fields');
},
getAdditionalFields: function(eventName) {
return $http.get('/admin/api/events/'+eventName+'/additional-field').error(HttpErrorHandler.handle);
},
Expand Down

0 comments on commit f9af902

Please sign in to comment.