Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions client/cypress/component/watershed/MapPointSelector.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import MapPointSelector from '@/components/MapPointSelector.vue';

describe('<MapPointSelector />', () => {
it('watershed page', () => {
cy.mount(MapPointSelector, {
props: {
points: [{
properties: {
lic: "TEST LICENSE",
org: "DOMESTIC",
qty: 10000,
src_name: "TEST SOURCE",
pod: "TEST POD",
}
}],
open: true,
page: 'watershed',
}
});
cy.get('[data-cy="point-qty"]').should('have.text', ' Quantity: 10000 m³/year ')
});

it('waterportal page', () => {
cy.mount(MapPointSelector, {
props: {
points: [{
properties: {
name: "TEST NAME",
yr: "[2010,2011]",
area: 1000,
net: "TEST NETWORK",
}
}],
open: true,
page: 'waterportal',
}
});

cy.get('[data-cy="point-yr"]').should('have.text', ' Year Range: 2010-2011')
cy.get('[data-cy="point-area"]').should('have.text', ' Area: 1000.0km2')
});
});
50 changes: 29 additions & 21 deletions client/src/components/MapFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@
Analysis metrics:
<template
v-for = "analysis in filters.other.analyses"
:key = "analysis.key"
>
<q-chip
v-if = "analysis.key in activePoint.properties && activePoint.properties[analysis.key]"
:key = "analysis.key"
dense
>
{{ analysis.label }}
Expand Down Expand Up @@ -159,6 +159,7 @@
>
<div
v-for="button in localFilters.matchFilters.find(cat => cat.category === 'Type').filters"
:key="button.label"
class="legend-item"
>
<div class="legend-point">
Expand Down Expand Up @@ -333,16 +334,25 @@
dense
/>
</div>

<div

<div
v-if="props.loading"
class="map-points-loader"
>
<q-spinner size="lg" />
<div class="q-mt-sm">
Getting points in map view...
</div>
</div>
<div
v-if="filteredPoints && !filteredPoints.length"
class="q-ma-md"
>
<div class="text-h6">
No results.
No results.
</div>
<div v-if="textFilter?.length">
You have a search filter applied that may be too restrictive.
You have a search filter applied that may be too restrictive.
</div>
There may be no {{ props.pointsName.toLowerCase() }} in the current map view.
</div>
Expand Down Expand Up @@ -388,17 +398,14 @@
<q-item-label
class="item-label"
>
<div>
<span v-if="'org' in item.properties">
<div v-if="'org' in item.properties">
{{ item.properties.org }}
</span>
<span class="q-mx-sm">∙</span>
<span v-if="'qty' in item.properties && item.properties.qty > 0">
{{ item.properties.qty }} m³/year
</span>
</div>
<div v-if="'src_name' in item.properties">
Source: {{ item.properties.src_name }}
</div>
<div v-if="'qty' in item.properties && item.properties.qty > 0">
Quantity: {{ item.properties.qty }} m³/year
</div>
<div v-if="'src_name' in item.properties">
Source: {{ item.properties.src_name }}
</div>
<div v-if="'nid' in item.properties">
Licence: <span>({{ item.properties.nid }})</span>
Expand Down Expand Up @@ -440,7 +447,7 @@
Station: {{ item.properties.name }}
</q-item-label>
<q-item-label v-if="'yr' in item.properties" class="item-label">
Year Range: {{ item.properties.yr[0] }} - {{ item.properties.yr[item.properties.yr.length - 1] }}
Year Range: {{ yearRangeString(item.properties.yr) }}
</q-item-label>
<q-item-label v-if="'area' in item.properties" class="item-label">
Area: {{ item.properties.area }}km²
Expand Down Expand Up @@ -470,7 +477,8 @@
</template>

<script setup>
import { computed, onMounted, ref, watch } from "vue";
import { computed, ref, watch } from "vue";
import { yearRangeString } from "@/utils/stringHelpers.js";

const props = defineProps({
allPoints: {
Expand Down Expand Up @@ -624,9 +632,9 @@ const filteredPoints = computed(() => {
return (
point.properties.id.toString().includes(textFilter.value) ||
('lic' in point.properties && point.properties.lic.toString().toLowerCase().includes(textFilter.value.toLowerCase())) ||
('nid' in point.properties && point.properties.nid.toString().toLowerCase().includes(textFilter.value.toLowerCase())) ||
('src_name' in point.properties && point.properties.src_name.toString().toLowerCase().includes(textFilter.value.toLowerCase())) ||
('pod' in point.properties && point.properties.pod.toString().toLowerCase().includes(textFilter.value.toLowerCase())) ||
('nid' in point.properties && point.properties.nid.toString().toLowerCase().includes(textFilter.value.toLowerCase())) ||
('src_name' in point.properties && point.properties.src_name.toString().toLowerCase().includes(textFilter.value.toLowerCase())) ||
('pod' in point.properties && point.properties.pod.toString().toLowerCase().includes(textFilter.value.toLowerCase())) ||
('org' in point.properties && point.properties.org.toString().toLowerCase().includes(textFilter.value.toLowerCase()))
)
}
Expand Down Expand Up @@ -790,7 +798,7 @@ const clearFilters = () => {
border: 2px solid black;
border-radius: 50%;
margin-right: 1rem;

&.GW {
background-color: #234075;
border-color: white;
Expand Down
72 changes: 61 additions & 11 deletions client/src/components/MapPointSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,84 @@
:model-value="props.open"
@update:model-value="emit('close')"
>
<q-card
<q-card
class="popup-content"
square
>
<q-card-section
class="header"
>
<div class="row">
<div class="spaced-flex-row">
<div class="text-h6">{{ props.points.length }} points at these coordinates</div>
<q-space />
<q-btn
icon="close"
flat
@click="emit('close')"
/>
</div>
</q-card-section>
<q-card-section
<q-card-section
class="points-list"
>
<q-list
separator
>
<q-item
v-for="point in props.points"
:key="point.id"
clickable
@click="() => selectPoint(point)"
>
<q-item-section>
<q-item-label v-if="'name' in point.properties"> Name: {{ point.properties.name }} </q-item-label>
<q-item-label> ID: {{ point.properties.id }} </q-item-label>
<q-item-label caption>
<q-icon name="location_on"/> {{ point.geometry.coordinates[0].toFixed(4) }}, {{ point.geometry.coordinates[1].toFixed(4) }}
</q-item-label>
<div v-if="props.page === 'watershed'">
<q-item-label v-if="'lic' in point.properties">{{ point.properties.lic }}</q-item-label>
<q-item-label
class="item-label"
caption
>
<div v-if="'org' in point.properties">
{{ point.properties.org }}
</div>
<div
v-if="'qty' in point.properties && point.properties.qty > 0"
data-cy="point-qty"
>
Quantity: {{ point.properties.qty }} m³/year
</div>
<div v-if="'src_name' in point.properties">
Source: {{ point.properties.src_name }}
</div>
<div v-if="'nid' in point.properties">
Licence: <span>({{ point.properties.nid }})</span>
</div>
<div v-if="'pod' in point.properties">
POD: {{ point.properties.pod }}
</div>
</q-item-label>
</div>
<div v-else-if="props.page === 'waterportal'">
<q-item-label v-if="'name' in point.properties"> {{ point.properties.name }} </q-item-label>
<q-item-label
class="item-label"
caption
>
<div
v-if="'yr' in point.properties"
data-cy="point-yr"
>
Year Range: {{ yearRangeString(JSON.parse(point.properties.yr)) }}
</div>
<div
v-if="'area' in point.properties"
data-cy="point-area"
>
Area: {{ point.properties.area.toFixed(1) }}km<sup>2</sup>
</div>
<div v-if="'net' in point.properties">
Network: {{ point.properties.net }}
</div>
</q-item-label>
</div>
</q-item-section>
</q-item>
</q-list>
Expand All @@ -46,6 +90,8 @@
</template>

<script setup>
import { yearRangeString } from "@/utils/stringHelpers.js";

const emit = defineEmits(['close']);

const props = defineProps({
Expand All @@ -62,7 +108,11 @@ const props = defineProps({
open: {
type: Boolean,
default: false,
}
},
page: {
type: String,
default: '',
},
});

const selectPoint = (point) => {
Expand All @@ -80,7 +130,7 @@ const selectPoint = (point) => {
overflow: hidden;
}
.points-list {
max-height: 20rem;
max-height: 22rem;
overflow-y: auto;
}
</style>
Loading
Loading