Reduced dom changes, improved performance.

This commit is contained in:
Martin Edenhofer 2015-08-16 13:57:27 +02:00
parent 592b014508
commit df3addd915
20 changed files with 27 additions and 38 deletions

View file

@ -210,7 +210,7 @@ class App.Controller extends Spine.Controller
# console.log('rewrite frontendTimeUpdate', this, $(this).hasClass('escalation')) # console.log('rewrite frontendTimeUpdate', this, $(this).hasClass('escalation'))
ui.frontendTimeUpdateItem(item) ui.frontendTimeUpdateItem(item)
) )
App.Interval.set( update, 30000, 'frontendTimeUpdate', 'ui' ) App.Interval.set( update, 61000, 'frontendTimeUpdate', 'ui' )
frontendTimeUpdateItem: (item) => frontendTimeUpdateItem: (item) =>
timestamp = item.data('time') timestamp = item.data('time')

View file

@ -401,9 +401,6 @@ class App.GenericHistory extends App.ControllerModal
# enable user popups # enable user popups
@userPopups() @userPopups()
# show frontend times
@delay( @frontendTimeUpdate, 800, 'ui-time-update' )
sortorder: => sortorder: =>
@items = @items.reverse() @items = @items.reverse()

View file

@ -274,9 +274,4 @@ class App.ControllerTable extends App.Controller
) )
) )
time = =>
@frontendTimeUpdate()
@delay(time, 80) # to show time immediately for normal tables
@delay(time, 280) # to show time immediately for tables in modal dialog
table table

View file

@ -51,9 +51,6 @@ class App.DashboardActivityStream extends App.Controller
@$('.activity-entries').remove() @$('.activity-entries').remove()
@el.append html @el.append html
# update time
@frontendTimeUpdate()
renderItem: (item) -> renderItem: (item) ->
html = $(App.view('dashboard/activity_stream')( html = $(App.view('dashboard/activity_stream')(
item: item item: item

View file

@ -42,9 +42,6 @@ class Index extends App.ControllerContent
sessions: data.sessions sessions: data.sessions
) )
# show frontend times
@frontendTimeUpdate()
destroy: (e) -> destroy: (e) ->
e.preventDefault() e.preventDefault()
sessionId = $( e.target ).closest('a').data('session-id') sessionId = $( e.target ).closest('a').data('session-id')

View file

@ -321,9 +321,6 @@ class Table extends App.Controller
# start organization popups # start organization popups
@organizationPopups() @organizationPopups()
# show frontend times
@frontendTimeUpdate()
# start bulk action observ # start bulk action observ
@el.find('.bulkAction').append( @bulk_form() ) @el.find('.bulkAction').append( @bulk_form() )
if @el.find('.table-overview').find('input[name="bulk"]:checked').length isnt 0 if @el.find('.table-overview').find('input[name="bulk"]:checked').length isnt 0

View file

@ -112,9 +112,6 @@ class ArticleViewItem extends App.Controller
article: @article article: @article
) )
# show frontend times
@frontendTimeUpdate()
# set see more option # set see more option
@setSeeMore() @setSeeMore()

View file

@ -12,8 +12,5 @@ class App.TicketZoomMeta extends App.Controller
isCustomer: @isRole('Customer') isCustomer: @isRole('Customer')
) )
# show frontend times
@frontendTimeUpdate()
release: => release: =>
App.Ticket.unsubscribe( @subscribeId ) App.Ticket.unsubscribe( @subscribeId )

View file

@ -130,9 +130,6 @@ class App.OnlineNotificationWidget extends App.Controller
$( App.view('widget/online_notification_content')(items: items) ) $( App.view('widget/online_notification_content')(items: items) )
) )
# show frontend times
@frontendTimeUpdate()
createContainer: => createContainer: =>
@removeContainer() @removeContainer()

View file

@ -144,7 +144,6 @@ class TicketStatsList extends App.Controller
limit: @limit limit: @limit
) )
@frontendTimeUpdate()
@ticketPopups() @ticketPopups()
showAll: (e) => showAll: (e) =>

View file

@ -107,7 +107,12 @@ class App extends Spine.Controller
# use pretty time for datetime # use pretty time for datetime
else if attribute_config.tag is 'datetime' else if attribute_config.tag is 'datetime'
isHtmlEscape = true isHtmlEscape = true
result = "<span class=\"humanTimeFromNow #{attribute_config.class}\" data-time=\"#{result}\">?</span>" timestamp = App.i18n.translateTimestamp(result)
escalation = undefined
if attribute_config.class is 'escalation'
escalation
humanTime = App.PrettyDate.humanTime(result, escalation)
result = "<span class=\"humanTimeFromNow #{attribute_config.class}\" data-time=\"#{result}\" data-tooltip=\"#{timestamp}\">#{humanTime}</span>"
#result = App.i18n.translateTimestamp(result) #result = App.i18n.translateTimestamp(result)
if !isHtmlEscape && typeof result is 'string' if !isHtmlEscape && typeof result is 'string'
@ -216,6 +221,14 @@ class App extends Spine.Controller
params.humanFileSize = ( size ) -> params.humanFileSize = ( size ) ->
App.Utils.humanFileSize(size) App.Utils.humanFileSize(size)
# define pretty/human time helper
params.humanTime = ( time, escalation ) ->
App.PrettyDate.humanTime(time, escalation)
# define pretty/human time helper
params.timestamp = ( time ) ->
App.i18n.translateTimestamp(time)
# define template # define template
JST["app/views/#{name}"](params) JST["app/views/#{name}"](params)
template template

View file

@ -21,6 +21,9 @@ class App.Run extends App.Controller
# create web socket connection # create web socket connection
App.WebSocket.connect() App.WebSocket.connect()
# start frontend time update
@frontendTimeUpdate()
# start navbars # start navbars
@setupWidget( 'Navigations', 'nav', @el ) @setupWidget( 'Navigations', 'nav', @el )

View file

@ -5,7 +5,7 @@
<span class="activity-text"> <span class="activity-text">
<%= @item.created_by.displayName() %> <%- @T( @item.type ) %> <%- @T( @item.object_name ) %><% if @item.title: %> (<%= @item.title %>)<% end %> <%= @item.created_by.displayName() %> <%- @T( @item.type ) %> <%- @T( @item.object_name ) %><% if @item.title: %> (<%= @item.title %>)<% end %>
</span> </span>
<span class="activity-time humanTimeFromNow" data-time="<%- @item.created_at %>">?</span> <span class="activity-time humanTimeFromNow" data-time="<%- @item.created_at %>" data-tooltip="<%- @timestamp(@item.created_at) %>"><%- @humanTime(@item.created_at) %></span>
</span> </span>
<span class="activity-icon"> <span class="activity-icon">
<span class="<%- @item.cssIcon %> icon"></span> <span class="<%- @item.cssIcon %> icon"></span>

View file

@ -5,7 +5,7 @@
<% for item in @items: %> <% for item in @items: %>
<span class="user-popover" data-id="<%= item.created_by.id %>"><%= item.created_by.displayName() %></span> - <span class="user-popover" data-id="<%= item.created_by.id %>"><%= item.created_by.displayName() %></span> -
<span class="humanTimeFromNow" data-time="<%- item.created_at %>">?</span> <span class="humanTimeFromNow" data-time="<%- item.created_at %>" data-tooltip="<%- @timestamp(item.created_at) %>"><%- @humanTime(item.created_at) %></span>
<ul> <ul>
<% for content in item.records: %> <% for content in item.records: %>
<li><%- content %></li> <li><%- content %></li>

View file

@ -10,7 +10,7 @@
</div> </div>
<div class="task-text"> <div class="task-text">
<a class="name ticket-popover" data-id="<%- item.id %>" href="#ticket/zoom/<%= item.id %>"><%= item.title %></a> <a class="name ticket-popover" data-id="<%- item.id %>" href="#ticket/zoom/<%= item.id %>"><%= item.title %></a>
<div class="time humanTimeFromNow" data-time="<%- item.created_at %>"></div> <div class="time humanTimeFromNow" data-time="<%- item.created_at %>" data-tooltip="<%- @timestamp(item.created_at) %>"><%- @humanTime(item.created_at) %></div>
</div> </div>
<div class="sidebar-list-item-delete js-delete" data-object="Ticket" data-object-id="<%= item.id %>" data-link-type="<%= type %>" data-type="remove"> <div class="sidebar-list-item-delete js-delete" data-object="Ticket" data-object-id="<%= item.id %>" data-link-type="<%= type %>" data-type="remove">
<svg class="icon icon-diagonal-cross"><use xlink:href="#icon-diagonal-cross" /></svg> <svg class="icon icon-diagonal-cross"><use xlink:href="#icon-diagonal-cross" /></svg>

View file

@ -18,8 +18,8 @@
<td><% if session.data.user: %><%= session.data.user.displayName() %><% end %></td> <td><% if session.data.user: %><%= session.data.user.displayName() %><% end %></td>
<td title="<%= session.data.user_agent %>"><%= session.data.user_agent %></td> <td title="<%= session.data.user_agent %>"><%= session.data.user_agent %></td>
<td title="<%= session.data.remote_id %>"><% if session.data.geo && session.data.geo.country_name: %><%= session.data.geo.country_name %> <%= session.data.geo.city_name %><% else: %><%= session.data.remote_id %><% end %></td> <td title="<%= session.data.remote_id %>"><% if session.data.geo && session.data.geo.country_name: %><%= session.data.geo.country_name %> <%= session.data.geo.city_name %><% else: %><%= session.data.remote_id %><% end %></td>
<td><span class="humanTimeFromNow" data-time="<%- session.created_at %>">?</span></td> <td><span class="humanTimeFromNow" data-time="<%- session.created_at %>" data-tooltip="<%- @timestamp(session.created_at) %>"><%- @humanTime(session.created_at) %></span></td>
<td><span class="humanTimeFromNow" data-time="<%- session.updated_at %>">?</span></td> <td><span class="humanTimeFromNow" data-time="<%- session.updated_at %>" data-tooltip="<%- @timestamp(session.updated_at) %>"><%- @humanTime(session.updated_at) %></span></td>
<td><a href="#" data-session-id="<%- session.id %>" data-type="delete" title="<%- @Ti('Delete') %>"><svg class="icon-trash" data-type="destroy"><use xlink:href="#icon-trash"></use></svg></a></td> <td><a href="#" data-session-id="<%- session.id %>" data-type="delete" title="<%- @Ti('Delete') %>"><svg class="icon-trash" data-type="destroy"><use xlink:href="#icon-trash"></use></svg></a></td>
</tr> </tr>
<% end %> <% end %>

View file

@ -82,4 +82,4 @@
<div class="js-article-actions"></div> <div class="js-article-actions"></div>
<small class="task-subline zIndex-1"><time class="humanTimeFromNow" data-time="<%- @article.created_at %>">?</time></small> <small class="task-subline zIndex-1"><time class="humanTimeFromNow" data-time="<%- @article.created_at %>" data-tooltip="<%- @timestamp(@article.created_at) %>x"><%- @humanTime(@article.created_at) %>x</time></small>

View file

@ -1,3 +1,3 @@
<small class="task-subline"> <small class="task-subline">
<%- @C('ticket_hook') %> <span class="ticket-number"><%- @ticket.number %></span> - <%- @T('created') %> <span class="humanTimeFromNow" data-time="<%- @ticket.created_at %>">?</span> <% if !@isCustomer && @ticket.escalation_time: %> - <%- @T('escalation') %> <span class="humanTimeFromNow escalation" data-time="<%- @ticket.escalation_time %>">?</span><% end %> <%- @C('ticket_hook') %> <span class="ticket-number"><%- @ticket.number %></span> - <%- @T('created') %> <span class="humanTimeFromNow" data-time="<%- @ticket.created_at %>" data-tooltip="<%- @timestamp(@ticket.created_at) %>"><%- @humanTime(@ticket.created_at) %></span> <% if !@isCustomer && @ticket.escalation_time: %> - <%- @T('escalation') %> <span class="humanTimeFromNow escalation" data-time="<%- @ticket.escalation_time %>" data-tooltip="<%- @timestamp(@ticket.escalation_time) %>"><%- @humanTime(@ticket.escalation_time, true) %></span><% end %>
</small> </small>

View file

@ -9,7 +9,7 @@
<span class="activity-text"> <span class="activity-text">
<%= item.created_by.displayName() %> <%- @T( item.type ) %> <%- @T( item.object_name ) %><% if item.title: %> (<%= item.title %>)<% end %> <%= item.created_by.displayName() %> <%- @T( item.type ) %> <%- @T( item.object_name ) %><% if item.title: %> (<%= item.title %>)<% end %>
</span> </span>
<span class="activity-time humanTimeFromNow" data-time="<%- item.created_at %>">?</span> <span class="activity-time humanTimeFromNow" data-time="<%- item.created_at %>" data-tooltip="<%- @timestamp(item.created_at) %>"><%- @humanTime(item.created_at) %></span>
</span> </span>
</a> </a>
</div> </div>

View file

@ -9,7 +9,7 @@
</div> </div>
<div class="task-text"> <div class="task-text">
<a class="name ticket-popover" data-id="<%- ticket_id %>" href="<%- ticket.uiUrl() %>"><%= ticket.title %></a> <a class="name ticket-popover" data-id="<%- ticket_id %>" href="<%- ticket.uiUrl() %>"><%= ticket.title %></a>
<div class="time humanTimeFromNow" data-time="<%- ticket.created_at %>"></div> <div class="time humanTimeFromNow" data-time="<%- ticket.created_at %>" data-tooltip="<%- @timestamp(ticket.created_at) %>"><%- @humanTime(ticket.created_at) %></div>
</div> </div>
</li> </li>
<% end %> <% end %>