Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions .github/workflows/codetest-sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ jobs:
sed -i "s/<source>\/home\/runner\/work\/DriveBC.ca\/DriveBC.ca<\/source>/<source>\/github\/workspace<\/source>/g" /home/runner/work/DriveBC.ca/DriveBC.ca/coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@v8.2.0
with:
args: >
-Dsonar.exclusions=src/frontend/src/index.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6 changes: 3 additions & 3 deletions src/backend/apps/wildfire/tests/test_wildfire_populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@ def test_populate_wildfire_function(self):
**self.combine_with_area(holding_feature),
'status': WILDFIRE_STATUS.UNDR_CNTRL,
}
assert populate_wildfire_from_data(under_control_data) is None
assert not Wildfire.objects.filter(id='G90400').exists()
assert populate_wildfire_from_data(under_control_data) is not None
assert Wildfire.objects.filter(id='G90400').exists()

# Out, not populated
out_data = {
**self.combine_with_area(holding_feature),
'status': WILDFIRE_STATUS.OUT,
}
populate_wildfire_from_data(out_data)
assert not Wildfire.objects.filter(id='G90400').exists()
assert Wildfire.objects.filter(id='G90400').exists()

# Being Held
populate_wildfire_from_data(self.combine_with_area(holding_feature))
Expand Down
25 changes: 25 additions & 0 deletions src/frontend/src/Components/data/featureStyleDefinitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import cameraIconHover from '../../images/mapIcons/camera-hover.png';
import cameraIconStatic from '../../images/mapIcons/camera-static.png';
import cameraIconHoverUnread from '../../images/mapIcons/camera-hover-unread.png';
import cameraIconStaticUnread from '../../images/mapIcons/camera-static-unread.png';
import cameraGroupedIconActive from '../../images/mapIcons/camera-grouped-active.png';
import cameraGroupedIconHover from '../../images/mapIcons/camera-grouped-hover.png';
import cameraGroupedIconStatic from '../../images/mapIcons/camera-grouped-static.png';

// Ferries
import ferryIconActive from '../../images/mapIcons/ferry-active.png';
Expand Down Expand Up @@ -209,6 +212,28 @@ export const cameraStyles = {
}),
};

// Camera icon styles
export const cameraGroupedStyles = {
static: new Style({
image: new Icon({
scale: 0.25,
src: cameraGroupedIconStatic,
}),
}),
hover: new Style({
image: new Icon({
scale: 0.25,
src: cameraGroupedIconHover,
}),
}),
active: new Style({
image: new Icon({
scale: 0.25,
src: cameraGroupedIconActive,
}),
}),
};

export const unreadCameraStyles = {
static: new Style({
image: new Icon({
Expand Down
59 changes: 44 additions & 15 deletions src/frontend/src/Components/map/handlers/click.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// External imports
import { fromLonLat } from "ol/proj";
import { boundingExtent } from 'ol/extent';

Check warning on line 3 in src/frontend/src/Components/map/handlers/click.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import of 'boundingExtent'.

See more on https://sonarcloud.io/project/issues?id=bcgov_DriveBC.ca&issues=AZ9nTaVLvxAj1o_Zb6Ki&open=AZ9nTaVLvxAj1o_Zb6Ki&pullRequest=1385
Comment thread
github-code-quality[bot] marked this conversation as resolved.
Fixed

// Internal imports
import { isRestStopClosed } from '../../data/restStops.js';
Expand Down Expand Up @@ -188,7 +189,7 @@
updateClickedFeature(null);
break;
}
if (isCamDetail && targetFeature && targetFeature.get('type') === 'camera') {
if (isCamDetail && targetFeature?.get('type') === 'camera') {
if (highlighted_camera_list.length > 0) {
highlighted_camera_list[0].setCameraStyle('static');
highlighted_camera_list[0].set('clicked', false);
Expand Down Expand Up @@ -232,8 +233,7 @@
updateReferenceFeature,
mapContext
) => {
if ((clickedFeatureRef.current && clickedFeatureRef.current.values_.type == 'camera')
|| (clickedFeatureRef.current && (clickedFeatureRef.current.values_.type != feature.values_.type))) {
if (clickedFeatureRef.current?.values_?.type === 'camera' || clickedFeatureRef.current?.values_?.type !== feature.values_?.type) {
resetClickedStates(
feature,
clickedFeatureRef,
Expand All @@ -257,6 +257,7 @@
feature.setCameraStyle('active');
feature.set('clicked', true, true);
feature.set('unread', false);
feature.set('hovered', false);

if (isCamDetail) {
// Do not auto center on feature on cam details page
Expand Down Expand Up @@ -295,7 +296,7 @@
isCamDetail,
) => {
// reset previous clicked feature
if (!isCamDetail || !(clickedFeatureRef.current && clickedFeatureRef.current.values_.type == 'camera')) {
if (!isCamDetail || clickedFeatureRef.current?.values_?.type !== 'camera') {
resetClickedStates(
feature,
clickedFeatureRef,
Expand Down Expand Up @@ -330,7 +331,7 @@
isCamDetail,
) => {
// reset previous clicked feature
if (!isCamDetail || !(clickedFeatureRef.current && clickedFeatureRef.current.values_.type == 'camera')) {
if (!isCamDetail || clickedFeatureRef.current?.values_?.type !== 'camera') {
resetClickedStates(
feature,
clickedFeatureRef,
Expand All @@ -356,7 +357,7 @@
updateClickedFeature,
isCamDetail,
) => {
if (!isCamDetail || !(clickedFeatureRef.current && clickedFeatureRef.current.values_.type == 'camera')) {
if (!isCamDetail || clickedFeatureRef.current?.values_?.type !== 'camera') {
// reset previous clicked feature
resetClickedStates(
feature,
Expand All @@ -382,7 +383,7 @@
updateClickedFeature,
isCamDetail,
) => {
if (!isCamDetail || !(clickedFeatureRef.current && clickedFeatureRef.current.values_.type == 'camera')) {
if (!isCamDetail || clickedFeatureRef.current?.values_?.type !== 'camera') {
// reset previous clicked feature
resetClickedStates(
feature,
Expand Down Expand Up @@ -411,7 +412,7 @@
isCamDetail,
) => {
// reset previous clicked feature
if (!isCamDetail || !(clickedFeatureRef.current && clickedFeatureRef.current.values_.type == 'camera')) {
if (!isCamDetail || clickedFeatureRef.current?.values_?.type !== 'camera') {
resetClickedStates(
feature,
clickedFeatureRef,
Expand All @@ -438,7 +439,7 @@
isCamDetail,
) => {
// reset previous clicked feature
if (!isCamDetail || !(clickedFeatureRef.current && clickedFeatureRef.current.values_.type == 'camera')) {
if (!isCamDetail || clickedFeatureRef.current?.values_?.type !== 'camera') {
resetClickedStates(
feature,
clickedFeatureRef,
Expand Down Expand Up @@ -477,7 +478,7 @@
updateClickedFeature,
) => {
// reset previous clicked feature
if (!(clickedFeatureRef.current && clickedFeatureRef.current.values_.type == 'camera')) {
if (clickedFeatureRef.current?.values_?.type !== 'camera') {
resetClickedStates(
feature,
clickedFeatureRef,
Expand All @@ -501,7 +502,7 @@
isCamDetail,
) => {
// reset previous clicked feature
if (!isCamDetail || !(clickedFeatureRef.current && clickedFeatureRef.current.values_.type == 'camera')) {
if (!isCamDetail || clickedFeatureRef.current?.values_?.type !== 'camera') {
resetClickedStates(
feature,
clickedFeatureRef,
Expand Down Expand Up @@ -543,7 +544,7 @@
isCamDetail,
) => {
// reset previous clicked feature
if (!isCamDetail || !(clickedFeatureRef.current && clickedFeatureRef.current.values_.type == 'camera')) {
if (!isCamDetail || clickedFeatureRef.current?.values_?.type !== 'camera') {
resetClickedStates(
feature,
clickedFeatureRef,
Expand Down Expand Up @@ -580,8 +581,36 @@
mapContext
) => {
if (features.length) {
const clickedFeature = features[0];
switch (clickedFeature.getProperties()['type']) {
let clickedFeature = features[0];

const clusterFeatures = clickedFeature.get('features');

if (clusterFeatures) {
if (clusterFeatures.length > 1) {
clusterFeatures.forEach(feature => {
feature.set('hovered', false);
feature.set('clicked', false);
feature.setCameraStyle('static');
});

mapView.current.animate({
center: clickedFeature.getGeometry().getCoordinates(),
zoom: mapView.current.getZoom() + 1,
duration: 300,
});

return;
}

clickedFeature = clusterFeatures[0];
}

if (!clickedFeature.get('type')) {
clickedFeature = features[0].values_?.features[0];
}


switch (clickedFeature?.getProperties()['type']) {
case 'camera':
trackEvent(
'click',
Expand Down Expand Up @@ -793,7 +822,7 @@
isCamDetail,
) => {
// reset previous clicked feature
if (!(clickedFeatureRef.current && clickedFeatureRef.current.values_.type == 'camera')) {
if (clickedFeatureRef.current?.values_?.type !== 'camera') {
resetClickedStates(
feature,
clickedFeatureRef,
Expand Down
46 changes: 39 additions & 7 deletions src/frontend/src/Components/map/handlers/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,22 @@ export const resetHoveredStates = (targetFeature, hoveredFeatureRef) => {

// Reset feature if target isn't clicked
if (hoveredFeature && targetFeature != hoveredFeature) {

const clusterFeatures = hoveredFeature.get('features');
if (clusterFeatures && clusterFeatures.length > 1) {
clusterFeatures.forEach((f) => {
if (!f.get('clicked')) {
f.set('hovered', false);
}
});
} else



if (!hoveredFeature.getProperties().clicked) {
switch (hoveredFeature.getProperties()['type']) {
case 'camera':
hoveredFeature.set('hovered', false);
hoveredFeature.setCameraStyle('static');
break;
case 'event': {
Expand Down Expand Up @@ -148,15 +161,34 @@ export const pointerMoveHandler = (e, mapRef, hoveredFeature) => {
});

if (features.length) {
const targetFeature = features[0];
resetHoveredStates(targetFeature, hoveredFeature);
hoveredFeature.current = targetFeature;
let targetFeature = features[0];
let clusterFeatures = targetFeature?.get('features');
if(targetFeature && !targetFeature.get('type')) {

// Set hover style if feature isn't clicked
switch (targetFeature.getProperties()['type']) {
if (clusterFeatures?.length === 1) {
targetFeature = clusterFeatures[0];
clusterFeatures = null;
}
}

const realFeature = targetFeature;
resetHoveredStates(realFeature, hoveredFeature);
hoveredFeature.current = realFeature;

if (clusterFeatures?.length > 1) {
clusterFeatures.forEach((f) => {
if (!f.get('clicked')) {
f.set('hovered', true);
}
});
return;
}

switch (realFeature?.get('type')) {
case 'camera':
if (!targetFeature.get('clicked')) {
targetFeature.setCameraStyle('hover');
if (!realFeature.get('clicked')) {
realFeature.setCameraStyle('hover');
realFeature.set('hovered', true);
}
return;
case 'event':
Expand Down
Loading