2989 |
02 Dec 14 |
olle |
var LabEnvDbDisp = function() |
2989 |
02 Dec 14 |
olle |
2 |
{ |
2989 |
02 Dec 14 |
olle |
var labenvdbdisp = {}; |
2989 |
02 Dec 14 |
olle |
var debug = 0; |
2989 |
02 Dec 14 |
olle |
var storageIntervalInSeconds = null; |
2989 |
02 Dec 14 |
olle |
6 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.getStorageIntervalInSeconds = function() |
2989 |
02 Dec 14 |
olle |
8 |
{ |
2989 |
02 Dec 14 |
olle |
return storageIntervalInSeconds; |
2989 |
02 Dec 14 |
olle |
10 |
} |
2989 |
02 Dec 14 |
olle |
11 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.setStorageIntervalInSeconds = function(storageIntervalInSecondsInput) |
2989 |
02 Dec 14 |
olle |
13 |
{ |
2989 |
02 Dec 14 |
olle |
//alert("setStorageIntervalInSeconds(): storageIntervalInSecondsInput = " + storageIntervalInSecondsInput); |
2989 |
02 Dec 14 |
olle |
storageIntervalInSeconds = storageIntervalInSecondsInput; |
2989 |
02 Dec 14 |
olle |
16 |
} |
2989 |
02 Dec 14 |
olle |
17 |
|
2989 |
02 Dec 14 |
olle |
// Page initialization |
2989 |
02 Dec 14 |
olle |
labenvdbdisp.initPage = function() |
2989 |
02 Dec 14 |
olle |
20 |
{ |
2989 |
02 Dec 14 |
olle |
var frm = document.forms['labenv']; |
2989 |
02 Dec 14 |
olle |
22 |
|
2989 |
02 Dec 14 |
olle |
// Step 1 |
2989 |
02 Dec 14 |
olle |
24 |
|
2989 |
02 Dec 14 |
olle |
// Step 2 |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('step-2', 'wizard-initialize', labenvdbdisp.initializeStep2); |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('step-2', 'wizard-validate', labenvdbdisp.validateStep2); |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('fromdate', 'blur', labenvdbdisp.fromDateTimeOnChange); |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('fromtime', 'blur', labenvdbdisp.fromDateTimeOnChange); |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('todate', 'blur', labenvdbdisp.toDateTimeOnChange); |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('totime', 'blur', labenvdbdisp.toDateTimeOnChange); |
2989 |
02 Dec 14 |
olle |
32 |
|
2989 |
02 Dec 14 |
olle |
// Step 3 |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('printButton', 'click', labenvdbdisp.printVersion); |
2989 |
02 Dec 14 |
olle |
35 |
|
2989 |
02 Dec 14 |
olle |
// Navigation |
2989 |
02 Dec 14 |
olle |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2989 |
02 Dec 14 |
olle |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2989 |
02 Dec 14 |
olle |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2989 |
02 Dec 14 |
olle |
Buttons.addClickHandler('gocreate', Wizard.goRegister); |
2989 |
02 Dec 14 |
olle |
41 |
|
2989 |
02 Dec 14 |
olle |
// Final registration |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('wizard', 'wizard-submit', labenvdbdisp.submit); |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('printButton', 'click', labenvdbdisp.printVersion); |
2989 |
02 Dec 14 |
olle |
45 |
|
2989 |
02 Dec 14 |
olle |
Doc.show('step-1'); |
2989 |
02 Dec 14 |
olle |
Doc.show('gonext'); |
2989 |
02 Dec 14 |
olle |
48 |
|
2989 |
02 Dec 14 |
olle |
// Create lab sensor menu from configuration data |
2989 |
02 Dec 14 |
olle |
labenvdbdisp.createSensorMenu(); |
2989 |
02 Dec 14 |
olle |
51 |
|
2989 |
02 Dec 14 |
olle |
// Fetch and store storage interval in seconds |
2989 |
02 Dec 14 |
olle |
labenvdbdisp.fetchStorageIntervalInSeconds(); |
2989 |
02 Dec 14 |
olle |
54 |
} |
2989 |
02 Dec 14 |
olle |
55 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.createSensorMenu = function() |
2989 |
02 Dec 14 |
olle |
57 |
{ |
2989 |
02 Dec 14 |
olle |
// Get lab sensor configurations JSON object with AJAX |
2989 |
02 Dec 14 |
olle |
var request = Ajax.getXmlHttpRequest(); |
2989 |
02 Dec 14 |
olle |
var url = '../LabEnvironment.servlet?ID='+App.getSessionId(); |
2989 |
02 Dec 14 |
olle |
url += '&cmd=GetLabSensorConfigList'; |
2989 |
02 Dec 14 |
olle |
62 |
|
2989 |
02 Dec 14 |
olle |
Wizard.asyncJsonRequest(url, labenvdbdisp.createSensorMenu2); |
2989 |
02 Dec 14 |
olle |
64 |
} |
2989 |
02 Dec 14 |
olle |
65 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.createSensorMenu2 = function(response) |
2989 |
02 Dec 14 |
olle |
67 |
{ |
2989 |
02 Dec 14 |
olle |
Doc.show('navigation'); |
2989 |
02 Dec 14 |
olle |
if (response.status != 'ok') |
2989 |
02 Dec 14 |
olle |
70 |
{ |
2989 |
02 Dec 14 |
olle |
setFatalError(response.message); |
2989 |
02 Dec 14 |
olle |
return false; |
2989 |
02 Dec 14 |
olle |
73 |
} |
2989 |
02 Dec 14 |
olle |
// Get sensor configurations information from the AJAX response |
4527 |
20 Jun 17 |
nicklas |
var labSensorConfigList = response.sensors; |
2989 |
02 Dec 14 |
olle |
if (labSensorConfigList != null) |
2989 |
02 Dec 14 |
olle |
77 |
{ |
2989 |
02 Dec 14 |
olle |
// Construct lab sensor menu from JSON data |
2989 |
02 Dec 14 |
olle |
var sensorSelect = document.getElementById('sensorSelectId'); |
2989 |
02 Dec 14 |
olle |
for (var i=0; i < labSensorConfigList.length; i++) |
2989 |
02 Dec 14 |
olle |
81 |
{ |
2989 |
02 Dec 14 |
olle |
// Get URL and name for lab sensor number 'i' |
2989 |
02 Dec 14 |
olle |
var labSensorConfig = labSensorConfigList[i]; |
2989 |
02 Dec 14 |
olle |
var sensorUrl = labSensorConfig['url']; |
2989 |
02 Dec 14 |
olle |
var sensorName = labSensorConfig['name']; |
2989 |
02 Dec 14 |
olle |
// Create and add new option element to select menu |
2989 |
02 Dec 14 |
olle |
var optionEl = document.createElement('option'); |
2989 |
02 Dec 14 |
olle |
optionEl.setAttribute('value',sensorUrl); |
2989 |
02 Dec 14 |
olle |
optionEl.innerHTML = sensorName; |
2989 |
02 Dec 14 |
olle |
sensorSelect.appendChild(optionEl); |
2989 |
02 Dec 14 |
olle |
91 |
} |
2989 |
02 Dec 14 |
olle |
92 |
} |
2989 |
02 Dec 14 |
olle |
93 |
} |
2989 |
02 Dec 14 |
olle |
94 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.fetchStorageIntervalInSeconds = function() |
2989 |
02 Dec 14 |
olle |
96 |
{ |
2989 |
02 Dec 14 |
olle |
// Get lab environment database configuration JSON object with AJAX |
2989 |
02 Dec 14 |
olle |
var request = Ajax.getXmlHttpRequest(); |
2989 |
02 Dec 14 |
olle |
var url = '../LabEnvironment.servlet?ID='+App.getSessionId(); |
2989 |
02 Dec 14 |
olle |
url += '&cmd=GetLabEnvDatabaseConfig'; |
2989 |
02 Dec 14 |
olle |
101 |
|
2989 |
02 Dec 14 |
olle |
Wizard.asyncJsonRequest(url, labenvdbdisp.fetchStorageIntervalInSeconds2); |
2989 |
02 Dec 14 |
olle |
103 |
} |
2989 |
02 Dec 14 |
olle |
104 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.fetchStorageIntervalInSeconds2 = function(response) |
2989 |
02 Dec 14 |
olle |
106 |
{ |
2989 |
02 Dec 14 |
olle |
if (response.status != 'ok') |
2989 |
02 Dec 14 |
olle |
108 |
{ |
2989 |
02 Dec 14 |
olle |
setFatalError(response.message); |
2989 |
02 Dec 14 |
olle |
return false; |
2989 |
02 Dec 14 |
olle |
111 |
} |
2989 |
02 Dec 14 |
olle |
// Get lab environment database configuration information from the AJAX response |
2989 |
02 Dec 14 |
olle |
var labEnvDatabaseConfig = response.labEnvDatabaseConfig; |
2989 |
02 Dec 14 |
olle |
if (labEnvDatabaseConfig != null) |
2989 |
02 Dec 14 |
olle |
115 |
{ |
2989 |
02 Dec 14 |
olle |
var storageIntervalInSecondsCurrent = labEnvDatabaseConfig.storageIntervalInSeconds; |
2989 |
02 Dec 14 |
olle |
labenvdbdisp.setStorageIntervalInSeconds(storageIntervalInSecondsCurrent); |
2989 |
02 Dec 14 |
olle |
118 |
} |
2989 |
02 Dec 14 |
olle |
119 |
} |
2989 |
02 Dec 14 |
olle |
120 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.initializeStep2 = function() |
2989 |
02 Dec 14 |
olle |
122 |
{ |
2989 |
02 Dec 14 |
olle |
Wizard.setCurrentStep(2); |
2989 |
02 Dec 14 |
olle |
var frm = document.forms['labenv']; |
2989 |
02 Dec 14 |
olle |
frm.reporttype.disabled = true; |
2989 |
02 Dec 14 |
olle |
// Hide report period input fields |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection01").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection02").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection04").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
// Hide day-time filter input fields |
2989 |
02 Dec 14 |
olle |
document.getElementById("dayTimeFilterSubSection01").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("dayTimeFilterSubSection02").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("dayTimeFilterSubSection04").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
// Hide weekday filter pop-up menu |
2989 |
02 Dec 14 |
olle |
document.getElementById("weekDayFilterSubSection01").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("weekDayFilterSubSection02").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("weekDayFilterSubSection04").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
// Hide chart variant pop-up menu |
2989 |
02 Dec 14 |
olle |
document.getElementById("chartVariantSubSection01").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("chartVariantSubSection02").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("chartVariantSubSection04").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
if (frm.reporttype.value == 'labenvironmentdailydisplay' |
2989 |
02 Dec 14 |
olle |
|| frm.reporttype.value == 'labenvironmentweeklydisplay' |
2989 |
02 Dec 14 |
olle |
|| frm.reporttype.value == 'labenvironmentoverviewdisplay') |
2989 |
02 Dec 14 |
olle |
145 |
{ |
2989 |
02 Dec 14 |
olle |
// Show report period input fields |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection01").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection02").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection04").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection01Header").innerHTML="Date"; |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection04HelpText").innerHTML="Date (YYYYMMDD) Blank field gives current date."; |
2989 |
02 Dec 14 |
olle |
if (frm.reporttype.value == 'labenvironmentweeklydisplay') |
2989 |
02 Dec 14 |
olle |
153 |
{ |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection01Header").innerHTML="Start date"; |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection04HelpText").innerHTML="Start date (YYYYMMDD) Blank field gives current date - 6 days."; |
2989 |
02 Dec 14 |
olle |
156 |
} |
2989 |
02 Dec 14 |
olle |
else if (frm.reporttype.value == 'labenvironmentoverviewdisplay') |
2989 |
02 Dec 14 |
olle |
158 |
{ |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection01Header").innerHTML="Start Date"; |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection04HelpText").innerHTML="Start date (YYYYMMDD) Blank field gives data from start."; |
2989 |
02 Dec 14 |
olle |
161 |
} |
2989 |
02 Dec 14 |
olle |
162 |
} |
2989 |
02 Dec 14 |
olle |
if (frm.reporttype.value == 'labenvironmentweeklydisplay' |
2989 |
02 Dec 14 |
olle |
|| frm.reporttype.value == 'labenvironmentoverviewdisplay') |
2989 |
02 Dec 14 |
olle |
165 |
{ |
2989 |
02 Dec 14 |
olle |
// Show day-time filter input fields |
2989 |
02 Dec 14 |
olle |
document.getElementById("dayTimeFilterSubSection01").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("dayTimeFilterSubSection02").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("dayTimeFilterSubSection04").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
170 |
} |
2989 |
02 Dec 14 |
olle |
if (frm.reporttype.value == 'labenvironmentweeklydisplay' |
2989 |
02 Dec 14 |
olle |
|| frm.reporttype.value == 'labenvironmentoverviewdisplay') |
2989 |
02 Dec 14 |
olle |
173 |
{ |
2989 |
02 Dec 14 |
olle |
// Show weekday filter pop-up menu |
2989 |
02 Dec 14 |
olle |
document.getElementById("weekDayFilterSubSection01").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("weekDayFilterSubSection02").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("weekDayFilterSubSection04").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
178 |
} |
2989 |
02 Dec 14 |
olle |
if (frm.reporttype.value == 'labenvironmentdailydisplay' |
2989 |
02 Dec 14 |
olle |
|| frm.reporttype.value == 'labenvironmentweeklydisplay' |
2989 |
02 Dec 14 |
olle |
|| frm.reporttype.value == 'labenvironmentoverviewdisplay') |
2989 |
02 Dec 14 |
olle |
182 |
{ |
2989 |
02 Dec 14 |
olle |
// Show chart data pop-up menu |
2989 |
02 Dec 14 |
olle |
document.getElementById("chartVariantSubSection01").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("chartVariantSubSection02").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("chartVariantSubSection04").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
187 |
} |
2989 |
02 Dec 14 |
olle |
Doc.show('parameterSection'); |
2989 |
02 Dec 14 |
olle |
189 |
|
2989 |
02 Dec 14 |
olle |
Doc.show('step-2'); |
2989 |
02 Dec 14 |
olle |
Doc.show('gocreate'); |
2989 |
02 Dec 14 |
olle |
Doc.hide('gonext'); |
2989 |
02 Dec 14 |
olle |
frm.fromdate.focus(); |
2989 |
02 Dec 14 |
olle |
194 |
} |
2989 |
02 Dec 14 |
olle |
195 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.validateStep2 = function(event) |
2989 |
02 Dec 14 |
olle |
197 |
{ |
2989 |
02 Dec 14 |
olle |
labenvdbdisp.dateOnChange(); |
2989 |
02 Dec 14 |
olle |
//if (!periodIsValid) event.preventDefault(); |
2989 |
02 Dec 14 |
olle |
200 |
} |
2989 |
02 Dec 14 |
olle |
201 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.addEventHandlers = function(elements, eventName, handler) |
2989 |
02 Dec 14 |
olle |
203 |
{ |
2989 |
02 Dec 14 |
olle |
for (var i = 0; i < elements.length; i++) |
2989 |
02 Dec 14 |
olle |
205 |
{ |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler(elements[i], eventName, handler); |
2989 |
02 Dec 14 |
olle |
207 |
} |
2989 |
02 Dec 14 |
olle |
208 |
} |
2989 |
02 Dec 14 |
olle |
209 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.fromDateTimeOnChange = function() |
2989 |
02 Dec 14 |
olle |
211 |
{ |
2989 |
02 Dec 14 |
olle |
var frm = document.forms['labenv']; |
2989 |
02 Dec 14 |
olle |
var todaysDate = new Date(); |
2989 |
02 Dec 14 |
olle |
fromDateIsValid = false; |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('fromdate', '', ''); |
2989 |
02 Dec 14 |
olle |
216 |
|
2989 |
02 Dec 14 |
olle |
var fromDate = frm.fromdate.value; |
2989 |
02 Dec 14 |
olle |
var fromTime = '0000'; |
2989 |
02 Dec 14 |
olle |
219 |
|
2989 |
02 Dec 14 |
olle |
if (fromDate != '' || fromTime != '') |
2989 |
02 Dec 14 |
olle |
221 |
{ |
2989 |
02 Dec 14 |
olle |
// Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits. |
2989 |
02 Dec 14 |
olle |
fromDate = autoFillDate(fromDate); |
2989 |
02 Dec 14 |
olle |
frm.fromdate.value = fromDate; |
2989 |
02 Dec 14 |
olle |
225 |
|
2989 |
02 Dec 14 |
olle |
if (!Dates.isDate(fromDate, 'yyyyMMdd')) |
2989 |
02 Dec 14 |
olle |
227 |
{ |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('fromdate', 'Not a valid date', 'invalid'); |
2989 |
02 Dec 14 |
olle |
return; |
2989 |
02 Dec 14 |
olle |
230 |
} |
2989 |
02 Dec 14 |
olle |
231 |
|
2989 |
02 Dec 14 |
olle |
if (!Dates.isDate(fromDate + ' ' + fromTime, 'yyyyMMdd HHmm')) |
2989 |
02 Dec 14 |
olle |
233 |
{ |
2989 |
02 Dec 14 |
olle |
if (fromDate != '') Wizard.setInputStatus('fromdate', 'Not a valid time (if time unknown, also leave date field blank)', 'invalid'); |
2989 |
02 Dec 14 |
olle |
return; |
2989 |
02 Dec 14 |
olle |
236 |
} |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('fromdate', '', 'valid'); |
2989 |
02 Dec 14 |
olle |
238 |
} |
2989 |
02 Dec 14 |
olle |
fromDateIsValid = true; |
2989 |
02 Dec 14 |
olle |
240 |
} |
2989 |
02 Dec 14 |
olle |
241 |
|
2989 |
02 Dec 14 |
olle |
var intervalIsValid = true; |
2989 |
02 Dec 14 |
olle |
243 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.dateOnChange = function() |
2989 |
02 Dec 14 |
olle |
245 |
{ |
2989 |
02 Dec 14 |
olle |
var frm = document.forms['labenv']; |
2989 |
02 Dec 14 |
olle |
var fdate; |
2989 |
02 Dec 14 |
olle |
var tdate; |
2989 |
02 Dec 14 |
olle |
249 |
|
2989 |
02 Dec 14 |
olle |
intervalIsValid = false; |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('displayInterval','','valid'); |
2989 |
02 Dec 14 |
olle |
if (frm.fromdate.value != null && frm.fromdate.value != '') |
2989 |
02 Dec 14 |
olle |
253 |
{ |
2989 |
02 Dec 14 |
olle |
frm.fromdate.value = autoFillDate(frm.fromdate.value); |
2989 |
02 Dec 14 |
olle |
if (!Dates.isDate(frm.fromdate.value, 'yyyyMMdd')) |
2989 |
02 Dec 14 |
olle |
256 |
{ |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('displayInterval','Not a valid from-date', 'invalid'); |
2989 |
02 Dec 14 |
olle |
return; |
2989 |
02 Dec 14 |
olle |
259 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
261 |
{ |
2989 |
02 Dec 14 |
olle |
fdate = frm.fromdate.value; |
2989 |
02 Dec 14 |
olle |
fdate = new Date(fdate.substr(0,4), parseInt(fdate.substr(4,2), 10)-1, fdate.substr(6,2)); |
2989 |
02 Dec 14 |
olle |
264 |
} |
2989 |
02 Dec 14 |
olle |
265 |
} |
2989 |
02 Dec 14 |
olle |
266 |
|
2989 |
02 Dec 14 |
olle |
if (frm.reporttype.value == 'labenvironmentdailydisplay') |
2989 |
02 Dec 14 |
olle |
268 |
{ |
2989 |
02 Dec 14 |
olle |
tdate = fdate; |
2989 |
02 Dec 14 |
olle |
270 |
} |
2989 |
02 Dec 14 |
olle |
271 |
|
2989 |
02 Dec 14 |
olle |
if (tdate != null && fdate != null) |
2989 |
02 Dec 14 |
olle |
273 |
{ |
2989 |
02 Dec 14 |
olle |
if (fdate > tdate) |
2989 |
02 Dec 14 |
olle |
275 |
{ |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('displayInterval', 'Invalid period', 'invalid') |
2989 |
02 Dec 14 |
olle |
return; |
2989 |
02 Dec 14 |
olle |
278 |
} |
2989 |
02 Dec 14 |
olle |
279 |
} |
2989 |
02 Dec 14 |
olle |
intervalIsValid = true; |
2989 |
02 Dec 14 |
olle |
281 |
} |
2989 |
02 Dec 14 |
olle |
282 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.submit = function(event) |
2989 |
02 Dec 14 |
olle |
284 |
{ |
2989 |
02 Dec 14 |
olle |
var frm = document.forms['labenv']; |
2989 |
02 Dec 14 |
olle |
var reportType = frm.reporttype.value; |
2989 |
02 Dec 14 |
olle |
287 |
|
2989 |
02 Dec 14 |
olle |
var url = '../LabEnvironmentDisplay.servlet?ID='+App.getSessionId(); |
2989 |
02 Dec 14 |
olle |
url += '&cmd='+reportType; |
2989 |
02 Dec 14 |
olle |
url += '&fdate='+encodeURIComponent(frm.fromdate.value); |
2989 |
02 Dec 14 |
olle |
if (reportType == 'labenvironmentweeklydisplay' || reportType == 'labenvironmentoverviewdisplay') |
2989 |
02 Dec 14 |
olle |
292 |
{ |
2989 |
02 Dec 14 |
olle |
url += '&weekdayfilter='+encodeURIComponent(frm.weekdayfilter.value); |
2989 |
02 Dec 14 |
olle |
url += '&filterfromtime='+encodeURIComponent(frm.filterfromtime.value); |
2989 |
02 Dec 14 |
olle |
url += '&filtertotime='+encodeURIComponent(frm.filtertotime.value); |
2989 |
02 Dec 14 |
olle |
296 |
} |
2989 |
02 Dec 14 |
olle |
url += '&cvariant='+encodeURIComponent(frm.chartvariant.value); |
2989 |
02 Dec 14 |
olle |
298 |
|
2989 |
02 Dec 14 |
olle |
Wizard.showLoadingAnimation('Generating plots...'); |
2989 |
02 Dec 14 |
olle |
Wizard.asyncJsonRequest(url, labenvdbdisp.onPlotGenerated); |
2989 |
02 Dec 14 |
olle |
301 |
} |
2989 |
02 Dec 14 |
olle |
302 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.onPlotGenerated = function(response) |
2989 |
02 Dec 14 |
olle |
304 |
{ |
2989 |
02 Dec 14 |
olle |
var frm = document.forms['labenv']; |
2989 |
02 Dec 14 |
olle |
var reportType = frm.reporttype.value; |
2989 |
02 Dec 14 |
olle |
//alert("onPlotGenerated(): reportType = " + reportType); |
2989 |
02 Dec 14 |
olle |
if (response.status != 'ok') |
2989 |
02 Dec 14 |
olle |
309 |
{ |
2989 |
02 Dec 14 |
olle |
setFatalError(response.message); |
2989 |
02 Dec 14 |
olle |
return false; |
2989 |
02 Dec 14 |
olle |
312 |
} |
2989 |
02 Dec 14 |
olle |
var report = response.report; |
2989 |
02 Dec 14 |
olle |
var permissionDeniedForPatientName = report.permissionDeniedForPatientName; |
2989 |
02 Dec 14 |
olle |
var reportTable; |
2989 |
02 Dec 14 |
olle |
var cellElement = document.getElementById('reportdiv'); |
2989 |
02 Dec 14 |
olle |
317 |
|
2989 |
02 Dec 14 |
olle |
if (report != null) |
2989 |
02 Dec 14 |
olle |
319 |
{ |
2989 |
02 Dec 14 |
olle |
if (reportType == 'labenvironmentdailydisplay' || |
2989 |
02 Dec 14 |
olle |
reportType == 'labenvironmentweeklydisplay' || |
2989 |
02 Dec 14 |
olle |
reportType == 'labenvironmentoverviewdisplay') |
2989 |
02 Dec 14 |
olle |
323 |
{ |
2989 |
02 Dec 14 |
olle |
//alert("onPlotGenerated(): Inside plot block for labenvironmentdailydisplay"); |
2989 |
02 Dec 14 |
olle |
var storageIntervalInSeconds = labenvdbdisp.getStorageIntervalInSeconds(); |
2989 |
02 Dec 14 |
olle |
var draw_area_wdt = 700; |
2989 |
02 Dec 14 |
olle |
var draw_area_hgt = 550; |
2989 |
02 Dec 14 |
olle |
var draw_scale_factor = 2; |
2989 |
02 Dec 14 |
olle |
var jsonStatisticsPlotArray = report.plotStatistics; |
2989 |
02 Dec 14 |
olle |
// Draw plots |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportdiv").innerHTML=""; |
2989 |
02 Dec 14 |
olle |
for (var plotIndex in jsonStatisticsPlotArray) |
2989 |
02 Dec 14 |
olle |
333 |
{ |
2989 |
02 Dec 14 |
olle |
334 |
// |
2989 |
02 Dec 14 |
olle |
// Get plot JSON data container with extra info and plot data |
2989 |
02 Dec 14 |
olle |
var plotJsonDataContainer = jsonStatisticsPlotArray[plotIndex]; |
2989 |
02 Dec 14 |
olle |
// Get plot JSON extra info and plot data |
2989 |
02 Dec 14 |
olle |
var plotChartVariant = plotJsonDataContainer['chartVariant']; |
2989 |
02 Dec 14 |
olle |
var plotViewType = plotJsonDataContainer['viewType']; |
2989 |
02 Dec 14 |
olle |
var plotOptionalHeadline = plotJsonDataContainer['optionalHeadline']; |
2989 |
02 Dec 14 |
olle |
var boxPlotJsonData = plotJsonDataContainer['plotData']; |
2989 |
02 Dec 14 |
olle |
// Create plot from plot JSON data |
2989 |
02 Dec 14 |
olle |
if (plotOptionalHeadline != null && plotOptionalHeadline != '') |
2989 |
02 Dec 14 |
olle |
344 |
{ |
2989 |
02 Dec 14 |
olle |
// Print optional headline |
2989 |
02 Dec 14 |
olle |
var headlineText = document.createElement('text'); |
2989 |
02 Dec 14 |
olle |
headlineText.innerHTML = "<BR>" + plotOptionalHeadline + "<BR>"; |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(headlineText); |
2989 |
02 Dec 14 |
olle |
349 |
} |
2989 |
02 Dec 14 |
olle |
var plotKey = plotChartVariant + '_' + plotViewType; |
2989 |
02 Dec 14 |
olle |
// Add plot |
2989 |
02 Dec 14 |
olle |
var canvasInTable = document.createElement('canvas'); |
2989 |
02 Dec 14 |
olle |
canvasInTable.setAttribute('id', plotKey); |
2989 |
02 Dec 14 |
olle |
canvasInTable.setAttribute('width', draw_area_wdt * draw_scale_factor); |
2989 |
02 Dec 14 |
olle |
canvasInTable.setAttribute('height', draw_area_hgt * draw_scale_factor); |
2989 |
02 Dec 14 |
olle |
createGraphPlot(boxPlotJsonData, canvasInTable, draw_area_wdt, draw_area_hgt, draw_scale_factor, plotViewType, storageIntervalInSeconds); |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(canvasInTable); |
2989 |
02 Dec 14 |
olle |
canvasInTable.addEventListener('mousemove', labenvdbdisp.drawCanvasGuidelines, false); |
2989 |
02 Dec 14 |
olle |
canvasInTable.addEventListener('mouseleave', labenvdbdisp.hideCanvasGuidelines, false); |
2989 |
02 Dec 14 |
olle |
360 |
} |
2989 |
02 Dec 14 |
olle |
// Print optional appended info |
2989 |
02 Dec 14 |
olle |
var appendedInfo = report.appendedInfo; |
2989 |
02 Dec 14 |
olle |
if (appendedInfo != null && appendedInfo != '') |
2989 |
02 Dec 14 |
olle |
364 |
{ |
2989 |
02 Dec 14 |
olle |
// Print optional headline |
2989 |
02 Dec 14 |
olle |
var infoText = document.createElement('text'); |
2989 |
02 Dec 14 |
olle |
infoText.innerHTML = "<BR>" + appendedInfo + "<BR>"; |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(infoText); |
2989 |
02 Dec 14 |
olle |
369 |
} |
2989 |
02 Dec 14 |
olle |
370 |
} |
2989 |
02 Dec 14 |
olle |
371 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
373 |
{ |
2989 |
02 Dec 14 |
olle |
var messageCell = labenvdbdisp.getTableCellElement('No values could be found during given period', 'reportheader'); |
2989 |
02 Dec 14 |
olle |
var messageRow = document.createElement('tr'); |
2989 |
02 Dec 14 |
olle |
messageRow.appendChild(messageCell); |
2989 |
02 Dec 14 |
olle |
var messageTable = labenvdbdisp.getReportTable(); |
2989 |
02 Dec 14 |
olle |
messageTable.appendChild(messageRow); |
2989 |
02 Dec 14 |
olle |
reportTable = messageTable; |
2989 |
02 Dec 14 |
olle |
380 |
} |
2989 |
02 Dec 14 |
olle |
Doc.show('step-3'); |
2989 |
02 Dec 14 |
olle |
Doc.show('printButton'); |
2989 |
02 Dec 14 |
olle |
Doc.show('gorestart'); |
2989 |
02 Dec 14 |
olle |
384 |
} |
2989 |
02 Dec 14 |
olle |
385 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.getReportTable = function() |
2989 |
02 Dec 14 |
olle |
387 |
{ |
2989 |
02 Dec 14 |
olle |
var reportTable = document.createElement('table'); |
2989 |
02 Dec 14 |
olle |
reportTable.setAttribute('class','reporttable'); |
2989 |
02 Dec 14 |
olle |
reportTable.setAttribute('border','1'); |
2989 |
02 Dec 14 |
olle |
return reportTable; |
2989 |
02 Dec 14 |
olle |
392 |
} |
2989 |
02 Dec 14 |
olle |
393 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.getTableCellElement = function(text, clazz, colspan, rowspan) |
2989 |
02 Dec 14 |
olle |
395 |
{ |
2989 |
02 Dec 14 |
olle |
var cellElement = document.createElement('td'); |
2989 |
02 Dec 14 |
olle |
text = new String(text); |
2989 |
02 Dec 14 |
olle |
var textArray = text.split("\n"); |
2989 |
02 Dec 14 |
olle |
if (textArray.length > 1) |
2989 |
02 Dec 14 |
olle |
400 |
{ |
2989 |
02 Dec 14 |
olle |
for (var i=0;i<textArray.length;i++) |
2989 |
02 Dec 14 |
olle |
402 |
{ |
2989 |
02 Dec 14 |
olle |
if (i>0)cellElement.appendChild(document.createElement('br')); |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(document.createTextNode(textArray[i])); |
2989 |
02 Dec 14 |
olle |
405 |
} |
2989 |
02 Dec 14 |
olle |
406 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
408 |
{ |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(document.createTextNode(text)); |
2989 |
02 Dec 14 |
olle |
410 |
} |
2989 |
02 Dec 14 |
olle |
cellElement.setAttribute('class', clazz); |
2989 |
02 Dec 14 |
olle |
if (colspan != null) cellElement.setAttribute('colspan', colspan); |
2989 |
02 Dec 14 |
olle |
if (rowspan != null) cellElement.setAttribute('rowspan', rowspan); |
2989 |
02 Dec 14 |
olle |
414 |
|
2989 |
02 Dec 14 |
olle |
return cellElement; |
2989 |
02 Dec 14 |
olle |
416 |
} |
2989 |
02 Dec 14 |
olle |
417 |
|
2989 |
02 Dec 14 |
olle |
var xGuide; |
2989 |
02 Dec 14 |
olle |
var yGuide; |
2989 |
02 Dec 14 |
olle |
420 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.drawCanvasGuidelines = function(event) |
2989 |
02 Dec 14 |
olle |
422 |
{ |
2989 |
02 Dec 14 |
olle |
if (!xGuide) |
2989 |
02 Dec 14 |
olle |
424 |
{ |
2989 |
02 Dec 14 |
olle |
xGuide = document.getElementById('x-guide'); |
2989 |
02 Dec 14 |
olle |
yGuide = document.getElementById('y-guide'); |
2989 |
02 Dec 14 |
olle |
427 |
} |
2989 |
02 Dec 14 |
olle |
var canvas = event.target; |
2989 |
02 Dec 14 |
olle |
var centerX = event.clientX; |
2989 |
02 Dec 14 |
olle |
var centerY = event.clientY; |
2989 |
02 Dec 14 |
olle |
var canvasPos = Doc.getElementPosition(canvas); |
4526 |
19 Jun 17 |
nicklas |
var startX = canvasPos.left+60; |
4526 |
19 Jun 17 |
nicklas |
var widthX = canvasPos.width-120; |
4526 |
19 Jun 17 |
nicklas |
var startY = canvasPos.top+65; |
4526 |
19 Jun 17 |
nicklas |
var heightY = canvasPos.height-120; |
2989 |
02 Dec 14 |
olle |
if (centerY < startY || centerY > startY+heightY) |
2989 |
02 Dec 14 |
olle |
437 |
{ |
2989 |
02 Dec 14 |
olle |
// Hide when mouse is in the text area below or over the plot |
2989 |
02 Dec 14 |
olle |
yGuide.style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
440 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
442 |
{ |
2989 |
02 Dec 14 |
olle |
yGuide.style.top = (centerY-2) + 'px'; |
2989 |
02 Dec 14 |
olle |
yGuide.style.left = startX + 'px'; |
2989 |
02 Dec 14 |
olle |
yGuide.style.width = widthX + 'px'; |
2989 |
02 Dec 14 |
olle |
yGuide.style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
447 |
} |
2989 |
02 Dec 14 |
olle |
if (centerX < startX || centerX > startX + widthX) |
2989 |
02 Dec 14 |
olle |
449 |
{ |
2989 |
02 Dec 14 |
olle |
// Hide when mouse is in the text area to the left or right of the plot |
2989 |
02 Dec 14 |
olle |
xGuide.style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
452 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
454 |
{ |
2989 |
02 Dec 14 |
olle |
// Avoid drawing outside the avilable height (causes an extra pair of scroll bars) |
2989 |
02 Dec 14 |
olle |
var yLimit = App.getWindowPosition().height; |
2989 |
02 Dec 14 |
olle |
if (startY+heightY > yLimit) |
2989 |
02 Dec 14 |
olle |
458 |
{ |
2989 |
02 Dec 14 |
olle |
heightY = yLimit-startY; |
2989 |
02 Dec 14 |
olle |
460 |
} |
2989 |
02 Dec 14 |
olle |
xGuide.style.top = startY + 'px'; |
2989 |
02 Dec 14 |
olle |
xGuide.style.left = (centerX-2) + 'px'; |
2989 |
02 Dec 14 |
olle |
xGuide.style.height = heightY + 'px'; |
2989 |
02 Dec 14 |
olle |
xGuide.style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
465 |
} |
2989 |
02 Dec 14 |
olle |
466 |
} |
2989 |
02 Dec 14 |
olle |
467 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.hideCanvasGuidelines = function(event) |
2989 |
02 Dec 14 |
olle |
469 |
{ |
2989 |
02 Dec 14 |
olle |
xGuide.style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
yGuide.style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
472 |
} |
2989 |
02 Dec 14 |
olle |
473 |
|
2989 |
02 Dec 14 |
olle |
labenvdbdisp.printVersion = function() |
2989 |
02 Dec 14 |
olle |
475 |
{ |
2989 |
02 Dec 14 |
olle |
var printNote = '<b>Note!</b> For better printing set page orientation to <i>portrait</i>.'; |
2989 |
02 Dec 14 |
olle |
printNote += ' Scale down to <i>90%</i> to fit 2 plots per page.'; |
3735 |
10 Feb 16 |
olle |
LabEnv.openPrintWindow('step-3-content', 'Lab environment display', 'portrait', printNote, '../', 'report.css'); |
2989 |
02 Dec 14 |
olle |
479 |
} |
2989 |
02 Dec 14 |
olle |
480 |
|
2989 |
02 Dec 14 |
olle |
return labenvdbdisp; |
2989 |
02 Dec 14 |
olle |
482 |
}(); |
2989 |
02 Dec 14 |
olle |
483 |
|
2989 |
02 Dec 14 |
olle |
Doc.onLoad(LabEnvDbDisp.initPage); |