X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f2cf5a532e7dee1ab68948db89272a0e2579e781..6346a7c4c0cb5d7e8c5f01392b6cc64d329b68ec:/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 0a7fc25209..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,88 +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 = jobGraphData.length - 1; i >= 0; i-- ) { - if( jobGraphData[i]['t'] === timestamp ) { - found = true; - jobGraphData[i][series] = scaledDatum; - break; - } else if( jobGraphData[i]['t'] < timestamp ) { - // we've gone far enough back in time and this data is supposed to be sorted - break; - } - } - if(!found) { - i += 1; - var entry = { 't': timestamp }; - entry[series] = scaledDatum; - jobGraphData.splice( i, 0, 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