mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
Co-authored-by: Jorge Lobo <jlobo@opennebula.systems>
This commit is contained in:
parent
fb67699091
commit
611e5114bc
@ -201,8 +201,12 @@ define(function(require) {
|
||||
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
$.each(this.wizardTabs, function(index, wizardTab) {
|
||||
wizardTab.setup($("#" + wizardTab.wizardTabId, context));
|
||||
if(wizardTab.title === "Image"){
|
||||
that.uploader = wizardTab.uploader;
|
||||
}
|
||||
});
|
||||
Foundation.reflow(context, "tabs");
|
||||
Foundation.reflow(context, "tooltip");
|
||||
@ -307,39 +311,40 @@ define(function(require) {
|
||||
//this is an image upload we trigger FileUploader
|
||||
//to start the upload
|
||||
if (upload) {
|
||||
if (that.uploader.files.length == 0) {
|
||||
Sunstone.hideFormPanelLoading(that.tabId);
|
||||
Notifier.notifyError(Locale.tr("Please select a file to upload"));
|
||||
return false;
|
||||
}
|
||||
|
||||
Sunstone.resetFormPanel(that.tabId, that.formPanelId);
|
||||
Sunstone.hideFormPanel(that.tabId);
|
||||
|
||||
that.uploader.on("fileSuccess", function(file) {
|
||||
$("div[id=\"" + file.fileName + "-info\"]").text(Locale.tr("Registering in OpenNebula"));
|
||||
$.ajax({
|
||||
url: "upload",
|
||||
type: "POST",
|
||||
data: {
|
||||
csrftoken: csrftoken,
|
||||
img : JSON.stringify(img_obj),
|
||||
file: file.fileName,
|
||||
tempfile: file.uniqueIdentifier
|
||||
},
|
||||
success: function() {
|
||||
Notifier.notifyMessage("Image uploaded correctly");
|
||||
$("div[id=\"" + file.fileName + "progressBar\"]").remove();
|
||||
Sunstone.runAction(that.resource+".refresh");
|
||||
},
|
||||
error: function(response) {
|
||||
Notifier.onError({}, OpenNebulaError(response));
|
||||
$("div[id=\"" + file.fileName + "progressBar\"]").remove();
|
||||
}
|
||||
if(that.uploader){
|
||||
if (that.uploader.files && that.uploader.files.length == 0) {
|
||||
Sunstone.hideFormPanelLoading(that.tabId);
|
||||
Notifier.notifyError(Locale.tr("Please select a file to upload"));
|
||||
return false;
|
||||
}
|
||||
Sunstone.resetFormPanel(that.tabId, that.formPanelId);
|
||||
Sunstone.hideFormPanel(that.tabId);
|
||||
that.uploader.on("fileSuccess", function(file) {
|
||||
$("div[id=\"" + file.fileName + "-info\"]").text(Locale.tr("Registering in OpenNebula"));
|
||||
$.ajax({
|
||||
url: "upload",
|
||||
type: "POST",
|
||||
data: {
|
||||
csrftoken: csrftoken,
|
||||
img : JSON.stringify(img_obj),
|
||||
file: file.fileName,
|
||||
tempfile: file.uniqueIdentifier
|
||||
},
|
||||
success: function() {
|
||||
Notifier.notifyMessage("Image uploaded correctly");
|
||||
$("div[id=\"" + file.fileName + "progressBar\"]").remove();
|
||||
Sunstone.runAction(that.resource+".refresh");
|
||||
},
|
||||
error: function(response) {
|
||||
Notifier.onError({}, OpenNebulaError(response));
|
||||
$("div[id=\"" + file.fileName + "progressBar\"]").remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
that.uploader.upload();
|
||||
that.uploader.upload();
|
||||
}else{
|
||||
Notifier.notifyError(Locale.tr("you don't have a valid uploader"));
|
||||
}
|
||||
} else {
|
||||
Sunstone.runAction(that.resource+".create", img_obj);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user