Commit 47fd2774 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

populateData

parent d741e0f3
......@@ -152,19 +152,19 @@
return urlParams;
};
// // Test card:populateData event.
// reqwest({
// url: "input",
// method: 'get',
// type: 'json',
// success: function (inputjson) {
// var cardevt = document.createEvent("CustomEvent");
// cardevt.initCustomEvent('card:populateData', false, false, {
// 'geojson' : inputjson
// });
// window.dispatchEvent(cardevt);
// }
// });
// Test card:populateData event.
reqwest({
url: "input",
method: 'get',
type: 'json',
success: function (inputjson) {
var cardevt = document.createEvent("CustomEvent");
cardevt.initCustomEvent('card:populateData', false, false, {
'geojson' : inputjson
});
window.dispatchEvent(cardevt);
}
});
</script>
......
......@@ -20,8 +20,8 @@ app.get('/demo/input', function (req, res) {
"type": "Feature",
"properties": {
"uuid": "785b50c5-4804-462d-8a24-1dc2c9fd14f8",
"type": "object",
"subtype": "floatingbuoy",
"type": "oil",
"subtype": "spill",
"meanLng": 20.214843749999996,
"meanLat": 58.95000823335702,
"simulation": {
......@@ -30,17 +30,17 @@ app.get('/demo/input', function (req, res) {
"mode": "Normal",
"forecast": "NEMO",
"forwardCalculation": true,
"amount": "100.0",
"amount": "130.0",
"amountUnit": "m3",
"oilclass": "Floating object / Algae",
"substance": "Floating object, file",
"fresh": false,
"instantaneous": true,
"oilclass": "Oil, specific",
"substance": "JET FUEL AND KEROSINE",
"fresh": true,
"instantaneous": false,
"uncertainty": false,
"winddrag": "0",
"depth": "0",
"duration": "",
"durationUnit": ""
"depth": "4",
"duration": "6",
"durationUnit": "hours"
},
"observation": [],
"status": "COMPLETE",
......@@ -57,12 +57,6 @@ app.get('/demo/input', function (req, res) {
);
});
app.get('/demo/availableTimes/ms/HELCOM_NEMO', function (req, res) {
res.send(
{"availableTime":{"start":1491094800000,"stop":1492124400000},"missingTime":[]}
);
});
app.post('/demo/startos', function (req, res) {
var result = {};
result["id"] = "uuid";
......
......@@ -285,6 +285,19 @@ var OSLocation = (function (_super) {
json.features[i]["properties"] = {};
geojson.features.push(json.features[i]);
}
var observation = {
"id": null,
"provider": "USER",
"providerDataRef": null,
"providerImgRef": null,
"providerType": null,
"type": "MANUAL",
"date": 1495538160000
};
geojson.features[0].properties["simulation"] = {};
geojson.features[0].properties["simulation"]["depth"] = self.depthInput.value;
geojson.features[0].properties["observation"] = {};
geojson.features[0].properties["observation"].push(observation);
};
OSLocation.prototype.clear = function () {
var self = this;
......@@ -527,7 +540,6 @@ var OSPeriod = (function (_super) {
};
OSPeriod.prototype.populateData = function (geojson) {
var self = this;
geojson.features[0].properties["simulation"] = {};
geojson.features[0].properties["simulation"]["forwardCalculation"] = self.forward;
geojson.features[0].properties["simulation"]["startDate"] = self.from.valueOf();
geojson.features[0].properties["simulation"]["stopDate"] = self.to.valueOf();
......@@ -697,7 +709,14 @@ var OSType = (function (_super) {
};
OSType.prototype.populateData = function (geojson) {
var self = this;
// geojson.features[0].properties["simulation"]["winddrag"] = self.input.value;
if (self.selectOilClass.selectedIndex !== -1) {
geojson.features[0].properties["simulation"]["oilclass"] = 'Oil classes';
geojson.features[0].properties["simulation"]["oilclass"] = self.selectOilClass.options[self.selectOilClass.selectedIndex].value;
}
if (self.selectOilSpecific.selectedIndex !== -1) {
geojson.features[0].properties["simulation"]["oilclass"] = 'Oil, specific';
geojson.features[0].properties["simulation"]["oilclass"] = self.selectOilSpecific.options[self.selectOilSpecific.selectedIndex].value;
}
};
OSType.prototype.clear = function () {
var self = this;
......@@ -740,13 +759,13 @@ var OSAmount = (function (_super) {
var amountUnitDiv = L.DomUtil.create('div', 'uk-width-1-2 uk-form-select select', amountValueDiv);
amountUnitDiv.setAttribute('data-uk-form-select', '');
var selectedAmountUnit = L.DomUtil.create('span', '', amountUnitDiv);
var amountSelect = L.DomUtil.create('select', '', amountUnitDiv);
addOption(amountSelect, 'm3', '');
addOption(amountSelect, 'tonnes', 'tonnes');
addOption(amountSelect, 'm3/hour', 'm³ / hour');
addOption(amountSelect, 'tonnes/hour', 'tonnes / hour');
addOption(amountSelect, 'm3/day', 'm³ / day');
addOption(amountSelect, 'tonnes/day', 'tonnes / day');
self.amountSelect = L.DomUtil.create('select', '', amountUnitDiv);
addOption(self.amountSelect, 'm3', '');
addOption(self.amountSelect, 'tonnes', 'tonnes');
addOption(self.amountSelect, 'm3/hour', 'm³ / hour');
addOption(self.amountSelect, 'tonnes/hour', 'tonnes / hour');
addOption(self.amountSelect, 'm3/day', 'm³ / day');
addOption(self.amountSelect, 'tonnes/day', 'tonnes / day');
var durationRowDiv = L.DomUtil.create('div', 'uk-form-row', fieldset);
_super.prototype.addLabelDiv.call(_this, durationRowDiv, "Duration", "See more information <a style='color:#faa732;' href='help/classic/#oil-os-amount-duration' target='_blank'>here</a>");
var durationDiv = L.DomUtil.create('div', '', durationRowDiv);
......@@ -758,9 +777,9 @@ var OSAmount = (function (_super) {
var durationUnitDiv = L.DomUtil.create('div', 'uk-width-1-2 uk-form-select select', durationDiv);
durationUnitDiv.setAttribute('data-uk-form-select', '');
var selectedDurationUnit = L.DomUtil.create('span', '', durationUnitDiv);
var durationSelect = L.DomUtil.create('select', '', durationUnitDiv);
addOption(durationSelect, 'hours', 'hours');
addOption(durationSelect, 'days', 'days');
self.durationSelect = L.DomUtil.create('select', '', durationUnitDiv);
addOption(self.durationSelect, 'hours', 'hours');
addOption(self.durationSelect, 'days', 'days');
self.amountInput.onchange = function () {
validate();
};
......@@ -821,7 +840,10 @@ var OSAmount = (function (_super) {
};
OSAmount.prototype.populateData = function (geojson) {
var self = this;
// geojson.features[0].properties["simulation"]["winddrag"] = self.input.value;
geojson.features[0].properties["simulation"]["amount"] = self.amountInput.value;
geojson.features[0].properties["simulation"]["amountUnit"] = self.amountSelect.options[self.amountSelect.selectedIndex].value;
geojson.features[0].properties["simulation"]["duration"] = self.durationInput.value;
geojson.features[0].properties["simulation"]["durationUnit"] = self.durationSelect.options[self.durationSelect.selectedIndex].value;
};
OSAmount.prototype.clear = function () {
var self = this;
......
This diff is collapsed.
......@@ -318,6 +318,21 @@ class OSLocation extends OilSpillCard {
json.features[i]["properties"] = {};
geojson.features.push(json.features[i]);
}
var observation = {
"id": null,
"provider": "USER",
"providerDataRef": null,
"providerImgRef": null,
"providerType": null,
"type": "MANUAL",
"date": 1495538160000
};
geojson.features[0].properties["simulation"] = {};
geojson.features[0].properties["simulation"]["depth"] = self.depthInput.value;
geojson.features[0].properties["observation"] = {};
geojson.features[0].properties["observation"].push(observation);
}
public clear() {
......@@ -433,7 +448,6 @@ class OSPeriod extends OilSpillCard {
});
self.slider = $(availableDiv).data("ionRangeSlider");
self.durationHours.onchange = function() {
var date = moment.utc(self.startDateInput.value+' '+ self.startTimeInput.value, self.datetimeFormat);
if (self.forward) {
......@@ -581,7 +595,6 @@ class OSPeriod extends OilSpillCard {
public populateData(geojson) {
var self = this;
geojson.features[0].properties["simulation"] = {};
geojson.features[0].properties["simulation"]["forwardCalculation"] = self.forward;
geojson.features[0].properties["simulation"]["startDate"] = self.from.valueOf();
geojson.features[0].properties["simulation"]["stopDate"] = self.to.valueOf();
......@@ -767,7 +780,14 @@ class OSType extends OilSpillCard {
public populateData(geojson) {
var self = this;
// geojson.features[0].properties["simulation"]["winddrag"] = self.input.value;
if (self.selectOilClass.selectedIndex !== -1) {
geojson.features[0].properties["simulation"]["oilclass"] = 'Oil classes';
geojson.features[0].properties["simulation"]["oilclass"] = self.selectOilClass.options[self.selectOilClass.selectedIndex].value;
}
if (self.selectOilSpecific.selectedIndex !== -1) {
geojson.features[0].properties["simulation"]["oilclass"] = 'Oil, specific';
geojson.features[0].properties["simulation"]["oilclass"] = self.selectOilSpecific.options[self.selectOilSpecific.selectedIndex].value;
}
}
......@@ -787,6 +807,8 @@ class OSAmount extends OilSpillCard {
public oncallback : Function;
public amountInput : HTMLInputElement;
public durationInput : HTMLInputElement;
public amountSelect : HTMLSelectElement;
public durationSelect : HTMLSelectElement;
public nextButton : any;
constructor(id, parentDiv, lang, map) {
......@@ -819,13 +841,13 @@ class OSAmount extends OilSpillCard {
var amountUnitDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-width-1-2 uk-form-select select', amountValueDiv);
amountUnitDiv.setAttribute('data-uk-form-select','');
var selectedAmountUnit = <HTMLSpanElement>L.DomUtil.create('span', '', amountUnitDiv);
var amountSelect = <HTMLSelectElement>L.DomUtil.create('select', '', amountUnitDiv);
addOption(amountSelect, 'm3', '');
addOption(amountSelect, 'tonnes', 'tonnes');
addOption(amountSelect, 'm3/hour', 'm³ / hour');
addOption(amountSelect, 'tonnes/hour', 'tonnes / hour');
addOption(amountSelect, 'm3/day', 'm³ / day');
addOption(amountSelect, 'tonnes/day', 'tonnes / day');
self.amountSelect = <HTMLSelectElement>L.DomUtil.create('select', '', amountUnitDiv);
addOption(self.amountSelect, 'm3', '');
addOption(self.amountSelect, 'tonnes', 'tonnes');
addOption(self.amountSelect, 'm3/hour', 'm³ / hour');
addOption(self.amountSelect, 'tonnes/hour', 'tonnes / hour');
addOption(self.amountSelect, 'm3/day', 'm³ / day');
addOption(self.amountSelect, 'tonnes/day', 'tonnes / day');
var durationRowDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-form-row', fieldset);
super.addLabelDiv(durationRowDiv, "Duration", "See more information <a style='color:#faa732;' href='help/classic/#oil-os-amount-duration' target='_blank'>here</a>");
......@@ -838,9 +860,9 @@ class OSAmount extends OilSpillCard {
var durationUnitDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-width-1-2 uk-form-select select', durationDiv);
durationUnitDiv.setAttribute('data-uk-form-select','');
var selectedDurationUnit = <HTMLSpanElement>L.DomUtil.create('span', '', durationUnitDiv);
var durationSelect = <HTMLSelectElement>L.DomUtil.create('select', '', durationUnitDiv);
addOption(durationSelect, 'hours', 'hours');
addOption(durationSelect, 'days', 'days');
self.durationSelect = <HTMLSelectElement>L.DomUtil.create('select', '', durationUnitDiv);
addOption(self.durationSelect, 'hours', 'hours');
addOption(self.durationSelect, 'days', 'days');
self.amountInput.onchange = function() {
validate();
......@@ -905,7 +927,10 @@ class OSAmount extends OilSpillCard {
public populateData(geojson) {
var self = this;
// geojson.features[0].properties["simulation"]["winddrag"] = self.input.value;
geojson.features[0].properties["simulation"]["amount"] = self.amountInput.value;
geojson.features[0].properties["simulation"]["amountUnit"] = self.amountSelect.options[self.amountSelect.selectedIndex].value;
geojson.features[0].properties["simulation"]["duration"] = self.durationInput.value;
geojson.features[0].properties["simulation"]["durationUnit"] = self.durationSelect.options[self.durationSelect.selectedIndex].value;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment