Fixed logout.

This commit is contained in:
Martin Edenhofer 2016-05-04 22:50:30 +02:00
parent 08c5ca3e62
commit 2e9c6e78ed
6 changed files with 141 additions and 139 deletions

View file

@ -1,21 +1,13 @@
class Index extends App.ControllerContent
constructor: ->
super
@signout()
signout: ->
# remove remote session
App.Auth.logout()
# remove local session
@Session.init()
App.Event.trigger('ui:rerender')
# redirect to login
redirect = =>
@navigate 'login'
@delay redirect, 150
@delay redirect, 100
App.Config.set('logout', Index, 'Routes')
App.Config.set('Logout', { prio: 1800, parent: '#current_user', name: 'Sign out', translate: true, target: '#logout', divider: true, iconClass: 'signout', role: [ 'Agent', 'Customer' ] }, 'NavBarRight')

View file

@ -130,14 +130,13 @@ class App.Auth
App.Event.trigger('auth:login', data.session)
App.Event.trigger('ui:rerender')
App.TaskManager.tasksInitial()
@_logout: (rerender = true) ->
App.Log.debug 'Auth', '_logout'
App.Ajax.abortAll()
# empty session
App.TaskManager.reset()
App.Session.init()
App.Event.trigger('auth')

View file

@ -20,9 +20,6 @@ class App.Run extends App.Controller
# create web socket connection
App.WebSocket.connect()
# init tasks
App.TaskManager.init()
# start frontend time update
@frontendTimeUpdate()

View file

@ -8,45 +8,64 @@ class App.TaskManager
_instance.all()
@allWithMeta: ->
return [] if !_instance
_instance.allWithMeta()
@execute: (params) ->
return if !_instance
_instance.execute(params)
@get: (key) ->
return if !_instance
_instance.get(key)
@update: (key, params) ->
return if !_instance
_instance.update(key, params)
@remove: (key) ->
return if !_instance
_instance.remove(key)
@notify: (key) ->
return if !_instance
_instance.notify(key)
@mute: (key) ->
return if !_instance
_instance.mute(key)
@reorder: (order) ->
return if !_instance
_instance.reorder(order)
@touch: (key) ->
return if !_instance
_instance.touch(key)
@reset: ->
return if !_instance
_instance.reset()
@tasksInitial: ->
if _instance == undefined
_instance ?= new _taskManagerSingleton
_instance.tasksInitial()
@worker: (key) ->
return if !_instance
_instance.worker(key)
@nextTaskUrl: ->
return if !_instance
_instance.nextTaskUrl()
@TaskbarId: ->
return if !_instance
_instance.TaskbarId()
@hideAll: ->
return if !_instance
_instance.showControllerHideOthers()
class _taskManagerSingleton extends App.Controller
@ -61,20 +80,8 @@ class _taskManagerSingleton extends App.Controller
@offlineModus = params.offlineModus
@tasksInitial()
# render on login
App.Event.bind('auth:login', =>
@tasksInitial()
'task'
)
# render on logout
App.Event.bind('auth:logout', =>
@reset()
'task'
)
# send updates to server
App.Interval.set(@taskUpdateLoop, 2500, 'check_update_to_server_pending', 'task')
App.Interval.set(@taskUpdateLoop, 3000, 'check_update_to_server_pending', 'task')
init: ->
@workers = {}
@ -330,6 +337,7 @@ class _taskManagerSingleton extends App.Controller
task = @allTasksByKey[key]
delete @allTasksByKey[key]
return if !task
# rerender taskbar
App.Event.trigger('taskRemove', [task])
@ -502,12 +510,12 @@ class _taskManagerSingleton extends App.Controller
# initial load of permanent tasks
authentication = App.Session.get('id')
permanentTask = App.Config.get('permanentTask')
task_count = 0
taskCount = 0
if permanentTask
for key, config of permanentTask
if !config.authentication || (config.authentication && authentication)
task_count += 1
do (key, config, task_count) =>
taskCount += 1
do (key, config, taskCount) =>
App.Delay.set(
=>
@execute(
@ -518,15 +526,15 @@ class _taskManagerSingleton extends App.Controller
persistent: true
init: true
)
task_count * 450
taskCount * 350
undefined
'task'
)
# initial load of taskbar collection
for key, task of @allTasksByKey
task_count += 1
do (task, task_count) =>
taskCount += 1
do (task, taskCount) =>
App.Delay.set(
=>
@execute(
@ -537,7 +545,7 @@ class _taskManagerSingleton extends App.Controller
persistent: false
init: true
)
task_count * 450
taskCount * 350
undefined
'task'
)

View file

@ -18,15 +18,15 @@ test( "taskbar basic tests", function() {
show: true,
persistent: false,
})
equal( $('#taskbars .content').length, 1, "check available active contents" );
equal( $('#taskbars .content.active').length, 1, "check available active contents" );
equal( $('#taskbars .content.active').text(), "some test controller message:'#1',show:'true',hide:'false',active:'true'", "check active content!" );
equal($('#taskbars .content').length, 1, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#1',show:'true',hide:'false',active:'true'", "check active content!")
// verify
task = App.TaskManager.get('TestKey1')
equal(task.notify, false)
deepEqual(task.state, undefined)
deepEqual( task.params, { "message": "#1" } )
deepEqual(task.params, { "message": "#1", "shown": true })
// update
App.TaskManager.update('TestKey1', { 'state': 'abc' })
@ -49,11 +49,11 @@ test( "taskbar basic tests", function() {
show: true,
persistent: false,
})
equal( $('#taskbars .content').length, 2, "check available active contents" );
equal( $('#taskbars .content.active').length, 1, "check available active contents" );
equal( $('#taskbars .content.active').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'", "check active content!" );
equal($('#taskbars .content').length, 2, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'", "check active content!")
equal( $('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!" );
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
// check task history
equal(App.TaskManager.nextTaskUrl(), '#/some/url/#2')
@ -68,12 +68,12 @@ test( "taskbar basic tests", function() {
show: false,
persistent: false,
})
equal( $('#taskbars .content').length, 3, "check available active contents" );
equal( $('#taskbars .content.active').length, 1, "check available active contents" );
equal( $('#taskbars .content.active').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'" );
equal($('#taskbars .content').length, 3, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'")
equal( $('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'false',hide:'true',active:'false'", "check active content!" );
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'false',hide:'true',active:'false'", "check active content!")
App.TaskManager.execute({
@ -85,13 +85,13 @@ test( "taskbar basic tests", function() {
show: false,
persistent: true,
})
equal( $('#taskbars .content').length, 4, "check available active contents" );
equal( $('#taskbars .content.active').length, 1, "check available active contents" );
equal( $('#taskbars .content.active').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'" );
equal($('#taskbars .content').length, 4, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'")
equal( $('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'false',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey4').text(), "some test controller message:'#4',show:'false',hide:'true',active:'false'", "check active content!" );
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'false',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey4').text(), "some test controller message:'#4',show:'false',hide:'true',active:'false'", "check active content!")
App.TaskManager.execute({
@ -103,14 +103,14 @@ test( "taskbar basic tests", function() {
show: true,
persistent: true,
})
equal( $('#taskbars .content').length, 5, "check available active contents" );
equal( $('#taskbars .content.active').length, 1, "check available active contents" );
equal( $('#taskbars .content.active').text(), "some test controller message:'#5',show:'true',hide:'false',active:'true'" );
equal($('#taskbars .content').length, 5, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#5',show:'true',hide:'false',active:'true'")
equal( $('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'false',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey4').text(), "some test controller message:'#4',show:'false',hide:'true',active:'false'", "check active content!" );
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'false',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey4').text(), "some test controller message:'#4',show:'false',hide:'true',active:'false'", "check active content!")
App.TaskManager.execute({
@ -122,28 +122,28 @@ test( "taskbar basic tests", function() {
show: true,
persistent: false,
})
equal( $('#taskbars .content').length, 6, "check available active contents" );
equal( $('#taskbars .content.active').length, 1, "check available active contents" );
equal( $('#taskbars .content.active').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'" );
equal($('#taskbars .content').length, 6, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'")
equal( $('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'false',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey4').text(), "some test controller message:'#4',show:'false',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!" );
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'false',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey4').text(), "some test controller message:'#4',show:'false',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
// remove task#2
App.TaskManager.remove('TestKey2')
equal( $('#taskbars .content').length, 5, "check available active contents" );
equal( $('#taskbars .content.active').length, 1, "check available active contents" );
equal( $('#taskbars .content.active').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'" );
equal($('#taskbars .content').length, 5, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'")
equal( $('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'false',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey4').text(), "some test controller message:'#4',show:'false',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!" );
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'false',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey4').text(), "some test controller message:'#4',show:'false',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
// activate task#3
App.TaskManager.execute({
@ -155,13 +155,13 @@ test( "taskbar basic tests", function() {
show: true,
persistent: false,
})
equal( $('#taskbars .content').length, 5, "check available active contents" );
equal( $('#taskbars .content.active').length, 1, "check available active contents" );
equal( $('#taskbars .content.active').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'" );
equal($('#taskbars .content').length, 5, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'")
equal( $('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey4').text(), "some test controller message:'#4',show:'false',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!" );
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey4').text(), "some test controller message:'#4',show:'false',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
// activate task#1
@ -174,38 +174,37 @@ test( "taskbar basic tests", function() {
show: true,
persistent: false,
})
equal( $('#taskbars .content').length, 5, "check available active contents" );
equal( $('#taskbars .content.active').length, 1, "check available active contents" );
equal( $('#taskbars .content.active').text(), "some test controller message:'#1',show:'true',hide:'true',active:'true'" );
equal( $('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey4').text(), "some test controller message:'#4',show:'false',hide:'true',active:'false'", "check active content!" );
equal( $('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!" );
equal($('#taskbars .content').length, 5, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#1',show:'true',hide:'true',active:'true'")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey4').text(), "some test controller message:'#4',show:'false',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
// remove task#1
App.TaskManager.remove('TestKey1')
// verify if task#3 is active
equal( $('#taskbars .content').length, 4, "check available active contents" );
equal( $('#taskbars .content.active').length, 0, "check available active contents" );
equal( $('#taskbars .content.active').text(), "" );
equal($('#taskbars .content').length, 4, "check available active contents")
equal($('#taskbars .content.active').length, 0, "check available active contents")
equal($('#taskbars .content.active').text(), "")
// remove task#3
App.TaskManager.remove('TestKey3')
// verify if task#5 is active
equal( $('#taskbars .content').length, 3, "check available active contents" );
equal( $('#taskbars .content.active').length, 0, "check available active contents" );
equal( $('#taskbars .content.active').text(), "" );
equal($('#taskbars .content').length, 3, "check available active contents")
equal($('#taskbars .content.active').length, 0, "check available active contents")
equal($('#taskbars .content.active').text(), "")
// remove task#5 // can not get removed because of permanent task
App.TaskManager.remove('TestKey5')
// verify if task#5 is active
equal( $('#taskbars .content').length, 3, "check available active contents" );
equal( $('#taskbars .content.active').length, 0, "check available active contents" );
equal( $('#taskbars .content.active').text(), "" );
equal($('#taskbars .content').length, 3, "check available active contents")
equal($('#taskbars .content.active').length, 0, "check available active contents")
equal($('#taskbars .content.active').text(), "")
// create task#7
App.TaskManager.execute({
@ -217,17 +216,17 @@ test( "taskbar basic tests", function() {
show: true,
persistent: false,
})
equal( $('#taskbars .content').length, 4, "check available active contents" );
equal( $('#taskbars .content.active').length, 1, "check available active contents" );
equal( $('#taskbars .content.active').text(), "some test controller message:'#7',show:'true',hide:'false',active:'true'", "check active content!" );
equal($('#taskbars .content').length, 4, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#7',show:'true',hide:'false',active:'true'", "check active content!")
// remove task#7
App.TaskManager.remove('TestKey7')
// verify if task#5 is active
equal( $('#taskbars .content').length, 3, "check available active contents" );
equal( $('#taskbars .content.active').length, 0, "check available active contents" );
equal( $('#taskbars .content.active').text(), "" );
equal($('#taskbars .content').length, 3, "check available active contents")
equal($('#taskbars .content.active').length, 0, "check available active contents")
equal($('#taskbars .content.active').text(), "")
// check task history
equal(App.TaskManager.nextTaskUrl(), '#/some/url/#6')
@ -246,7 +245,7 @@ test( "taskbar basic tests", function() {
App.TaskManager.reset()
// check if any taskar exists
equal( $('#taskbars .content').length, 0, "check available active contents" );
equal($('#taskbars .content').length, 0, "check available active contents")
})

View file

@ -110,5 +110,12 @@ class AAbUnitTest < TestCase
css: '.result .failed',
value: '0',
)
location(url: browser_url + '/tests_taskbar')
sleep 4
match(
css: '.result .failed',
value: '0',
)
end
end