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

populateData

parent d741e0f3
...@@ -152,19 +152,19 @@ ...@@ -152,19 +152,19 @@
return urlParams; return urlParams;
}; };
// // Test card:populateData event. // Test card:populateData event.
// reqwest({ reqwest({
// url: "input", url: "input",
// method: 'get', method: 'get',
// type: 'json', type: 'json',
// success: function (inputjson) { success: function (inputjson) {
// var cardevt = document.createEvent("CustomEvent"); var cardevt = document.createEvent("CustomEvent");
// cardevt.initCustomEvent('card:populateData', false, false, { cardevt.initCustomEvent('card:populateData', false, false, {
// 'geojson' : inputjson 'geojson' : inputjson
// }); });
// window.dispatchEvent(cardevt); window.dispatchEvent(cardevt);
// } }
// }); });
</script> </script>
......
...@@ -20,8 +20,8 @@ app.get('/demo/input', function (req, res) { ...@@ -20,8 +20,8 @@ app.get('/demo/input', function (req, res) {
"type": "Feature", "type": "Feature",
"properties": { "properties": {
"uuid": "785b50c5-4804-462d-8a24-1dc2c9fd14f8", "uuid": "785b50c5-4804-462d-8a24-1dc2c9fd14f8",
"type": "object", "type": "oil",
"subtype": "floatingbuoy", "subtype": "spill",
"meanLng": 20.214843749999996, "meanLng": 20.214843749999996,
"meanLat": 58.95000823335702, "meanLat": 58.95000823335702,
"simulation": { "simulation": {
...@@ -30,17 +30,17 @@ app.get('/demo/input', function (req, res) { ...@@ -30,17 +30,17 @@ app.get('/demo/input', function (req, res) {
"mode": "Normal", "mode": "Normal",
"forecast": "NEMO", "forecast": "NEMO",
"forwardCalculation": true, "forwardCalculation": true,
"amount": "100.0", "amount": "130.0",
"amountUnit": "m3", "amountUnit": "m3",
"oilclass": "Floating object / Algae", "oilclass": "Oil, specific",
"substance": "Floating object, file", "substance": "JET FUEL AND KEROSINE",
"fresh": false, "fresh": true,
"instantaneous": true, "instantaneous": false,
"uncertainty": false, "uncertainty": false,
"winddrag": "0", "winddrag": "0",
"depth": "0", "depth": "4",
"duration": "", "duration": "6",
"durationUnit": "" "durationUnit": "hours"
}, },
"observation": [], "observation": [],
"status": "COMPLETE", "status": "COMPLETE",
...@@ -57,12 +57,6 @@ app.get('/demo/input', function (req, res) { ...@@ -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) { app.post('/demo/startos', function (req, res) {
var result = {}; var result = {};
result["id"] = "uuid"; result["id"] = "uuid";
......
...@@ -285,6 +285,19 @@ var OSLocation = (function (_super) { ...@@ -285,6 +285,19 @@ var OSLocation = (function (_super) {
json.features[i]["properties"] = {}; json.features[i]["properties"] = {};
geojson.features.push(json.features[i]); 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 () { OSLocation.prototype.clear = function () {
var self = this; var self = this;
...@@ -527,7 +540,6 @@ var OSPeriod = (function (_super) { ...@@ -527,7 +540,6 @@ var OSPeriod = (function (_super) {
}; };
OSPeriod.prototype.populateData = function (geojson) { OSPeriod.prototype.populateData = function (geojson) {
var self = this; var self = this;
geojson.features[0].properties["simulation"] = {};
geojson.features[0].properties["simulation"]["forwardCalculation"] = self.forward; geojson.features[0].properties["simulation"]["forwardCalculation"] = self.forward;
geojson.features[0].properties["simulation"]["startDate"] = self.from.valueOf(); geojson.features[0].properties["simulation"]["startDate"] = self.from.valueOf();
geojson.features[0].properties["simulation"]["stopDate"] = self.to.valueOf(); geojson.features[0].properties["simulation"]["stopDate"] = self.to.valueOf();
...@@ -697,7 +709,14 @@ var OSType = (function (_super) { ...@@ -697,7 +709,14 @@ var OSType = (function (_super) {
}; };
OSType.prototype.populateData = function (geojson) { OSType.prototype.populateData = function (geojson) {
var self = this; 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 () { OSType.prototype.clear = function () {
var self = this; var self = this;
...@@ -740,13 +759,13 @@ var OSAmount = (function (_super) { ...@@ -740,13 +759,13 @@ var OSAmount = (function (_super) {
var amountUnitDiv = L.DomUtil.create('div', 'uk-width-1-2 uk-form-select select', amountValueDiv); var amountUnitDiv = L.DomUtil.create('div', 'uk-width-1-2 uk-form-select select', amountValueDiv);
amountUnitDiv.setAttribute('data-uk-form-select', ''); amountUnitDiv.setAttribute('data-uk-form-select', '');
var selectedAmountUnit = L.DomUtil.create('span', '', amountUnitDiv); var selectedAmountUnit = L.DomUtil.create('span', '', amountUnitDiv);
var amountSelect = L.DomUtil.create('select', '', amountUnitDiv); self.amountSelect = L.DomUtil.create('select', '', amountUnitDiv);
addOption(amountSelect, 'm3', ''); addOption(self.amountSelect, 'm3', '');
addOption(amountSelect, 'tonnes', 'tonnes'); addOption(self.amountSelect, 'tonnes', 'tonnes');
addOption(amountSelect, 'm3/hour', 'm³ / hour'); addOption(self.amountSelect, 'm3/hour', 'm³ / hour');
addOption(amountSelect, 'tonnes/hour', 'tonnes / hour'); addOption(self.amountSelect, 'tonnes/hour', 'tonnes / hour');
addOption(amountSelect, 'm3/day', 'm³ / day'); addOption(self.amountSelect, 'm3/day', 'm³ / day');
addOption(amountSelect, 'tonnes/day', 'tonnes / day'); addOption(self.amountSelect, 'tonnes/day', 'tonnes / day');
var durationRowDiv = L.DomUtil.create('div', 'uk-form-row', fieldset); 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>"); _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); var durationDiv = L.DomUtil.create('div', '', durationRowDiv);
...@@ -758,9 +777,9 @@ var OSAmount = (function (_super) { ...@@ -758,9 +777,9 @@ var OSAmount = (function (_super) {
var durationUnitDiv = L.DomUtil.create('div', 'uk-width-1-2 uk-form-select select', durationDiv); var durationUnitDiv = L.DomUtil.create('div', 'uk-width-1-2 uk-form-select select', durationDiv);
durationUnitDiv.setAttribute('data-uk-form-select', ''); durationUnitDiv.setAttribute('data-uk-form-select', '');
var selectedDurationUnit = L.DomUtil.create('span', '', durationUnitDiv); var selectedDurationUnit = L.DomUtil.create('span', '', durationUnitDiv);
var durationSelect = L.DomUtil.create('select', '', durationUnitDiv); self.durationSelect = L.DomUtil.create('select', '', durationUnitDiv);
addOption(durationSelect, 'hours', 'hours'); addOption(self.durationSelect, 'hours', 'hours');
addOption(durationSelect, 'days', 'days'); addOption(self.durationSelect, 'days', 'days');
self.amountInput.onchange = function () { self.amountInput.onchange = function () {
validate(); validate();
}; };
...@@ -821,7 +840,10 @@ var OSAmount = (function (_super) { ...@@ -821,7 +840,10 @@ var OSAmount = (function (_super) {
}; };
OSAmount.prototype.populateData = function (geojson) { OSAmount.prototype.populateData = function (geojson) {
var self = this; 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 () { OSAmount.prototype.clear = function () {
var self = this; var self = this;
......
This diff is collapsed.
...@@ -317,7 +317,22 @@ class OSLocation extends OilSpillCard { ...@@ -317,7 +317,22 @@ class OSLocation extends OilSpillCard {
for (var i = 0; i < json.features.length; i++) { for (var i = 0; i < json.features.length; i++) {
json.features[i]["properties"] = {}; json.features[i]["properties"] = {};
geojson.features.push(json.features[i]); 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() { public clear() {
...@@ -433,7 +448,6 @@ class OSPeriod extends OilSpillCard { ...@@ -433,7 +448,6 @@ class OSPeriod extends OilSpillCard {
}); });
self.slider = $(availableDiv).data("ionRangeSlider"); self.slider = $(availableDiv).data("ionRangeSlider");
self.durationHours.onchange = function() { self.durationHours.onchange = function() {
var date = moment.utc(self.startDateInput.value+' '+ self.startTimeInput.value, self.datetimeFormat); var date = moment.utc(self.startDateInput.value+' '+ self.startTimeInput.value, self.datetimeFormat);
if (self.forward) { if (self.forward) {
...@@ -581,7 +595,6 @@ class OSPeriod extends OilSpillCard { ...@@ -581,7 +595,6 @@ class OSPeriod extends OilSpillCard {
public populateData(geojson) { public populateData(geojson) {
var self = this; var self = this;
geojson.features[0].properties["simulation"] = {};
geojson.features[0].properties["simulation"]["forwardCalculation"] = self.forward; geojson.features[0].properties["simulation"]["forwardCalculation"] = self.forward;
geojson.features[0].properties["simulation"]["startDate"] = self.from.valueOf(); geojson.features[0].properties["simulation"]["startDate"] = self.from.valueOf();
geojson.features[0].properties["simulation"]["stopDate"] = self.to.valueOf(); geojson.features[0].properties["simulation"]["stopDate"] = self.to.valueOf();
...@@ -767,7 +780,14 @@ class OSType extends OilSpillCard { ...@@ -767,7 +780,14 @@ class OSType extends OilSpillCard {
public populateData(geojson) { public populateData(geojson) {
var self = this; 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 { ...@@ -787,6 +807,8 @@ class OSAmount extends OilSpillCard {
public oncallback : Function; public oncallback : Function;
public amountInput : HTMLInputElement; public amountInput : HTMLInputElement;
public durationInput : HTMLInputElement; public durationInput : HTMLInputElement;
public amountSelect : HTMLSelectElement;
public durationSelect : HTMLSelectElement;
public nextButton : any; public nextButton : any;
constructor(id, parentDiv, lang, map) { constructor(id, parentDiv, lang, map) {
...@@ -819,13 +841,13 @@ class OSAmount extends OilSpillCard { ...@@ -819,13 +841,13 @@ class OSAmount extends OilSpillCard {
var amountUnitDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-width-1-2 uk-form-select select', amountValueDiv); var amountUnitDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-width-1-2 uk-form-select select', amountValueDiv);
amountUnitDiv.setAttribute('data-uk-form-select',''); amountUnitDiv.setAttribute('data-uk-form-select','');
var selectedAmountUnit = <HTMLSpanElement>L.DomUtil.create('span', '', amountUnitDiv); var selectedAmountUnit = <HTMLSpanElement>L.DomUtil.create('span', '', amountUnitDiv);
var amountSelect = <HTMLSelectElement>L.DomUtil.create('select', '', amountUnitDiv); self.amountSelect = <HTMLSelectElement>L.DomUtil.create('select', '', amountUnitDiv);
addOption(amountSelect, 'm3', ''); addOption(self.amountSelect, 'm3', '');
addOption(amountSelect, 'tonnes', 'tonnes'); addOption(self.amountSelect, 'tonnes', 'tonnes');
addOption(amountSelect, 'm3/hour', 'm³ / hour'); addOption(self.amountSelect, 'm3/hour', 'm³ / hour');
addOption(amountSelect, 'tonnes/hour', 'tonnes / hour'); addOption(self.amountSelect, 'tonnes/hour', 'tonnes / hour');
addOption(amountSelect, 'm3/day', 'm³ / day'); addOption(self.amountSelect, 'm3/day', 'm³ / day');
addOption(amountSelect, 'tonnes/day', 'tonnes / day'); addOption(self.amountSelect, 'tonnes/day', 'tonnes / day');
var durationRowDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-form-row', fieldset); 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>"); 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 { ...@@ -838,9 +860,9 @@ class OSAmount extends OilSpillCard {
var durationUnitDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-width-1-2 uk-form-select select', durationDiv); var durationUnitDiv = <HTMLDivElement>L.DomUtil.create('div', 'uk-width-1-2 uk-form-select select', durationDiv);
durationUnitDiv.setAttribute('data-uk-form-select',''); durationUnitDiv.setAttribute('data-uk-form-select','');
var selectedDurationUnit = <HTMLSpanElement>L.DomUtil.create('span', '', durationUnitDiv); var selectedDurationUnit = <HTMLSpanElement>L.DomUtil.create('span', '', durationUnitDiv);
var durationSelect = <HTMLSelectElement>L.DomUtil.create('select', '', durationUnitDiv); self.durationSelect = <HTMLSelectElement>L.DomUtil.create('select', '', durationUnitDiv);
addOption(durationSelect, 'hours', 'hours'); addOption(self.durationSelect, 'hours', 'hours');
addOption(durationSelect, 'days', 'days'); addOption(self.durationSelect, 'days', 'days');
self.amountInput.onchange = function() { self.amountInput.onchange = function() {
validate(); validate();
...@@ -905,7 +927,10 @@ class OSAmount extends OilSpillCard { ...@@ -905,7 +927,10 @@ class OSAmount extends OilSpillCard {
public populateData(geojson) { public populateData(geojson) {
var self = this; 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