diff --git a/js/core.min.js b/js/core.min.js index 9e9b02af09..650350c4bb 100644 --- a/js/core.min.js +++ b/js/core.min.js @@ -268,8 +268,9 @@ return;} if(r.server_messages)msgprint(r.server_messages) if(r.exc){console.log(r.exc);};if(r['403']){wn.container.change_to('403');} if(r.docs){LocalDB.sync(r.docs);}} -wn.request.call=function(opts){wn.request.prepare(opts);$.ajax({url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus) -if(opts.error)opts.error(xhr)}})} +wn.request.call=function(opts){wn.request.prepare(opts);var args={url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus) +if(opts.error)opts.error(xhr)}};if(opts.progress_bar){var interval=null;$.extend(args,{xhr:function(){var xhr=jquery.ajaxSettings.xhr();interval=setInterval(function(){if(xhr.readyState>2){var total=parseInt(xhr.getResponseHeader('Content-length'));var completed=parseInt(xhr.responseText.length);opts.progress_bar.css('width',(100.0/total*completed).toFixed(2)+'%');}},50);},complete:function(){clearInterval(interval);}})} +$.ajax(args)} wn.call=function(opts){var args=$.extend({},opts.args) if(opts.module&&opts.page){args.cmd=opts.module+'.page.'+opts.page+'.'+opts.page+'.'+opts.method}else if(opts.method){args.cmd=opts.method;} for(key in args){if(args[key]&&typeof args[key]!='string'){args[key]=JSON.stringify(args[key]);}} @@ -278,4 +279,4 @@ wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,f * lib/js/core.js */ if(!console){var console={log:function(txt){}}} -window._version_number="d58703b2c2e2a5dd1294cd924eb13c57161cf583571b48248ed44bbc";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); \ No newline at end of file +window._version_number="7ab7a080278624be7e07a858feb00d5dace34c9757ef9c5d353d3e40";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); \ No newline at end of file diff --git a/js/wn/request.js b/js/wn/request.js index a4d27c6691..12d35b00c6 100644 --- a/js/wn/request.js +++ b/js/wn/request.js @@ -81,7 +81,7 @@ wn.request.cleanup = function(opts, r) { wn.request.call = function(opts) { wn.request.prepare(opts); - $.ajax({ + var args = { url: opts.url || wn.request.url, data: opts.args, type: opts.type || 'POST', @@ -95,7 +95,28 @@ wn.request.call = function(opts) { show_alert('Unable to complete request: ' + textStatus) if(opts.error)opts.error(xhr) } - }) + }; + + if(opts.progress_bar) { + var interval = null; + $.extend(args, { + xhr: function() { + var xhr = jquery.ajaxSettings.xhr(); + interval = setInterval(function() { + if(xhr.readyState > 2) { + var total = parseInt(xhr.getResponseHeader('Content-length')); + var completed = parseInt(xhr.responseText.length); + opts.progress_bar.css('width', (100.0 / total * completed).toFixed(2) + '%'); + } + }, 50); + }, + complete: function() { + clearInterval(interval); + } + }) + } + + $.ajax(args) } // generic server call (call page, object) diff --git a/js/wn/views/grid_report.js b/js/wn/views/grid_report.js index 95ca4a51ca..4b91c23aa1 100644 --- a/js/wn/views/grid_report.js +++ b/js/wn/views/grid_report.js @@ -24,7 +24,7 @@ wn.provide("wn.report_dump"); $.extend(wn.report_dump, { data: {}, - with_data: function(doctypes, callback) { + with_data: function(doctypes, callback, progress_bar) { var missing = []; $.each(doctypes, function(i, v) { if(!wn.report_dump.data[v]) missing.push(v); @@ -48,7 +48,8 @@ $.extend(wn.report_dump, { wn.report_dump.data[doctype] = data; }); callback(); - } + }, + progress_bar: progress_bar }) } else { callback(); @@ -61,8 +62,9 @@ wn.views.GridReport = Class.extend({ init: function(opts) { this.filter_inputs = {}; $.extend(this, opts); - this.wrapper = $("
").appendTo(this.parent); - this.id = wn.dom.set_unique_id(this.wrapper.get(0)); + + this.wrapper = $('
').appendTo(this.parent); + if(this.filters) { this.make_filters(); } @@ -88,13 +90,13 @@ wn.views.GridReport = Class.extend({ me.setup(); me.refresh(); - }); + }, this.wrapper.find(".progress .bar")); }, make_waiting: function() { - $('
\ + this.waiting = $('
\

Loading Report...

\
\ -
') +
') .appendTo(this.wrapper); }, load_filters: function(callback) { @@ -134,6 +136,11 @@ wn.views.GridReport = Class.extend({ }, render: function() { // new slick grid + this.waiting.toggle(false); + this.grid_wrapper = $("
") + .appendTo(this.wrapper); + this.id = wn.dom.set_unique_id(this.grid_wrapper.get(0)); + this.grid = new Slick.Grid("#"+this.id, this.dataView, this.columns, this.options); // bind events