spinner on tickets import

This commit is contained in:
Davide Alberani 2017-09-16 17:49:09 +02:00
parent 2842918e0e
commit 253701e159
2 changed files with 14 additions and 4 deletions

View file

@ -26,7 +26,7 @@
</div>
<div>
<br />
<input type="submit" value="{{'Import' | translate}}" ng-click="apiImport()" />
<input type="submit" value="{{'Import' | translate}}" ng-click="apiImport()" ng-disabled="importRunning" />
</div>
</form>
</div>
@ -55,7 +55,7 @@
<div>
<br />
<input type="submit" value="{{'Import' | translate}}" ng-click="upload(file, '/ebcsvpersons')" />
<input type="submit" value="{{'Import' | translate}}" ng-click="upload(file, '/ebcsvpersons')" ng-disabled="importRunning" />
</div>
<div class="form-group top5">

View file

@ -838,21 +838,31 @@ eventManControllers.controller('FileUploadCtrl', ['$scope', '$log', '$upload', '
$scope.ebEventID = '';
$scope.reply = {};
$scope.events = Event.all();
$scope.importRunning = false;
$scope.apiImport = function() {
if (!($scope.ebAPIkey && $scope.ebEventID)) {
$log.warn('missing Eventbrite API key or Event ID');
return;
}
$scope.importRunning = true;
var watingToaster = toaster.pop({type: 'wait', title: 'importing tickets',
body: 'this may take a while...',
timeout: 0, showCloseButton: false,
tapToDismiss: false});
EbAPI.apiImport({
create: $scope.createNewEvent,
eventID: $scope.ebEventID,
targetEvent: $scope.targetEvent,
oauthToken: $scope.ebAPIkey
}, function(data) {
console.log(data);
toaster.pop({type: 'info', title: 'imported tickets',
toaster.clear(watingToaster);
toaster.pop({type: 'info', title: 'tickets imported!',
body: 'total: ' + data.total + ' errors: ' + (data.total - data.valid)})
$scope.importRunning = false;
}, function(data) {
toaster.clear(watingToaster);
$scope.importRunning = false;
});
};