mirror of https://github.com/apache/cloudstack.git
Init iframe
This commit is contained in:
parent
b35fe9ad66
commit
cc4606f087
|
|
@ -110,41 +110,11 @@
|
|||
title: 'label.action.register.template',
|
||||
docID: 'helpNetworkOfferingName',
|
||||
preFilter: cloudStack.preFilter.createTemplate,
|
||||
|
||||
// Handles POST to upload server
|
||||
// -- standard action handler won't be called until success() callback
|
||||
fileUpload: {
|
||||
action: function(args) {
|
||||
var fileData = args.fileData;
|
||||
var ajax = $.ajax({
|
||||
xhr: function() {
|
||||
var xhr = jQuery.ajaxSettings.xhr();
|
||||
|
||||
if (xhr instanceof window.XMLHttpRequest) {
|
||||
xhr.upload.addEventListener('progress', function(e) {
|
||||
console.log('progress -> ', e);
|
||||
});
|
||||
}
|
||||
|
||||
return xhr;
|
||||
},
|
||||
url: '/test-upload.php',
|
||||
type: 'POST',
|
||||
data: fileData,
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
processData: false, // Don't process the files
|
||||
contentType: false, // jQuery will tell the server this is a query string request
|
||||
success: function(uploadData, textStatus, jqXHR) {
|
||||
// Files uploaded successfully; proceed to handle rest of action
|
||||
args.response.success({ data: uploadData });
|
||||
},
|
||||
error: function(error) {
|
||||
args.response.error('Error uploading files');
|
||||
}
|
||||
getURL: function(args) {
|
||||
args.response.success({
|
||||
data: 'http://10.223.183.3/test-upload.json'
|
||||
});
|
||||
|
||||
debugger;
|
||||
}
|
||||
},
|
||||
fields: {
|
||||
|
|
|
|||
|
|
@ -684,32 +684,20 @@
|
|||
}
|
||||
|
||||
var uploadFiles = function() {
|
||||
var formData = new FormData();
|
||||
|
||||
$form.prepend($('<div>').addClass('loading-overlay').text('Uploading files...'));
|
||||
$.each($form.data('files'), function(key, value) {
|
||||
formData.append(key, value);
|
||||
});
|
||||
args.form.fileUpload.action({
|
||||
args.form.fileUpload.getURL({
|
||||
formData: data,
|
||||
context: args.context,
|
||||
fileData: formData,
|
||||
response: {
|
||||
success: function(successArgs) {
|
||||
$form.find('.loading-overlay').remove();
|
||||
$form.data('files', null);
|
||||
var $uploadFrame = $('<iframe>');
|
||||
|
||||
args.after({
|
||||
data: $.extend(data, { uploadData: successArgs.data }),
|
||||
ref: args.ref, // For backwards compatibility; use context
|
||||
context: args.context,
|
||||
$form: $form
|
||||
});
|
||||
$uploadFrame.appendTo('html body');
|
||||
|
||||
$('div.overlay').remove();
|
||||
$('.tooltip-box').remove();
|
||||
$formContainer.remove();
|
||||
$(this).dialog('destroy');
|
||||
$('.hovered-elem').hide();
|
||||
|
||||
// debug
|
||||
$uploadFrame.css({background:'white',width:320,height:240,position:'absolute',left:0,top:0,'z-index':12000}).show();
|
||||
//
|
||||
},
|
||||
error: function(msg) {
|
||||
cloudStack.dialog.error({ message: msg });
|
||||
|
|
|
|||
Loading…
Reference in New Issue