From 902013f0838770226e11aa22d2c5a0480af875e0 Mon Sep 17 00:00:00 2001 From: Luke McFarlane Date: Thu, 8 Aug 2024 14:27:55 +1000 Subject: [PATCH 1/9] Added pull request template file Signed-off-by: Luke McFarlane --- .github/pull_request_template.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..7a8bdd10e --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,26 @@ +# FEAT/FIX: + +## JIRA Ticket + +[<JIRA_TICKET>](https://jira.csiro.com/browse/<JIRA_TICKET>) + +## Description + +Briefly describe the purpose of this pull request. + +## Proposed Changes + +List the changes made in this PR. + +## How to Test + +Explain how to test the changes. + +## Additional Information s + +Add any additional information or context about the pull request here. + +## Checklist + +- [ ] I have confirmed all commits have been signed. +- [ ] I have added JSDoc style comments to any new functions or classes. From 8073f6c10a8fd085c7efbe048fa7660c0b0c4e01 Mon Sep 17 00:00:00 2001 From: Luke McFarlane <luke.mcfarlane@rocketlab.com.au> Date: Thu, 8 Aug 2024 14:49:14 +1000 Subject: [PATCH 2/9] Fixed a typo and removed title from template Signed-off-by: Luke McFarlane <luke.mcfarlane@rocketlab.com.au> --- .github/pull_request_template.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 7a8bdd10e..0f52cb4e3 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,5 +1,3 @@ -# FEAT/FIX: <title> - ## JIRA Ticket [<JIRA_TICKET>](https://jira.csiro.com/browse/<JIRA_TICKET>) @@ -16,7 +14,7 @@ List the changes made in this PR. Explain how to test the changes. -## Additional Information s +## Additional Information Add any additional information or context about the pull request here. From e20ef282fc716c75f14a412e7fcd7fe3bb9e713a Mon Sep 17 00:00:00 2001 From: Luke McFarlane <luke.mcfarlane@rocketlab.com.au> Date: Thu, 8 Aug 2024 14:59:27 +1000 Subject: [PATCH 3/9] Added title and extra checklist item Signed-off-by: Luke McFarlane <luke.mcfarlane@rocketlab.com.au> --- .github/pull_request_template.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 0f52cb4e3..bd560fbbe 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,3 +1,5 @@ +# feat(scope): pr title in semver format + ## JIRA Ticket [<JIRA_TICKET>](https://jira.csiro.com/browse/<JIRA_TICKET>) @@ -22,3 +24,4 @@ Add any additional information or context about the pull request here. - [ ] I have confirmed all commits have been signed. - [ ] I have added JSDoc style comments to any new functions or classes. +- [ ] Relevant documentation such as READMEs, guides, and class comments are updated. From 64ec03e31e656007212583425d2850601dfa1e12 Mon Sep 17 00:00:00 2001 From: Luke McFarlane <luke.mcfarlane@rocketlab.com.au> Date: Tue, 13 Aug 2024 12:00:44 +1000 Subject: [PATCH 4/9] Added zoom buttons to map component, updated styling Signed-off-by: Luke McFarlane <luke.mcfarlane@rocketlab.com.au> --- app/src/gui/fields/maps/MapWrapper.tsx | 3 ++- app/src/index.css | 28 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/src/gui/fields/maps/MapWrapper.tsx b/app/src/gui/fields/maps/MapWrapper.tsx index 58a8a782a..e08ca7747 100644 --- a/app/src/gui/fields/maps/MapWrapper.tsx +++ b/app/src/gui/fields/maps/MapWrapper.tsx @@ -36,6 +36,7 @@ import {register} from 'ol/proj/proj4'; import Button, {ButtonProps} from '@mui/material/Button'; import CloseIcon from '@mui/icons-material/Close'; import GeoJSON from 'ol/format/GeoJSON'; +import Zoom from 'ol/control/Zoom'; // define some EPSG codes - these are for two sample images // TODO: we need to have a better way to include a useful set or allow @@ -131,7 +132,7 @@ function MapWrapper(props: MapProps) { target: element, layers: [tileLayer], view: view, - controls: [], + controls: [new Zoom()], }); theMap.getView().setCenter(center); diff --git a/app/src/index.css b/app/src/index.css index ec2585e8c..feb591879 100644 --- a/app/src/index.css +++ b/app/src/index.css @@ -11,3 +11,31 @@ code { font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } + +.ol-zoom { + position: absolute; + right: 12px; + bottom: 12px; + background-color: white; + border-radius: 6px; + display: flex; + flex-direction: column; + gap: 12px; + padding: 12px; +} + +.ol-zoom-in { + font-size: 24px; + background-color: rgb(23 23 23); + color: white; + font-weight: bold; + border-radius: 6px; +} + +.ol-zoom-out { + font-size: 24px; + background-color: rgb(23 23 23); + color: white; + font-weight: bold; + border-radius: 6px; +} \ No newline at end of file From fd48e7f2e74c8540ef816385fa0f2216fec9cc1a Mon Sep 17 00:00:00 2001 From: Luke McFarlane <luke.mcfarlane@rocketlab.com.au> Date: Tue, 13 Aug 2024 16:26:57 +1000 Subject: [PATCH 5/9] Created react DOM icon/button/styling, updated map component to use custom control Signed-off-by: Luke McFarlane <luke.mcfarlane@rocketlab.com.au> --- app/src/App.css | 21 +++++++++++ .../components/map/center-control-icon.tsx | 22 ++++++++++++ app/src/gui/components/map/center-control.tsx | 35 +++++++++++++++++++ app/src/gui/fields/maps/MapWrapper.tsx | 3 ++ 4 files changed, 81 insertions(+) create mode 100644 app/src/gui/components/map/center-control-icon.tsx create mode 100644 app/src/gui/components/map/center-control.tsx diff --git a/app/src/App.css b/app/src/App.css index ca0fe3c41..df4dd4d7c 100644 --- a/app/src/App.css +++ b/app/src/App.css @@ -25,3 +25,24 @@ background-color: #e0e0e0; font-weight:700 } + +.ol-center-button { + padding: 1px; + display: flex; + justify-content: center; + align-items: center; + background-color: rgb(23 23 23); + border-radius: 6px; +} + +.ol-center-box { + position: absolute; + right: 12px; + bottom: 128px; + background-color: white; + border-radius: 6px; + display: flex; + flex-direction: column; + gap: 12px; + padding: 12px; +} \ No newline at end of file diff --git a/app/src/gui/components/map/center-control-icon.tsx b/app/src/gui/components/map/center-control-icon.tsx new file mode 100644 index 000000000..bbd8386d6 --- /dev/null +++ b/app/src/gui/components/map/center-control-icon.tsx @@ -0,0 +1,22 @@ +/** + * Creates an SVG icon for the center control button. + * + * @returns {SVGSVGElement} - The SVG element representing the center control icon. + */ +export const CenterControlIcon = () => { + const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + svg.setAttribute('width', '24'); + svg.setAttribute('height', '24'); + svg.setAttribute('viewBox', '0 0 24 24'); + + const path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + path.setAttribute( + 'd', + 'M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm8.94-3c-.46-4.17-3.77-7.48-7.94-7.94V1h-2v2.06C6.83 3.52 3.52 6.83 3.06 11H1v2h2.06c.46 4.17 3.77 7.48 7.94 7.94V23h2v-2.06c4.17-.46 7.48-3.77 7.94-7.94H23v-2h-2.06zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z' + ); + path.setAttribute('fill', '#ffffff'); + + svg.appendChild(path); + + return svg; +}; diff --git a/app/src/gui/components/map/center-control.tsx b/app/src/gui/components/map/center-control.tsx new file mode 100644 index 000000000..f06527bfd --- /dev/null +++ b/app/src/gui/components/map/center-control.tsx @@ -0,0 +1,35 @@ +import {Control} from 'ol/control'; +import {Coordinate} from 'ol/coordinate'; +import {View} from 'ol'; +import {CenterControlIcon} from './center-control-icon'; + +/** + * Creates a custom control button that centers the map view to a specified coordinate. + * + * @param {View} view - The map view instance to be controlled. + * @param {Coordinate} center - The coordinate to which the map view should be centered. + * @returns {Control} - The custom control instance. + */ +export const createCenterControl = ( + view: View, + center: Coordinate +): Control => { + const button = document.createElement('button'); + button.className = 'ol-center-button'; + + button.appendChild(CenterControlIcon()); + + const handleClick = () => { + view.setCenter(center); + }; + + button.addEventListener('click', handleClick); + + const element = document.createElement('div'); + element.className = 'ol-center-box'; + element.appendChild(button); + + return new Control({ + element: element, + }); +}; diff --git a/app/src/gui/fields/maps/MapWrapper.tsx b/app/src/gui/fields/maps/MapWrapper.tsx index 58a8a782a..dc74fc639 100644 --- a/app/src/gui/fields/maps/MapWrapper.tsx +++ b/app/src/gui/fields/maps/MapWrapper.tsx @@ -64,6 +64,7 @@ interface MapProps extends ButtonProps { import {AppBar, Dialog, IconButton, Toolbar, Typography} from '@mui/material'; import Feature from 'ol/Feature'; import {Geometry} from 'ol/geom'; +import {createCenterControl} from '../../components/map/center-control'; const styles = { mapContainer: { @@ -134,6 +135,8 @@ function MapWrapper(props: MapProps) { controls: [], }); + theMap.addControl(createCenterControl(theMap.getView(), center)); + theMap.getView().setCenter(center); return theMap; From c1da328fe9817cf2d699c9e8f0a95ac56bdbf8ee Mon Sep 17 00:00:00 2001 From: Peter Baker <peter.baker122@csiro.au> Date: Wed, 14 Aug 2024 10:04:25 +1000 Subject: [PATCH 6/9] Improving git ignore to not include dist/bak generated during readme setup Signed-off-by: Peter Baker <peter.baker122@csiro.au> --- api/.gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/.gitignore b/api/.gitignore index 85abb98ea..2f9f432cf 100644 --- a/api/.gitignore +++ b/api/.gitignore @@ -120,4 +120,7 @@ local_auth/ local_state/ projects_dummy_listing/ keys -couchdb/*.ini \ No newline at end of file +couchdb/*.ini + +couchdb/local.ini* +!couchdb/local.ini.dist \ No newline at end of file From 867c317ef86ba895bba6c5575400e556442ceebb Mon Sep 17 00:00:00 2001 From: Peter Baker <peter.baker122@csiro.au> Date: Thu, 15 Aug 2024 08:16:51 +1000 Subject: [PATCH 7/9] making node modules purge script executable Signed-off-by: Peter Baker <peter.baker122@csiro.au> --- purge.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 purge.sh diff --git a/purge.sh b/purge.sh old mode 100644 new mode 100755 From 8e35ff967cdbdce612e814608fbbf3c620c33b91 Mon Sep 17 00:00:00 2001 From: Luke McFarlane <luke.mcfarlane@rocketlab.com.au> Date: Thu, 15 Aug 2024 12:06:25 +1000 Subject: [PATCH 8/9] removed ambiguity in title Signed-off-by: Luke McFarlane <luke.mcfarlane@rocketlab.com.au> --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index bd560fbbe..b733548a7 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,4 +1,4 @@ -# feat(scope): pr title in semver format +# feat/fix/chore: pr title ## JIRA Ticket From 80c9226423329a1eec92d3bca703ce459e386213 Mon Sep 17 00:00:00 2001 From: Luke McFarlane <luke.mcfarlane@rocketlab.com.au> Date: Thu, 15 Aug 2024 15:13:50 +1000 Subject: [PATCH 9/9] Moved svg into separate file, generalised function for creating dom icons, updated button Signed-off-by: Luke McFarlane <luke.mcfarlane@rocketlab.com.au> --- .../components/map/center-control-icon.tsx | 22 ------------- app/src/gui/components/map/center-control.tsx | 12 +++++-- app/src/gui/components/map/dom-icon.tsx | 32 +++++++++++++++++++ app/src/target.svg | 5 +++ 4 files changed, 47 insertions(+), 24 deletions(-) delete mode 100644 app/src/gui/components/map/center-control-icon.tsx create mode 100644 app/src/gui/components/map/dom-icon.tsx create mode 100644 app/src/target.svg diff --git a/app/src/gui/components/map/center-control-icon.tsx b/app/src/gui/components/map/center-control-icon.tsx deleted file mode 100644 index bbd8386d6..000000000 --- a/app/src/gui/components/map/center-control-icon.tsx +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Creates an SVG icon for the center control button. - * - * @returns {SVGSVGElement} - The SVG element representing the center control icon. - */ -export const CenterControlIcon = () => { - const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); - svg.setAttribute('width', '24'); - svg.setAttribute('height', '24'); - svg.setAttribute('viewBox', '0 0 24 24'); - - const path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); - path.setAttribute( - 'd', - 'M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm8.94-3c-.46-4.17-3.77-7.48-7.94-7.94V1h-2v2.06C6.83 3.52 3.52 6.83 3.06 11H1v2h2.06c.46 4.17 3.77 7.48 7.94 7.94V23h2v-2.06c4.17-.46 7.48-3.77 7.94-7.94H23v-2h-2.06zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z' - ); - path.setAttribute('fill', '#ffffff'); - - svg.appendChild(path); - - return svg; -}; diff --git a/app/src/gui/components/map/center-control.tsx b/app/src/gui/components/map/center-control.tsx index f06527bfd..1fefb5ae1 100644 --- a/app/src/gui/components/map/center-control.tsx +++ b/app/src/gui/components/map/center-control.tsx @@ -1,7 +1,8 @@ import {Control} from 'ol/control'; import {Coordinate} from 'ol/coordinate'; import {View} from 'ol'; -import {CenterControlIcon} from './center-control-icon'; +import {CreateDomIcon} from './dom-icon'; +import src from '../../../target.svg'; /** * Creates a custom control button that centers the map view to a specified coordinate. @@ -17,7 +18,14 @@ export const createCenterControl = ( const button = document.createElement('button'); button.className = 'ol-center-button'; - button.appendChild(CenterControlIcon()); + button.appendChild( + CreateDomIcon({ + src, + width: 24, + height: 24, + alt: 'Center map', + }) + ); const handleClick = () => { view.setCenter(center); diff --git a/app/src/gui/components/map/dom-icon.tsx b/app/src/gui/components/map/dom-icon.tsx new file mode 100644 index 000000000..4961d4c91 --- /dev/null +++ b/app/src/gui/components/map/dom-icon.tsx @@ -0,0 +1,32 @@ +interface CenterControlIconProps { + src: string; + width: number; + height: number; + alt: string; +} + +/** + * Creates a DOM image element with the specified properties. + * + * @param {CenterControlIconProps} props - The properties for the image element. + * @param {string} props.src - The source URL of the image. + * @param {number} props.width - The width of the image in pixels. + * @param {number} props.height - The height of the image in pixels. + * @param {string} props.alt - The alternative text for the image. + * @returns {HTMLImageElement} - The created image element. + */ +export const CreateDomIcon = ({ + src, + width, + height, + alt, +}: CenterControlIconProps) => { + const img = document.createElement('img'); + + img.width = width; + img.height = height; + img.src = src; + img.alt = alt; + + return img; +}; diff --git a/app/src/target.svg b/app/src/target.svg new file mode 100644 index 000000000..ea0c2ed43 --- /dev/null +++ b/app/src/target.svg @@ -0,0 +1,5 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> + <g fill="#ffffff"> + <path d="M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm8.94-3c-.46-4.17-3.77-7.48-7.94-7.94V1h-2v2.06C6.83 3.52 3.52 6.83 3.06 11H1v2h2.06c.46 4.17 3.77 7.48 7.94 7.94V23h2v-2.06c4.17-.46 7.48-3.77 7.94-7.94H23v-2h-2.06zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"/> + </g> +</svg> \ No newline at end of file