@@ -40,6 +40,7 @@ var profileOwner;
4040/* Save JobHistory data here */
4141var historyData = { } ;
4242var runningData = { } ;
43+ var unStartedJobs = [ ] ;
4344
4445/*
4546 Running, stopped, suspended etc.
@@ -1163,24 +1164,43 @@ window.onload = function () {
11631164
11641165 var longJobNames = [ ] ;
11651166 data . forEach ( function ( job , index ) {
1166- var header = job [ 'header' ] ;
1167- var updates = job [ 'updates' ] ;
1168- var longName = header [ 'jobName' ] + '-' + header [ 'jobInstance' ] ;
1169- var saveData = { } ;
1170-
1171- console . log ( "Creating listing for job: " + index + " (" + longName + ")" ) ;
1172- longJobNames . push ( longName ) ;
1173-
1174- // Save the data for later use. It should consist of two arrays,
1175- // 1st with just the job header and 2nd with an array of status updates
1176- // (for a running job, updates will periodically be added to
1177- saveData [ 'header' ] = [ header ] ;
1178- saveData [ 'updates' ] = updates ;
1179- runningData [ longName ] = saveData ;
1180- //console.log("XXX " + JSON.stringify(runningData[longName]));
1167+ console . log ( "createRunningJobsList() handling job: " + index ) ;
1168+
1169+ var longName ;
1170+ if ( job [ 'waiting' ] ) {
1171+ longName = job [ 'jobData' ] . jobName + "-" + job [ 'jobData' ] . jobInstance ;
1172+
1173+ //console.log("Job waiting: " + JSON.stringify(job));
1174+ //console.log("Job waiting: " + Object.keys(job));
1175+ //console.log(job['jobData'].jobName + "-" + job['jobData'].jobInstance + " is waiting.");
1176+ //console.log(job['jobData'].jobName + "-" + job['jobData'].jobInstance + " is waiting. Needs " + JSON.stringify(job['jobData'].jobSensorIds));
1177+
1178+ // Add this job to unStartedJobs list
1179+ unStartedJobs [ longName ] = job ;
1180+
1181+ } else {
1182+ var header = job [ 'header' ] ;
1183+ var updates = job [ 'updates' ] ;
1184+ var saveData = { } ;
1185+
1186+ longName = header [ 'jobName' ] + '-' + header [ 'jobInstance' ] ;
1187+
1188+ // If previously unstarted, remove it from list
1189+ if ( unStartedJobs [ longName ] ) delete unStartedJobs [ longName ] ;
1190+
1191+ console . log ( "Creating listing for running job: " + index + " (" + longName + ")" ) ;
1192+ longJobNames . push ( longName ) ;
1193+
1194+ // Save the data for later use. It should consist of two arrays,
1195+ // 1st with just the job header and 2nd with an array of status updates
1196+ // (for a running job, updates will periodically be added to
1197+ saveData [ 'header' ] = [ header ] ;
1198+ saveData [ 'updates' ] = updates ;
1199+ runningData [ longName ] = saveData ;
1200+ }
1201+ //console.log("ZZZ");
1202+ updateJobsList ( longJobNames , 'running_jobsHolder' ) ;
11811203 } ) ;
1182- console . log ( "ZZZ" ) ;
1183- updateJobsList ( longJobNames , 'running_jobsHolder' ) ;
11841204 }
11851205
11861206 function updateRunningJob ( data ) {
@@ -1966,6 +1986,35 @@ window.onload = function () {
19661986 }
19671987 } ) ;
19681988
1989+ /*
1990+ Before drawing the running jobs, look for any non starters
1991+ (perhaps due to unavailability of a required sensor)
1992+ and set up a notification.
1993+ */
1994+ var unStartedJobsKeys = Object . keys ( unStartedJobs ) ;
1995+ //console.log("unstarted job(s): " + unStartedJobsKeys);
1996+
1997+ unStartedJobsKeys . forEach ( function ( key ) {
1998+ //console.log("Advising of unstarted job: " + key + " --- " + JSON.stringify(unStartedJobs[key]));
1999+
2000+ var sensorIds = unStartedJobs [ key ] [ 'jobData' ] . jobSensorIds ;
2001+ //console.log("Needs sensor" + (sensorIds.length>1?"s":"") + ": " + sensorIds);
2002+
2003+ var jobElement = document . createElement ( 'DIV' ) ;
2004+ jobElement . id = 'jobElement_' + key ;
2005+ jobElement . className = 'jobCantStart' ;
2006+
2007+ var jobItemName = document . createElement ( 'DIV' ) ;
2008+ jobItemName . id = 'jobItemName_' + i ;
2009+ jobItemName . className = 'jobCantStartName' ;
2010+ jobItemName . innerHTML = "<html>Job " + key + " can't start yet. Needs sensor" + ( sensorIds . length > 1 ?"s" :"" ) + ": " + sensorIds + "</html>" ;
2011+
2012+ jobElement . appendChild ( jobItemName ) ;
2013+ jobsListHolder . appendChild ( jobElement ) ;
2014+ } ) ;
2015+
2016+ /* Now the jobs running normally
2017+ */
19692018 for ( var i = 0 ; i < jobFiles . length ; i ++ ) {
19702019 //console.log(" " + jobFiles[i]);
19712020 // Extract some identifiers from the filename
0 commit comments