Skip to content

Commit

Permalink
Merge branch 'master' of github.com:links-ads/ermes-web-frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
lucabruno91 committed Jul 26, 2024
2 parents dcaad7f + 1a03702 commit 39e0c1f
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 101 deletions.
3 changes: 3 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Ver.
-----------------------

Ver. 2.22.6 - 2024-05-17
-----------------------
- Bugfix - Small bugs (#200)

Ver. 2.22.5 - 2024-05-09
-----------------------
Expand Down
6 changes: 5 additions & 1 deletion public/locales/en/filters.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"report" : "Reports",
"mission" : "Missions",
"persons" : "People",
"fire": "Incendio",
"fire": "Flames",
"smoke": "Smoke",
"desc-detected": "Automatically Detected",
"desc-validated": "Validated / Manually Added",
"desc-discarded": "Discarded",
"set_filters": "Selected filters",
"any": "any",
"from_date": "From",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"all": "All",
"filter_by_type": "Filter by type",
"flood": "Flood",
"fire": "Flames",
"fire": "Fire",
"landslide": "Landslide",
"wind": "Wind",
"storm": "Storm",
Expand Down Expand Up @@ -55,6 +55,7 @@
"coord_org": "Coordinator",
"mission_state": "Mission state",
"associated_report_list": "List of associated reports",
"associatedReports": "Associated reports",
"operation_create": "Create",
"operation_update": "Update",
"operation_delete": "Delete",
Expand Down
6 changes: 5 additions & 1 deletion public/locales/it/filters.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"report" : "Segnalazioni",
"mission" : "Missioni",
"persons" : "Persone",
"fire": "Incendio",
"fire": "Fiamme",
"smoke": "Fumo",
"desc-detected": "Rilevato Automaticamente",
"desc-validated": "Validato / Aggiunto Manualmente",
"desc-discarded": "Scartato",
"set_filters": "Filtri impostati",
"any": "qualsiasi",
"from_date": "Da",
Expand Down
6 changes: 5 additions & 1 deletion public/locales/it/maps.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"all": "Tutti",
"filter_by_type": "Filtra per tipo",
"flood": "Allagamento",
"fire": "Fiamme",
"fire": "Incendio",
"landslide": "Slavina",
"wind": "Vento",
"storm": "Tempesta",
Expand Down Expand Up @@ -55,6 +55,7 @@
"coord_org": "Coordinatore",
"mission_state": "Stato missione",
"associated_report_list": "Lista segnalazioni associate",
"associatedReports": "Segnalazioni associate",
"operation_create": "Crea",
"operation_update": "Aggiorna",
"operation_delete": "Elimina",
Expand Down Expand Up @@ -174,6 +175,9 @@
"add": "Aggiungi",
"remove": "Rimuovi",
"confirm": "Conferma",
"confirmed": "Confermate/o",
"discard": "Scarta",
"disprove": "Scarta",
"disproved": "Scartate/o",
"hazard": "Evento"
}
16 changes: 8 additions & 8 deletions src/common/app-bar-widgets/brand-logo/brand-logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next'
import { staticAssetsUrl } from '../../../config/base-path'
import { AppConfig, AppConfigContext } from '../../../config'
import { getRandomBackgroundAndTextColors } from '../../../utils/color.utils'
import { useUITheme } from '../../../state/preferences/preferences.hooks'
import { useUITheme } from '../../../state/preferences/preferences.hooks'

const rotate360 = keyframes`
from {
Expand All @@ -19,7 +19,6 @@ const rotate360 = keyframes`
}
`


interface BrandLogoProps {
envTag?: string
envTagBackgroundColor?: string
Expand Down Expand Up @@ -51,6 +50,9 @@ export const BrandLogoD = styled.div<BrandLogoProps>`
height: 64px;
width: 226px;
}
@media (max-width: 960px) {
display: none;
}
&::after {
content: '${(props) => props.envTag || ''}';
Expand All @@ -67,7 +69,7 @@ export const BrandLogoD = styled.div<BrandLogoProps>`
text-transform: uppercase;
border-radius: 20px 5px 20px;
color: ${(props) => props.envTagColor || '#000'};
background-color: ${(props) => props.envTagBackgroundColor || '#FF0'}
background-color: ${(props) => props.envTagBackgroundColor || '#FF0'};
}
`

Expand All @@ -80,11 +82,9 @@ export const BrandLogo = memo(function BrandLogo() {
const { textColor, backgroundColor } = getColors()

const { theme, themeName } = useUITheme()
var logoSrc = new URL('icons/brand_light.png', staticAssetsUrl).href
if(themeName == 'light')
logoSrc = new URL('icons/brand_light.png', staticAssetsUrl).href
else
logoSrc = new URL('icons/brand_dark.png', staticAssetsUrl).href
var logoSrc = new URL('icons/brand_light.png', staticAssetsUrl).href
if (themeName == 'light') logoSrc = new URL('icons/brand_light.png', staticAssetsUrl).href
else logoSrc = new URL('icons/brand_dark.png', staticAssetsUrl).href
return (
<Route
render={({ location }) => {
Expand Down
4 changes: 2 additions & 2 deletions src/common/drawer/nav-drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ const useStyles = (props) =>
'.EdgeHeaderOffset': {
height: props.filterActive ? '107px!important' : 64,
'@media screen and (min-width: 514px)': {
height: props.filterActive ? '245px!important' : 64
height: props.filterActive ? '205px!important' : 64
},
'@media screen and (min-width: 1075px)': {
height: props.filterActive ? '205px!important' : 64
},
'@media screen and (min-width: 1321px)': {
height: props.filterActive ? '146px!important' : 64
},
'@media screen and (min-width: 1566px)': {
'@media screen and (min-width: 1430px)': {
height: props.filterActive ? '107px!important' : 64
}
}
Expand Down
94 changes: 49 additions & 45 deletions src/pages/protected/events/map/map-click-handler.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,54 @@
import { polygon } from "@turf/helpers"
import { clearEventMap, drawPolyToMap, parseEvent } from "../../../../common/map/map-common"
import { CLUSTER_LAYER_ID, EVENTS_LAYER_ID, getColorForHazard, SOURCE_ID } from "./map-init"

import { polygon } from '@turf/helpers'
import { clearEventMap, drawPolyToMap, parseEvent } from '../../../../common/map/map-common'
import { CLUSTER_LAYER_ID, EVENTS_LAYER_ID, getColorForHazard, SOURCE_ID } from './map-init'

export const mapClickHandler = (evt, mapRef, leftClickState, setLeftClickState, spiderifierRef) => {
// handle only left click
evt.preventDefault()
evt.stopPropagation()
if (!evt['leftButton']) {
return
}
const features = evt.features
const map = mapRef.current?.getMap()
//check that a point with features has been clicked
if (map && Array.isArray(features) && features.length > 0) {
const layer = features[0]['layer']['id'] as string
if (layer === EVENTS_LAYER_ID || layer.startsWith(SOURCE_ID + '-spider-leaves')) {
// Cast is necessary
const feature = (features[0] as unknown) as GeoJSON.Feature<GeoJSON.Point>
const properties = feature.properties
const centroid = JSON.parse(properties?.center)
const coordinates = JSON.parse(properties?.polygon)
drawPolyToMap(
map,
{ longitude: centroid[0], latitude: centroid[1] },
polygon(coordinates, properties),
getColorForHazard as mapboxgl.Expression
)
const newLeftClickState = { showPoint: true, clickedPoint: { long: centroid[0], lat: centroid[1] }, pointFeatures: parseEvent(properties) }
setLeftClickState(newLeftClickState)
}
else if (layer === CLUSTER_LAYER_ID) {
// Depending on settings, it will either expand the cluster or open the spider
if (spiderifierRef.current && mapRef.current) {
spiderifierRef.current.toggleSpiders(map, evt)
}
setLeftClickState({ showPoint: false, clickedPoint: null, pointFeatures: { ...leftClickState.pointFeatures } })
}
else {
clearEventMap(map, setLeftClickState, leftClickState)
}
// handle only left click
evt.preventDefault()
evt.stopPropagation()
if (!evt['leftButton']) {
return
}
const features = evt.features
const map = mapRef.current?.getMap()
//check that a point with features has been clicked
if (map && Array.isArray(features) && features.length > 0) {
const layer = features[0]['layer']['id'] as string
if (layer === EVENTS_LAYER_ID || layer.startsWith(SOURCE_ID + '-spider-leaves')) {
// Cast is necessary
const feature = features[0] as unknown as GeoJSON.Feature<GeoJSON.Point>
const properties = feature.properties
const centroid = JSON.parse(properties?.center)
const coordinates = JSON.parse(properties?.polygon)[0]
drawPolyToMap(
map,
{ longitude: centroid[0], latitude: centroid[1] },
polygon(coordinates, properties),
getColorForHazard as mapboxgl.Expression
)
const newLeftClickState = {
showPoint: true,
clickedPoint: { long: centroid[0], lat: centroid[1] },
pointFeatures: parseEvent(properties)
}
setLeftClickState(newLeftClickState)
} else if (layer === CLUSTER_LAYER_ID) {
// Depending on settings, it will either expand the cluster or open the spider
if (spiderifierRef.current && mapRef.current) {
spiderifierRef.current.toggleSpiders(map, evt)
}
setLeftClickState({
showPoint: false,
clickedPoint: null,
pointFeatures: { ...leftClickState.pointFeatures }
})
} else {
clearEventMap(map, setLeftClickState, leftClickState)
}
else {
// Clear feature
if (map) {
clearEventMap(map, setLeftClickState, leftClickState)
}
} else {
// Clear feature
if (map) {
clearEventMap(map, setLeftClickState, leftClickState)
}
}
}
4 changes: 2 additions & 2 deletions src/pages/protected/map/api-data/emergency.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,8 @@ function StationCard({ data, latitude, longitude }) {
</CardActions>
<CardActions className={ccmClasses.cardAction}>
<div className={ccmClasses.chipContainer}>
<CameraChip status={hasFire} label={t('maps:fire')} />
<CameraChip status={hasSmoke} label={t('maps:smoke')} />
<CameraChip status={hasFire} label={t('filters:fire')} />
<CameraChip status={hasSmoke} label={t('filters:smoke')} />
</div>
<Button variant="contained" color="primary" size="small" onClick={handleShowDetails}>
{t('common:details')}
Expand Down
8 changes: 1 addition & 7 deletions src/pages/protected/map/common.components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,12 @@ export const MapContainer = styled(SizeAwareContainer).attrs({ className: 'map-c
top: 269px;
}
@media screen and (min-width: 365px) {
top: 229px;
top: 189px;
}
@media screen and (min-width: 514px) {
top: 181px;
}
@media screen and (min-width: 1054px) {
top: 141px;
}
@media screen and (min-width: 1321px) {
top: 83px;
}
@media screen and (min-width: 1566px) {
top: 43px;
}
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function ValidatedIcon({ type, avatar = false }) {
backgroundColor: containerColor
}}
>
{t(`maps:${type}`)}
{t(`filters:${type}`)}
<CheckCircle
style={{ fill: iconColor, backgroundColor: 'black', borderRadius: '50%', fontSize: 14 }}
/>
Expand All @@ -39,7 +39,7 @@ export function DiscardedIcon({ type, avatar = false }) {
backgroundColor: containerColor
}}
>
{t(`maps:${type}`)}
{t(`filters:${type}`)}
<Cancel style={{ fill: iconColor, fontSize: 14 }} />
</div>
)
Expand All @@ -59,7 +59,7 @@ export function DetectedIcon({ type }) {
backgroundColor: containerColor
}}
>
{t(`maps:${type}`)}
{t(`filters:${type}`)}
<Cancel
style={{
fill: iconColor,
Expand Down
24 changes: 12 additions & 12 deletions src/pages/protected/map/map-drawer/camera-details.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const PAGE_SIZE = 3
function ValidationButton({ show, baseColor, onClick, metadata, type, value = null }: any) {
const theme = useTheme()

const { t } = useTranslation(['common', 'maps'])
const { t } = useTranslation(['common', 'maps', 'filters'])

if (!show) {
return null
Expand Down Expand Up @@ -93,49 +93,49 @@ function ValidationButton({ show, baseColor, onClick, metadata, type, value = nu
>
{validationStatus === CameraValidationStatus.DetectedAndValidated && value && (
<>
{t(`maps:${type}`)} {t('maps:confirmed')} <CheckCircle />
{t(`filters:${type}`)} {t('maps:confirmed')} <CheckCircle />
</>
)}

{validationStatus === CameraValidationStatus.DetectedAndDiscarded && value === false && (
<>
{t(`maps:${type}`)} {t('maps:disproved')} <Cancel />
{t(`filters:${type}`)} {t('maps:disproved')} <Cancel />
</>
)}

{validationStatus === CameraValidationStatus.UndetectedAndAdded && (
<>
{t(`maps:remove`)} {t(`maps:${type}`)} <RemoveCircle />
{t(`maps:remove`)} {t(`filters:${type}`)} <RemoveCircle />
</>
)}

{validationStatus === CameraValidationStatus.Undetected && (
<>
{t(`maps:add`)} {t(`maps:${type}`)} <AddCircle />
{t(`maps:add`)} {t(`filters:${type}`)} <AddCircle />
</>
)}

{validationStatus === CameraValidationStatus.Detected && value && (
<>
{t(`maps:confirm`)} {t(`maps:${type}`)} <CheckCircle />
{t(`maps:confirm`)} {t(`filters:${type}`)} <CheckCircle />
</>
)}

{validationStatus === CameraValidationStatus.DetectedAndDiscarded && value && (
<>
{t(`maps:confirm`)} {t(`maps:${type}`)} <CheckCircle />
{t(`maps:confirm`)} {t(`filters:${type}`)} <CheckCircle />
</>
)}

{validationStatus === CameraValidationStatus.Detected && value === false && (
<>
{t(`maps:disprove`)} {t(`maps:${type}`)} <Cancel />
{t(`maps:disprove`)} {t(`filters:${type}`)} <Cancel />
</>
)}

{validationStatus === CameraValidationStatus.DetectedAndValidated && value === false && (
<>
{t(`maps:disprove`)} {t(`maps:${type}`)} <Cancel />
{t(`maps:disprove`)} {t(`filters:${type}`)} <Cancel />
</>
)}
</Button>
Expand All @@ -145,7 +145,7 @@ function ValidationButton({ show, baseColor, onClick, metadata, type, value = nu
const emptyArray = []

export function CameraDetails({}: CameraDetailsProps) {
const { t } = useTranslation(['common', 'maps'])
const { t } = useTranslation(['common', 'maps', 'filters'])
const elem = useSelector((state: AppState) => state.selectedCameraState)
const hasMeasurements = elem?.sensors?.some((sensor) => sensor.measurements?.length)
const [selectedSensorId, setSelectedSensorId] = useState<string | undefined>()
Expand Down Expand Up @@ -344,8 +344,8 @@ export function CameraDetails({}: CameraDetailsProps) {
label={
<div>
<div style={localStyles.badgeContainer}>
<CameraChip status={hasFire} label={t('maps:fire')} />
<CameraChip status={hasSmoke} label={t('maps:smoke')} />
<CameraChip status={hasFire} label={t('filters:fire')} />
<CameraChip status={hasSmoke} label={t('filters:smoke')} />
</div>
<img
style={{ width: 200, height: 100, objectFit: 'cover' }}
Expand Down
Loading

0 comments on commit 39e0c1f

Please sign in to comment.