X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/cb03f98d530626bc31c55acdcf6e60f9596fc759..163c8f8750193b791eb62f5a8d73dc44a006b69e:/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 8f9728afbf..e576ba97a3 100644 --- a/apps/workbench/app/assets/javascripts/event_log.js +++ b/apps/workbench/app/assets/javascripts/event_log.js @@ -1,3 +1,7 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + /* * This js establishes a websockets connection with the API Server. */ @@ -56,85 +60,3 @@ $(document).on('ajax:complete ready', function() { subscribeToEventLog(); } }); - - -function processLogLineForChart( logLine ) { - var recreate = false; - var rescale = false; - // TODO: make this more robust: anything could go wrong in here - var match = logLine.match(/(.*)crunchstat:(.*)-- interval(.*)/); - if( match ) { - var series = match[2].trim().split(' ')[0]; - if( $.inArray( series, jobGraphSeries) < 0 ) { - jobGraphSeries.push(series); - jobGraphMaxima[series] = null; - recreate = true; - } - var intervalData = match[3].trim().split(' '); - var dt = parseFloat(intervalData[0]); - var dsum = 0.0; - for(var i=2; i < intervalData.length; i += 2 ) { - dsum += parseFloat(intervalData[i]); - } - var datum = dsum/dt; - if( datum !== 0 && ( jobGraphMaxima[series] === null || jobGraphMaxima[series] < datum ) ) { - // use old maximum to get a scale conversion - var scaleConversion = jobGraphMaxima[series]/datum; - // set new maximum - jobGraphMaxima[series] = datum; - // rescale - $.each( jobGraphData, function( i, entry ) { - if( entry[series] !== null && entry[series] !== undefined ) { - entry[series] *= scaleConversion; - } - }); - } - // scale - // FIXME: what about negative numbers? - var scaledDatum = null; - if( jobGraphMaxima[series] !== null && jobGraphMaxima[series] !== 0 ) { - scaledDatum = datum/jobGraphMaxima[series] - } else { - scaledDatum = datum; - } - // more parsing - var preamble = match[1].trim().split(' '); - var timestamp = preamble[0].replace('_','T'); - // identify x axis point - var found = false; - for( var i = 0; i < jobGraphData.length; i++ ) { - if( jobGraphData[i]['t'] === timestamp ) { - found = true; - break; - } - } - if(found) { - jobGraphData[i][series] = scaledDatum; - } else { - var entry = { 't': timestamp }; - entry[series] = scaledDatum; - jobGraphData.push( entry ); - } - } - return recreate; -} - -$(document).on('arv-log-event', '#log_graph_div', function(event, eventData) { - if( eventData.properties.text ) { - var recreate = processLogLineForChart( eventData.properties.text ); - if( recreate ) { - // series have changed, draw entirely new graph - $('#log_graph_div').html(''); - window.jobGraph = Morris.Line({ - element: 'log_graph_div', - data: jobGraphData, - xkey: 't', - ykeys: jobGraphSeries, - labels: jobGraphSeries - }); - } else { - jobGraph.setData( jobGraphData ); - } - } - -} ); \ No newline at end of file