add progress

This commit is contained in:
aj 2017-08-25 23:47:31 +00:00
parent effee987be
commit a5742d1a2a
2 changed files with 25 additions and 4 deletions

View File

@ -868,6 +868,9 @@
, request: function (preq, _sys) {
return new OAUTH3.PromiseA(function (resolve, reject) {
var xhr;
var headers = preq.headers || {};
var multipart;
try {
xhr = new XMLHttpRequest(_sys);
} catch(e) {
@ -898,9 +901,24 @@
, status: xhr.status
});
};
console.log('$$$$$$$$$$$$$$$$$$$$$$$$ preq.progress:');
console.log(preq.progress);
if (preq.progress) {
xhr.upload.onprogress = function (ev) {
console.log('[progress]');
console.log(ev);
preq.progress({
loaded: ev.loaded
, total: ev.total
});
if (OAUTH3._digest) {
// $rootScope.$digest();
OAUTH3._digest();
}
};
}
xhr.open(preq.method || 'GET', preq.url, true);
var headers = preq.headers || {};
var multipart;
if (preq.data) {
headers['Content-Type'] = 'application/json'; // TODO XXX TODO utf8

View File

@ -5,8 +5,8 @@ var modules = {
azp: [
'$timeout'
, '$q'
, function Oauth3($timeout, $q) {
, '$rootScope'
, function Oauth3($timeout, $q, $rootScope) {
var OAUTH3 = window.OAUTH3;
// We need to make angular's $q appear to be a standard Promise/A+
@ -29,6 +29,9 @@ var modules = {
PromiseAngularQ.all = $q.all;
OAUTH3.PromiseA = PromiseAngularQ;
OAUTH3._digest = function () {
$rootScope.$digest();
};
window.ngOauth3 = OAUTH3;