From db47d2e420a65fc40161e6e9d6a59efb657fdb68 Mon Sep 17 00:00:00 2001 From: Max Ogden Date: Wed, 3 Aug 2011 12:01:31 -0400 Subject: [PATCH] notify user that large uploads might take a while --- attachments/pages/index.html | 1 + attachments/script/costco-csv-worker.js | 1 + attachments/script/costco.js | 7 +++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/attachments/pages/index.html b/attachments/pages/index.html index 016b61e4..ceaacda0 100755 --- a/attachments/pages/index.html +++ b/attachments/pages/index.html @@ -47,6 +47,7 @@
+ diff --git a/attachments/script/costco-csv-worker.js b/attachments/script/costco-csv-worker.js index b1ca2e83..e1b09207 100644 --- a/attachments/script/costco-csv-worker.js +++ b/attachments/script/costco-csv-worker.js @@ -5,6 +5,7 @@ onmessage = function(message) { var docs = []; _.each(rows, function(row) { if (row.length == 0) return; + postMessage(JSON.stringify({size: rows.length})); var doc = {}; _.each(row.split(','), function(field, index) { doc['field' + index] = field }); docs.push(doc); diff --git a/attachments/script/costco.js b/attachments/script/costco.js index 467bb9b8..2cf7e61d 100755 --- a/attachments/script/costco.js +++ b/attachments/script/costco.js @@ -116,12 +116,15 @@ var costco = function() { }; var worker = new Worker('script/costco-csv-worker.js'); worker.onmessage = function(message) { - if(JSON.parse(message.data).done) { + message = JSON.parse(message.data); + if(message.done) { util.hide('dialog'); util.notify("Data uploaded successfully!"); recline.initializeTable(app.offset); + } else if (message.size) { + util.notify("Processing " + message.size + " rows. This could take a while...", {persist: true, loader: true}); } else { - util.notify(message.data); + util.notify(JSON.stringify(message)); } }; worker.postMessage(payload);