Difference between revisions of "Widget:WFSP-Dashboard"

From Open Energy Information

(converted timestamps from UTC to local)
Line 311: Line 311:
 
     totalProjects = 0;
 
     totalProjects = 0;
 
     runningProjects = 0;
 
     runningProjects = 0;
 +
    reportingProjects = 0;
  
 
     //fetch turbine data
 
     //fetch turbine data
Line 327: Line 328:
 
             var turbineStatus = itemData[i].turbine_status.toString().replace(/,/g,'<br />');
 
             var turbineStatus = itemData[i].turbine_status.toString().replace(/,/g,'<br />');
 
             var systemStatus = itemData[i].system_status.toString().replace(/,/g,'<br />');
 
             var systemStatus = itemData[i].system_status.toString().replace(/,/g,'<br />');
             var lastReported = String(new Date((itemData[i].last_reported).concat(" UTC"))).slice(0,21);
+
             var lastReported = new Date((itemData[i].last_reported).concat(" UTC"));
 +
 
 +
            var oneWeekAgo = new Date();
 +
            oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
 +
 
 +
            if (lastReported > oneWeekAgo) {reportingProjects += 1};
 +
 
 
             wfspEnergy += turbineEnergy;
 
             wfspEnergy += turbineEnergy;
 
             if(!$.inArray("Running", systemStatus)){
 
             if(!$.inArray("Running", systemStatus)){
Line 341: Line 348:
 
               runningProjects -= 1;
 
               runningProjects -= 1;
 
             }
 
             }
             $('tr[data-id="'+turbineID+'"]').append('<td>'+turbinePower+'</td><td>'+turbineWindSpeed+'</td><td>'+turbineDailyEnergy+'</td><td>'+turbineEnergy+'</td><td>'+turbineStatus+'</td><td class="alert '+statusCode+'">'+systemStatus+'</td><td>'+lastReported+'</td>');
+
             $('tr[data-id="'+turbineID+'"]').append('<td>'+turbinePower+'</td><td>'+turbineWindSpeed+'</td><td>'+turbineDailyEnergy+'</td><td>'+turbineEnergy+'</td><td>'+turbineStatus+'</td><td class="alert '+statusCode+'">'+systemStatus+'</td><td>'+String(lastReported).slice(0,21)+'</td>');
 
           }
 
           }
 +
          // console.log(reportingProjects);
 
           totalProjects = Object.keys(latestData).length;
 
           totalProjects = Object.keys(latestData).length;
 
           //health = Math.round((runningProjects/totalProjects)*100);
 
           //health = Math.round((runningProjects/totalProjects)*100);
Line 362: Line 370:
 
           $('#turbineCount').text(totalProjects);
 
           $('#turbineCount').text(totalProjects);
 
           //$('#pctOnline').text(health);
 
           //$('#pctOnline').text(health);
           $('#runningCount').text(runningProjects);
+
           $('#runningCount').text(reportingProjects);
 
           $('#totalEnergy').text(wfspEnergy.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
 
           $('#totalEnergy').text(wfspEnergy.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
 
           //$('#videoPlayback').text(videoHrs.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
 
           //$('#videoPlayback').text(videoHrs.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));

Revision as of 13:22, 27 September 2017

This widget helps with Wind for Schools Portal Dashboard content.

{{#Widget:WFSP-Dashboard}}