Browse Source
[REF] profiler: Many changes (see list below)
[REF] profiler: Many changes (see list below)
- Refactor the import - Add player - Update display with css - Add access rule to show or hide the playerpull/375/head
jssuzanne
10 years ago
committed by
Moisés López
No known key found for this signature in database
GPG Key ID: F49F27BE918BFA35
10 changed files with 128 additions and 93 deletions
-
10profiler/__openerp__.py
-
23profiler/controllers.py
-
0profiler/controllers/main.py
-
11profiler/security/group.xml
-
21profiler/static/src/css/player.css
-
3profiler/static/src/js/boot.js
-
53profiler/static/src/js/player.js
-
32profiler/static/src/js/profiler.js
-
18profiler/static/src/xml/player.xml
-
50profiler/view/menu.xml
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data noupdate="1"> |
|||
<record id="group_profiler_player" model="res.groups"> |
|||
<field name="name">Profiling capability</field> |
|||
</record> |
|||
<record model="res.users" id="base.user_root"> |
|||
<field name="groups_id" eval="[(4, ref('profiler.group_profiler_player'))]"/> |
|||
</record> |
|||
</data> |
|||
</openerp> |
@ -0,0 +1,21 @@ |
|||
.openerp .oe_topbar_item.profiler_player img { |
|||
cursor: pointer; |
|||
} |
|||
.openerp .oe_topbar_item.profiler_player.profiler_player_enabled img.profiler_enable { |
|||
display: None; |
|||
} |
|||
.openerp .oe_topbar_item.profiler_player.profiler_player_enabled img.profiler_dump { |
|||
display: None; |
|||
} |
|||
.openerp .oe_topbar_item.profiler_player.profiler_player_disabled img.profiler_disable { |
|||
display: None; |
|||
} |
|||
.openerp .oe_topbar_item.profiler_player.profiler_player_clear img.profiler_disable { |
|||
display: None; |
|||
} |
|||
.openerp .oe_topbar_item.profiler_player.profiler_player_clear img.profiler_clear { |
|||
display: None; |
|||
} |
|||
.openerp .oe_topbar_item.profiler_player.profiler_player_clear img.profiler_dump { |
|||
display: None; |
|||
} |
@ -1,3 +0,0 @@ |
|||
openerp.profiler = function(instance) { |
|||
openerp.profiler.profiler_enable(); |
|||
}; |
@ -0,0 +1,53 @@ |
|||
openerp.profiler = function(instance) { |
|||
instance.profiler.Player = instance.web.Widget.extend({ |
|||
template: 'profiler.player', |
|||
events: { |
|||
"click .profiler_enable": "enable", |
|||
"click .profiler_disable": "disable", |
|||
"click .profiler_clear": "clear", |
|||
"click .profiler_dump": "dump", |
|||
}, |
|||
apply_class: function(css_class) { |
|||
console.log(css_class) |
|||
this.$el.removeClass('profiler_player_enabled'); |
|||
this.$el.removeClass('profiler_player_disabled'); |
|||
this.$el.removeClass('profiler_player_clear'); |
|||
this.$el.addClass(css_class); |
|||
}, |
|||
enable: function() { |
|||
this.rpc('/web/profiler/enable', {}); |
|||
this.apply_class('profiler_player_enabled'); |
|||
}, |
|||
disable: function() { |
|||
this.rpc('/web/profiler/disable', {}); |
|||
this.apply_class('profiler_player_disabled'); |
|||
}, |
|||
clear: function() { |
|||
this.rpc('/web/profiler/clear', {}); |
|||
this.apply_class('profiler_player_clear'); |
|||
}, |
|||
dump: function() { |
|||
$.blockUI(); |
|||
this.session.get_file({ |
|||
url: '/web/profiler/dump', |
|||
complete: $.unblockUI |
|||
}); |
|||
}, |
|||
}); |
|||
|
|||
instance.web.UserMenu.include({ |
|||
do_update: function () { |
|||
var self = this; |
|||
this.update_promise.done(function () { |
|||
self.rpc('/web/profiler/initial_state', {}).done(function(state) { |
|||
if (state.has_player_group) { |
|||
this.profiler_player = new instance.profiler.Player(this); |
|||
this.profiler_player.prependTo(instance.webclient.$('.oe_systray')); |
|||
this.profiler_player.apply_class(state.player_state); |
|||
} |
|||
}); |
|||
}); |
|||
return this._super(); |
|||
}, |
|||
}); |
|||
}; |
@ -1,32 +0,0 @@ |
|||
openerp.profiler = function(instance) { |
|||
openerp.profiler.profiler_enable(instance); |
|||
}; |
|||
|
|||
openerp.profiler.profiler_enable = function(instance) { |
|||
instance.profiler.controllers = { |
|||
'profiler.enable': 'enable', |
|||
'profiler.disable': 'disable', |
|||
'profiler.clear': 'clear', |
|||
}; |
|||
instance.profiler.simple_action = function(parent, action) { |
|||
console.info(action); |
|||
parent.session.rpc('/web/profiler/' + instance.profiler.controllers[action.tag], {}); |
|||
}; |
|||
|
|||
instance.profiler.dump = function(parent, action) { |
|||
$.blockUI(); |
|||
parent.session.get_file({ |
|||
url: '/web/profiler/dump', |
|||
complete: $.unblockUI |
|||
}); |
|||
|
|||
}; |
|||
instance.web.client_actions.add("profiler.enable", |
|||
"instance.profiler.simple_action"); |
|||
instance.web.client_actions.add("profiler.disable", |
|||
"instance.profiler.simple_action"); |
|||
instance.web.client_actions.add("profiler.clear", |
|||
"instance.profiler.simple_action"); |
|||
instance.web.client_actions.add("profiler.dump", |
|||
"instance.profiler.dump"); |
|||
}; |
@ -0,0 +1,18 @@ |
|||
<templates> |
|||
<t t-name="profiler.player"> |
|||
<div class="oe_topbar_item profiler_player"> |
|||
<img class="profiler_enable" |
|||
title="Enable the profiler" |
|||
src="/web/static/src/img/icons/gtk-media-record.png"/> |
|||
<img class="profiler_disable" |
|||
title="Disable the profiler" |
|||
src="/web/static/src/img/icons/gtk-media-pause.png"/> |
|||
<img class="profiler_clear" |
|||
title="Clean previous profiling" |
|||
src="/web/static/src/img/icons/gtk-media-stop.png"/> |
|||
<img class="profiler_dump" |
|||
title="Dump the previous profiling" |
|||
src="/web/static/src/img/icons/gtk-floppy.png"/> |
|||
</div> |
|||
</t> |
|||
</templates> |
@ -1,50 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<menuitem id="menu_main" |
|||
parent="base.menu_administration" |
|||
sequence="0" |
|||
name="Profiler"/> |
|||
|
|||
<record model="ir.actions.client" id="action_profiler_enable"> |
|||
<field name="name">Enable Profiler</field> |
|||
<field name="tag">profiler.enable</field> |
|||
</record> |
|||
<menuitem id="menu_enable" |
|||
parent="menu_main" |
|||
sequence="10" |
|||
action="action_profiler_enable" |
|||
name="Start profiling"/> |
|||
|
|||
<record model="ir.actions.client" id="action_profiler_disable"> |
|||
<field name="name">Disable Profiler</field> |
|||
<field name="tag">profiler.disable</field> |
|||
</record> |
|||
<menuitem id="menu_disable" |
|||
parent="menu_main" |
|||
sequence="20" |
|||
action="action_profiler_disable" |
|||
name="Stop profiling"/> |
|||
|
|||
<record model="ir.actions.client" id="action_profiler_dump"> |
|||
<field name="name">Dump Stats</field> |
|||
<field name="tag">profiler.dump</field> |
|||
</record> |
|||
<menuitem id="menu_dump" |
|||
parent="menu_main" |
|||
sequence="30" |
|||
action="action_profiler_dump" |
|||
name="Dump stats"/> |
|||
|
|||
<record model="ir.actions.client" id="action_profiler_clear"> |
|||
<field name="name">Clear Stats</field> |
|||
<field name="tag">profiler.clear</field> |
|||
</record> |
|||
<menuitem id="menu_clear" |
|||
parent="menu_main" |
|||
sequence="40" |
|||
action="action_profiler_clear" |
|||
name="Clear stats"/> |
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue