making notifications when bulk uploading csvs make a little more sense

This commit is contained in:
Max Ogden
2011-08-01 22:04:19 -04:00
parent f72b9c31db
commit 9b76faf60f
4 changed files with 10 additions and 12 deletions

View File

@@ -13,12 +13,6 @@ onmessage = function(message) {
req.onreadystatechange = function() {
if (req.readyState == 4) postMessage(JSON.stringify({done: true}))
};
req.onprogress = function(e) {
if (e.lengthComputable) {
var percentComplete = (e.loaded / e.total) * 100;
postMessage(JSON.stringify({percent: percentComplete}));
}
}
req.open('POST', message.data.url);
req.setRequestHeader('Content-Type', 'application/json');
req.send(JSON.stringify({docs: docs}));

View File

@@ -105,13 +105,11 @@ var costco = function() {
}
function uploadCSV() {
util.notify('Upload started.');
var file = $('#file')[0].files[0];
if (file) {
var reader = new FileReader();
reader.readAsText(file);
reader.onload = function(event) {
util.notify('File loaded.');
var payload = {
url: window.location.href + "/api/_bulk_docs", // todo more robust url composition
data: event.target.result
@@ -119,9 +117,9 @@ var costco = function() {
var worker = new Worker('script/costco-csv-worker.js');
worker.onmessage = function(message) {
if(JSON.parse(message.data).done) {
util.hide('dialog');
util.notify("Data uploaded successfully!");
recline.initializeTable(app.offset);
util.hide('dialog');
} else {
util.notify(message.data);
}

View File

@@ -186,6 +186,13 @@ app.after = {
);
})
},
uploadImport: function() {
$('.dialog-content .okButton').click(function(e) {
util.hide('dialog');
util.notify("Saving documents...", {persist: true, loader: true});
costco.uploadCSV();
})
},
jsonTree: function() {
util.renderTree(app.apiDocs);
$('.dialog-content .okButton').click(function(e) {