Performance improvements (moved from interval to on demand).
This commit is contained in:
parent
19e65367c0
commit
dfdfb15d43
4 changed files with 59 additions and 33 deletions
|
@ -22,7 +22,5 @@ class ProfileRouter extends App.ControllerPermanent
|
||||||
App.Config.set('profile', ProfileRouter, 'Routes')
|
App.Config.set('profile', ProfileRouter, 'Routes')
|
||||||
App.Config.set('profile/:target', ProfileRouter, 'Routes')
|
App.Config.set('profile/:target', ProfileRouter, 'Routes')
|
||||||
|
|
||||||
App.Config.set('Profile', { controller: 'Profile', permission: ['user_preferences.*'] }, 'permanentTask')
|
|
||||||
|
|
||||||
App.Config.set('Profile', { prio: 1000, name: 'Profile', target: '#profile' }, 'NavBarProfile')
|
App.Config.set('Profile', { prio: 1000, name: 'Profile', target: '#profile' }, 'NavBarProfile')
|
||||||
App.Config.set('Profile', { prio: 1700, parent: '#current_user', name: 'Profile', target: '#profile', translate: true }, 'NavBarRight')
|
App.Config.set('Profile', { prio: 1700, parent: '#current_user', name: 'Profile', target: '#profile', translate: true }, 'NavBarRight')
|
||||||
|
|
|
@ -30,6 +30,16 @@ class App.Ajax
|
||||||
_instance ?= new _ajaxSingleton
|
_instance ?= new _ajaxSingleton
|
||||||
_instance.abortAll()
|
_instance.abortAll()
|
||||||
|
|
||||||
|
@queue: ->
|
||||||
|
if _instance == undefined
|
||||||
|
_instance ?= new _ajaxSingleton
|
||||||
|
_instance.queue()
|
||||||
|
|
||||||
|
@current: ->
|
||||||
|
if _instance == undefined
|
||||||
|
_instance ?= new _ajaxSingleton
|
||||||
|
_instance.current()
|
||||||
|
|
||||||
# The actual Singleton class
|
# The actual Singleton class
|
||||||
class _ajaxSingleton
|
class _ajaxSingleton
|
||||||
defaults:
|
defaults:
|
||||||
|
@ -91,24 +101,24 @@ class _ajaxSingleton
|
||||||
data = $.extend({}, @defaults, params)
|
data = $.extend({}, @defaults, params)
|
||||||
|
|
||||||
# execute call with id, clear old call first if exists
|
# execute call with id, clear old call first if exists
|
||||||
if params['id']
|
if data['id']
|
||||||
@abort(params['id'])
|
@abort(data['id'])
|
||||||
@addCurrentRequest(params['id'], data)
|
@addCurrentRequest(data['id'], data)
|
||||||
return params['id']
|
return data['id']
|
||||||
|
|
||||||
# generate a uniq rand id
|
# generate a uniq rand id
|
||||||
params['id'] = "rand-#{new Date().getTime()}-#{Math.floor(Math.random() * 99999)}"
|
data['id'] = "rand-#{new Date().getTime()}-#{Math.floor(Math.random() * 99999)}"
|
||||||
|
|
||||||
# queue request
|
# queue request
|
||||||
if params['queue']
|
if data['queue']
|
||||||
@queueList.push data
|
@queueList.push data
|
||||||
if !@queueRunning
|
if !@queueRunning
|
||||||
@runNextInQueue()
|
@runNextInQueue()
|
||||||
|
|
||||||
# execute request
|
# execute request
|
||||||
else
|
else
|
||||||
@addCurrentRequest(params['id'], data)
|
@addCurrentRequest(data['id'], data)
|
||||||
params['id']
|
data['id']
|
||||||
|
|
||||||
addCurrentRequest: (id, data, queueRunning) =>
|
addCurrentRequest: (id, data, queueRunning) =>
|
||||||
data.complete = =>
|
data.complete = =>
|
||||||
|
@ -154,6 +164,12 @@ class _ajaxSingleton
|
||||||
data = @queueList.shift()
|
data = @queueList.shift()
|
||||||
@addCurrentRequest(data['id'], data, true)
|
@addCurrentRequest(data['id'], data, true)
|
||||||
|
|
||||||
|
queue: =>
|
||||||
|
@queueList
|
||||||
|
|
||||||
|
current: =>
|
||||||
|
@currentRequest
|
||||||
|
|
||||||
_show_spinner: =>
|
_show_spinner: =>
|
||||||
@count++
|
@count++
|
||||||
$('.spinner').show()
|
$('.spinner').show()
|
||||||
|
|
|
@ -83,9 +83,6 @@ class _taskManagerSingleton extends App.Controller
|
||||||
@offlineModus = params.offlineModus
|
@offlineModus = params.offlineModus
|
||||||
@tasksInitial()
|
@tasksInitial()
|
||||||
|
|
||||||
# send updates to server
|
|
||||||
App.Interval.set(@taskUpdateLoop, 3000, 'check_update_to_server_pending', 'task')
|
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
@domStore = {}
|
@domStore = {}
|
||||||
@shownStore = {}
|
@shownStore = {}
|
||||||
|
@ -220,7 +217,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
|
|
||||||
# empty static content if task is shown
|
# empty static content if task is shown
|
||||||
if params.show
|
if params.show
|
||||||
@el.find('#content').empty()
|
@$('#content').empty()
|
||||||
|
|
||||||
# set all tasks to active false, only new/selected one to active
|
# set all tasks to active false, only new/selected one to active
|
||||||
if params.show
|
if params.show
|
||||||
|
@ -279,7 +276,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
if key isnt thisKey
|
if key isnt thisKey
|
||||||
if @shownStore[key] isnt false
|
if @shownStore[key] isnt false
|
||||||
@hide(key)
|
@hide(key)
|
||||||
$('#content').addClass('hide')
|
@$('#content').addClass('hide')
|
||||||
|
|
||||||
for key of @workers
|
for key of @workers
|
||||||
if key is thisKey
|
if key is thisKey
|
||||||
|
@ -292,18 +289,21 @@ class _taskManagerSingleton extends App.Controller
|
||||||
|
|
||||||
domKey = @domID(key)
|
domKey = @domID(key)
|
||||||
domStoreItem = @domStore[domKey]
|
domStoreItem = @domStore[domKey]
|
||||||
localEl = domStoreItem.el
|
if !@$("##{domKey}").get(0) && domStoreItem && domStoreItem.el
|
||||||
if !@$("##{domKey}").get(0) && localEl
|
@el.append(domStoreItem.el)
|
||||||
@el.append(localEl)
|
@$("##{domKey}").removeClass('hide').addClass('active')
|
||||||
@$("##{domKey}").removeClass('hide').addClass('active')
|
|
||||||
|
if controller
|
||||||
|
|
||||||
|
# set position of view
|
||||||
|
if domStoreItem.position
|
||||||
|
controller.setPosition(domStoreItem.position)
|
||||||
|
|
||||||
|
else
|
||||||
|
@$("##{domKey}").removeClass('hide').addClass('active')
|
||||||
|
|
||||||
if controller
|
if controller
|
||||||
|
|
||||||
# set position of view
|
|
||||||
position = @domStore[@domID(key)].position
|
|
||||||
if position
|
|
||||||
controller.setPosition(position)
|
|
||||||
|
|
||||||
# set controller state to active
|
# set controller state to active
|
||||||
if controller.active && _.isFunction(controller.active)
|
if controller.active && _.isFunction(controller.active)
|
||||||
controller.active(true)
|
controller.active(true)
|
||||||
|
@ -319,17 +319,18 @@ class _taskManagerSingleton extends App.Controller
|
||||||
controller = @workers[ key ]
|
controller = @workers[ key ]
|
||||||
@shownStore[key] = false
|
@shownStore[key] = false
|
||||||
|
|
||||||
if @$("##{@domID(key)}").get(0)
|
element = @$("##{@domID(key)}")
|
||||||
|
if element.get(0)
|
||||||
domKey = @domID(key)
|
domKey = @domID(key)
|
||||||
domStoreItem = @domStore[domKey]
|
domStoreItem = @domStore[domKey]
|
||||||
|
|
||||||
if controller && _.isFunction(controller.currentPosition)
|
if controller && _.isFunction(controller.currentPosition)
|
||||||
position = controller.currentPosition()
|
position = controller.currentPosition()
|
||||||
domStoreItem.position = position
|
domStoreItem.position = position
|
||||||
@$("##{@domID(key)}").addClass('hide').removeClass('active')
|
element.addClass('hide').removeClass('active')
|
||||||
domStoreItem.el = @$("##{@domID(key)}").detach()
|
domStoreItem.el = element.detach()
|
||||||
else
|
else
|
||||||
@$("##{@domID(key)}").addClass('hide').removeClass('active')
|
element.addClass('hide').removeClass('active')
|
||||||
|
|
||||||
return false if !controller
|
return false if !controller
|
||||||
|
|
||||||
|
@ -423,6 +424,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
if localDomStore.el
|
if localDomStore.el
|
||||||
$('#app').append("<div id=\"#{domKey}_trash\" class=\"hide\"></div>")
|
$('#app').append("<div id=\"#{domKey}_trash\" class=\"hide\"></div>")
|
||||||
$("#app ##{domKey}_trash").append(localDomStore.el).remove()
|
$("#app ##{domKey}_trash").append(localDomStore.el).remove()
|
||||||
|
localDomStore.el = undefined
|
||||||
localDomStore = undefined
|
localDomStore = undefined
|
||||||
delete @domStore[@domID(key)]
|
delete @domStore[@domID(key)]
|
||||||
worker = @workers[key]
|
worker = @workers[key]
|
||||||
|
@ -430,8 +432,9 @@ class _taskManagerSingleton extends App.Controller
|
||||||
worker = undefined
|
worker = undefined
|
||||||
delete @workers[key]
|
delete @workers[key]
|
||||||
try
|
try
|
||||||
@$("##{@domID(key)}").html('')
|
element = @$("##{@domID(key)}")
|
||||||
@$("##{@domID(key)}").remove()
|
element.html('')
|
||||||
|
element.remove()
|
||||||
catch
|
catch
|
||||||
@log 'notice', "invalid key '#{key}'"
|
@log 'notice', "invalid key '#{key}'"
|
||||||
|
|
||||||
|
@ -484,6 +487,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
taskUpdate: (task, mute = false) ->
|
taskUpdate: (task, mute = false) ->
|
||||||
@log 'debug', 'UPDATE task', task, mute
|
@log 'debug', 'UPDATE task', task, mute
|
||||||
@tasksToUpdate[ task.key ] = 'toUpdate'
|
@tasksToUpdate[ task.key ] = 'toUpdate'
|
||||||
|
@taskUpdateTrigger()
|
||||||
return if mute
|
return if mute
|
||||||
@touch(task.key)
|
@touch(task.key)
|
||||||
|
|
||||||
|
@ -498,7 +502,12 @@ class _taskManagerSingleton extends App.Controller
|
||||||
@title task.meta.title
|
@title task.meta.title
|
||||||
|
|
||||||
App.Event.trigger('taskUpdate', [task])
|
App.Event.trigger('taskUpdate', [task])
|
||||||
App.Delay.set(delay, 20, "task-#{key}")
|
App.Delay.set(delay, 20, "task-#{key}", undefined)
|
||||||
|
|
||||||
|
taskUpdateTrigger: =>
|
||||||
|
|
||||||
|
# send updates to server
|
||||||
|
App.Delay.set(@taskUpdateLoop, 2000, 'check_update_to_server_pending', 'task', true)
|
||||||
|
|
||||||
taskUpdateLoop: =>
|
taskUpdateLoop: =>
|
||||||
return if @offlineModus
|
return if @offlineModus
|
||||||
|
@ -531,6 +540,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
800
|
800
|
||||||
undefined
|
undefined
|
||||||
'task'
|
'task'
|
||||||
|
true
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -544,7 +554,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
tasksAutoCleanupDelay: =>
|
tasksAutoCleanupDelay: =>
|
||||||
delay = =>
|
delay = =>
|
||||||
@tasksAutoCleanup()
|
@tasksAutoCleanup()
|
||||||
App.Delay.set(delay, 10000, 'task-autocleanup')
|
App.Delay.set(delay, 12000, 'task-autocleanup', undefined, true)
|
||||||
|
|
||||||
tasksAutoCleanup: =>
|
tasksAutoCleanup: =>
|
||||||
|
|
||||||
|
@ -598,6 +608,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
taskCount * 350
|
taskCount * 350
|
||||||
undefined
|
undefined
|
||||||
'task'
|
'task'
|
||||||
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
# initial load of taskbar collection
|
# initial load of taskbar collection
|
||||||
|
@ -617,6 +628,7 @@ class _taskManagerSingleton extends App.Controller
|
||||||
taskCount * 350
|
taskCount * 350
|
||||||
undefined
|
undefined
|
||||||
'task'
|
'task'
|
||||||
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
App.Event.trigger 'taskbar:ready'
|
App.Event.trigger 'taskbar:ready'
|
||||||
|
|
|
@ -74,7 +74,7 @@ class TaskbarTaskTest < TestCase
|
||||||
css: '.active .newTicket [data-name="body"]',
|
css: '.active .newTicket [data-name="body"]',
|
||||||
value: 'OUTBOUND BODY TEST#1',
|
value: 'OUTBOUND BODY TEST#1',
|
||||||
)
|
)
|
||||||
sleep 2
|
sleep 3
|
||||||
|
|
||||||
logout()
|
logout()
|
||||||
sleep 4
|
sleep 4
|
||||||
|
|
Loading…
Reference in a new issue