diff --git a/document/archive/README_Sync.md b/document/archive/README_Sync.md index a1e388de95df606219332098b75a34ceefaf3d8a..2a2295dfa6c17063bd313679791b391a4518be5e 100644 --- a/document/archive/README_Sync.md +++ b/document/archive/README_Sync.md @@ -2,7 +2,7 @@ > Technical details about Sync process ## Features -### 1. One way sync +### 1. One way sync > One way Sync received the required data from Server and overwrites to local (normally local storage) <br> Affected data in Ony way sync @@ -21,6 +21,7 @@ Data in one way sync stored in localstorage system. Affected data in two way sync : ``` Observation List +Observation Time Series List Point of Interest (POI) List ``` In Two way Sync, text data stored in localstorage system and image data stored in local IndexedDB @@ -46,7 +47,7 @@ syncOneWayDifferentTimeStamp() > This one way sync works when data changes in server with different timestamp ### syncTwoWay() ->As mentioned earlier, two way sync works mainly on Observations and Point of Interests. +>As mentioned earlier, two way sync works mainly on Observations and Point of Interests. <br> This function decides which services (Observation / Point of interest) required and call method ``` syncTwoWayInitiate() ``` for initiate two way sync. diff --git a/src/components/CommonUtil.vue b/src/components/CommonUtil.vue index 7174fc752b6411fae5e5844f36c7c0c49d028ed4..709d2780864037e2372e443a3ea715cde48e0827 100644 --- a/src/components/CommonUtil.vue +++ b/src/components/CommonUtil.vue @@ -85,11 +85,24 @@ CONST_FIELD_MANDATORY: '<font color=red>*</font>', - logInfo: function(message) { + logInfo: function(message, obj) { if(CommonUtilLocal.CONST_DEBUG){ - console.info(message); + if (obj !== undefined) { + console.info(message, obj); + } else { + console.info(message); + } } }, + logError: function(message, obj) { + if(CommonUtilLocal.CONST_DEBUG) { + if (obj !== undefined) { + console.error(message, obj); + } else { + console.error(message); + } + } + }, timeSeriesLabel(observationTimeSeries) { if (observationTimeSeries && observationTimeSeries.name) { let timeSeriesName = observationTimeSeries.name; diff --git a/src/components/Observation.vue b/src/components/Observation.vue index e9321fc19314848f04b8d3842b707eab70746895..73e2abd5c27ef7e7b49fec9a13c717120cae3b39 100644 --- a/src/components/Observation.vue +++ b/src/components/Observation.vue @@ -650,8 +650,11 @@ export default { } this.observationForStore.userId = this.observation.userId; this.observationForStore.observationTimeSeriesId = this.observation.observationTimeSeriesId; - this.observationForStore.geoinfo = JSON.stringify(this.mapGeoinfo); - this.observationForStore.locationPointOfInterestId = this.mapLocationPointOfInterestId; + if(this.mapLocationPointOfInterestId) { + this.observationForStore.locationPointOfInterestId = this.mapLocationPointOfInterestId; + } else { + this.observationForStore.geoinfo = JSON.stringify(this.mapGeoinfo); + } this.observationForStore.broadcastMessage = this.observation.broadcastMessage; this.observationForStore.statusRemarks = this.observation.statusRemarks; this.observationForStore.observationHeading = this.observation.observationHeading; @@ -833,7 +836,6 @@ export default { // Special treatment if observation belongs to an observation time series if (this.paramObservationTimeSeries) { - console.info("this.paramObservationTimeSeries", this.paramObservationTimeSeries) this.observation.observationTimeSeries = this.paramObservationTimeSeries; this.observation.observationTimeSeriesId = this.paramObservationTimeSeries.observationTimeSeriesId; @@ -842,8 +844,6 @@ export default { this.observation.cropOrganismId = this.paramObservationTimeSeries.cropOrganismId; this.observation.organismId = this.paramObservationTimeSeries.organismId; - // TODO Remove geoinfo? - this.observation.geoinfo = this.paramObservationTimeSeries.geoInfo; this.observation.locationPointOfInterestId = this.paramObservationTimeSeries.locationPointOfInterestId; this.observation.locationPointOfInterest = this.paramObservationTimeSeries.locationPointOfInterest; this.observation.locationIsPrivate = this.paramObservationTimeSeries.locationIsPrivate; diff --git a/src/components/Sync.vue b/src/components/Sync.vue index 2307928f9190211e097965b8c6c721aacb3cd0b4..8b4be9a6e25da83745ad3b14d6e0707d4ddde66b 100644 --- a/src/components/Sync.vue +++ b/src/components/Sync.vue @@ -178,6 +178,8 @@ export default { } This.syncTwoWayInitiate(value, strUrl); }); + } else { + CommonUtil.logError("Offline, sync is not run"); } }, @@ -718,6 +720,7 @@ export default { if (response.status === 200) { //CommonUtil.logInfo("Done POSTING") } else { + console.error("Posting failed with status code " + response.status, This.CONST_URL_DOMAIN + CommonUtil.CONST_URL_SYNC_UPDATE_OBSERVATION) /** Even if the response is not success, still need to increase the counter, * to decide for next action after all PUSH */ This.counterTwoWaySyncPOST = This.counterTwoWaySyncPOST + 1; @@ -1015,7 +1018,6 @@ export default { .then((data) => { let jsonServerOtsList = data; let jsonLocalOtsList = localStorage.getItem(CommonUtil.CONST_STORAGE_OBSERVATION_TIME_SERIES_LIST); - if (jsonLocalOtsList) { jsonLocalOtsList = JSON.parse(jsonLocalOtsList);