diff --git a/src/sunstone/public/js/plugins/files-tab.js b/src/sunstone/public/js/plugins/files-tab.js index 2c4f9b04e5..d9eeb433dc 100644 --- a/src/sunstone/public/js/plugins/files-tab.js +++ b/src/sunstone/public/js/plugins/files-tab.js @@ -93,6 +93,7 @@ var create_file_tmpl ='
\
\
\
\ + \
\
\ \ @@ -623,6 +624,68 @@ function setupCreateFileDialog(){ var file_obj; + var uploader = new Resumable({ + target: '/upload_chunk', + chunkSize: 10*1024*1024, + maxFiles: 1, + testChunks: false, + query: { + csrftoken: csrftoken + } + }); + + uploader.assignBrowse($('#files_file-uploader-input',dialog)[0]); + + var fileName = ''; + var file_input = false; + + uploader.on('fileAdded', function(file){ + fileName = file.fileName; + file_input = fileName; + }); + + uploader.on('uploadStart', function() { + $('#files_upload_progress_bars').append('
\ +
\ + '+tr("Uploading...")+'\ +
\ +
\ +
\ + \ +
\ +
'+fileName+'
\ +
\ +
'); + }); + + uploader.on('progress', function() { + $('span.meter', $('div[id="files-'+fileName+'-progressBar"]')).css('width', uploader.progress()*100.0+'%') + }); + + uploader.on('fileSuccess', function(file) { + $('div[id="files-'+fileName+'-info"]').text(tr('Registering in OpenNebula')); + $.ajax({ + url: '/upload', + type: "POST", + data: { + csrftoken: csrftoken, + img : JSON.stringify(img_obj), + file: fileName, + tempfile: file.uniqueIdentifier + }, + success: function(){ + notifyMessage("Image uploaded correctly"); + $('div[id="file-'+fileName+'-progressBar"]').remove(); + Sunstone.runAction("Image.refresh"); + }, + error: function(response){ + //onError({}, JSON.parse(response) ); + notifyMessage(response); + $('div[id="file-'+fileName+'-progressBar"]').remove(); + } + }); + }); +/* // Upload is handled by FileUploader vendor plugin var uploader = new qq.FileUploaderBasic({ button: $('#files_file-uploader',$create_file_dialog)[0], @@ -687,11 +750,10 @@ function setupCreateFileDialog(){ onCancel: function(id, fileName){ } }); +*/ + + - var file_input = false; - uploader._button._options.onChange = function(input) { - file_input = input; return false; - }; $('#create_file_form_easy',dialog).submit(function(){ var upload = false; diff --git a/src/sunstone/views/index.erb b/src/sunstone/views/index.erb index 8d4cb966f3..4eabb2db3f 100644 --- a/src/sunstone/views/index.erb +++ b/src/sunstone/views/index.erb @@ -34,7 +34,6 @@ -