Browse Source

spinner on tickets import

Davide Alberani 6 years ago
parent
commit
253701e159
2 changed files with 14 additions and 4 deletions
  1. 2 2
      angular_app/import-persons.html
  2. 12 2
      angular_app/js/controllers.js

+ 2 - 2
angular_app/import-persons.html

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

+ 12 - 2
angular_app/js/controllers.js

@@ -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;
             });
         };