Renammed chat to im

bzr revid: nicolas.vanhoren@openerp.com-20121127100241-qq43we149rxpclk8
This commit is contained in:
niv-openerp
2012-11-27 11:02:41 +01:00
parent 38dc28f46b
commit 01e12e5462
9 changed files with 44 additions and 44 deletions
-3
View File
@@ -1,3 +0,0 @@
import chat
import chat_controller
-16
View File
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- vim:fdl=1:
-->
<templates xml:space="preserve">
<t t-name="Chat">
<div class="oe_chat">
<div class="oe_chat_content"></div>
<input class="oe_chat_input" type="text"/>
</div>
</t>
<t t-name="ChatTopButton">
<div title='Display chat' class="oe_topbar_item oe_topbar_chatbutton">
<button></button>
</div>
</t>
</templates>
+3
View File
@@ -0,0 +1,3 @@
import im
import im_controller
@@ -1,5 +1,5 @@
{
'name' : 'Chat',
'name' : 'Instant Messaging',
'version': '1.0',
'category': 'Tools',
'complexity': 'easy',
@@ -85,8 +85,8 @@ if openerp.tools.config.options["gevent"]:
class chat_message(osv.osv):
_name = 'chat.message'
class im_message(osv.osv):
_name = 'im.message'
_columns = {
'message': fields.char(string="Message", size=200),
}
@@ -2,10 +2,10 @@
import openerp
import openerp.tools.config
import chat
import im
class ImportController(openerp.addons.web.http.Controller):
_cp_path = '/chat'
_cp_path = '/im'
@openerp.addons.web.http.jsonrequest
def poll(self, req, last=None):
@@ -13,10 +13,10 @@ class ImportController(openerp.addons.web.http.Controller):
raise Exception("Not usable in a server not running gevent")
num = 0
while True:
res = req.session.model('chat.message').get_messages(last, req.session.eval_context(req.context))
res = req.session.model('im.message').get_messages(last, req.session.eval_context(req.context))
if num >= 1 or len(res["res"]) > 0:
return res
last = res["last"]
num += 1
print "waiting"
chat.Watcher.get_watcher(res["dbname"]).stop(30)
im.Watcher.get_watcher(res["dbname"]).stop(30)
@@ -1,11 +1,11 @@
.openerp .oe_chat {
.openerp .oe_im {
position: fixed;
background-color: #E8EBEF;
width: 220px;
border-left: 1px solid #AEB9BD;
}
.openerp .oe_topbar_chatbutton{
.openerp .oe_topbar_imbutton{
}
@@ -1,32 +1,32 @@
openerp.web_chat = function(instance) {
openerp.web_im = function(instance) {
instance.web.UserMenu.include({
do_update: function(){
var self = this;
this.update_promise.then(function() {
var chat = new instance.web_chat.Chat(self);
chat.appendTo(instance.client.$el);
var button = new instance.web.ChatTopButton(self);
button.chat = chat;
var im = new instance.web_im.InstantMessaging(self);
im.appendTo(instance.client.$el);
var button = new instance.web.IMTopButton(self);
button.im = im;
button.appendTo(instance.webclient.$el.find('.oe_systray'));
});
return this._super.apply(this, arguments);
},
});
instance.web.ChatTopButton = instance.web.Widget.extend({
template:'ChatTopButton',
instance.web.IMTopButton = instance.web.Widget.extend({
template:'IMTopButton',
events: {
"click button": "clicked",
},
clicked: function() {
this.chat.switch_display();
this.im.switch_display();
},
});
instance.web_chat.Chat = instance.web.Widget.extend({
template: "Chat",
instance.web_im.InstantMessaging = instance.web.Widget.extend({
template: "InstantMessaging",
init: function(parent) {
this._super(parent);
this.shown = false;
@@ -40,13 +40,13 @@ openerp.web_chat = function(instance) {
$(window).scroll(_.bind(this.calc_box, this));
$(window).resize(_.bind(this.calc_box, this));
self.calc_box();
self.$(".oe_chat_input").keypress(function(e) {
self.$(".oe_im_input").keypress(function(e) {
if(e.which != 13) {
return;
}
var mes = self.$(".oe_chat_input").val();
self.$(".oe_chat_input").val("");
var model = new instance.web.Model("chat.message");
var mes = self.$(".oe_im_input").val();
self.$(".oe_im_input").val("");
var model = new instance.web.Model("im.message");
model.call("post", [mes], {context: new instance.web.CompoundContext()});
}).focus();
},
@@ -78,13 +78,13 @@ openerp.web_chat = function(instance) {
},
poll: function() {
var self = this;
this.rpc("/chat/poll", {
this.rpc("/im/poll", {
last: this.last,
context: new instance.web.CompoundContext()
}, {shadow: true}).then(function(result) {
self.last = result.last;
_.each(result.res, function(mes) {
$("<div>").text(mes).appendTo(self.$(".oe_chat_content"));
$("<div>").text(mes).appendTo(self.$(".oe_im_content"));
});
self.poll();
}, function(unused, e) {
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- vim:fdl=1:
-->
<templates xml:space="preserve">
<t t-name="InstantMessaging">
<div class="oe_im">
<div class="oe_im_content"></div>
<input class="oe_im_input" type="text"/>
</div>
</t>
<t t-name="IMTopButton">
<div title='Display im' class="oe_topbar_item oe_topbar_imbutton">
<button></button>
</div>
</t>
</templates>