[REM] web: Proxy.load
Not really useful at this point, if we ever go down the path of embedded web client we can probably make the relevant controllers CORS.
This commit is contained in:
@@ -76,16 +76,17 @@ var LivechatButton = Widget.extend({
|
||||
return this._super();
|
||||
},
|
||||
|
||||
load_qweb_template: function () {
|
||||
var xml_files = ['/mail/static/src/xml/chat_window.xml',
|
||||
'/mail/static/src/xml/thread.xml',
|
||||
'/im_livechat/static/src/xml/im_livechat.xml'];
|
||||
var defs = _.map(xml_files, function (tmpl) {
|
||||
return session.rpc('/web/proxy/load', {path: tmpl}).then(function (xml) {
|
||||
QWeb.add_template(xml);
|
||||
});
|
||||
load_qweb_template: function(){
|
||||
return $.when(
|
||||
$.get('/mail/static/src/xml/chat_window.xml'),
|
||||
$.get('/mail/static/src/xml/thread.xml'),
|
||||
$.get('/im_livechat/static/src/xml/im_livechat.xml')
|
||||
).then(function (chat_window, mail_thread, livechat) {
|
||||
// results are triplets of [dom: XMLDocument, status: String, xhr: jqXHR]
|
||||
QWeb.add_template(chat_window[0]);
|
||||
QWeb.add_template(mail_thread[0]);
|
||||
QWeb.add_template(livechat[0]);
|
||||
});
|
||||
return $.when.apply($, defs);
|
||||
},
|
||||
|
||||
open_chat: function () {
|
||||
|
||||
@@ -601,22 +601,6 @@ class WebClient(http.Controller):
|
||||
|
||||
class Proxy(http.Controller):
|
||||
|
||||
@http.route('/web/proxy/load', type='json', auth="none")
|
||||
def load(self, path):
|
||||
""" Proxies an HTTP request through a JSON request.
|
||||
|
||||
It is strongly recommended to not request binary files through this,
|
||||
as the result will be a binary data blob as well.
|
||||
|
||||
:param path: actual request path
|
||||
:return: file content
|
||||
"""
|
||||
from werkzeug.test import Client
|
||||
from werkzeug.wrappers import BaseResponse
|
||||
|
||||
base_url = request.httprequest.base_url
|
||||
return Client(request.httprequest.app, BaseResponse).get(path, base_url=base_url).data
|
||||
|
||||
@http.route('/web/proxy/post/<path:path>', type='http', auth='user', methods=['GET'])
|
||||
def post(self, path):
|
||||
"""Effectively execute a POST request that was hooked through user login"""
|
||||
|
||||
@@ -236,14 +236,13 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, {
|
||||
return d;
|
||||
},
|
||||
load_qweb: function(mods) {
|
||||
var self = this;
|
||||
self.qweb_mutex.exec(function() {
|
||||
return self.rpc('/web/proxy/load', {path: '/web/webclient/qweb?mods=' + mods}).then(function(xml) {
|
||||
if (!xml) { return; }
|
||||
qweb.add_template(_.str.trim(xml));
|
||||
this.qweb_mutex.exec(function() {
|
||||
return $.get('/web/webclient/qweb?mods=' + mods).then(function (doc) {
|
||||
if (!doc) { return; }
|
||||
qweb.add_template(doc);
|
||||
});
|
||||
});
|
||||
return self.qweb_mutex.def;
|
||||
return this.qweb_mutex.def;
|
||||
},
|
||||
on_modules_loaded: function() {
|
||||
var openerp = window.openerp;
|
||||
|
||||
Reference in New Issue
Block a user