@@ -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,20 +1164,31 @@ window.onload = function () {
11631164
11641165 var longJobNames = [ ] ;
11651166 data . forEach ( function ( job , index ) {
1166-
11671167 console . log ( "createRunningJobsList() handling job: " + index ) ;
1168+
1169+ var longName ;
11681170 if ( job [ 'waiting' ] ) {
1169- console . log ( "Job waiting: " + JSON . stringify ( job ) ) ;
1170- console . log ( "Job waiting: " + Object . keys ( job ) ) ;
1171- console . log ( job [ 'jobData' ] . jobName + "-" + job [ 'jobData' ] . jobInstance + " is waiting." ) ;
1172- console . log ( job [ 'jobData' ] . jobName + "-" + job [ 'jobData' ] . jobInstance + " is waiting. Needs " + JSON . stringify ( job [ 'jobData' ] . jobSensorIds ) ) ;
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+
11731181 } else {
11741182 var header = job [ 'header' ] ;
11751183 var updates = job [ 'updates' ] ;
1176- var longName = header [ 'jobName' ] + '-' + header [ 'jobInstance' ] ;
11771184 var saveData = { } ;
11781185
1179- console . log ( "Creating listing for job: " + index + " (" + longName + ")" ) ;
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 + ")" ) ;
11801192 longJobNames . push ( longName ) ;
11811193
11821194 // Save the data for later use. It should consist of two arrays,
@@ -1185,10 +1197,9 @@ window.onload = function () {
11851197 saveData [ 'header' ] = [ header ] ;
11861198 saveData [ 'updates' ] = updates ;
11871199 runningData [ longName ] = saveData ;
1188- //console.log("XXX " + JSON.stringify(runningData[longName]));
1189- console . log ( "ZZZ" ) ;
1190- updateJobsList ( longJobNames , 'running_jobsHolder' ) ;
11911200 }
1201+ //console.log("ZZZ");
1202+ updateJobsList ( longJobNames , 'running_jobsHolder' ) ;
11921203 } ) ;
11931204 }
11941205
@@ -1975,6 +1986,35 @@ window.onload = function () {
19751986 }
19761987 } ) ;
19771988
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+ */
19782018 for ( var i = 0 ; i < jobFiles . length ; i ++ ) {
19792019 //console.log(" " + jobFiles[i]);
19802020 // Extract some identifiers from the filename
0 commit comments