@@ -268,8 +268,9 @@ return;} | |||||
if(r.server_messages)msgprint(r.server_messages) | 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.exc){console.log(r.exc);};if(r['403']){wn.container.change_to('403');} | ||||
if(r.docs){LocalDB.sync(r.docs);}} | 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) | 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;} | 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]);}} | 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 | * lib/js/core.js | ||||
*/ | */ | ||||
if(!console){var console={log:function(txt){}}} | 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());}); | |||||
window._version_number="7ab7a080278624be7e07a858feb00d5dace34c9757ef9c5d353d3e40";$(document).ready(function(){wn.assets.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); |
@@ -81,7 +81,7 @@ wn.request.cleanup = function(opts, r) { | |||||
wn.request.call = function(opts) { | wn.request.call = function(opts) { | ||||
wn.request.prepare(opts); | wn.request.prepare(opts); | ||||
$.ajax({ | |||||
var args = { | |||||
url: opts.url || wn.request.url, | url: opts.url || wn.request.url, | ||||
data: opts.args, | data: opts.args, | ||||
type: opts.type || 'POST', | type: opts.type || 'POST', | ||||
@@ -95,7 +95,28 @@ wn.request.call = function(opts) { | |||||
show_alert('Unable to complete request: ' + textStatus) | show_alert('Unable to complete request: ' + textStatus) | ||||
if(opts.error)opts.error(xhr) | 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) | // generic server call (call page, object) | ||||
@@ -24,7 +24,7 @@ wn.provide("wn.report_dump"); | |||||
$.extend(wn.report_dump, { | $.extend(wn.report_dump, { | ||||
data: {}, | data: {}, | ||||
with_data: function(doctypes, callback) { | |||||
with_data: function(doctypes, callback, progress_bar) { | |||||
var missing = []; | var missing = []; | ||||
$.each(doctypes, function(i, v) { | $.each(doctypes, function(i, v) { | ||||
if(!wn.report_dump.data[v]) missing.push(v); | if(!wn.report_dump.data[v]) missing.push(v); | ||||
@@ -48,7 +48,8 @@ $.extend(wn.report_dump, { | |||||
wn.report_dump.data[doctype] = data; | wn.report_dump.data[doctype] = data; | ||||
}); | }); | ||||
callback(); | callback(); | ||||
} | |||||
}, | |||||
progress_bar: progress_bar | |||||
}) | }) | ||||
} else { | } else { | ||||
callback(); | callback(); | ||||
@@ -61,8 +62,9 @@ wn.views.GridReport = Class.extend({ | |||||
init: function(opts) { | init: function(opts) { | ||||
this.filter_inputs = {}; | this.filter_inputs = {}; | ||||
$.extend(this, opts); | $.extend(this, opts); | ||||
this.wrapper = $("<div style='height: 500px; border: 1px solid #aaa;'>").appendTo(this.parent); | |||||
this.id = wn.dom.set_unique_id(this.wrapper.get(0)); | |||||
this.wrapper = $('<div>').appendTo(this.parent); | |||||
if(this.filters) { | if(this.filters) { | ||||
this.make_filters(); | this.make_filters(); | ||||
} | } | ||||
@@ -88,13 +90,13 @@ wn.views.GridReport = Class.extend({ | |||||
me.setup(); | me.setup(); | ||||
me.refresh(); | me.refresh(); | ||||
}); | |||||
}, this.wrapper.find(".progress .bar")); | |||||
}, | }, | ||||
make_waiting: function() { | make_waiting: function() { | ||||
$('<div class="well" style="width: 63%; margin: 30px auto;">\ | |||||
this.waiting = $('<div class="well" style="width: 63%; margin: 30px auto;">\ | |||||
<p style="text-align: center;">Loading Report...</p>\ | <p style="text-align: center;">Loading Report...</p>\ | ||||
<div class="progress progress-striped active">\ | <div class="progress progress-striped active">\ | ||||
<div class="bar" style="width: 100%"></div></div>') | |||||
<div class="bar" style="width: 10%"></div></div>') | |||||
.appendTo(this.wrapper); | .appendTo(this.wrapper); | ||||
}, | }, | ||||
load_filters: function(callback) { | load_filters: function(callback) { | ||||
@@ -134,6 +136,11 @@ wn.views.GridReport = Class.extend({ | |||||
}, | }, | ||||
render: function() { | render: function() { | ||||
// new slick grid | // new slick grid | ||||
this.waiting.toggle(false); | |||||
this.grid_wrapper = $("<div style='height: 500px; border: 1px solid #aaa;'>") | |||||
.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); | this.grid = new Slick.Grid("#"+this.id, this.dataView, this.columns, this.options); | ||||
// bind events | // bind events | ||||