From c5533cecd2da5ade2056b1c996229c2a64154e4e Mon Sep 17 00:00:00 2001 From: CindyvdVries Date: Fri, 5 Jun 2020 07:57:27 +0200 Subject: [PATCH 1/7] Update data-set-controls.vue --- components/data-set-controls.vue | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/components/data-set-controls.vue b/components/data-set-controls.vue index f95cfaa4..69dbc64e 100644 --- a/components/data-set-controls.vue +++ b/components/data-set-controls.vue @@ -20,7 +20,7 @@ @click="toggleRasterLayer(dataset.id)" /> -
+
@@ -30,6 +30,16 @@ class="data-set-controls__tooltip-text markdown" /> +
+ +

[{{ dataset.units }}]

@@ -48,9 +58,10 @@ import Panel from './panel' import UiRadio from './ui-radio' import UiToggle from './ui-toggle' + import UiSelect from './ui-select' export default { - components: { Icon, LayerLegend, Panel, UiRadio, UiToggle, VueMarkdown }, + components: { Icon, LayerLegend, Panel, UiRadio, UiToggle, VueMarkdown, UiSelect }, props: { datasets: { type: Array, @@ -60,6 +71,7 @@ data() { return { hoverId: null, + layerSelected: '', } }, computed: { @@ -72,6 +84,16 @@ themeName() { return _.get(this.getActiveTheme, 'name') || 'All datasets' }, + // layerSelected: { + // get() { + // console.log(this.activeRasterData) + // return this.activeRasterData.layerOptions.find(data => data.selected === true) + // }, + // set(val) { + // console.log(val) + // this.dataset + // }, + // }, }, methods: { onTooltipClick(id) { From 2edef6c4edaf9bc635b07e04bcaeca2ae601bfb3 Mon Sep 17 00:00:00 2001 From: CindyvdVries Date: Fri, 5 Jun 2020 12:48:03 +0200 Subject: [PATCH 2/7] configurable layers by select --- components/data-set-controls.vue | 60 +++++++++++++++++++++++--------- components/graph-line.vue | 8 ++--- components/layer-legend.vue | 17 +++++---- store/map/index.js | 7 ++-- 4 files changed, 60 insertions(+), 32 deletions(-) diff --git a/components/data-set-controls.vue b/components/data-set-controls.vue index ddc46a09..d0b8d600 100644 --- a/components/data-set-controls.vue +++ b/components/data-set-controls.vue @@ -36,12 +36,16 @@ >
- + +

[{{ dataset.units }}]

@@ -49,7 +53,7 @@ @@ -199,7 +223,8 @@ } .data-set-controls__legend-bar { - flex: 0 0 100%; + flex: 1 1 auto; + margin-right: 0.5rem; } .data-set-controls__legend p { @@ -208,4 +233,7 @@ .data-set-controls__item-radio { width: 32px; } + .data-set-controls__select-layer { + margin-top: var(--spacing-small); + } diff --git a/components/graph-line.vue b/components/graph-line.vue index a0816b0e..cb61eaa2 100644 --- a/components/graph-line.vue +++ b/components/graph-line.vue @@ -8,13 +8,13 @@ > -
+
{{ title }}
@@ -28,17 +28,17 @@ Download data Download image diff --git a/components/layer-legend.vue b/components/layer-legend.vue index 20e14542..550eab63 100644 --- a/components/layer-legend.vue +++ b/components/layer-legend.vue @@ -18,33 +18,33 @@
- {{ minValue }}{{ unit }} + {{ minValue }}{{ unit }}
-
- {{ maxValue }}{{ unit }} +
+ {{ maxValue }}{{ unit }}
- Cancel - Reset - Save + Cancel + Reset + Save
@@ -108,7 +108,6 @@ min: this.minValue, max: this.maxValue, } - this.retrieveRasterLayerByImageId({ imageId, range }) }, }, diff --git a/store/map/index.js b/store/map/index.js index c04e1a9c..29142a40 100644 --- a/store/map/index.js +++ b/store/map/index.js @@ -132,11 +132,12 @@ export const actions = { }) }, - retrieveRasterLayerByImageId({ commit, state, getters }, { imageId, range }) { + retrieveRasterLayerByImageId({ commit, state, getters }, options) { commit('setLoadingRasterLayers', true) + const imageId = options.imageId const dataset = getters.getActiveRasterLayer - const params = range ? `?min=${range.min}&max=${range.max}` : '' - + let params = options.range ? `?min=${options.range.min}&max=${options.range.max}` : '' + params += options.band ? `?band=${options.band}` : '' // Retrieve complete new rasterLayer by imageId and dataset return getFromApi(`datasets/${dataset}/${imageId}${params}`).then(val => { commit('updateRasterLayer', { dataset, rasterLayer: val }) From 47173d38fd2ddc954c09d77630cb0e4078f0e329 Mon Sep 17 00:00:00 2001 From: CindyvdVries Date: Fri, 5 Jun 2020 16:38:37 +0200 Subject: [PATCH 3/7] lint fix --- components/data-set-controls.vue | 4 ++-- components/graph-line.vue | 8 ++++---- components/layer-legend.vue | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/components/data-set-controls.vue b/components/data-set-controls.vue index 8779dfe1..614449a5 100644 --- a/components/data-set-controls.vue +++ b/components/data-set-controls.vue @@ -24,7 +24,7 @@ @click="toggleRasterLayer(dataset.id)" />
-
+
@@ -42,10 +42,10 @@
diff --git a/components/graph-line.vue b/components/graph-line.vue index f85fd4d8..6da05d07 100644 --- a/components/graph-line.vue +++ b/components/graph-line.vue @@ -8,13 +8,13 @@ > -
+
{{ title }}
Download data Download image diff --git a/components/layer-legend.vue b/components/layer-legend.vue index 550eab63..35101850 100644 --- a/components/layer-legend.vue +++ b/components/layer-legend.vue @@ -18,7 +18,7 @@
- {{ minValue }}{{ unit }} + {{ minValue }}{{ unit }}
-
- {{ maxValue }}{{ unit }} +
+ {{ maxValue }}{{ unit }}
- Cancel - Reset - Save + Cancel + Reset + Save
From 853df07f48ecfc9682cd02499de0012c24070c64 Mon Sep 17 00:00:00 2001 From: CindyvdVries Date: Tue, 9 Jun 2020 08:25:12 +0200 Subject: [PATCH 4/7] fix setting legend and initial layer selected --- components/data-set-controls.vue | 7 ++++--- components/layer-legend.vue | 23 +++++++++++++++++------ layouts/default.vue | 3 +-- store/map/index.js | 4 ++-- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/components/data-set-controls.vue b/components/data-set-controls.vue index 614449a5..b880301b 100644 --- a/components/data-set-controls.vue +++ b/components/data-set-controls.vue @@ -86,9 +86,10 @@ activeRasterData: { handler(data) { const datasets = this.getDatasets - const raster = datasets[this.getActiveRasterLayer] - if (raster.layerOptions) { - this.selectedLayer = raster.name + const meta = datasets[this.getActiveRasterLayer].metadata + const raster = datasets[this.getActiveRasterLayer].raster + if (meta.layerOptions) { + this.selectedLayer = raster.band } }, deep: true, diff --git a/components/layer-legend.vue b/components/layer-legend.vue index 35101850..af942b8f 100644 --- a/components/layer-legend.vue +++ b/components/layer-legend.vue @@ -60,7 +60,7 @@ props: { unit: { type: String, - required: true, + default: () => '', }, }, data() { @@ -75,15 +75,26 @@ computed: { ...mapGetters('map', ['activeRasterData', 'activeRasterLegendData']), }, + watch: { + activeRasterLegendData: { + handler() { + this.updateMinMax() + }, + deep: true, + }, + }, mounted() { - const { min, max } = this.activeRasterLegendData - this.minValue = min.toString() - this.defaultMinValue = min.toString() - this.maxValue = max.toString() - this.defaultMaxValue = max.toString() + this.updateMinMax() }, methods: { ...mapActions('map', ['retrieveRasterLayerByImageId']), + updateMinMax() { + const { min, max } = this.activeRasterLegendData + this.minValue = min.toString() + this.defaultMinValue = min.toString() + this.maxValue = max.toString() + this.defaultMaxValue = max.toString() + }, cancelEditRange() { this.minValue = this.defaultMinValue this.maxValue = this.defaultMaxValue diff --git a/layouts/default.vue b/layouts/default.vue index 780f0239..631c574d 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -59,7 +59,7 @@ - +
@@ -224,7 +224,6 @@ setStyleLayers() { // Wait for refs to be loaded - console.log(this.$refs, _.get(this.$refs, 'map.map')) this.map = this.$refs.map.map // Wait for map to be loaded and then add background labels and features this.map.addLayer({ diff --git a/store/map/index.js b/store/map/index.js index 29142a40..3813e633 100644 --- a/store/map/index.js +++ b/store/map/index.js @@ -140,7 +140,7 @@ export const actions = { params += options.band ? `?band=${options.band}` : '' // Retrieve complete new rasterLayer by imageId and dataset return getFromApi(`datasets/${dataset}/${imageId}${params}`).then(val => { - commit('updateRasterLayer', { dataset, rasterLayer: val }) + commit('updateRasterLayer', { dataset, rasterLayer: val.rasterLayer }) commit('setLoadingRasterLayers', false) }) }, @@ -293,7 +293,7 @@ export const getters = { } return _.get(datasets, `${activeRasterLayerId}.raster`) }, - activeRasterLegendData({ datasets, activeRasterLayerId, activeDatasets }) { + activeRasterLegendData({ datasets, activeRasterLayerId }) { // Return the active raster data tiles (if not defined, return []) if (activeRasterLayerId === '' || activeRasterLayerId === null) { return [] From c340fb1eae75e2fe8a2dab6eb0f640989aa6fd88 Mon Sep 17 00:00:00 2001 From: CindyvdVries Date: Tue, 9 Jun 2020 08:41:46 +0200 Subject: [PATCH 5/7] correction in band retrieval --- store/map/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/store/map/index.js b/store/map/index.js index 3813e633..f848fb9c 100644 --- a/store/map/index.js +++ b/store/map/index.js @@ -137,7 +137,14 @@ export const actions = { const imageId = options.imageId const dataset = getters.getActiveRasterLayer let params = options.range ? `?min=${options.range.min}&max=${options.range.max}` : '' - params += options.band ? `?band=${options.band}` : '' + + // If band has changed, use band from options. If band is not defined use already set band + if (options.band) { + params += `?band=${options.band}` + } else if (_.get(getters, 'activeRasterData.band')) { + params += `?band=${_.get(getters, 'activeRasterData.band')}` + } + console.log(params) // Retrieve complete new rasterLayer by imageId and dataset return getFromApi(`datasets/${dataset}/${imageId}${params}`).then(val => { commit('updateRasterLayer', { dataset, rasterLayer: val.rasterLayer }) From f5a26c26a10ec9d5d72a4b76cc647e41dad67e83 Mon Sep 17 00:00:00 2001 From: CindyvdVries Date: Wed, 10 Jun 2020 10:07:08 +0200 Subject: [PATCH 6/7] review update 1 --- components/data-set-controls.vue | 19 +++++++++---------- components/layer-legend.vue | 16 ++++++++-------- components/time-stamp.vue | 8 ++++---- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/components/data-set-controls.vue b/components/data-set-controls.vue index b880301b..7dc5190c 100644 --- a/components/data-set-controls.vue +++ b/components/data-set-controls.vue @@ -24,7 +24,7 @@ @click="toggleRasterLayer(dataset.id)" />
-
+
@@ -42,10 +42,10 @@
@@ -108,7 +108,7 @@ }, }, methods: { - ...mapActions('map', ['retrieveRasterLayerByImageId']), + ...mapActions('map', ['retrieveRasterLayer']), onTooltipClick(id) { this.hoverId ? (this.hoverId = null) : (this.hoverId = id) }, @@ -136,15 +136,14 @@ const option = raster.metadata.layerOptions.find(opt => { return opt.band === this.selectedLayer }) - this.retrieveRasterLayerByImageId({ imageId: raster.raster.imageId, band: option.band }) + this.retrieveRasterLayer({ imageId: raster.raster.imageId, band: option.band }) }, - optionItems(layers) { + items(options) { // Add value to the array to use in the ui-select - const options = layers.map(layer => { - layer.value = layer.band - return layer + return options.map(option => { + option.value = option.band + return option }) - return options }, }, } diff --git a/components/layer-legend.vue b/components/layer-legend.vue index af942b8f..3a2634eb 100644 --- a/components/layer-legend.vue +++ b/components/layer-legend.vue @@ -18,7 +18,7 @@
- {{ minValue }}{{ unit }} + {{ minValue }}{{ unit }}
-
- {{ maxValue }}{{ unit }} +
+ {{ maxValue }}{{ unit }}
- Cancel - Reset - Save + Cancel + Reset + Save
@@ -87,7 +87,7 @@ this.updateMinMax() }, methods: { - ...mapActions('map', ['retrieveRasterLayerByImageId']), + ...mapActions('map', ['retrieveRasterLayer']), updateMinMax() { const { min, max } = this.activeRasterLegendData this.minValue = min.toString() @@ -119,7 +119,7 @@ min: this.minValue, max: this.maxValue, } - this.retrieveRasterLayerByImageId({ imageId, range }) + this.retrieveRasterLayer({ imageId, range }) }, }, } diff --git a/components/time-stamp.vue b/components/time-stamp.vue index 5942c322..929e0541 100644 --- a/components/time-stamp.vue +++ b/components/time-stamp.vue @@ -6,8 +6,8 @@