[IMP] graphs code

bzr revid: fp@tinyerp.com-20120507095147-qxelcvv2m12t50l4
This commit is contained in:
Fabien Pinckaers 2012-05-07 11:51:47 +02:00
parent 76b1514392
commit 63b583aead
2 changed files with 28 additions and 27 deletions

View File

@ -4,28 +4,28 @@ try:
except ImportError: except ImportError:
import web.common.http as openerpweb import web.common.http as openerpweb
WIDGET_CONTENT_PATTERN = """<!DOCTYPE html> #WIDGET_CONTENT_PATTERN = """<!DOCTYPE html>
<html> #<html>
<head><title>[[Widget %(id)d]]</title></head> # <head><title>[[Widget %(id)d]]</title></head>
<body> # <body>
%(content)s # %(content)s
<script type="text/javascript"> # <script type="text/javascript">
var load = window.onload; # var load = window.onload;
window.onload = function () { # window.onload = function () {
if (load) { # if (load) {
load(); # load();
} # }
window.frameElement.style.height = document.height + 'px'; # window.frameElement.style.height = document.height + 'px';
} # }
</script> # </script>
</body> # </body>
</html> #</html>
""" #"""
class Widgets(openerpweb.Controller): #class Widgets(openerpweb.Controller):
_cp_path = '/web_dashboard/widgets' # _cp_path = '/web_dashboard/widgets'
#
@openerpweb.httprequest # @openerpweb.httprequest
def content(self, request, widget_id): # def content(self, request, widget_id):
return WIDGET_CONTENT_PATTERN % request.session.model('res.widget').read( # return WIDGET_CONTENT_PATTERN % request.session.model('res.widget').read(
[int(widget_id)], ['content'], request.session.eval_context(request.context) # [int(widget_id)], ['content'], request.session.eval_context(request.context)
)[0] # )[0]

View File

@ -262,7 +262,7 @@ instance.web_graph.GraphView = instance.web.View.extend({
schedule_chart: function(results) { schedule_chart: function(results) {
self.graph_render(...) self.graph_render({})
}, },
// render the graph using the domain, context and group_by // render the graph using the domain, context and group_by
@ -271,7 +271,8 @@ instance.web_graph.GraphView = instance.web.View.extend({
var self = this; var self = this;
return $.when(this.is_loaded).pipe(function() { return $.when(this.is_loaded).pipe(function() {
// todo: find the right syntax to perform an Ajax call // todo: find the right syntax to perform an Ajax call
return self.rpc.graph_get_data(self.view_id, domain, context, group_by).then($.proxy(self, 'schedule_chart')); // return self.rpc.graph_get_data(self.view_id, domain, context, group_by).then($.proxy(self, 'schedule_chart'));
$.proxy(self, "schedule_chart");
}); });
}, },