Changeset 551 in tmcsimulator for trunk/webapps/common


Ignore:
Timestamp:
12/26/2019 03:14:52 PM (6 years ago)
Author:
jdalbey
Message:

Multi-file commit to implement saving evaluation ratings from einotebook to a log file and merging with unified log. Also fix defect #212. cgi-bin/saveEvals.py cgi-bin/saveRatingsToLog.py common/js/displayutils.js common/js/fileutils.js common/js/revision_number.dat common/unifiedlog.css dynamicdata/CADcomments.log dynamicdata/caddetails.csv dynamicdata cms_messages.json dynamicdata/har_messages.json dynamicdata highway_status.json dynamicdata/ratings.csv dynamicdata/unifiedlog.csv dynamicdata/unifiedlog_final.csv einotebook/roles/index.html einotebook roles/roles.js einotebook/script/index.html einotebook/script scrollframe.js einotebook/scripts/Evaluation.js einotebook/scripts/Event.js mergelogs.bash unifiedlogdisplay.html unifiedlogmonitor.html

Location:
trunk/webapps/common
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/webapps/common/js/displayutils.js

    r386 r551  
    1414} 
    1515 
     16// Load a CSV file and convert to a string of formatted HTML 
     17// @param filename the file containing the CSV input 
     18// @param targetDiv the div element in which the HTML should be placed. 
     19function loadLog(filename, targetDiv) 
     20{ 
     21    // Asynchronous file read of unified log data 
     22    loadJSON("dynamicdata/" + filename, function(response) 
     23    { 
     24        // Format the csv data into an HTML table 
     25        var allRows = response.split(/\r?\n|\r/); 
     26        var table = '<table>'; 
     27        // Put the last log entry at the TOP of the table 
     28        for (var singleRow = allRows.length-1; singleRow >= 0; singleRow--) 
     29        { 
     30            var rowCells = allRows[singleRow].split(','); 
     31            var msg_type = ""; // color white is default 
     32 
     33            // trimming white space in the type field  
     34            // ingore the empty line  
     35            if (rowCells.length > 1)  
     36            { 
     37                rowCells[1] = rowCells[1].trim(); 
     38            } 
     39            var label = String(rowCells[1]); 
     40            var info = String(rowCells[3]).trim(); 
     41            // Implement ticket #190  
     42            // Checking for the type of logging information  
     43            if (label.startsWith("CAD")) { 
     44                msg_type = "class=\"CAD\""; 
     45                if (info.startsWith("Detail")) { 
     46                    msg_type = "class=\"CADdetail\""; 
     47                } 
     48            } else if (label.startsWith("Activity")) { 
     49                msg_type = "class=\"Activity\""; 
     50            //} else if (rowCells[1] == "CMS Activated.") { 
     51            } else if (label.startsWith("CMS")) { 
     52                msg_type = "class=\"CMS\""; 
     53            } else if (label.startsWith("Eval")) { 
     54                msg_type = "class=\"Evaluation\""; 
     55            }  
     56 
     57            // add the message type class to that row  
     58            table += '<tr ' + msg_type + '>'; 
     59            for (var rowCell = 0; rowCell < rowCells.length; rowCell++) 
     60            { 
     61                table += '<td>'; 
     62                table += rowCells[rowCell]; 
     63                table += '</td>'; 
     64            } 
     65            table += '</tr>'; 
     66        } 
     67        table += '</table>'; 
     68        targetDiv.innerHTML = table; 
     69    } 
     70    ); 
     71} 
  • trunk/webapps/common/js/fileutils.js

    r442 r551  
    1     // Load the dynamic json file for highways, etc. 
    2     // Ref: https://codepen.io/KryptoniteDove/post/load-json-file-locally-using-pure-javascript 
    3     function loadJSON(inFile, callback) 
     1// Load the dynamic json file for highways, etc. 
     2// Ref: https://codepen.io/KryptoniteDove/post/load-json-file-locally-using-pure-javascript 
     3function loadJSON(inFile, callback) 
     4{ 
     5    var xobj = new XMLHttpRequest(); 
     6    // Assume XML unless filename ends with .json 
     7    if (inFile.endsWith(".json")) 
    48    { 
    5         var xobj = new XMLHttpRequest(); 
    6         // Assume XML unless filename ends with .json 
    7         if (inFile.endsWith(".json")) 
     9        xobj.overrideMimeType("application/json"); 
     10    } 
     11    if (inFile.endsWith(".csv")) 
     12    { 
     13        xobj.overrideMimeType("text/csv"); 
     14    } 
     15    xobj.open('GET', inFile, true); 
     16    xobj.onreadystatechange = function() 
     17    { 
     18        if (xobj.readyState == 4 && xobj.status == "200") 
    819        { 
    9             xobj.overrideMimeType("application/json"); 
     20            callback(xobj.responseText); 
    1021        } 
    11         if (inFile.endsWith(".csv")) 
    12         { 
    13             xobj.overrideMimeType("text/csv"); 
    14         } 
    15         xobj.open('GET', inFile, true); 
    16         xobj.onreadystatechange = function() 
    17         { 
    18             if (xobj.readyState == 4 && xobj.status == "200") 
    19             { 
    20                 callback(xobj.responseText); 
    21             } 
    22         }; 
    23         // We want ajax to ignore any cached responses 
    24         xobj.setRequestHeader('If-Modified-Since', 'Sat, 01 Jan 2000 01:01:01 GMT') 
    25         xobj.send(null); 
     22    }; 
     23    // We want ajax to ignore any cached responses 
     24    xobj.setRequestHeader('If-Modified-Since', 'Sat, 01 Jan 2000 01:01:01 GMT') 
     25    xobj.send(null); 
     26} 
     27 
     28/* Retrieve URL parameters passed to a web page 
     29   @return a dictionary of key/value pairs 
     30*/ 
     31function getQueryParms() 
     32{ 
     33    var items = {}; 
     34    var query = window.location.search.substring(1); 
     35    var parms = query.split("&"); 
     36    // Examine each parameter 
     37    for (var i = 0, max = parms.length; i < max; i++) 
     38    { 
     39        // check for trailing & with no param 
     40        if (parms[i] === "")  
     41            continue; // skip it 
     42 
     43        var param = parms[i].split("="); 
     44        // If it's valid add it to dictionary 
     45        items[decodeURIComponent(param[0])] = decodeURIComponent(param[1] || ""); 
    2646    } 
    27  
     47    return items 
     48} 
  • trunk/webapps/common/js/revision_number.dat

    r547 r551  
    11 
    2     var revisionNumber = "540"; 
     2    var revisionNumber = "549"; 
    33     
Note: See TracChangeset for help on using the changeset viewer.