2989 |
02 Dec 14 |
olle |
var LabEnvDbStat = function() |
2989 |
02 Dec 14 |
olle |
2 |
{ |
2989 |
02 Dec 14 |
olle |
var labenvdbstat = {}; |
2989 |
02 Dec 14 |
olle |
var debug = 0; |
2989 |
02 Dec 14 |
olle |
5 |
|
2989 |
02 Dec 14 |
olle |
// Page initialization |
2989 |
02 Dec 14 |
olle |
labenvdbstat.initPage = function() |
2989 |
02 Dec 14 |
olle |
8 |
{ |
2989 |
02 Dec 14 |
olle |
var frm = document.forms['labenv']; |
2989 |
02 Dec 14 |
olle |
10 |
|
2989 |
02 Dec 14 |
olle |
// Step 1 |
2989 |
02 Dec 14 |
olle |
12 |
|
2989 |
02 Dec 14 |
olle |
// Step 2 |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('step-2', 'wizard-initialize', labenvdbstat.initializeStep2); |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('step-2', 'wizard-validate', labenvdbstat.validateStep2); |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('fromdate', 'blur', labenvdbstat.fromDateTimeOnChange); |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('fromtime', 'blur', labenvdbstat.fromDateTimeOnChange); |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('todate', 'blur', labenvdbstat.toDateTimeOnChange); |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('totime', 'blur', labenvdbstat.toDateTimeOnChange); |
2989 |
02 Dec 14 |
olle |
20 |
|
2989 |
02 Dec 14 |
olle |
// Step 3 |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('printButton', 'click', labenvdbstat.printVersion); |
2989 |
02 Dec 14 |
olle |
23 |
|
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 |
29 |
|
2989 |
02 Dec 14 |
olle |
// Final registration |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('wizard', 'wizard-submit', labenvdbstat.submit); |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler('printButton', 'click', labenvdbstat.printVersion); |
2989 |
02 Dec 14 |
olle |
33 |
|
2989 |
02 Dec 14 |
olle |
Doc.show('step-1'); |
2989 |
02 Dec 14 |
olle |
Doc.show('gonext'); |
2989 |
02 Dec 14 |
olle |
36 |
|
2989 |
02 Dec 14 |
olle |
// Create lab sensor menu from configuration data |
2989 |
02 Dec 14 |
olle |
labenvdbstat.createSensorMenu(); |
2989 |
02 Dec 14 |
olle |
39 |
} |
2989 |
02 Dec 14 |
olle |
40 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.createSensorMenu = function() |
2989 |
02 Dec 14 |
olle |
42 |
{ |
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 |
47 |
|
2989 |
02 Dec 14 |
olle |
Wizard.asyncJsonRequest(url, labenvdbstat.createSensorMenu2); |
2989 |
02 Dec 14 |
olle |
49 |
} |
2989 |
02 Dec 14 |
olle |
50 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.createSensorMenu2 = function(response) |
2989 |
02 Dec 14 |
olle |
52 |
{ |
2989 |
02 Dec 14 |
olle |
Doc.show('navigation'); |
2989 |
02 Dec 14 |
olle |
if (response.status != 'ok') |
2989 |
02 Dec 14 |
olle |
55 |
{ |
2989 |
02 Dec 14 |
olle |
setFatalError(response.message); |
2989 |
02 Dec 14 |
olle |
return false; |
2989 |
02 Dec 14 |
olle |
58 |
} |
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 |
62 |
{ |
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 |
66 |
{ |
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 |
76 |
} |
2989 |
02 Dec 14 |
olle |
77 |
} |
2989 |
02 Dec 14 |
olle |
78 |
} |
2989 |
02 Dec 14 |
olle |
79 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.initializeStep2 = function() |
2989 |
02 Dec 14 |
olle |
81 |
{ |
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 view type pop-up menu |
2989 |
02 Dec 14 |
olle |
document.getElementById("viewTypeSubSection01").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("viewTypeSubSection02").style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("viewTypeSubSection04").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 == 'labenvironmentdailydistribution' |
2989 |
02 Dec 14 |
olle |
|| frm.reporttype.value == 'labenvironmentweeklydistribution') |
2989 |
02 Dec 14 |
olle |
107 |
{ |
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="From"; |
2989 |
02 Dec 14 |
olle |
document.getElementById("reportPeriodSubSection04HelpText").innerHTML="Start date+time (YYYYMMDD, HHMM) Blank fields give data from start."; |
2989 |
02 Dec 14 |
olle |
// Show view type pop-up menu |
2989 |
02 Dec 14 |
olle |
document.getElementById("viewTypeSubSection01").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("viewTypeSubSection02").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
document.getElementById("viewTypeSubSection04").style.display = 'block'; |
2989 |
02 Dec 14 |
olle |
118 |
} |
2989 |
02 Dec 14 |
olle |
if (frm.reporttype.value == 'labenvironmentdailydistribution' |
2989 |
02 Dec 14 |
olle |
|| frm.reporttype.value == 'labenvironmentweeklydistribution') |
2989 |
02 Dec 14 |
olle |
121 |
{ |
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 |
126 |
} |
2989 |
02 Dec 14 |
olle |
if (frm.reporttype.value == 'labenvironmentweeklydistribution') |
2989 |
02 Dec 14 |
olle |
128 |
{ |
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 |
133 |
} |
2989 |
02 Dec 14 |
olle |
if (frm.reporttype.value == 'labenvironmentdailydistribution' |
2989 |
02 Dec 14 |
olle |
|| frm.reporttype.value == 'labenvironmentweeklydistribution') |
2989 |
02 Dec 14 |
olle |
136 |
{ |
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 |
141 |
} |
2989 |
02 Dec 14 |
olle |
Doc.show('parameterSection'); |
2989 |
02 Dec 14 |
olle |
143 |
|
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 |
147 |
|
2989 |
02 Dec 14 |
olle |
frm.fromdate.focus(); |
2989 |
02 Dec 14 |
olle |
149 |
} |
2989 |
02 Dec 14 |
olle |
150 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.validateStep2 = function(event) |
2989 |
02 Dec 14 |
olle |
152 |
{ |
2989 |
02 Dec 14 |
olle |
labenvdbstat.dateOnChange(); |
2989 |
02 Dec 14 |
olle |
//if (!periodIsValid) event.preventDefault(); |
2989 |
02 Dec 14 |
olle |
155 |
} |
2989 |
02 Dec 14 |
olle |
156 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.addEventHandlers = function(elements, eventName, handler) |
2989 |
02 Dec 14 |
olle |
158 |
{ |
2989 |
02 Dec 14 |
olle |
for (var i = 0; i < elements.length; i++) |
2989 |
02 Dec 14 |
olle |
160 |
{ |
2989 |
02 Dec 14 |
olle |
Events.addEventHandler(elements[i], eventName, handler); |
2989 |
02 Dec 14 |
olle |
162 |
} |
2989 |
02 Dec 14 |
olle |
163 |
} |
2989 |
02 Dec 14 |
olle |
164 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.fromDateTimeOnChange = function() |
2989 |
02 Dec 14 |
olle |
166 |
{ |
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 |
171 |
|
2989 |
02 Dec 14 |
olle |
var fromDate = frm.fromdate.value; |
2989 |
02 Dec 14 |
olle |
var fromTime = frm.fromtime.value; |
2989 |
02 Dec 14 |
olle |
174 |
|
2989 |
02 Dec 14 |
olle |
if (fromDate != '' || fromTime != '') |
2989 |
02 Dec 14 |
olle |
176 |
{ |
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 |
180 |
|
2989 |
02 Dec 14 |
olle |
fromTime = autoFillTime(fromTime); |
2989 |
02 Dec 14 |
olle |
frm.fromtime.value = fromTime; |
2989 |
02 Dec 14 |
olle |
183 |
|
2989 |
02 Dec 14 |
olle |
if (!Dates.isDate(fromDate, 'yyyyMMdd')) |
2989 |
02 Dec 14 |
olle |
185 |
{ |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('fromdate', 'Not a valid date', 'invalid'); |
2989 |
02 Dec 14 |
olle |
return; |
2989 |
02 Dec 14 |
olle |
188 |
} |
2989 |
02 Dec 14 |
olle |
189 |
|
2989 |
02 Dec 14 |
olle |
if (!Dates.isDate(fromDate + ' ' + fromTime, 'yyyyMMdd HHmm')) |
2989 |
02 Dec 14 |
olle |
191 |
{ |
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 |
194 |
} |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('fromdate', '', 'valid'); |
2989 |
02 Dec 14 |
olle |
196 |
} |
2989 |
02 Dec 14 |
olle |
fromDateIsValid = true; |
2989 |
02 Dec 14 |
olle |
labenvdbstat.toDateTimeOnChange(); |
2989 |
02 Dec 14 |
olle |
199 |
} |
2989 |
02 Dec 14 |
olle |
200 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.toDateTimeOnChange = function() |
2989 |
02 Dec 14 |
olle |
202 |
{ |
2989 |
02 Dec 14 |
olle |
var frm = document.forms['labenv']; |
2989 |
02 Dec 14 |
olle |
var todaysDate = new Date(); |
2989 |
02 Dec 14 |
olle |
toDateIsValid = false; |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('toDate', '', ''); |
2989 |
02 Dec 14 |
olle |
207 |
|
2989 |
02 Dec 14 |
olle |
var toDate = frm.todate.value; |
2989 |
02 Dec 14 |
olle |
var toTime = frm.totime.value; |
2989 |
02 Dec 14 |
olle |
210 |
|
2989 |
02 Dec 14 |
olle |
if (toDate != '' || toTime != '') |
2989 |
02 Dec 14 |
olle |
212 |
{ |
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 |
toDate = autoFillDate(toDate); |
2989 |
02 Dec 14 |
olle |
frm.todate.value = toDate; |
2989 |
02 Dec 14 |
olle |
216 |
|
2989 |
02 Dec 14 |
olle |
toTime = autoFillTime(toTime); |
2989 |
02 Dec 14 |
olle |
frm.totime.value = toTime; |
2989 |
02 Dec 14 |
olle |
219 |
|
2989 |
02 Dec 14 |
olle |
if (!Dates.isDate(toDate, 'yyyyMMdd')) |
2989 |
02 Dec 14 |
olle |
221 |
{ |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('todate', 'Not a valid date', 'invalid'); |
2989 |
02 Dec 14 |
olle |
return; |
2989 |
02 Dec 14 |
olle |
224 |
} |
2989 |
02 Dec 14 |
olle |
225 |
|
2989 |
02 Dec 14 |
olle |
if (!Dates.isDate(toDate + ' ' + toTime, 'yyyyMMdd HHmm')) |
2989 |
02 Dec 14 |
olle |
227 |
{ |
2989 |
02 Dec 14 |
olle |
if (toDate != '') Wizard.setInputStatus('todate', 'Not a valid time (if time unknown, also leave date field blank)', 'invalid'); |
2989 |
02 Dec 14 |
olle |
return; |
2989 |
02 Dec 14 |
olle |
230 |
} |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('todate', '', 'valid'); |
2989 |
02 Dec 14 |
olle |
232 |
} |
2989 |
02 Dec 14 |
olle |
toDateIsValid = true; |
2989 |
02 Dec 14 |
olle |
234 |
} |
2989 |
02 Dec 14 |
olle |
235 |
|
2989 |
02 Dec 14 |
olle |
var intervalIsValid = true; |
2989 |
02 Dec 14 |
olle |
237 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.dateOnChange = function() |
2989 |
02 Dec 14 |
olle |
239 |
{ |
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 |
243 |
|
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 |
247 |
{ |
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 |
250 |
{ |
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 |
253 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
255 |
{ |
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 |
258 |
} |
2989 |
02 Dec 14 |
olle |
259 |
} |
2989 |
02 Dec 14 |
olle |
260 |
|
2989 |
02 Dec 14 |
olle |
if (frm.todate.value != null && frm.todate.value != '') |
2989 |
02 Dec 14 |
olle |
262 |
{ |
2989 |
02 Dec 14 |
olle |
frm.todate.value = autoFillDate(frm.todate.value); |
2989 |
02 Dec 14 |
olle |
if (!Dates.isDate(frm.todate.value, 'yyyyMMdd')) |
2989 |
02 Dec 14 |
olle |
265 |
{ |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('displayInterval', 'Not a valid to-date', 'invalid'); |
2989 |
02 Dec 14 |
olle |
return; |
2989 |
02 Dec 14 |
olle |
268 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
270 |
{ |
2989 |
02 Dec 14 |
olle |
tdate = frm.todate.value; |
2989 |
02 Dec 14 |
olle |
tdate = new Date(tdate.substr(0,4), parseInt(tdate.substr(4,2), 10)-1, tdate.substr(6,2)); |
2989 |
02 Dec 14 |
olle |
273 |
} |
2989 |
02 Dec 14 |
olle |
274 |
} |
2989 |
02 Dec 14 |
olle |
275 |
|
2989 |
02 Dec 14 |
olle |
if (tdate != null && fdate != null) |
2989 |
02 Dec 14 |
olle |
277 |
{ |
2989 |
02 Dec 14 |
olle |
if (fdate > tdate) |
2989 |
02 Dec 14 |
olle |
279 |
{ |
2989 |
02 Dec 14 |
olle |
Wizard.setInputStatus('displayInterval', 'Invalid period', 'invalid') |
2989 |
02 Dec 14 |
olle |
return; |
2989 |
02 Dec 14 |
olle |
282 |
} |
2989 |
02 Dec 14 |
olle |
283 |
} |
2989 |
02 Dec 14 |
olle |
intervalIsValid = true; |
2989 |
02 Dec 14 |
olle |
285 |
} |
2989 |
02 Dec 14 |
olle |
286 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.submit = function(event) |
2989 |
02 Dec 14 |
olle |
288 |
{ |
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 |
291 |
|
2989 |
02 Dec 14 |
olle |
var url = '../LabEnvironmentStatistics.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 |
url += '&ftime='+encodeURIComponent(frm.fromtime.value); |
2989 |
02 Dec 14 |
olle |
url += '&tdate='+encodeURIComponent(frm.todate.value); |
2989 |
02 Dec 14 |
olle |
url += '&ttime='+encodeURIComponent(frm.totime.value); |
2989 |
02 Dec 14 |
olle |
url += '&weekdayfilter='+encodeURIComponent(frm.weekdayfilter.value); |
2989 |
02 Dec 14 |
olle |
if (reportType == 'labenvironmentweeklydistribution') |
2989 |
02 Dec 14 |
olle |
300 |
{ |
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 |
303 |
} |
2989 |
02 Dec 14 |
olle |
url += '&cvariant='+encodeURIComponent(frm.chartvariant.value); |
2989 |
02 Dec 14 |
olle |
305 |
|
2989 |
02 Dec 14 |
olle |
Wizard.showLoadingAnimation('Generating plots...'); |
2989 |
02 Dec 14 |
olle |
Wizard.asyncJsonRequest(url, labenvdbstat.onPlotGenerated); |
2989 |
02 Dec 14 |
olle |
308 |
} |
2989 |
02 Dec 14 |
olle |
309 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.onPlotGenerated = function(response) |
2989 |
02 Dec 14 |
olle |
311 |
{ |
2989 |
02 Dec 14 |
olle |
//alert("labenvironmentdatabasestatistics.js::onPlotGenerated(): response = " + response); |
2989 |
02 Dec 14 |
olle |
if (response.status != 'ok') |
2989 |
02 Dec 14 |
olle |
314 |
{ |
2989 |
02 Dec 14 |
olle |
setFatalError(response.message); |
2989 |
02 Dec 14 |
olle |
return false; |
2989 |
02 Dec 14 |
olle |
317 |
} |
2989 |
02 Dec 14 |
olle |
var report = response.report; |
2989 |
02 Dec 14 |
olle |
var permissionDeniedForPatientName = report.permissionDeniedForPatientName; |
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("labenvironmentdatabasestatistics.js::onPlotGenerated(): reportType = " + reportType); |
2989 |
02 Dec 14 |
olle |
var reportTable; |
2989 |
02 Dec 14 |
olle |
var cellElement = document.getElementById('reportdiv'); |
2989 |
02 Dec 14 |
olle |
325 |
|
2989 |
02 Dec 14 |
olle |
if (report != null) |
2989 |
02 Dec 14 |
olle |
327 |
{ |
2989 |
02 Dec 14 |
olle |
if (reportType == 'labenvironmentdailydistribution' || reportType == 'labenvironmentweeklydistribution') |
2989 |
02 Dec 14 |
olle |
329 |
{ |
2989 |
02 Dec 14 |
olle |
//alert("onPlotGenerated(): Inside plot block for labenvironmentdailydistribution"); |
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 |
338 |
{ |
2989 |
02 Dec 14 |
olle |
339 |
// |
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 |
349 |
{ |
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 |
354 |
} |
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 |
//alert("onPlotGenerated(): Calling createBoxPlot()"); |
2989 |
02 Dec 14 |
olle |
createBoxPlot(boxPlotJsonData, canvasInTable, draw_area_wdt, draw_area_hgt, draw_scale_factor); |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(canvasInTable); |
2989 |
02 Dec 14 |
olle |
canvasInTable.addEventListener('mousemove', labenvdbstat.drawCanvasGuidelines, false); |
2989 |
02 Dec 14 |
olle |
canvasInTable.addEventListener('mouseleave', labenvdbstat.hideCanvasGuidelines, false); |
2989 |
02 Dec 14 |
olle |
366 |
} |
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 |
370 |
{ |
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 |
375 |
} |
2989 |
02 Dec 14 |
olle |
376 |
} |
2989 |
02 Dec 14 |
olle |
377 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
379 |
{ |
2989 |
02 Dec 14 |
olle |
var messageCell = labenvdbstat.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 = labenvdbstat.getReportTable(); |
2989 |
02 Dec 14 |
olle |
messageTable.appendChild(messageRow); |
2989 |
02 Dec 14 |
olle |
reportTable = messageTable; |
2989 |
02 Dec 14 |
olle |
386 |
} |
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 |
390 |
} |
2989 |
02 Dec 14 |
olle |
391 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.getReportTable = function() |
2989 |
02 Dec 14 |
olle |
393 |
{ |
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 |
398 |
} |
2989 |
02 Dec 14 |
olle |
399 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.getTableCellElement = function(text, clazz, colspan, rowspan) |
2989 |
02 Dec 14 |
olle |
401 |
{ |
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 |
406 |
{ |
2989 |
02 Dec 14 |
olle |
for (var i=0;i<textArray.length;i++) |
2989 |
02 Dec 14 |
olle |
408 |
{ |
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 |
411 |
} |
2989 |
02 Dec 14 |
olle |
412 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
414 |
{ |
2989 |
02 Dec 14 |
olle |
cellElement.appendChild(document.createTextNode(text)); |
2989 |
02 Dec 14 |
olle |
416 |
} |
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 |
420 |
|
2989 |
02 Dec 14 |
olle |
return cellElement; |
2989 |
02 Dec 14 |
olle |
422 |
} |
2989 |
02 Dec 14 |
olle |
423 |
|
2989 |
02 Dec 14 |
olle |
var xGuide; |
2989 |
02 Dec 14 |
olle |
var yGuide; |
2989 |
02 Dec 14 |
olle |
426 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.drawCanvasGuidelines = function(event) |
2989 |
02 Dec 14 |
olle |
428 |
{ |
2989 |
02 Dec 14 |
olle |
if (!xGuide) |
2989 |
02 Dec 14 |
olle |
430 |
{ |
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 |
433 |
} |
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); |
2989 |
02 Dec 14 |
olle |
var startX = canvasPos.left+50; |
2989 |
02 Dec 14 |
olle |
var widthX = canvasPos.width-100; |
2989 |
02 Dec 14 |
olle |
var startY = canvasPos.top+80; |
2989 |
02 Dec 14 |
olle |
var heightY = canvasPos.height-160; |
2989 |
02 Dec 14 |
olle |
if (centerY < startY || centerY > startY+heightY) |
2989 |
02 Dec 14 |
olle |
443 |
{ |
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 |
446 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
448 |
{ |
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 |
453 |
} |
2989 |
02 Dec 14 |
olle |
if (centerX < startX || centerX > startX + widthX) |
2989 |
02 Dec 14 |
olle |
455 |
{ |
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 |
458 |
} |
2989 |
02 Dec 14 |
olle |
else |
2989 |
02 Dec 14 |
olle |
460 |
{ |
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 |
464 |
{ |
2989 |
02 Dec 14 |
olle |
heightY = yLimit-startY; |
2989 |
02 Dec 14 |
olle |
466 |
} |
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 |
471 |
} |
2989 |
02 Dec 14 |
olle |
472 |
} |
2989 |
02 Dec 14 |
olle |
473 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.hideCanvasGuidelines = function(event) |
2989 |
02 Dec 14 |
olle |
475 |
{ |
2989 |
02 Dec 14 |
olle |
xGuide.style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
yGuide.style.display = 'none'; |
2989 |
02 Dec 14 |
olle |
478 |
} |
2989 |
02 Dec 14 |
olle |
479 |
|
2989 |
02 Dec 14 |
olle |
labenvdbstat.printVersion = function() |
2989 |
02 Dec 14 |
olle |
481 |
{ |
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 statistics', 'portrait', printNote, '../', 'report.css'); |
2989 |
02 Dec 14 |
olle |
485 |
} |
2989 |
02 Dec 14 |
olle |
486 |
|
2989 |
02 Dec 14 |
olle |
return labenvdbstat; |
2989 |
02 Dec 14 |
olle |
488 |
}(); |
2989 |
02 Dec 14 |
olle |
489 |
|
2989 |
02 Dec 14 |
olle |
Doc.onLoad(LabEnvDbStat.initPage); |