Skip to content

Commit 745695c

Browse files
committed
Merge branch 'dev'
2 parents a985650 + 3dc183b commit 745695c

File tree

87 files changed

+580
-343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+580
-343
lines changed

app/actuators/ReactiveMap.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export default class ReactiveMap extends Component {
152152
}
153153

154154
afterChannelResponse(res) {
155-
const getResult = ReactiveMapHelper.afterChannelResponse(res, this.state.rawData, this.props.appbaseField, this.state.markersData);
155+
const getResult = ReactiveMapHelper.afterChannelResponse(res, this.state.rawData, this.props.dataField, this.state.markersData);
156156
this.reposition = true;
157157
this.streamFlag = getResult.streamFlag;
158158
this.queryStartTime = getResult.queryStartTime ? getResult.queryStartTime : 0;
@@ -190,15 +190,15 @@ export default class ReactiveMap extends Component {
190190
key: "geoQuery",
191191
value: {
192192
queryType: "geo_bounding_box",
193-
inputData: this.props.appbaseField,
193+
inputData: this.props.dataField,
194194
customQuery: this.geoCustomQuery
195195
}
196196
};
197197
const obj1 = {
198198
key: "updateExecute",
199199
value: {
200200
queryType: "random",
201-
inputData: this.props.appbaseField
201+
inputData: this.props.dataField
202202
}
203203
};
204204

@@ -211,7 +211,7 @@ export default class ReactiveMap extends Component {
211211
if (value && (this.initialMapBoundQuery || this.searchAsMove)) {
212212
query = {
213213
geo_bounding_box: {
214-
[this.props.appbaseField]: value
214+
[this.props.dataField]: value
215215
}
216216
};
217217
if (this.geoRelatedEventsChange) {
@@ -442,10 +442,10 @@ export default class ReactiveMap extends Component {
442442
};
443443
if (markersData && markersData.length) {
444444
markersData = markersData.filter((hit) => {
445-
return ReactiveMapHelper.identifyGeoData(hit._source[self.props.appbaseField]);
445+
return ReactiveMapHelper.identifyGeoData(hit._source[self.props.dataField]);
446446
});
447447
response.markerComponent = markersData.map((hit, index) => {
448-
const field = ReactiveMapHelper.identifyGeoData(hit._source[self.props.appbaseField]);
448+
const field = ReactiveMapHelper.identifyGeoData(hit._source[self.props.dataField]);
449449
response.convertedGeo.push(field);
450450
const position = {
451451
position: field
@@ -638,7 +638,7 @@ export default class ReactiveMap extends Component {
638638
}
639639

640640
ReactiveMap.propTypes = {
641-
appbaseField: React.PropTypes.string.isRequired,
641+
dataField: React.PropTypes.string.isRequired,
642642
onIdle: React.PropTypes.func,
643643
onAllData: React.PropTypes.func,
644644
onData: React.PropTypes.func,

app/helper/ReactiveMapHelper.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function Bearing(lat1, lng1, lat2, lng2) {
1616
}
1717

1818
// append stream boolean flag and also start time of stream
19-
export function streamDataModify(rawData, res, appbaseField) {
19+
export function streamDataModify(rawData, res, dataField) {
2020
if (res.data) {
2121
res.data.stream = true;
2222
res.data.streamStart = new Date();
@@ -26,8 +26,8 @@ export function streamDataModify(rawData, res, appbaseField) {
2626
} else {
2727
const prevData = rawData.hits.hits.filter(hit => hit._id === res.data._id);
2828
if (prevData && prevData.length) {
29-
const preCord = prevData[0]._source[appbaseField];
30-
const newCord = res.data._source[appbaseField];
29+
const preCord = prevData[0]._source[dataField];
30+
const newCord = res.data._source[dataField];
3131
res.data.angleDeg = Bearing(preCord.lat, preCord.lon, newCord.lat, newCord.lon);
3232
}
3333
const hits = rawData.hits.hits.filter(hit => hit._id !== res.data._id);
@@ -43,10 +43,10 @@ export function streamDataModify(rawData, res, appbaseField) {
4343
}
4444

4545
// tranform the raw data to marker data
46-
export function setMarkersData(data, appbaseField) {
46+
export function setMarkersData(data, dataField) {
4747
if (data && data.hits && data.hits.hits) {
4848
let markersData = data.hits.hits.map((hit, index) => {
49-
hit._source.mapPoint = identifyGeoData(hit._source[appbaseField]);
49+
hit._source.mapPoint = identifyGeoData(hit._source[dataField]);
5050
return hit;
5151
});
5252
markersData = markersData.filter((hit, index) => hit._source.mapPoint && !(hit._source.mapPoint.lat === 0 && hit._source.mapPoint.lng === 0));
@@ -113,7 +113,7 @@ export function identifyGeoData(input) {
113113
return convertedGeo;
114114
}
115115

116-
export function afterChannelResponse(res, rawData, appbaseField, oldMarkersData) {
116+
export function afterChannelResponse(res, rawData, dataField, oldMarkersData) {
117117
const data = res.data;
118118
let markersData;
119119
const response = {
@@ -123,19 +123,19 @@ export function afterChannelResponse(res, rawData, appbaseField, oldMarkersData)
123123
};
124124
if (res.mode === "streaming") {
125125
response.channelMethod = "streaming";
126-
const modData = streamDataModify(rawData, res, appbaseField);
126+
const modData = streamDataModify(rawData, res, dataField);
127127
rawData = modData.rawData;
128128
res = modData.res;
129129
response.streamFlag = true;
130-
markersData = setMarkersData(rawData, appbaseField);
130+
markersData = setMarkersData(rawData, dataField);
131131
response.currentData = oldMarkersData;
132-
res.data._source.mapPoint = identifyGeoData(res.data._source[appbaseField]);
132+
res.data._source.mapPoint = identifyGeoData(res.data._source[dataField]);
133133
response.newData = res.data;
134134
} else if (res.mode === "historic") {
135135
response.channelMethod = "historic";
136136
response.queryStartTime = res.startTime;
137137
rawData = data;
138-
markersData = setMarkersData(data, appbaseField);
138+
markersData = setMarkersData(data, dataField);
139139
response.newData = markersData;
140140
}
141141
response.rawData = rawData;

app/sensors/GeoDistanceDropdown.js

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export default class GeoDistanceDropdown extends Component {
167167
key: this.props.componentId,
168168
value: {
169169
queryType: this.type,
170-
appbaseField: this.props.appbaseField,
170+
dataField: this.props.dataField,
171171
customQuery: this.props.customQuery ? this.props.customQuery : this.customQuery,
172172
reactiveId: this.context.reactiveId,
173173
showFilter: this.props.showFilter,
@@ -185,7 +185,7 @@ export default class GeoDistanceDropdown extends Component {
185185
if (value && value.start >= 0 && value.end >= 0 && value.location !== "") {
186186
query = {
187187
[this.type]: {
188-
[this.props.appbaseField]: value.location,
188+
[this.props.dataField]: value.location,
189189
from: value.start + this.unit,
190190
to: value.end + this.unit
191191
}
@@ -228,7 +228,13 @@ export default class GeoDistanceDropdown extends Component {
228228

229229
const execQuery = () => {
230230
if(this.props.onValueChange) {
231-
this.props.onValueChange(obj.value);
231+
this.props.onValueChange({
232+
input: this.state.currentValue,
233+
start: this.state.selected.start,
234+
end: this.state.selected.end,
235+
location: this.locString,
236+
unit: this.unit
237+
});
232238
}
233239
helper.selectedSensor.setSortInfo(sortObj);
234240
helper.URLParams.update(this.props.componentId, this.setURLValue(), this.props.URLParams);
@@ -239,15 +245,21 @@ export default class GeoDistanceDropdown extends Component {
239245
key: this.props.componentId,
240246
value: {
241247
[this.sortInfo.type]: {
242-
[this.props.appbaseField]: this.locString,
248+
[this.props.dataField]: this.locString,
243249
order: this.sortInfo.order,
244250
unit: this.unit
245251
}
246252
}
247253
};
248254

249255
if (this.props.beforeValueChange) {
250-
this.props.beforeValueChange(obj.value)
256+
this.props.beforeValueChange({
257+
input: this.state.currentValue,
258+
start: this.state.selected.start,
259+
end: this.state.selected.end,
260+
location: this.locString,
261+
unit: this.unit
262+
})
251263
.then(() => {
252264
execQuery();
253265
})
@@ -271,7 +283,7 @@ export default class GeoDistanceDropdown extends Component {
271283
}
272284

273285
if (this.props.beforeValueChange) {
274-
this.props.beforeValueChange(obj.value)
286+
this.props.beforeValueChange(null)
275287
.then(() => {
276288
execNullQuery();
277289
})
@@ -310,14 +322,26 @@ export default class GeoDistanceDropdown extends Component {
310322

311323
const execQuery = () => {
312324
if(this.props.onValueChange) {
313-
this.props.onValueChange(obj.value);
325+
this.props.onValueChange({
326+
input: null,
327+
start: this.state.selected.start,
328+
end: this.state.selected.end,
329+
location: null,
330+
unit: this.unit
331+
});
314332
}
315333
helper.URLParams.update(this.props.componentId, null, this.props.URLParams);
316334
helper.selectedSensor.set(obj, true);
317335
};
318336

319337
if (this.props.beforeValueChange) {
320-
this.props.beforeValueChange(obj.value)
338+
this.props.beforeValueChange({
339+
input: null,
340+
start: this.state.selected.start,
341+
end: this.state.selected.end,
342+
location: null,
343+
unit: this.unit
344+
})
321345
.then(() => {
322346
execQuery();
323347
})
@@ -428,7 +452,7 @@ export default class GeoDistanceDropdown extends Component {
428452

429453
GeoDistanceDropdown.propTypes = {
430454
componentId: React.PropTypes.string.isRequired,
431-
appbaseField: React.PropTypes.string.isRequired,
455+
dataField: React.PropTypes.string.isRequired,
432456
title: React.PropTypes.oneOfType([
433457
React.PropTypes.string,
434458
React.PropTypes.element
@@ -477,8 +501,8 @@ GeoDistanceDropdown.contextTypes = {
477501

478502
GeoDistanceDropdown.types = {
479503
componentId: TYPES.STRING,
480-
appbaseField: TYPES.STRING,
481-
appbaseFieldType: TYPES.GEO_POINT,
504+
dataField: TYPES.STRING,
505+
dataFieldType: TYPES.GEO_POINT,
482506
title: TYPES.STRING,
483507
data: TYPES.ARRAY,
484508
unit: TYPES.STRING,

app/sensors/GeoDistanceSlider.js

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export default class GeoDistanceSlider extends Component {
2121
this.defaultSelected.distance < this.props.range.start ?
2222
this.props.range.start : this.defaultSelected.distance : this.props.range.start;
2323
value = parseInt(value, 10);
24-
this.defaultSelected.distance = parseInt(this.defaultSelected.distance, 10);
24+
if (this.defaultSelected) {
25+
this.defaultSelected.distance = parseInt(this.defaultSelected.distance, 10);
26+
}
2527
this.state = {
2628
currentValue: "",
2729
currentDistance: value + this.props.unit,
@@ -150,7 +152,7 @@ export default class GeoDistanceSlider extends Component {
150152
key: this.props.componentId,
151153
value: {
152154
queryType: this.type,
153-
appbaseField: this.props.appbaseField,
155+
dataField: this.props.dataField,
154156
customQuery: this.props.customQuery ? this.props.customQuery : this.customQuery,
155157
reactiveId: this.context.reactiveId,
156158
showFilter: this.props.showFilter,
@@ -168,7 +170,7 @@ export default class GeoDistanceSlider extends Component {
168170
if (value && value.currentValue !== "" && value.location !== "") {
169171
query = {
170172
[this.type]: {
171-
[this.props.appbaseField]: value.location,
173+
[this.props.dataField]: value.location,
172174
distance: value.currentDistance
173175
}
174176
};
@@ -210,7 +212,7 @@ export default class GeoDistanceSlider extends Component {
210212
key: this.props.componentId,
211213
value: {
212214
[this.sortInfo.type]: {
213-
[this.props.appbaseField]: this.locString,
215+
[this.props.dataField]: this.locString,
214216
order: this.sortInfo.order,
215217
unit: this.sortInfo.unit
216218
}
@@ -219,15 +221,25 @@ export default class GeoDistanceSlider extends Component {
219221

220222
const execQuery = () => {
221223
if(this.props.onValueChange) {
222-
this.props.onValueChange(obj.value);
224+
this.props.onValueChange({
225+
input: this.state.currentValue,
226+
distance: this.state.currentDistance,
227+
location: this.locString,
228+
unit: this.props.unit
229+
});
223230
}
224231
helper.selectedSensor.setSortInfo(sortObj);
225232
helper.URLParams.update(this.props.componentId, this.setURLValue(), this.props.URLParams);
226233
helper.selectedSensor.set(obj, true);
227234
};
228235

229236
if (this.props.beforeValueChange) {
230-
this.props.beforeValueChange(obj.value)
237+
this.props.beforeValueChange({
238+
input: this.state.currentValue,
239+
distance: this.state.currentDistance,
240+
location: this.locString,
241+
unit: this.props.unit
242+
})
231243
.then(() => {
232244
execQuery();
233245
})
@@ -251,7 +263,7 @@ export default class GeoDistanceSlider extends Component {
251263
}
252264

253265
if (this.props.beforeValueChange) {
254-
this.props.beforeValueChange(obj.value)
266+
this.props.beforeValueChange(null)
255267
.then(() => {
256268
execNullQuery();
257269
})
@@ -293,13 +305,23 @@ export default class GeoDistanceSlider extends Component {
293305

294306
const execQuery = () => {
295307
if(this.props.onValueChange) {
296-
this.props.onValueChange(obj.value);
308+
this.props.onValueChange({
309+
input: null,
310+
distance: this.state.currentDistance,
311+
location: null,
312+
unit: this.props.unit
313+
});
297314
}
298315
helper.selectedSensor.set(obj, true);
299316
};
300317

301318
if (this.props.beforeValueChange) {
302-
this.props.beforeValueChange(obj.value)
319+
this.props.beforeValueChange({
320+
input: null,
321+
distance: this.state.currentDistance,
322+
location: null,
323+
unit: this.props.unit
324+
})
303325
.then(() => {
304326
execQuery();
305327
})
@@ -426,7 +448,7 @@ export default class GeoDistanceSlider extends Component {
426448

427449
GeoDistanceSlider.propTypes = {
428450
componentId: React.PropTypes.string.isRequired,
429-
appbaseField: React.PropTypes.string.isRequired,
451+
dataField: React.PropTypes.string.isRequired,
430452
title: React.PropTypes.oneOfType([
431453
React.PropTypes.string,
432454
React.PropTypes.element
@@ -484,8 +506,8 @@ GeoDistanceSlider.contextTypes = {
484506

485507
GeoDistanceSlider.types = {
486508
componentId: TYPES.STRING,
487-
appbaseField: TYPES.STRING,
488-
appbaseFieldType: TYPES.GEO_POINT,
509+
dataField: TYPES.STRING,
510+
dataFieldType: TYPES.GEO_POINT,
489511
title: TYPES.STRING,
490512
range: TYPES.OBJECT,
491513
rangeLabels: TYPES.OBJECT,

0 commit comments

Comments
 (0)