Fixed Dev backend simulated network behaviour and minor code cleanup
This commit is contained in:
parent
8b7a438039
commit
0abd559e81
@ -510,18 +510,12 @@ Clipperz.log("<<< Connection.messageExceptionHandler")
|
|||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
|
|
||||||
// 'uploadAttachment': function(someArguments, aProgressCallback) {
|
|
||||||
// return this.message('uploadAttachment', someArguments, {'uploadProgressCallback': aProgressCallback});
|
|
||||||
// },
|
|
||||||
|
|
||||||
'uploadAttachment': function(someArguments, aProgressCallback) {
|
'uploadAttachment': function(someArguments, aProgressCallback) {
|
||||||
return Clipperz.Async.callbacks("Connction.uploadAttachment", [
|
return Clipperz.Async.callbacks("Connction.uploadAttachment", [
|
||||||
MochiKit.Base.method(this, 'message', 'echo', {'echo':"echo"}),
|
MochiKit.Base.method(this, 'message', 'echo', {'echo':"echo"}),
|
||||||
MochiKit.Base.bind(function(){ return this.sharedSecret()}, this),
|
MochiKit.Base.bind(function(){ return this.sharedSecret()}, this),
|
||||||
MochiKit.Base.method(this.proxy(), 'uploadAttachment', someArguments, aProgressCallback/*, this.sharedSecret()*/),
|
MochiKit.Base.method(this.proxy(), 'uploadAttachment', someArguments, aProgressCallback/*, this.sharedSecret()*/),
|
||||||
], {trace:false});
|
], {trace:false});
|
||||||
|
|
||||||
// return this.proxy().uploadAttachment(someArguments, aProgressCallback, this.sharedSecret());
|
|
||||||
},
|
},
|
||||||
|
|
||||||
'downloadAttachment': function(someArguments, aProgressCallback) {
|
'downloadAttachment': function(someArguments, aProgressCallback) {
|
||||||
@ -530,8 +524,6 @@ Clipperz.log("<<< Connection.messageExceptionHandler")
|
|||||||
MochiKit.Base.bind(function(){ return this.sharedSecret()}, this),
|
MochiKit.Base.bind(function(){ return this.sharedSecret()}, this),
|
||||||
MochiKit.Base.method(this.proxy(), 'downloadAttachment', someArguments, aProgressCallback/*, this.sharedSecret()*/),
|
MochiKit.Base.method(this.proxy(), 'downloadAttachment', someArguments, aProgressCallback/*, this.sharedSecret()*/),
|
||||||
], {trace:false});
|
], {trace:false});
|
||||||
|
|
||||||
// return this.proxy().downloadAttachment(someArguments, aProgressCallback, this.sharedSecret());
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
|
@ -102,7 +102,6 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.JSON, Clipperz.PM.Proxy, {
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
// TODO: test
|
|
||||||
'_uploadAttachment': function(someArguments, aProgressCallback, aSharedSecret, aToll) {
|
'_uploadAttachment': function(someArguments, aProgressCallback, aSharedSecret, aToll) {
|
||||||
var formData;
|
var formData;
|
||||||
var deferredResult;
|
var deferredResult;
|
||||||
@ -142,7 +141,6 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.JSON, Clipperz.PM.Proxy, {
|
|||||||
throw someValues['message'];
|
throw someValues['message'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check return value with actual request. Expected: ArrayBuffer
|
|
||||||
return someValues;
|
return someValues;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -151,7 +149,6 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.JSON, Clipperz.PM.Proxy, {
|
|||||||
return deferredResult;
|
return deferredResult;
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: test
|
|
||||||
'_downloadAttachment': function(someArguments, aProgressCallback, aSharedSecret, aToll) {
|
'_downloadAttachment': function(someArguments, aProgressCallback, aSharedSecret, aToll) {
|
||||||
var deferredResult;
|
var deferredResult;
|
||||||
var parameters;
|
var parameters;
|
||||||
|
@ -281,6 +281,11 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
|
|||||||
uploadAttachment: function(someArguments, aProgressCallback, aSharedSecret, aToll) {
|
uploadAttachment: function(someArguments, aProgressCallback, aSharedSecret, aToll) {
|
||||||
var connection = this.currentStaticConnection();
|
var connection = this.currentStaticConnection();
|
||||||
var attachmentReference = someArguments['attachmentReference'];
|
var attachmentReference = someArguments['attachmentReference'];
|
||||||
|
var payloadSize = someArguments['arrayBufferData'].length;
|
||||||
|
var resultValue = {
|
||||||
|
result: {},
|
||||||
|
toll: this.getTollForRequestType('MESSAGE')
|
||||||
|
};
|
||||||
|
|
||||||
if (this.isReadOnly() == false) {
|
if (this.isReadOnly() == false) {
|
||||||
connection['userData']['attachments'][attachmentReference] = {
|
connection['userData']['attachments'][attachmentReference] = {
|
||||||
@ -290,10 +295,10 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
|
|||||||
'version': someArguments['version'],
|
'version': someArguments['version'],
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.simulateNetworkDelayResponse(someArguments['arrayBufferData'].length, aProgressCallback, {
|
return Clipperz.Async.callbacks("Proxy.Offline.DataStore.uploadAttachment", [
|
||||||
result: {},
|
MochiKit.Base.method(this, 'simulateNetworkDelay', payloadSize, aProgressCallback, resultValue),
|
||||||
toll: this.getTollForRequestType('MESSAGE')
|
function () { return resultValue; },
|
||||||
});
|
], {trace:false});
|
||||||
} else {
|
} else {
|
||||||
throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly;
|
throw Clipperz.PM.Proxy.Offline.DataStore.exception.ReadOnly;
|
||||||
}
|
}
|
||||||
@ -302,15 +307,19 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
|
|||||||
downloadAttachment: function(someArguments, aProgressCallback, aSharedSecret, aToll) {
|
downloadAttachment: function(someArguments, aProgressCallback, aSharedSecret, aToll) {
|
||||||
var connection = this.currentStaticConnection();
|
var connection = this.currentStaticConnection();
|
||||||
var reference = someArguments['reference'];
|
var reference = someArguments['reference'];
|
||||||
var result = connection['userData']['attachments'][reference]['data'];
|
var resultData = connection['userData']['attachments'][reference]['data'];
|
||||||
|
var resultValue = {
|
||||||
return this.simulateNetworkDelayResponse(result.length, aProgressCallback, {
|
result: resultData,
|
||||||
result: result,
|
|
||||||
// toll: this.getTollForRequestType('MESSAGE')
|
// toll: this.getTollForRequestType('MESSAGE')
|
||||||
});
|
};
|
||||||
|
|
||||||
|
return Clipperz.Async.callbacks("Proxy.Offline.DataStore.downloadAttachment", [
|
||||||
|
MochiKit.Base.method(this, 'simulateNetworkDelay', resultData.length, aProgressCallback, resultValue),
|
||||||
|
function () { return resultValue; },
|
||||||
|
], {trace:false});
|
||||||
},
|
},
|
||||||
|
|
||||||
simulateNetworkDelayResponse: function(payloadSize, progressCallback, aResponse) {
|
simulateNetworkDelay: function(payloadSize, progressCallback) {
|
||||||
var deferredResult;
|
var deferredResult;
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
@ -322,8 +331,6 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, {
|
|||||||
deferredResult.addMethod(this, 'runProgressCallback', progressCallback, loaded, payloadSize);
|
deferredResult.addMethod(this, 'runProgressCallback', progressCallback, loaded, payloadSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
deferredResult.addCallback(MochiKit.Async.succeed, aResponse);
|
|
||||||
|
|
||||||
deferredResult.callback();
|
deferredResult.callback();
|
||||||
|
|
||||||
return deferredResult;
|
return deferredResult;
|
||||||
|
@ -696,7 +696,7 @@ console.log("DROP"); //, anEvent);
|
|||||||
'progress': aProgress,
|
'progress': aProgress,
|
||||||
'border': 1
|
'border': 1
|
||||||
});
|
});
|
||||||
} else if (! broken /* && aStatus != 'DONE' && aStatus != 'FAILED' */ && aServerStatus != 'AVAILABLE' && queueOperationsInProgress) {
|
} else if (! broken && aServerStatus != 'AVAILABLE' && queueOperationsInProgress) {
|
||||||
result = Clipperz.PM.UI.Components.RadialProgressIndicator({
|
result = Clipperz.PM.UI.Components.RadialProgressIndicator({
|
||||||
'progress': 0,
|
'progress': 0,
|
||||||
'border': 1,
|
'border': 1,
|
||||||
|
@ -265,7 +265,6 @@ Clipperz.PM.UI.Components.Cards.ViewClass = React.createClass({
|
|||||||
renderAttachmentProgress: function(aStatus, aServerStatus, aProgress) {
|
renderAttachmentProgress: function(aStatus, aServerStatus, aProgress) {
|
||||||
var result;
|
var result;
|
||||||
|
|
||||||
var broken = (! aServerStatus && (! aStatus || aStatus == 'CANCELED' || aStatus == 'FAILED' || aStatus == 'DONE'));
|
|
||||||
var queueOperationsInProgress = (aStatus != 'DONE' && aStatus != 'CANCELED' && aStatus != 'FAILED');
|
var queueOperationsInProgress = (aStatus != 'DONE' && aStatus != 'CANCELED' && aStatus != 'FAILED');
|
||||||
|
|
||||||
result = null;
|
result = null;
|
||||||
@ -274,7 +273,7 @@ Clipperz.PM.UI.Components.Cards.ViewClass = React.createClass({
|
|||||||
'progress': aProgress,
|
'progress': aProgress,
|
||||||
'border': 1
|
'border': 1
|
||||||
});
|
});
|
||||||
} else if (! broken && queueOperationsInProgress /* && aServerStatus != 'AVAILABLE'*/) {
|
} else if (queueOperationsInProgress) {
|
||||||
result = Clipperz.PM.UI.Components.RadialProgressIndicator({
|
result = Clipperz.PM.UI.Components.RadialProgressIndicator({
|
||||||
'progress': 0,
|
'progress': 0,
|
||||||
'border': 1,
|
'border': 1,
|
||||||
@ -337,19 +336,6 @@ Clipperz.PM.UI.Components.Cards.ViewClass = React.createClass({
|
|||||||
}, "remove field");
|
}, "remove field");
|
||||||
}
|
}
|
||||||
|
|
||||||
// result = null;
|
|
||||||
// if (aStatus == 'DOWNLOADING') {
|
|
||||||
// result = React.DOM.a({
|
|
||||||
// 'className': 'cancel',
|
|
||||||
// 'onClick': MochiKit.Base.method(this, 'handleCancelDownload', anAttachment)
|
|
||||||
// }, "remove field");
|
|
||||||
// } else if (aServerStatus == 'AVAILABLE' && ! queueOperationsInProgress) {
|
|
||||||
// result = React.DOM.a({
|
|
||||||
// 'className': 'download',
|
|
||||||
// 'onClick': MochiKit.Base.method(this, 'handleGetAttachment', anAttachment),
|
|
||||||
// }, "\u2b07");
|
|
||||||
// }
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -389,7 +375,6 @@ Clipperz.PM.UI.Components.Cards.ViewClass = React.createClass({
|
|||||||
renderAttachments: function(someAttachments) {
|
renderAttachments: function(someAttachments) {
|
||||||
var result;
|
var result;
|
||||||
|
|
||||||
//console.log("View props:", this.props, someAttachments);
|
|
||||||
if (someAttachments.length > 0) {
|
if (someAttachments.length > 0) {
|
||||||
result = React.DOM.div({'className': 'cardAttachments'}, [
|
result = React.DOM.div({'className': 'cardAttachments'}, [
|
||||||
React.DOM.h3({'className': 'summaryText'}, "Attachments"),
|
React.DOM.h3({'className': 'summaryText'}, "Attachments"),
|
||||||
|
Loading…
Reference in New Issue
Block a user