import at a half

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

@ -67,6 +67,7 @@
@include opacity(0.5);
&:hover, &:active, &:focus {
background:#94BE42; // IE
color:white;
@include background(linear-gradient(#94BE42,#7FA938));
cursor:default;
}

@ -139,9 +139,6 @@
cursor: pointer;
}
input[type="text"] {
position:absolute;
top:50%;
@ -156,42 +153,6 @@
outline:none;
z-index:0;
}
// div.uploader {
// .qq-upload-button {
// margin:0 0 1px 3px;
// color:#397DBA;
// text-decoration:underline;
// font-style:italic;
// font-size:15px!important;
// cursor:pointer;
// &:hover {
// color:#333333;
// }
// }
// .qq-upload-drop-area {
// position:absolute;
// top:0;
// left:0;
// right:0;
// bottom:0;
// display:block;
// padding:14px 0 0 0;
// background:rgba(0,0,0,0.5);
// text-align:center;
// font-weight:bold;
// font-size: 16px;
// color:white;
// z-index:100;
// @include border-radius(4px);
// }
// .qq-upload-list {
// display:none;
// }
// }
}
div.info {

@ -40,7 +40,7 @@ class Api::Json::ImportsController < Api::ApplicationController
case
when params[:filename].present? && request.body.present?
filename = "waduswadus"
filename = "addresses.csv"#params[:filename]
filedata = request.body.read.force_encoding('utf-8')
when params[:file].present?
filename = params[:file].original_filename

@ -18,14 +18,15 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
"click ul > li > a.radiobutton" : "_changeOption",
'click div.url p' : "_activateTextInput",
'keyup input[type="text"]' : "_onInputChange",
'keypress input[type="text"]' : "_onKeyPress"
'submit form' : "_onSubmitForm"
},
initialize: function() {
// We need "this" in these functions
_.bindAll(this, "_activateTextInput", "_createTable", "_onUploadError", "_onUploadSubmit", "_onUploadProgress", "_onUploadCancel", "_onUploadAdd", "_onUploadComplete", "_changeOption", "_checkOptions");
_.bindAll(this, "_activateTextInput", "_createTable", "_onUploadError", "_onUploadSubmit", "_onUploadProgress",
"_onUploadDragOver", "_onUploadCancel", "_onUploadAdd", "_onUploadComplete", "_changeOption", "_checkOptions");
// Option selected by default
this.option = 0;
@ -90,7 +91,9 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
autoUpload: true,
add: this._onUploadAdd,
acceptFileTypes: this.options.acceptFileTypes,
//start: this._onUploadSubmit,
submit: this._onUploadSubmit,
drop: this._onDrop,
dragover: this._onUploadDragOver,
progress: this._onUploadProgress,
stop: this._onUploadCancel,
done: this._onUploadComplete,
@ -132,7 +135,10 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
this._checkOptions();
},
_onKeyPress: function(ev) {
_onSubmitForm: function(ev) {
ev.preventDefault();
ev.stopPropagation();
var code = (ev.keyCode ? ev.keyCode : ev.which);
if(code == 13) { //Enter keycode
this.$el.find("a.ok").click();
@ -188,34 +194,39 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
/* Uploader functions */
_onUploadSubmit: function(id,fileName) {
console.log("submit?");
_onUploadSubmit: function(ev,data) {
console.log("uploading");
this._changeState("uploading");
},
_onUploadProgress: function(id, fileName, loaded, total) {
_onUploadProgress: function(ev,data) {
console.log("progress?");
var loaded = data.loaded
, total = data.total;
var percentage = (loaded / total) * 100;
this.$content
.find("div.progress span")
.width(percentage + "%");
},
_onUploadCancel: function(id, fileName) {
_onUploadCancel: function(ev,data) {
console.log("cancel?");
this._changeState("reset");
// console.log(id,fileName);
// if (id.result) {
// this._changeState("reset");
// }
//this._changeState("reset");
},
_onUploadComplete: function(id, fileName, responseJSON) {
console.log("importing?");
_onUploadComplete: function(ev,data) {
this._changeState("importing");
this._importTable(fileName,responseJSON.file_uri)
//this._importTable(fileName,responseJSON.file_uri)
},
_onUploadError: function(ev,fileupload) {
console.log("error?");
var filename = fileupload.files[0].name
, error_type = fileupload.files[0].error
_onUploadError: function(ev,data) {
var filename = data.files[0].name
, error_type = data.files[0].error
, msg = this.options.error_messages[error_type].replace("{filename}", filename);
this.$content
@ -230,6 +241,29 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
},
_onUploadDragOver: function() {
console.log("TODO -> SHOW THE CLASS!");
this.$upload.addClass("drop");
},
// Import table from a url
_importTable: function(fileName,file_uri) {
@ -330,14 +364,15 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
_changeState: function(mode) {
console.log("changeState" + ":" + mode);
/* Change scenario depending on the app mode */
switch (mode) {
case "reset":
// Remove additional and error info
// this.$importation
// .find("div.info")
// .removeClass("active");
this.$importation
.find("div.info")
.removeClass("active");
// Change title
this.$importation
@ -465,11 +500,14 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
this.$loader.find("p").text("Uploading your table...");
this.$loader
.animate({
top: pos.top + "px"
},500)
.css({top: '40px', opacity: '0'})
.removeClass("creating")
.addClass("uploading")
.animate({
opacity: 1,
top: pos.top
},1000)
// Show the loader
this._showLoader();
@ -628,6 +666,8 @@ cdb.admin.CreateTableDialog = cdb.ui.common.Dialog.extend({
* Reclean some custom bindings
*/
_reClean: function() {
this.$upload.fileupload("destroy")
// Cancel upload
// TODO //
this.$upload.fileupload("destroy");
}
})

@ -62,15 +62,10 @@
// Set default to active
this.active = true;
/******************/
//this._showDialog()
/*******************/
// Any change, render this view
this.model.bind('change', this.render, this);
// Bind big mamufas upload
// Big mamufas upload
var self = this;
this.mamufasDrag = new MamufasDrag({
el: this.$("div.drag_mamufas")
@ -79,9 +74,6 @@
})
},
_tableChange: function() {
this.model.fetch();
},
render: function() {
var attrs = this.model.attributes;
@ -98,23 +90,41 @@
},
/**
* If there is any table change
*/
_tableChange: function() {
this.model.fetch();
},
/**
* Activate create button
*/
_activateCreate: function() {
this.active = true;
this.$el.find("a").removeClass("disabled");
},
/**
* Disable create button
*/
_disableCreate: function() {
this.active = false;
this.$el.find("a").addClass("disabled");
},
/*
* Show the create table dialog
/**
* Show import or create dialog
*/
_showDialog: function(ev,files) {
if (ev) ev.preventDefault();
// If view is not active, don't show the dialog
if (!this.active) return false;
this.mamufasDrag.disable();
// Create a new dialog
@ -134,6 +144,10 @@
});
},
/**
* Start background import
*/
_importStarted: function(imp) {
//TODO: create dialog to show the import progress
var self = this;

Loading…
Cancel
Save