From 4527124108cc3e9922a11397175ee9fced96566c Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 12 Jul 2014 15:21:01 +0200 Subject: [PATCH] Moved to own file for session taken over feature, because of non longer existing task bar widget. --- .../controllers/widget/maintenance.js.coffee | 2 +- .../widget/session_taken_over.js.coffee | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/app/controllers/widget/session_taken_over.js.coffee diff --git a/app/assets/javascripts/app/controllers/widget/maintenance.js.coffee b/app/assets/javascripts/app/controllers/widget/maintenance.js.coffee index 125a5f127..53aae0fff 100644 --- a/app/assets/javascripts/app/controllers/widget/maintenance.js.coffee +++ b/app/assets/javascripts/app/controllers/widget/maintenance.js.coffee @@ -31,4 +31,4 @@ class Message extends App.ControllerModal forceReload: message.reload ) -App.Config.set( 'maintenance', Widget, 'Widgets' ) +App.Config.set( 'maintenance', Widget, 'Widgets' ) \ No newline at end of file diff --git a/app/assets/javascripts/app/controllers/widget/session_taken_over.js.coffee b/app/assets/javascripts/app/controllers/widget/session_taken_over.js.coffee new file mode 100644 index 000000000..a52156b8d --- /dev/null +++ b/app/assets/javascripts/app/controllers/widget/session_taken_over.js.coffee @@ -0,0 +1,54 @@ +class Widget extends App.Controller + + constructor: -> + super + @bind() + + bind: -> + + # only do take over check after spool messages are finised + App.Event.bind( + 'spool:sent' + => + @spoolSent = true + + # broadcast to other browser instance + App.WebSocket.send( + action: 'broadcast' + event: 'session:takeover' + spool: true + recipient: + user_id: [ App.Session.get( 'id' ) ] + data: + taskbar_id: App.TaskManager.TaskbarId() + ) + 'maintenance' + ) + + # session take over message + App.Event.bind( + 'session:takeover' + (data) => + + # only if spool messages are already sent + return if !@spoolSent + + # check if error message is already shown + if !@error + + # only if new client id isnt own client id + if data.taskbar_id isnt App.TaskManager.TaskbarId() + @error = new App.SessionMessage( + title: 'Session' + message: 'Session taken over... please reload page or work with other browser window.' + keyboard: false + backdrop: true + close: true + button: 'Reload application' + forceReload: true + ) + @disconnectClient() + 'maintenance' + ) + +App.Config.set( 'session_taken_over', Widget, 'Widgets' ) \ No newline at end of file