Improved permanent task handling (check if controller need authentication first).

This commit is contained in:
Martin Edenhofer 2015-03-01 19:30:14 +01:00
parent 08bc3bda3e
commit 7bf4f3e91c
4 changed files with 36 additions and 39 deletions

View file

@ -1,11 +1,7 @@
class App.Dashboard extends App.Controller class App.Dashboard extends App.Controller
constructor: -> constructor: ->
super super
# check authentication
return if !@authenticate()
if @isRole('Customer') if @isRole('Customer')
@navigate '#' @navigate '#'
return return
@ -158,6 +154,9 @@ class DashboardRouter extends App.ControllerPermanent
constructor: (params) -> constructor: (params) ->
super super
# check authentication
return if !@authenticate()
App.TaskManager.execute( App.TaskManager.execute(
key: 'Dashboard' key: 'Dashboard'
controller: 'Dashboard' controller: 'Dashboard'
@ -166,8 +165,6 @@ class DashboardRouter extends App.ControllerPermanent
persistent: true persistent: true
) )
App.Config.set( 'dashboard', DashboardRouter, 'Routes' ) App.Config.set( 'dashboard', DashboardRouter, 'Routes' )
App.Config.set( 'Dashboard', { prio: 100, parent: '', name: 'Dashboard', target: '#dashboard', role: ['Agent'], class: 'dashboard' }, 'NavBar' ) App.Config.set( 'Dashboard', { prio: 100, parent: '', name: 'Dashboard', target: '#dashboard', role: ['Agent'], class: 'dashboard' }, 'NavBar' )
App.Config.set( 'Dashboard', { controller: 'Dashboard', authentication: true }, 'permanentTask' )
App.Config.set( 'Dashboard', 'Dashboard', 'permanentTask' )

View file

@ -2,9 +2,6 @@ class App.TicketOverview extends App.Controller
constructor: -> constructor: ->
super super
# check authentication
return if !@authenticate()
@render() @render()
render: -> render: ->
@ -515,7 +512,7 @@ class App.OverviewSettings extends App.ControllerModal
constructor: -> constructor: ->
super super
@overview = App.Overview.find(@overview_id) @overview = App.Overview.find(@overview_id)
console.log('overview_id', @overview_id)
@configure_attributes_article = [] @configure_attributes_article = []
if @view_mode is 'd' if @view_mode is 'd'
@configure_attributes_article.push({ @configure_attributes_article.push({
@ -795,6 +792,9 @@ class TicketOverviewRouter extends App.ControllerPermanent
constructor: (params) -> constructor: (params) ->
super super
# check authentication
return if !@authenticate()
# cleanup params # cleanup params
clean_params = clean_params =
view: params.view view: params.view
@ -809,8 +809,5 @@ class TicketOverviewRouter extends App.ControllerPermanent
App.Config.set( 'ticket/view', TicketOverviewRouter, 'Routes' ) App.Config.set( 'ticket/view', TicketOverviewRouter, 'Routes' )
App.Config.set( 'ticket/view/:view', TicketOverviewRouter, 'Routes' ) App.Config.set( 'ticket/view/:view', TicketOverviewRouter, 'Routes' )
#App.Config.set( 'ticket/view/:view/:position/:direction', Router, 'Routes' ) App.Config.set( 'TicketOverview', { controller: 'TicketOverview', authentication: true }, 'permanentTask' )
App.Config.set( 'TicketOverview', 'TicketOverview', 'permanentTask' )
App.Config.set( 'TicketOverview', { prio: 1000, parent: '', name: 'Overviews', target: '#ticket/view', role: ['Agent', 'Customer'], class: 'overviews' }, 'NavBar' ) App.Config.set( 'TicketOverview', { prio: 1000, parent: '', name: 'Overviews', target: '#ticket/view', role: ['Agent', 'Customer'], class: 'overviews' }, 'NavBar' )

View file

@ -80,6 +80,7 @@ class _taskManagerSingleton extends Spine.Module
App.Event.bind( App.Event.bind(
'auth:login' 'auth:login'
=> =>
@reset()
@tasksInitial() @tasksInitial()
'task' 'task'
) )
@ -202,7 +203,7 @@ class _taskManagerSingleton extends Spine.Module
startController: (params) => startController: (params) =>
@log 'debug', 'controller start try...', params #console.log 'debug', 'controller start try...', params
# create clean params # create clean params
params_app = _.clone(params.params) params_app = _.clone(params.params)
@ -444,31 +445,33 @@ class _taskManagerSingleton extends Spine.Module
App.Event.trigger 'taskbar:init' App.Event.trigger 'taskbar:init'
# initial load of permanent tasks # initial load of permanent tasks
task_count = 0 authentication = App.Session.get('id')
permanentTask = App.Config.get( 'permanentTask' ) permanentTask = App.Config.get( 'permanentTask' )
task_count = 0
if permanentTask if permanentTask
for key, callback of permanentTask for key, config of permanentTask
task_count += 1 if !config.authentication || ( config.authentication && authentication )
do (task) => task_count += 1
App.Delay.set( do (key, config, task_count) =>
=> App.Delay.set(
@execute( =>
key: key @execute(
controller: callback key: key
params: {} controller: config.controller
show: false params: {}
persistent: true show: false
init: true persistent: true
) init: true
task_count * 50 )
undefined task_count * 350
'task' undefined
) 'task'
)
# initial load of taskbar collection # initial load of taskbar collection
for task in @allTasks for task in @allTasks
task_count += 1 task_count += 1
do (task) => do (task, task_count) =>
App.Delay.set( App.Delay.set(
=> =>
@execute( @execute(

View file

@ -30,10 +30,10 @@ class AgentTicketOverviewLevel0Test < TestCase
:body => 'overview count test #3', :body => 'overview count test #3',
} }
) )
sleep 6 # till overview is updated
click( :css => '#navigation li.overviews a' ) click( :css => '#navigation li.overviews a' )
click( :css => '.content.active .sidebar a[href="#ticket/view/all_unassigned"]' ) click( :css => '.content.active .sidebar a[href="#ticket/view/all_unassigned"]' )
sleep 10 sleep 2 # till overview is rendered
# select both via bulk action # select both via bulk action
click( click(
@ -62,7 +62,7 @@ class AgentTicketOverviewLevel0Test < TestCase
click( click(
:css => '.active .bulkAction .js-submit', :css => '.active .bulkAction .js-submit',
) )
sleep 6 sleep 8
exists_not( exists_not(
:css => '.active table tr td input[value="' + ticket1[:id] + '"]', :css => '.active table tr td input[value="' + ticket1[:id] + '"]',