Commit 9e6f924c authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

populateCards

parent 47fd2774
......@@ -42,7 +42,13 @@ app.get('/demo/input', function (req, res) {
"duration": "6",
"durationUnit": "hours"
},
"observation": [],
"observation": [{ "id": null,
"provider": 'USER',
"providerDataRef": null,
"providerImgRef": null,
"providerType": null,
"type": 'MANUAL',
"date": 1495540800000 }],
"status": "COMPLETE",
"timestamp": 1491225478000,
"period": "2 days 0 hrs ",
......@@ -57,8 +63,15 @@ 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 = {};
console.log(req.body.features[0].properties);
result["id"] = "uuid";
res.send(result);
});
......
......@@ -277,6 +277,13 @@ var OSLocation = (function (_super) {
default:
break;
}
var simulation = geojson.features[0].properties.simulation;
self.depthInput.value = simulation.depth;
var observation = geojson.features[0].properties.observation[0];
var date = moment.utc(observation.date).format(self.dateFormat);
self.obsDateInput.value = date;
var time = moment.utc(observation.date).format(self.timeFormat);
self.obsTimeInput.value = time;
};
OSLocation.prototype.populateData = function (geojson) {
var self = this;
......@@ -292,11 +299,11 @@ var OSLocation = (function (_super) {
"providerImgRef": null,
"providerType": null,
"type": "MANUAL",
"date": 1495538160000
"date": moment.utc(self.obsDateInput.value + ' ' + self.obsTimeInput.value, self.datetimeFormat).valueOf()
};
geojson.features[0].properties["simulation"] = {};
geojson.features[0].properties["simulation"]["depth"] = self.depthInput.value;
geojson.features[0].properties["observation"] = {};
geojson.features[0].properties["observation"] = [];
geojson.features[0].properties["observation"].push(observation);
};
OSLocation.prototype.clear = function () {
......@@ -706,16 +713,25 @@ var OSType = (function (_super) {
OSType.prototype.populateCard = function (geojson) {
var self = this;
var simulation = geojson.features[0].properties.simulation;
if (simulation.oilclass == 'Oil classes') {
document.getElementById('osOilClassTab').click();
;
self.selectOilClass.value = geojson.features[0].properties["simulation"]["substance"];
}
if (simulation.oilclass == 'Oil, specific') {
document.getElementById('osOilSpecificTab').click();
self.selectOilClass.value = geojson.features[0].properties["simulation"]["substance"];
}
};
OSType.prototype.populateData = function (geojson) {
var self = this;
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;
geojson.features[0].properties["simulation"]["substance"] = 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;
geojson.features[0].properties["simulation"]["substance"] = self.selectOilSpecific.options[self.selectOilSpecific.selectedIndex].value;
}
};
OSType.prototype.clear = function () {
......@@ -837,6 +853,16 @@ var OSAmount = (function (_super) {
OSAmount.prototype.populateCard = function (geojson) {
var self = this;
var simulation = geojson.features[0].properties.simulation;
self.amountInput.value = simulation.amount;
var amountevt = document.createEvent('Event');
amountevt.initEvent("change", true, true);
self.amountInput.dispatchEvent(amountevt);
self.amountSelect.value = simulation.amountUnit;
self.durationInput.value = simulation.duration;
var durationevt = document.createEvent('Event');
durationevt.initEvent("change", true, true);
self.durationInput.dispatchEvent(durationevt);
self.durationSelect.value = simulation.durationUnit;
};
OSAmount.prototype.populateData = function (geojson) {
var self = this;
......
This diff is collapsed.
......@@ -309,6 +309,13 @@ class OSLocation extends OilSpillCard {
default:
break;
}
var simulation = geojson.features[0].properties.simulation;
self.depthInput.value = simulation.depth;
var observation = geojson.features[0].properties.observation[0];
var date = moment.utc(observation.date).format(self.dateFormat);
self.obsDateInput.value = date;
var time = moment.utc(observation.date).format(self.timeFormat);
self.obsTimeInput.value = time;
}
public populateData(geojson) {
......@@ -326,11 +333,12 @@ class OSLocation extends OilSpillCard {
"providerImgRef": null,
"providerType": null,
"type": "MANUAL",
"date": 1495538160000
"date": moment.utc(self.obsDateInput.value+' '+ self.obsTimeInput.value, self.datetimeFormat).valueOf()
};
geojson.features[0].properties["simulation"] = {};
geojson.features[0].properties["simulation"]["depth"] = self.depthInput.value;
geojson.features[0].properties["observation"] = {};
geojson.features[0].properties["observation"] = [];
geojson.features[0].properties["observation"].push(observation);
}
......@@ -776,17 +784,26 @@ class OSType extends OilSpillCard {
public populateCard(geojson) {
var self = this;
var simulation = geojson.features[0].properties.simulation;
if (simulation.oilclass == 'Oil classes') {
document.getElementById('osOilClassTab').click();;
self.selectOilClass.value = geojson.features[0].properties["simulation"]["substance"];
}
if (simulation.oilclass == 'Oil, specific') {
document.getElementById('osOilSpecificTab').click();
self.selectOilClass.value = geojson.features[0].properties["simulation"]["substance"];
}
}
public populateData(geojson) {
var self = this;
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;
geojson.features[0].properties["simulation"]["substance"] = 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;
geojson.features[0].properties["simulation"]["substance"] = self.selectOilSpecific.options[self.selectOilSpecific.selectedIndex].value;
}
}
......@@ -923,6 +940,18 @@ class OSAmount extends OilSpillCard {
public populateCard(geojson) {
var self = this;
var simulation = geojson.features[0].properties.simulation;
self.amountInput.value = simulation.amount;
var amountevt = document.createEvent('Event');
amountevt.initEvent("change", true, true);
self.amountInput.dispatchEvent(amountevt);
self.amountSelect.value = simulation.amountUnit;
self.durationInput.value = simulation.duration;
var durationevt = document.createEvent('Event');
durationevt.initEvent("change", true, true);
self.durationInput.dispatchEvent(durationevt);
self.durationSelect.value = simulation.durationUnit;
}
public populateData(geojson) {
......
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