X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/879e1f31b0165c6abaa35a023ff66400757bb44b..83561af02e156758b09ea771510ad4f9ee506b06:/apps/workbench/app/assets/javascripts/event_log.js diff --git a/apps/workbench/app/assets/javascripts/event_log.js b/apps/workbench/app/assets/javascripts/event_log.js index 0539021d83..8bfa1b0672 100644 --- a/apps/workbench/app/assets/javascripts/event_log.js +++ b/apps/workbench/app/assets/javascripts/event_log.js @@ -2,8 +2,7 @@ * This js establishes a websockets connection with the API Server. */ -/* The subscribe method takes a window element id and object id. - Any log events for that particular object id are sent to that window element. */ +/* Subscribe to websockets event log. Do nothing if already connected. */ function subscribeToEventLog () { // if websockets are not supported by browser, do not subscribe for events websocketsSupported = ('WebSocket' in window); @@ -11,10 +10,10 @@ function subscribeToEventLog () { return; } - // grab websocket connection from window, if one exists + // check if websocket connection is already stored on the window event_log_disp = $(window).data("arv-websocket"); if (event_log_disp == null) { - // create the event log dispatcher + // need to create new websocket and event log dispatcher websocket_url = $('meta[name=arv-websocket-url]').attr("content"); if (websocket_url == null) return; @@ -29,12 +28,13 @@ function subscribeToEventLog () { } } -/* send subscribe message to the websockets server */ +/* Send subscribe message to the websockets server. Without any filters + arguments, this subscribes to all events */ function onEventLogDispatcherOpen(event) { this.send('{"method":"subscribe"}'); } -/* trigger event for all applicable elements waiting for this event */ +/* Trigger event for all applicable elements waiting for this event */ function onEventLogDispatcherMessage(event) { parsedData = JSON.parse(event.data); object_uuid = parsedData.object_uuid; @@ -44,6 +44,8 @@ function onEventLogDispatcherMessage(event) { $(matches).trigger('arv-log-event', event.data); } +/* Automatically connect if there are any elements on the page that want to + received event log events. */ $(document).on('ajax:complete ready', function() { var a = $('.arv-log-event-listener'); if (a.length > 0) {