Improved performance of large object tables.

This commit is contained in:
Martin Edenhofer 2015-11-20 10:47:41 +01:00
parent 8800b6b61a
commit 9447a08e6e
4 changed files with 71 additions and 58 deletions

View file

@ -264,6 +264,7 @@ class App.ControllerTable extends App.Controller
table = App.view('generic/table')( table = App.view('generic/table')(
table_id: @table_id table_id: @table_id
header: @headers header: @headers
attributes: attributes
objects: @objects objects: @objects
checkbox: @checkbox checkbox: @checkbox
radio: @radio radio: @radio

View file

@ -1,6 +1,5 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
#= require_self #= require_self
#= require_tree ./lib/app_init #= require_tree ./lib/app_init
#= require ./config.coffee #= require ./config.coffee
@ -10,7 +9,8 @@
#= require_tree ./lib/app_post #= require_tree ./lib/app_post
class App extends Spine.Controller class App extends Spine.Controller
@viewPrint: (object, attribute_name) -> @viewPrint: (object, attribute_name, attributes) ->
if !attributes
attributes = {} attributes = {}
if object.constructor.attributesGet if object.constructor.attributesGet
attributes = object.constructor.attributesGet() attributes = object.constructor.attributesGet()
@ -34,8 +34,6 @@ class App extends Spine.Controller
if parts[0] && parts[1] && object[ parts[0] ] if parts[0] && parts[1] && object[ parts[0] ]
value = object[ parts[0] ][ parts[1] ] value = object[ parts[0] ][ parts[1] ]
#console.log('Pa', attribute_name, object, attribute_config, object[attribute_name], valueRef, value)
# if we have no config, get output this way # if we have no config, get output this way
if !attribute_config if !attribute_config
return @viewPrintItem(value) return @viewPrintItem(value)
@ -48,7 +46,7 @@ class App extends Spine.Controller
if object[attribute_name_without_ref] if object[attribute_name_without_ref]
valueRef = object[attribute_name_without_ref] valueRef = object[attribute_name_without_ref]
return @viewPrintItem( value, attribute_config, valueRef ) @viewPrintItem(value, attribute_config, valueRef)
# define print name helper # define print name helper
@viewPrintItem: (item, attribute_config = {}, valueRef) -> @viewPrintItem: (item, attribute_config = {}, valueRef) ->
@ -124,8 +122,8 @@ class App extends Spine.Controller
template = (params = {}) -> template = (params = {}) ->
# define print name helper # define print name helper
params.P = ( object, attribute_name ) -> params.P = (object, attribute_name, attributes) ->
App.viewPrint( object, attribute_name ) App.viewPrint(object, attribute_name, attributes)
# define date format helper # define date format helper
params.date = (time) -> params.date = (time) ->
@ -202,7 +200,6 @@ class App extends Spine.Controller
result = result + App.Utils.htmlEscape(item.name) + ' ' result = result + App.Utils.htmlEscape(item.name) + ' '
if item.address if item.address
result = result + " <span class=\"text-muted\">&lt;#{App.Utils.htmlEscape(item.address)}&gt</span>" result = result + " <span class=\"text-muted\">&lt;#{App.Utils.htmlEscape(item.address)}&gt</span>"
result result
# define file size helper # define file size helper

View file

@ -27,6 +27,11 @@ class App.Log
_instance ?= new _Singleton _instance ?= new _Singleton
_instance.config( type, regex ) _instance.config( type, regex )
@timeTrack: (message) ->
if _instance == undefined
_instance ?= new _Singleton
_instance.timeTrack(message)
class _Singleton class _Singleton
constructor: -> constructor: ->
@moduleColorsMap = {} @moduleColorsMap = {}
@ -116,3 +121,13 @@ class _Singleton
@hue += goldenRatio @hue += goldenRatio
@hue = @hue % 1 @hue = @hue % 1
@hue * 360 @hue * 360
timeTrack: (message) =>
currentTime = new Date().getTime()
if !@lastTime
@lastTime = currentTime
console.log('timeTrack start', message)
else
diff = currentTime - @lastTime
@lastTime = currentTime
console.log('timeTrack start', message, diff)

View file

@ -41,7 +41,7 @@
<% groupLast = '' %> <% groupLast = '' %>
<% for object in @objects: %> <% for object in @objects: %>
<% if @groupBy: %> <% if @groupBy: %>
<% groupByName = @P( object, @groupBy ) %> <% groupByName = @P( object, @groupBy, @attributes ) %>
<% if groupLast isnt groupByName: %> <% if groupLast isnt groupByName: %>
<tr class=""><td colspan="<%= length %>"><b><%= groupByName %></b></td></tr> <tr class=""><td colspan="<%= length %>"><b><%= groupByName %></b></td></tr>
<% groupLast = groupByName %> <% groupLast = groupByName %>
@ -68,7 +68,7 @@
</td> </td>
<% end %> <% end %>
<% for item in @header: %> <% for item in @header: %>
<% value = @P( object, item.name ) %> <% value = @P( object, item.name, @attributes ) %>
<% if @callbacks: %> <% if @callbacks: %>
<% if item.name.substr(item.name.length-3, item.name.length) is '_id' && object[ item.name.substr(0, item.name.length-3) ]: %> <% if item.name.substr(item.name.length-3, item.name.length) is '_id' && object[ item.name.substr(0, item.name.length-3) ]: %>
<% refObject = object[ item.name.substr(0, item.name.length-3) ] %> <% refObject = object[ item.name.substr(0, item.name.length-3) ] %>