import workin

2.0
Javier Alvarez 12 years ago committed by David Arango
parent cb5d5f88f6
commit 1f886bb0b6

@ -10,6 +10,7 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
3: All done, you can minimize the window
*/
events: {
'click .ok' : 'ok',
'click .cancel' : '_cancel',
@ -25,8 +26,8 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
initialize: function() {
// We need "this" in these functions
_.bindAll(this, "_activateTextInput", "_createTable", "_onUploadError", "_onUploadSubmit", "_onUploadProgress",
"_onUploadDragOver", "_onUploadCancel", "_onUploadAdd", "_onUploadComplete", "_changeOption", "_checkOptions");
_.bindAll(this, "_activateTextInput", "_createTable", "_onUploadError", "_onUploadProgress", "_onUploadStart",
"_onUploadDragOver", "_onUploadStop", "_onUploadAdd", "_onUploadComplete", "_changeOption", "_checkOptions");
// Option selected by default
this.option = 0;
@ -91,16 +92,18 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
autoUpload: true,
add: this._onUploadAdd,
acceptFileTypes: this.options.acceptFileTypes,
submit: this._onUploadSubmit,
drop: this._onDrop,
dragover: this._onUploadDragOver,
progress: this._onUploadProgress,
stop: this._onUploadCancel,
start: this._onUploadStart,
stop: this._onUploadStop,
done: this._onUploadComplete,
fail: this._onUploadError
});
// Have you dropped a file before?
// Have you dropped a file in the big mamufas?
if (this.options.files) {
$upload.fileupload('send', {files: this.options.files});
}
@ -193,14 +196,16 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
/* Uploader functions */
_onUploadSubmit: function(ev,data) {
console.log("uploading");
_onUploadStart: function(ev,data) {
console.log("uploading!");
this._changeState("uploading");
},
_onUploadProgress: function(ev,data) {
console.log("progress?");
console.log("progress!", data);
var loaded = data.loaded
, total = data.total;
@ -210,8 +215,8 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
.width(percentage + "%");
},
_onUploadCancel: function(ev,data) {
console.log("cancel?");
_onUploadStop: function(ev,data) {
console.log("stop!");
// console.log(id,fileName);
// if (id.result) {
// this._changeState("reset");
@ -220,11 +225,16 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
},
_onUploadComplete: function(ev,data) {
console.log("done!");
this._changeState("importing");
//this._importTable(fileName,responseJSON.file_uri)
this._importTable(data.result.item_queue_id)
},
_onUploadError: function(ev,data) {
console.log("error!", data);
this._changeState("reset");
var filename = data.files[0].name
, error_type = data.files[0].error
, msg = this.options.error_messages[error_type].replace("{filename}", filename);
@ -265,16 +275,11 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
// Import table from a url
_importTable: function(fileName,file_uri) {
var opts = {
table_name: fileName,
file_uri: file_uri
};
_importTable: function(item_queue_id) {
var self = this;
var imp = new cdb.admin.Import(opts)
var imp = new cdb.admin.Import({item_queue_id: item_queue_id})
.bind("importComplete", function(){
console.log("final!!");
},this)
@ -283,8 +288,8 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
self._showError(e.attributes.error_code,e.attributes.logger,'what about');
},this);
//this.trigger('importStarted', imp);
imp.save();
this.trigger('importStarted', imp);
//imp.save();
//this.hide();
},
@ -396,11 +401,11 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
this.$importation.find("div.foot a.ok").addClass("disabled green").removeClass("grey");
// Show options list
this.$list.animate({
this.$list.stop().animate({
marginTop: "0px",
height: "auto",
height: "100%",
opacity: 1
}, 500);
}, 1000);
// Customize the loader
var pos = this.$list.position();
@ -445,7 +450,7 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
marginTop: "-30px",
height: 0,
opacity: 0
}, 500);
}, {duration: 1500, queue: true});
// Customize the loader
this.$loader.find("span").width("100%");
@ -464,11 +469,6 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
break;
case "uploading":
// Remove additional and error info
this.$importation
.find("div.info")
.removeClass("active");
// Change title
this.$importation
.find("h3")
@ -488,10 +488,10 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
// Hide options list
this.$list.animate({
marginTop: "-30px",
marginTop: "-10px",
height: 0,
opacity: 0
}, 500);
}, {duration: 1500, queue: true});
// Customize the loader
var pos = this.$list.position();
@ -508,16 +508,11 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
top: pos.top
},1000)
// Show the loader
this._showLoader();
break;
case "importing":
// Remove additional and error info
this.$importation
.find("div.info")
.removeClass("active");
// Change title
this.$importation
@ -549,10 +544,10 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
// Hide options list
this.$list.animate({
marginTop: "-30px",
marginTop: "-10px",
height: 0,
opacity: 0
}, 500);
}, {duration: 1500, queue: true});
// Customize the loader
this.$loader.find("span").width("100%");
@ -563,7 +558,7 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
.animate({
left: "40px",
top: pos.top + "px"
},500)
},1000)
.addClass("creating");
// Show the loader

@ -23,9 +23,10 @@
_onDrop: function(ev,files_obj) {
if (files_obj.files.length > 0) {
this.$upload.fadeOut('fast');
this.trigger("drop",ev,files_obj);
}
this.$upload.fadeOut('fast');
},
_onDragOver: function(ev) {

Loading…
Cancel
Save