Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Uploader : error / response handling, autoClose, fix clicks issues in…
Browse files Browse the repository at this point in the history
… options pane (checkbox styling)
  • Loading branch information
cdujeu committed Sep 20, 2016
1 parent 8bd87da commit d421e2f
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 8 deletions.
1 change: 1 addition & 0 deletions core/src/plugins/access.fs/fsActions.xml
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion core/src/plugins/gui.ajax/res/js/es6/http/PydioApi.es6
Expand Up @@ -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){

Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/gui.ajax/res/js/es6/model/Registry.es6
Expand Up @@ -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');
Expand Down
8 changes: 7 additions & 1 deletion core/src/plugins/gui.ajax/res/js/ui/prototype/class.Modal.js
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/themes/orbit/css/allz.css

Large diffs are not rendered by default.

Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions core/src/plugins/gui.ajax/res/themes/orbit/css/pydio.css
Expand Up @@ -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;
Expand Down
38 changes: 34 additions & 4 deletions core/src/plugins/uploader.html/js/react/UploaderModel.js
Expand Up @@ -6,6 +6,7 @@
this._status = 'new';
this._type = type;
this._id = Math.random();
this._errorMessage = null;
}
getId(){
return this._id;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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(){
Expand All @@ -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;
}
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -364,6 +392,9 @@
}.bind(this));
}else{
UploadTask.getInstance().setIdle();
if(this.getAutoClose() && pydio.Controller.react_selector){
pydio.UI.modal.dismiss();
}
}
}
getNext(){
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion core/src/plugins/uploader.html/js/react/UploaderView.js
Expand Up @@ -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]];
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d421e2f

Please sign in to comment.