~15651933282-v/study.cs.ucl-password-collection-clients/study.cs.ucl-password-collection-clients

« back to all changes in this revision

Viewing changes to js/DataUploadService.js

  • Committer: Steve Dodier-Lazaro
  • Date: 2015-04-15 16:08:17 UTC
  • Revision ID: s.dodier-lazaro@cs.ucl.ac.uk-20150415160817-sd88nhumhtbjnrtu
 Fixing bug so button becomes reactive even if error or exit of modal

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
                            '_csrf_token': token
58
58
                        }
59
59
                    });
 
60
                }, function (error) {
 
61
                    error.statusText = !error.statusText ? 'Error during login' : error.statusText;
 
62
                    port.postMessage({success: false, errorCode: error.status, error: error.statusText});
 
63
                    port.disconnect();
 
64
                    return $q.reject();
60
65
                }).then(function () {
61
66
                    var xhr = new XMLHttpRequest();
62
67
                    xhr.open('POST', serverRootUrl + 'a/1/upload_direct', true);
80
85
                    };
81
86
                    port.postMessage({inProgress: true, stage: 4, text: 'Sending data'});
82
87
                    xhr.send(blob);
83
 
                }).catch(function (error) {
84
 
                    port.postMessage({success: false, errorCode: error.status, error: error.statusText});
85
 
                    port.disconnect();
 
88
                }, function (error) {
 
89
                    if (error) {
 
90
                        port.postMessage({success: false, errorCode: error.status, error: error.statusText});
 
91
                        port.disconnect();
 
92
                    }
86
93
                });
87
94
            }
88
95
        }