@@ -20,6 +20,10 @@ coreshop.messenger.list = Class.create({
2020 messagesStore : null ,
2121 failedMessagesStore : null ,
2222
23+ autoRefreshInterval : null ,
24+ autoRefreshTimer : null ,
25+ lastRefreshLabel : null ,
26+
2327 initialize : function ( ) {
2428 this . getPanel ( ) ;
2529 } ,
@@ -36,8 +40,47 @@ coreshop.messenger.list = Class.create({
3640 }
3741 } ,
3842
43+ updateLastRefreshLabel : function ( ) {
44+ if ( this . lastRefreshLabel ) {
45+ var now = new Date ( ) ;
46+ var timeString = Ext . Date . format ( now , 'Y-m-d H:i:s' ) ;
47+ this . lastRefreshLabel . setText ( t ( 'coreshop_messenger_last_refresh' ) + ': ' + timeString ) ;
48+ }
49+ } ,
50+
51+ startAutoRefresh : function ( interval ) {
52+ this . stopAutoRefresh ( ) ;
53+
54+ if ( interval > 0 ) {
55+ this . autoRefreshInterval = interval ;
56+ this . autoRefreshTimer = setInterval ( this . reload . bind ( this ) , interval * 1000 ) ;
57+ }
58+ } ,
59+
60+ stopAutoRefresh : function ( ) {
61+ if ( this . autoRefreshTimer ) {
62+ clearInterval ( this . autoRefreshTimer ) ;
63+ this . autoRefreshTimer = null ;
64+ }
65+ this . autoRefreshInterval = null ;
66+ } ,
67+
3968 getPanel : function ( ) {
4069 if ( ! this . panel ) {
70+ this . lastRefreshLabel = Ext . create ( 'Ext.toolbar.TextItem' , {
71+ text : ''
72+ } ) ;
73+
74+ var autoRefreshStore = Ext . create ( 'Ext.data.Store' , {
75+ fields : [ 'value' , 'text' ] ,
76+ data : [
77+ { value : 0 , text : t ( 'coreshop_messenger_auto_refresh_disabled' ) } ,
78+ { value : 5 , text : t ( 'coreshop_messenger_auto_refresh_5s' ) } ,
79+ { value : 10 , text : t ( 'coreshop_messenger_auto_refresh_10s' ) } ,
80+ { value : 30 , text : t ( 'coreshop_messenger_auto_refresh_30s' ) }
81+ ]
82+ } ) ;
83+
4184 this . panel = Ext . create ( 'Ext.panel.Panel' , {
4285 id : 'coreshop_messenger_list' ,
4386 title : t ( 'coreshop_messenger_list' ) ,
@@ -49,7 +92,21 @@ coreshop.messenger.list = Class.create({
4992 xtype : 'button' ,
5093 iconCls : 'pimcore_icon_reload' ,
5194 handler : this . reload . bind ( this )
52- } ] ,
95+ } , '-' , {
96+ xtype : 'combo' ,
97+ store : autoRefreshStore ,
98+ displayField : 'text' ,
99+ valueField : 'value' ,
100+ value : 0 ,
101+ editable : false ,
102+ width : 200 ,
103+ queryMode : 'local' ,
104+ listeners : {
105+ select : function ( combo , record ) {
106+ this . startAutoRefresh ( record . get ( 'value' ) ) ;
107+ } . bind ( this )
108+ }
109+ } , '->' , this . lastRefreshLabel ] ,
53110 items : [ {
54111 xtype : 'panel' ,
55112 layout : 'border' ,
@@ -78,6 +135,7 @@ coreshop.messenger.list = Class.create({
78135 tabPanel . setActiveItem ( 'coreshop_messenger_list' ) ;
79136
80137 this . panel . on ( 'destroy' , function ( ) {
138+ this . stopAutoRefresh ( ) ;
81139 pimcore . globalmanager . remove ( 'coreshop_messenger_list' ) ;
82140 } . bind ( this ) ) ;
83141
@@ -98,7 +156,10 @@ coreshop.messenger.list = Class.create({
98156 rootProperty : 'data'
99157 }
100158 } ,
101- fields : [ 'name' , 'count' ]
159+ fields : [ 'receiver' , 'count' ] ,
160+ listeners : {
161+ load : this . updateLastRefreshLabel . bind ( this )
162+ }
102163 } ) ;
103164 this . chartStore . load ( ) ;
104165
@@ -117,16 +178,23 @@ coreshop.messenger.list = Class.create({
117178 type : 'category' ,
118179 position : 'bottom' ,
119180 grid : true ,
120- fields : [ 'receiver' ] ,
181+ fields : [ 'receiver' ]
121182 } ] ,
122183 series : [ {
123184 type : 'bar' ,
124185 title : 'Messages' ,
125186 xField : 'receiver' ,
126187 yField : 'count' ,
188+ highlight : true ,
127189 label : {
128190 field : 'count' ,
129191 display : 'insideEnd'
192+ } ,
193+ tooltip : {
194+ trackMouse : true ,
195+ renderer : function ( tooltip , record ) {
196+ tooltip . setHtml ( record . get ( 'receiver' ) + ': ' + record . get ( 'count' ) + ' ' + t ( 'coreshop_messenger_messages' ) ) ;
197+ }
130198 }
131199 } ]
132200 } ;
0 commit comments