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

View file

@ -838,21 +838,31 @@ eventManControllers.controller('FileUploadCtrl', ['$scope', '$log', '$upload', '
$scope.ebEventID = ''; $scope.ebEventID = '';
$scope.reply = {}; $scope.reply = {};
$scope.events = Event.all(); $scope.events = Event.all();
$scope.importRunning = false;
$scope.apiImport = function() { $scope.apiImport = function() {
if (!($scope.ebAPIkey && $scope.ebEventID)) { if (!($scope.ebAPIkey && $scope.ebEventID)) {
$log.warn('missing Eventbrite API key or Event ID'); $log.warn('missing Eventbrite API key or Event ID');
return; 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({ EbAPI.apiImport({
create: $scope.createNewEvent, create: $scope.createNewEvent,
eventID: $scope.ebEventID, eventID: $scope.ebEventID,
targetEvent: $scope.targetEvent, targetEvent: $scope.targetEvent,
oauthToken: $scope.ebAPIkey oauthToken: $scope.ebAPIkey
}, function(data) { }, function(data) {
console.log(data); toaster.clear(watingToaster);
toaster.pop({type: 'info', title: 'imported tickets', toaster.pop({type: 'info', title: 'tickets imported!',
body: 'total: ' + data.total + ' errors: ' + (data.total - data.valid)}) body: 'total: ' + data.total + ' errors: ' + (data.total - data.valid)})
$scope.importRunning = false;
}, function(data) {
toaster.clear(watingToaster);
$scope.importRunning = false;
}); });
}; };