Permalink
Browse files

Uploader : error / response handling, autoClose, fix clicks issues in…

… options pane (checkbox styling)
  • Loading branch information...
1 parent 8bd87da commit d421e2f1533a3547e9a2742d416c781e5cfe9a1a @cdujeu cdujeu committed Sep 20, 2016
@@ -159,6 +159,7 @@
if(uploader.dialogOnComplete){
uploader.resourcesManager.load();
var dialogOnComplete = new Function("oForm", uploader.dialogOnComplete);
+ modal.setCloseAction(dialogOnComplete);
}
var dialogOpen = function(form){
if (form.down('#uploader_chooser')) form.down('#uploader_chooser').remove();
@@ -102,8 +102,11 @@ class PydioApi{
if(window.Connexion){
+ let localError = function(xhr){
+ onError('Request failed with status :' + xhr.status);
+ };
var c = new Connexion();
- return c.uploadFile(file, fileParameterName, uploadUrl, onComplete, onError, onProgress, xhrSettings);
+ return c.uploadFile(file, fileParameterName, uploadUrl, onComplete, localError, onProgress, xhrSettings);
}else if(window.jQuery){
@@ -178,6 +178,7 @@ class Registry{
}catch(e){
Logger.error("Ignoring Error in extensionOnInit code:");
Logger.error(extensionOnInit.firstChild.nodeValue);
+ Logger.error(e.message);
}
}
var dialogOnOpen = XMLUtils.XPathSelectSingleNode(xmlNode, 'processing/dialogOnOpen');
@@ -808,7 +808,13 @@ Class.create("Modal", {
Event.stopObserving(window, "resize", this.currentResizeListener);
this.currentResizeListener = null;
}
- }
+ },
+ /**
+ * Encapsulate HideLightBox call
+ */
+ dismiss: function(){
+ hideLightBox();
+ }
});
var modal = new Modal();
Oops, something went wrong.
@@ -215,6 +215,10 @@ div.shadow_class
margin-right: 0;
width: auto;
}
+ .react-mui-context .mui-enhanced-switch .mui-enhanced-switch-input{
+ width: 100%;
+ height: 100%;
+ }
select {
border-radius: @dialog_fields_border_radius;
@@ -1654,6 +1654,10 @@ div.shadow_class {
margin-right: 0;
width: auto;
}
+.dialogBox .dialogContent .react-mui-context .mui-enhanced-switch .mui-enhanced-switch-input {
+ width: 100%;
+ height: 100%;
+}
.dialogBox .dialogContent select {
border-radius: 0;
background-color: #ffffff;
@@ -6,6 +6,7 @@
this._status = 'new';
this._type = type;
this._id = Math.random();
+ this._errorMessage = null;
}
getId(){
return this._id;
@@ -23,6 +24,13 @@
this._status = status;
this.notify('status');
}
+ getErrorMessage(){
+ return this._errorMessage || '';
+ }
+ onError(errorMessage){
+ this._errorMessage = errorMessage;
+ this.setStatus('error');
+ }
process(completeCallback){
this._doProcess(completeCallback);
}
@@ -109,9 +117,19 @@
}
return queryString;
}
+ _parseXHRResponse(){
+ if(!this.xhr) return;
+ if (this.xhr.responseXML){
+ var result = PydioApi.getClient().parseXmlMessage(this.xhr.responseXML);
+ if(!result) this.onError('Empty response');
+ }else if (this.xhr.responseText && this.xhr.responseText != 'OK') {
+ this.onError('Unexpected response: ' + this.xhr.responseText);
+ }
+ }
_doProcess(completeCallback){
let complete = function(){
this.setStatus('loaded');
+ this._parseXHRResponse();
completeCallback();
}.bind(this);
let error = function(){
@@ -125,11 +143,18 @@
}.bind(this);
this.setStatus('loading');
+ let maxUpload = parseFloat(UploaderConfigs.getInstance().getOption('UPLOAD_MAX_SIZE'));
+ if(this.getSize() > maxUpload){
+ this.onError('File is too big: contact your admin to raise the upload value, or use the desktop client.');
+ completeCallback();
+ return;
+ }
+
let queryString;
try{
queryString = this.buildQueryString();
}catch(e){
- this.setStatus('error');
+ this.onError(e.message);
completeCallback();
return;
}
@@ -304,6 +329,9 @@
getAutoStart(){
return UploaderConfigs.getInstance().getOptionAsBool("DEFAULT_AUTO_START", "upload_auto_send");
}
+ getAutoClose(){
+ return UploaderConfigs.getInstance().getOptionAsBool("DEFAULT_AUTO_CLOSE", "upload_auto_close");
+ }
pushFolder(folderItem){
this._folders.push(folderItem);
UploadTask.getInstance().setPending(this.getQueueSize());
@@ -364,6 +392,9 @@
}.bind(this));
}else{
UploadTask.getInstance().setIdle();
+ if(this.getAutoClose() && pydio.Controller.react_selector){
+ pydio.UI.modal.dismiss();
+ }
}
}
getNext(){
@@ -508,14 +539,13 @@
getOptionAsBool(name, userPref = '', defaultValue = undefined){
let o = this.getOption(name, userPref, defaultValue);
- if(o === 'true') return true;
- else return false;
+ return (o === true || o === 'true');
}
getOption(name, userPref = '', defaultValue = undefined){
if(userPref){
let test = this.getUserPreference('originalUploadForm_XHRUploader', userPref);
- if(test !== null) return test;
+ if(test !== undefined && test !== null) return test;
}
if(this._global.has(name)){
return this._global.get(name);
@@ -130,6 +130,9 @@
}else{
stopButton = <span className="stop-button mdi mdi-close" onClick={this.abortTransfer}/>;
}
+ if(statusMessage === 'error' && this.props.item.getErrorMessage()){
+ statusMessage = this.props.item.getErrorMessage();
+ }
if(global.pydio.MessageHash[messageIds[statusMessage]]){
statusMessage = global.pydio.MessageHash[messageIds[statusMessage]];
}
@@ -267,7 +270,7 @@
render: function(){
let maxUpload = this.state.configs.getOption('UPLOAD_MAX_SIZE');
- let maxUploadMessage = MessageHash[282] + ':' + PathUtils.roundFileSize(maxUpload, '');
+ let maxUploadMessage = MessageHash[282] + ': ' + PathUtils.roundFileSize(maxUpload, '');
let toggleStart = this.state.configs.getOptionAsBool('DEFAULT_AUTO_START', 'upload_auto_send');
let toggleClose = this.state.configs.getOptionAsBool('DEFAULT_AUTO_CLOSE', 'upload_auto_close');
let toggleShowProcessed = this.state.configs.getOptionAsBool('UPLOAD_SHOW_PROCESSED', 'upload_show_processed', false);

0 comments on commit d421e2f

Please sign in to comment.