Fixed issue #2204 - Max size of tabs is not recognised

This commit is contained in:
Martin Edenhofer 2018-08-22 23:17:41 +02:00
parent 4dec6209dc
commit 61b1a8733f
4 changed files with 94 additions and 19 deletions

View file

@ -1,9 +1,10 @@
class App.TestController1 extends App.Controller
constructor: ->
super
@showState = false
@hideState = false
@activeState = false
@showState = false
@hideState = false
@activeState = false
@changedState ||= false
@render()
meta: ->
@ -21,6 +22,9 @@ class App.TestController1 extends App.Controller
@activeState = state
@render()
changed: =>
@changedState
render: ->
@html "<div>some test controller message:'#{@message}',show:'#{@showState}',hide:'#{@hideState}',active:'#{@activeState}'</div>"

View file

@ -83,6 +83,18 @@ class App.TaskManager
return if !_instance
_instance.preferencesTrigger(key)
@tasksAutoCleanupDelayTime: (key) ->
return if !_instance
if !key
return _instance.tasksAutoCleanupDelayTime
_instance.tasksAutoCleanupDelayTime = key
@tasksAutoCleanupTaskMax: (key) ->
return if !_instance
if !key
return _instance.maxTaskCount
_instance.maxTaskCount = key
class _taskManagerSingleton extends App.Controller
@include App.LogInclude
@ -108,9 +120,11 @@ class _taskManagerSingleton extends App.Controller
@tasksToUpdate = {}
@tasksPreferences = {}
@tasksPreferencesCallbacks = {}
@tasksAutoCleanupDelayTime = 12000
@activeTaskHistory = []
@queue = []
@queueRunning = false
@maxTaskCount = 30
all: ->
@ -599,7 +613,7 @@ class _taskManagerSingleton extends App.Controller
tasksAutoCleanupDelay: =>
delay = =>
@tasksAutoCleanup()
App.Delay.set(delay, 12000, 'task-autocleanup', undefined, true)
App.Delay.set(delay, @tasksAutoCleanupDelayTime, 'task-autocleanup', undefined, true)
tasksAutoCleanup: =>
@ -607,13 +621,19 @@ class _taskManagerSingleton extends App.Controller
currentTaskCount = =>
Object.keys(@allTasksByKey).length
maxTaskCount = 30
if currentTaskCount() > maxTaskCount
for task in App.Taskbar.search(sortBy:'updated_at', order:'ASC')
if currentTaskCount() > maxTaskCount
if currentTaskCount() > @maxTaskCount
if @offlineModus
tasks = @all()
else
tasks = App.Taskbar.search(sortBy:'updated_at', order:'ASC')
for task in tasks
if currentTaskCount() > @maxTaskCount
if !task.active
if _.isEmpty(task.state) || (_.isEmpty(task.state.ticket) && _.isEmpty(task.state.article))
@log 'notice', "More then #{maxTaskCount} tasks open, close oldest untouched task #{task.key}"
worker = App.TaskManager.worker(task.key)
if worker
if worker.changed && worker.changed()
continue
@log 'notice', "More then #{@maxTaskCount} tasks open, close oldest untouched task #{task.key}"
@remove(task.key)
tasksInitial: =>

View file

@ -40,7 +40,6 @@ test( "taskbar basic tests", function() {
deepEqual(task.state, 'abc')
deepEqual(task.params, { "a": 12 })
App.TaskManager.execute({
key: 'TestKey2',
controller: 'TestController1',
@ -258,12 +257,60 @@ test( "taskbar basic tests", function() {
equal(App.TaskManager.nextTaskUrl(), false)
equal(App.TaskManager.nextTaskUrl(), false)
// destroy task bar
App.TaskManager.reset()
// check max tabs
var times = 5;
App.TaskManager.tasksAutoCleanupDelayTime(200)
App.TaskManager.tasksAutoCleanupTaskMax(3)
// check if any taskar exists
equal($('#taskbars .content').length, 0, "check available active contents")
for(var i=0; i < times; i++){
App.TaskManager.execute({
key: 'TestKeyLoop' + i,
controller: 'TestController1',
params: {
message: "#" + i,
},
show: true,
persistent: false,
})
}
equal(App.TaskManager.all().length, 5)
})
App.Delay.set(function() {
test( "taskbar check max tabs 2", function() {
equal(App.TaskManager.all().length, 3)
var times = 5;
for(var i=0; i < times; i++){
App.TaskManager.execute({
key: 'TestKeyLoop2' + i,
controller: 'TestController1',
params: {
message: "#" + i,
changedState: true
},
show: true,
persistent: false,
})
}
equal(App.TaskManager.all().length, 8)
})
}, 1000);
App.Delay.set(function() {
test( "taskbar check max tabs 5", function() {
equal(App.TaskManager.all().length, 5)
// destroy task bar
App.TaskManager.reset()
// check if any taskar exists
equal($('#taskbars .content').length, 0, "check available active contents")
})
}, 2000);
}

View file

@ -5,10 +5,11 @@ class AAbUnitTest < TestCase
def test_core
@browser = browser_instance
location(url: browser_url + '/tests_core')
sleep 5
watch_for(
css: '.result',
value: 'Tests completed',
timeout: 8,
timeout: 4,
)
match(
css: '.result .failed',
@ -30,10 +31,11 @@ class AAbUnitTest < TestCase
)
location(url: browser_url + '/tests_model')
sleep 5
watch_for(
css: '.result',
value: 'Tests completed',
timeout: 8,
timeout: 3,
)
match(
css: '.result .failed',
@ -77,10 +79,11 @@ class AAbUnitTest < TestCase
def test_form
@browser = browser_instance
location(url: browser_url + '/tests_form')
sleep 5
watch_for(
css: '.result',
value: 'Tests completed',
timeout: 8,
timeout: 2,
)
match(
css: '.result .failed',
@ -212,10 +215,11 @@ class AAbUnitTest < TestCase
)
location(url: browser_url + '/tests_taskbar')
sleep 5
watch_for(
css: '.result',
value: 'Tests completed',
timeout: 8,
timeout: 3,
)
match(
css: '.result .failed',