From c71520ea0dbfa6a3bdacb5a2bafbaaf96acfeb11 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 30 Sep 2011 17:07:06 +0200 Subject: [PATCH] [IMP] web_livechat: convert to 6.1 web module bzr revid: chs@openerp.com-20110930150706-84xo4e21l58j9esw --- addons/web_livechat/LICENSE | 2 +- addons/web_livechat/__openerp__.py | 12 ++- addons/web_livechat/publisher_warranty.py | 2 +- .../{web/static => static/src}/css/lc.css | 4 +- .../web_livechat/static/src/img/available.png | Bin 0 -> 1153 bytes addons/web_livechat/static/src/img/away.png | Bin 0 -> 1398 bytes addons/web_livechat/static/src/img/busy.png | Bin 0 -> 1145 bytes .../static/src/js/web_livechat.js | 100 ++++++++++++++++++ .../static/src/xml/web_livechat.xml | 8 ++ addons/web_livechat/web/__init__.py | 5 - addons/web_livechat/web/editors.py | 93 ---------------- 11 files changed, 121 insertions(+), 105 deletions(-) rename addons/web_livechat/{web/static => static/src}/css/lc.css (74%) create mode 100644 addons/web_livechat/static/src/img/available.png create mode 100644 addons/web_livechat/static/src/img/away.png create mode 100644 addons/web_livechat/static/src/img/busy.png create mode 100644 addons/web_livechat/static/src/js/web_livechat.js create mode 100644 addons/web_livechat/static/src/xml/web_livechat.xml delete mode 100644 addons/web_livechat/web/__init__.py delete mode 100644 addons/web_livechat/web/editors.py diff --git a/addons/web_livechat/LICENSE b/addons/web_livechat/LICENSE index 27a1a4cf453..ff64be448e9 100644 --- a/addons/web_livechat/LICENSE +++ b/addons/web_livechat/LICENSE @@ -1,5 +1,5 @@ OpenERP, Open Source Management Solution -Copyright © 2010 OpenERP SA (). +Copyright © 2010-2011 OpenERP SA (). This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/addons/web_livechat/__openerp__.py b/addons/web_livechat/__openerp__.py index cea342ef05e..642600a75ef 100644 --- a/addons/web_livechat/__openerp__.py +++ b/addons/web_livechat/__openerp__.py @@ -2,7 +2,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2010 OpenERP s.a. (). +# Copyright (C) 2010-2011 OpenERP s.a. (). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -20,7 +20,7 @@ ############################################################################## { 'name': 'Live Chat Support', - 'version': '1.1', + 'version': '2.0', 'category': 'Tools', 'complexity': "easy", 'description': """ @@ -33,9 +33,15 @@ Add "Support" button in header from where you can access OpenERP Support. 'website': 'http://openerp.com', 'depends': ['base'], 'update_xml': [], + 'js' : [ + 'static/src/js/web_livechat.js', + ], + 'css' : [ + 'static/src/css/lc.css', + ], 'installable': True, 'active': True, 'web': True, 'certificate': '0013762192410413', - 'images': ['images/web_livechat_support.jpeg'], + 'images': ['static/src/img/web_livechat_support.jpeg'], } diff --git a/addons/web_livechat/publisher_warranty.py b/addons/web_livechat/publisher_warranty.py index ab83bc58c32..132e78d013e 100644 --- a/addons/web_livechat/publisher_warranty.py +++ b/addons/web_livechat/publisher_warranty.py @@ -44,7 +44,7 @@ class publisher_warranty_contract(osv.osv): @cache(skiparg=3) def get_default_livechat_text(self, cr, uid): - return 'Support' + return 'Support' publisher_warranty_contract() diff --git a/addons/web_livechat/web/static/css/lc.css b/addons/web_livechat/static/src/css/lc.css similarity index 74% rename from addons/web_livechat/web/static/css/lc.css rename to addons/web_livechat/static/src/css/lc.css index e6892857ddd..7f1876a2793 100644 --- a/addons/web_livechat/web/static/css/lc.css +++ b/addons/web_livechat/static/src/css/lc.css @@ -1,7 +1,7 @@ -#livechat_status a.online { +.livechat span.online { text-shadow: 0 0 0.2em #9a0404, 0 0 0.2em #9a0404, 0 0 0.2em #9a0404, 0 0 0.2em #9a0404; } -#livechat_status img { +.livechat img { vertical-align: middle; margin-right: 0.5em; } diff --git a/addons/web_livechat/static/src/img/available.png b/addons/web_livechat/static/src/img/available.png new file mode 100644 index 0000000000000000000000000000000000000000..e9eea88ae5ff7702f51f8308efeb35962c675460 GIT binary patch literal 1153 zcmV-{1b+L8P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2ign} z3j{IKe+8%j00aR^L_t(o!|j(%Xk1kk$A9O(H<@H+l7`d?&CG}`wnoK>wM{0iSQMcP zD?$-;(Y2$JAmkhF+t9+sWD{$m zb@Of#SjXj&NzVT^%FtMTc0ze~r1g%Mk3D_N)&k&{cX|fW-Kd@bA^`2TuVG7joN&kh zV4a))6auMugj77j#o-*^{WL_r5P)!C?Ug^;Q1&3`eBXMd#=gVd>t)7xvj}wG8|Q(I zEqDf0b-~&c39)`%jDN1?$xmAZIywgva_0D7C+7oTZn#RsxsQNWfUdjaY)mv_ty_}T zhYXKBxQ@n1sN|y8dIq{4t_h%bpmR5{9bi+ckvrR>IOmq7Ay3%R5yvw!6Kl#_Xm!jP z6j9_2fN-5h$NDC$vn!&p29LW^jU`*@On>^xDgc@O?#;kG0PV>b#>@oUN@;s4hVRcD z+==d~0^p2$s+5n(c>S_nKUa-W5-s&5d%K=JvL!Mn4Rt#RO;MjZzjmrEM_QZf_;WZ9 z5b>;kKX7UmfJzb|TJK@)${PoWgv~5xD5<$b)CLgt&8nP!hD~SNPF-SNCRA12Dgi*X zocu#`0sIYYnkoiZXII7k)U+!np3zDGqL)$Gl$&y^=7DRu*@Ib?3v)bRz6E_Gn|I_2 zmimyaIDpY?vDD0K$o^Qt1IEcGrOwb;amoB&OQ(yDE916w|0j;_Jv&(epg(i!2jCZg zOCtf(#g!$Zq49vg-3UU*&(;3|K@s!nOkn}P4;NRIikl)3^8U+!7km3VpQ)+`&U|s{ zLg(Yj9S9q81@Mj15MEpzP)m&{jSa$BR#7k@ySMI2UOjXC@?b?tw(sz^q_|)ZB!NJx z1>$RTNkQiv|!}kPZl)wssh5WSOv|_8Qs=gw|4A!!4ZICb5MfgUYo(wtjW#9APU+0$Gl10eB;X-v` T=8lUv00000NkvXXu0mjfR4yER literal 0 HcmV?d00001 diff --git a/addons/web_livechat/static/src/img/away.png b/addons/web_livechat/static/src/img/away.png new file mode 100644 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Q`kCPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2ign} z3kL#6f;W8t00a3+L_t(o!|j(%Y*bYg$A9O(H|++3`!L&n{>Fj7{yEd+`4#`Qs3|$6M2Mv*`Ioj%^RTW(d;%O=5v%9lT1+A)X0*J zYmp$ht2YzZ2N`ZZ%f$6T00n(}{fTpL2>3YxbZu|kiZ`tasq*UOROKGVlqHz2Mtd(a z+|dJG5tWZOoIJblt^mKaY^?LxlM2=8`qeDk`~V`tLN%TrVcO3f~G@b7L=sy7z zq@(%4HXxT=zLXW4vMgflNfr8s$ah@;uwG2d)>B<)rq2lh+PAFVgC`e+A(^^b+|43! zs4STxxw4AUzI+J&J>bb1Bk*I>hHlVx_f@Z?vMNKIa?WwB_Yb`Dh?ggJbas6giNNC%}q)=SSV z3;kmjZ+)!8TF>=@V!cqpd_5h`08BV}-Fo=5;3<{jJq59jv{9@F>-3!?Yd76LV>>>w zrl}2)Tqb~Q(#O({CwBzUTNG|sLEwriyI;NX%de3O$@{e}b%JXLYN|q|zD#4S2dD7+ zxG?Gk;HJXM`>+1|X=IIetDCoq_*Nj55}_sx2p2$c!z+We#^*&5wI{3)nHo>&Fo2QHy?XXrSZTqW_HU z=(S8sgE9KN7}*KBMwMzH4SEwKuS%N{Z5vONjvwyp9OItuX&(9uDr{l-Hk). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################*/ + +var __lc_buttons = []; + +openerp.web_livechat = function (openerp) { + +var QWeb = openerp.web.qweb; +QWeb.add_template('/web_livechat/static/src/xml/web_livechat.xml'); + + +// tracking code from LiveChat +var license = '1035052', + params = '', + lang = 'en', + skill = '0'; +__lc_load = function (p) { if (typeof __lc_loaded != 'function') + if (p) { var d = document, l = d.createElement('script'), s = + d.getElementsByTagName('script')[0], a = unescape('%26'), + h = ('https:' == d.location.protocol ? 'https://' : 'http://'); l.type = 'text/javascript'; l.async = true; + l.src = h + 'gis' + p +'.livechatinc.com/gis.cgi?serverType=control'+a+'licenseID='+license+a+'jsonp=__lc_load'; + if (!(typeof p['server'] !== 'string' || typeof __lc_serv === 'string')) { + l.src = h + (__lc_serv = p['server']) + '/licence/'+license+'/script.cgi?lang='+lang+a+'groups='+skill; + l.src += (params == '') ? '' : a+'params='+encodeURIComponent(encodeURIComponent(params)); s.parentNode.insertBefore(l, s); + } else setTimeout(__lc_load, 1000); if(typeof __lc_serv != 'string'){ s.parentNode.insertBefore(l, s);} + } else __lc_load(Math.ceil(Math.random()*5)); } +__lc_load(); + + + +openerp.web_livechat.Livechat = openerp.web.Widget.extend({ + template: 'Header-LiveChat', + + start: function() { + this._super(); + if (!this.session) + return; + var self = this; + var pwc = new openerp.web.Model(self.session, "publisher_warranty.contract"); + pwc.get_func('get_default_livechat_text')().then(function(text) { + self.$element.html(text); + self.do_update(); + }); + + openerp.webclient.header.do_update.add_last(this.do_update); + }, + + do_update: function() { + var self = this; + if (!this.session) { + self.$element.remove(); + return; + } + + var lc_id = _.uniqueId('livechat_'); + this.$element.attr('id', lc_id); + + var pwc = new openerp.web.Model(self.session, "publisher_warranty.contract"); + + pwc.get_func('is_livechat_enable')().then(function(res) { + console.log('res', res); + if(!res) { + //return; + } + + __lc_buttons.push({ + elementId: lc_id, //'livechat_status', + language: 'en', + skill: '0', + type: 'text', + labels: { + online: 'Support', + offline: 'Support', + } + }); + }); + } +}); + +openerp.webclient.livechat = new openerp.web_livechat.Livechat(openerp.webclient); +openerp.webclient.livechat.prependTo('div.header_corner'); + +}; diff --git a/addons/web_livechat/static/src/xml/web_livechat.xml b/addons/web_livechat/static/src/xml/web_livechat.xml new file mode 100644 index 00000000000..b5e2db515b0 --- /dev/null +++ b/addons/web_livechat/static/src/xml/web_livechat.xml @@ -0,0 +1,8 @@ + + + + +
+
+
diff --git a/addons/web_livechat/web/__init__.py b/addons/web_livechat/web/__init__.py deleted file mode 100644 index ec026b194f1..00000000000 --- a/addons/web_livechat/web/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -############################################################################## -# This file is part of the "web-livechatinc-odoo" OpenERP module. -# See LICENCE file at the root of the module folder. -############################################################################## -import editors diff --git a/addons/web_livechat/web/editors.py b/addons/web_livechat/web/editors.py deleted file mode 100644 index bb3dd3da354..00000000000 --- a/addons/web_livechat/web/editors.py +++ /dev/null @@ -1,93 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2010-2011 OpenERP s.a. (). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -import openobject.templating - -class BaseTemplateEditor(openobject.templating.TemplateEditor): - templates = ['/openobject/controllers/templates/base.mako'] - - def edit(self, template, template_text): - output = super(BaseTemplateEditor, self).edit(template, template_text) - - end_head = output.index('') - - output = output[:end_head] + """ - - <% - cp.session['livechat'] = rpc.RPCProxy('publisher_warranty.contract').is_livechat_enable() - %> - % if cp.session['livechat']: - - % endif - """ + output[end_head:] - - return output - - -class HeaderTemplateEditor(openobject.templating.TemplateEditor): - templates = ['/openerp/controllers/templates/header.mako'] - - - def edit(self, template, template_text): - output = super(HeaderTemplateEditor, self).edit(template, template_text) - - PATTERN = '
' - corner = output.index(PATTERN) + len(PATTERN) - - - output = output[:corner] + """ -

- ${ rpc.RPCProxy('publisher_warranty.contract').get_default_livechat_text() | n} -

- % if cp.session['livechat']: - - - - % endif - """ + output[corner:] - return output -