Skip to content

Commit

Permalink
Merge pull request #2333 from GlobalFishingWatch/deck-migration/base-…
Browse files Browse the repository at this point in the history
…branch

Deck migration/base branch
  • Loading branch information
satellitestudiodesign authored Jul 29, 2024
2 parents f543767 + fa09e81 commit 06b28d0
Show file tree
Hide file tree
Showing 682 changed files with 25,321 additions and 12,537 deletions.
2 changes: 2 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ data-transforms:
- libs/data-transforms/**/*
dataviews-client:
- libs/dataviews-client/**/*
deck-layer-composer:
- libs/deck-layer-composer/**/*
deck-layers:
- libs/deck-layers/**/*
deck-loaders:
Expand Down
32 changes: 17 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@ This monorepo hosts frontend packages and applications of the <a href="https://g

All of them availables with the `@globalfishingwatch/` prefix:

| | |
| ------------------------------------------------- | ------------------------------------------------------------------------------ |
| [api-client](libs/api-client) | JS library to simplify GFW API login and resources fetch |
| [api-types](libs/api-types) | API typescript schema definitions |
| [data-transforms](libs/data-transforms) | Set ot shared tools for data transformations |
| [deck-layers-composer](libs/deck-layers-composer) | Deck classes for GFW layers and its react integration |
| [dataviews-client](libs/dataviews-client) | Api-client wrapper to fetch and edit dataviews and associated datasets/data |
| [fourwings-aggregate](libs/fourwings-aggregate) | Logic to turn fourwings tiles or cells into meaningful values for the frontend |
| [i18n-labels](libs/i18n-labels) | GFW shared translations |
| [layer-composer](libs/layer-composer) | Orchestrates various Layer Generators to generate a Mapbox GL Style document |
| [ocean-areas](libs/ocean-areas) | Small library to get ocean area / eez names by viewport or by text search |
| [pbf-decoders](libs/pbf-decoders) | PBF custom responses parsers |
| [react-hooks](libs/react-hooks) | Set of hooks to use libraries easily in react |
| [timebar](libs/timebar) | Timebar component, not many more to say |
| [ui-components](libs/ui-components) | Reusable atoms components kit |
| | |
| ----------------------------------------------- | ------------------------------------------------------------------------------ |
| [api-client](libs/api-client) | JS library to simplify GFW API login and resources fetch |
| [api-types](libs/api-types) | API typescript schema definitions |
| [data-transforms](libs/data-transforms) | Set ot shared tools for data transformations |
| [deck-layer-composer](libs/deck-layer-composer) | Map integration of the deck-layers |
| [deck-layers](libs/deck-layers) | Deck classes for GFW layers |
| [deck-loaders](libs/deck-loaders) | Deck loaders for GFW layers |
| [dataviews-client](libs/dataviews-client) | Api-client wrapper to fetch and edit dataviews and associated datasets/data |
| [fourwings-aggregate](libs/fourwings-aggregate) | Logic to turn fourwings tiles or cells into meaningful values for the frontend |
| [i18n-labels](libs/i18n-labels) | GFW shared translations |
| [layer-composer](libs/layer-composer) | Orchestrates various Layer Generators to generate a Mapbox GL Style document |
| [ocean-areas](libs/ocean-areas) | Small library to get ocean area / eez names by viewport or by text search |
| [pbf-decoders](libs/pbf-decoders) | PBF custom responses parsers |
| [react-hooks](libs/react-hooks) | Set of hooks to use libraries easily in react |
| [timebar](libs/timebar) | Timebar component, not many more to say |
| [ui-components](libs/ui-components) | Reusable atoms components kit |

## Applications

Expand Down
5 changes: 4 additions & 1 deletion apps/api-portal/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"@globalfishingwatch/data-transforms": ["../../libs/data-transforms/src/index.ts"],
"@globalfishingwatch/datasets-client": ["../../libs/datasets-client/src/index.ts"],
"@globalfishingwatch/dataviews-client": ["../../libs/dataviews-client/src/index.ts"],
"@globalfishingwatch/deck-layer-composer": ["../../libs/deck-layer-composer/src/index.ts"],
"@globalfishingwatch/deck-layers": ["../../libs/deck-layers/src/index.ts"],
"@globalfishingwatch/deck-loaders": ["../../libs/deck-loaders/src/index.ts"],
"@globalfishingwatch/features-aggregate": ["../../libs/features-aggregate/src/index.ts"],
"@globalfishingwatch/fourwings-aggregate": ["../../libs/fourwings-aggregate/src/index.ts"],
"@globalfishingwatch/i18n-labels": ["../../libs/i18n-labels/index.ts"],
Expand All @@ -31,7 +34,7 @@
"@globalfishingwatch/ocean-areas": ["../../libs/ocean-areas/src/index.ts"],
"@globalfishingwatch/pbf-decoders": ["../../libs/pbf-decoders/index.ts"],
"@globalfishingwatch/react-hooks": ["../../libs/react-hooks/src/index.ts"],
"@globalfishingwatch/timebar": ["../../libs/timebar/src/index.js"],
"@globalfishingwatch/timebar": ["../../libs/timebar/src/index.ts"],
"@globalfishingwatch/ui-components": ["../../libs/ui-components/src/index.ts"],
"@globalfishingwatch/ui-components/*": ["../../libs/ui-components/src/*"]
},
Expand Down
3 changes: 2 additions & 1 deletion apps/fishing-map-e2e/src/support/app.po.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HINTS } from 'apps/fishing-map/data/config'
import { HIGHLIGHT_DATAVIEW_INSTANCE_ID } from '../../../fishing-map/features/workspace/highlight-panel/highlight-panel.content'
import { API_URL_4WINGS_TILES } from '../constants/urls'

Expand Down Expand Up @@ -42,7 +43,7 @@ export const disablePopups = () => {
localStorage.setItem('WelcomePopup', '{"visible":false,"showAgain":false}')
localStorage.setItem('VesselProfilePopup', '{"visible":false,"showAgain":false}')
localStorage.setItem(
'hints',
HINTS,
'{"fishingEffortHeatmap":true,"filterActivityLayers":true,"clickingOnAGridCellToShowVessels":true,"changingTheTimeRange":true,"areaSearch":true,"periodComparisonBaseline":true}'
)
}
Expand Down
86 changes: 43 additions & 43 deletions apps/fishing-map/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,50 +148,50 @@ steps:
gcloud -q beta builds triggers run --branch=develop ui-libs-i18n-labels-stable
fi
- id: 'smoke-test-e2e'
waitFor: ['deploy-cloud-run']
allowFailure: true
name: cypress/included:13.7.3
entrypoint: 'bash'
env:
- 'CYPRESS_publicApiGateway=$_NEXT_PUBLIC_API_GATEWAY'
- 'CYPRESS_basicAuth=$_BASIC_AUTH'
- 'CYPRESS_basicAuthUser=$_BASIC_AUTH_USER'
- 'CYPRESS_basicAuthPass=$_BASIC_AUTH_PASS'
- 'CYPRESS_apiAuthUser=$_CYPRESS_API_AUTH_USER'
- 'CYPRESS_apiAuthPass=$_CYPRESS_API_AUTH_PASS'
- 'CYPRESS_apiUserInitials=$_CYPRESS_API_USER_INITIALS'
- 'CYPRESS_DEFAULT_COMMAND_TIMEOUT=$_CYPRESS_DEFAULT_COMMAND_TIMEOUT'
- 'CYPRESS_REQUEST_TIMEOUT=$_CYPRESS_REQUEST_TIMEOUT'
- 'CYPRESS_RESPONSE_TIMEOUT=$_CYPRESS_RESPONSE_TIMEOUT'
args:
- '-eEuo'
- 'pipefail'
- '-c'
- |-
CYPRESS_BASE_URL=`cat app_url` \
yarn nx run fishing-map-e2e:test-pr --parallel
# - id: 'smoke-test-e2e'
# waitFor: ['deploy-cloud-run']
# allowFailure: true
# name: cypress/included:13.7.3
# entrypoint: 'bash'
# env:
# - 'CYPRESS_publicApiGateway=$_NEXT_PUBLIC_API_GATEWAY'
# - 'CYPRESS_basicAuth=$_BASIC_AUTH'
# - 'CYPRESS_basicAuthUser=$_BASIC_AUTH_USER'
# - 'CYPRESS_basicAuthPass=$_BASIC_AUTH_PASS'
# - 'CYPRESS_apiAuthUser=$_CYPRESS_API_AUTH_USER'
# - 'CYPRESS_apiAuthPass=$_CYPRESS_API_AUTH_PASS'
# - 'CYPRESS_apiUserInitials=$_CYPRESS_API_USER_INITIALS'
# - 'CYPRESS_DEFAULT_COMMAND_TIMEOUT=$_CYPRESS_DEFAULT_COMMAND_TIMEOUT'
# - 'CYPRESS_REQUEST_TIMEOUT=$_CYPRESS_REQUEST_TIMEOUT'
# - 'CYPRESS_RESPONSE_TIMEOUT=$_CYPRESS_RESPONSE_TIMEOUT'
# args:
# - '-eEuo'
# - 'pipefail'
# - '-c'
# - |-
# CYPRESS_BASE_URL=`cat app_url` \
# yarn nx run fishing-map-e2e:test-pr --parallel

- id: 'save-test-videos'
name: gcr.io/cloud-builders/gcloud
waitFor: ['smoke-test-e2e']
entrypoint: bash
env:
- '_NEXT_PUBLIC_WORKSPACE_ENV=$_NEXT_PUBLIC_WORKSPACE_ENV'
- '_E2E_BUCKET=$_E2E_BUCKET'
- '_E2E_BASE_URL=$_E2E_BASE_URL'
- 'BUILD_ID=$BUILD_ID'
args:
- '-eEuo'
- 'pipefail'
- '-c'
- |-
if [ -d "dist/cypress/apps/fishing-map-e2e/screenshots" ] && [ "$(ls -A dist/cypress/apps/fishing-map-e2e/screenshots)" ]; then
gsutil -m cp -r dist/cypress/apps/fishing-map-e2e gs://$_E2E_BUCKET/$_NEXT_PUBLIC_WORKSPACE_ENV/$BUILD_ID
echo "You can see the testing videos of this deploy in: "
echo "$_E2E_BASE_URL/${_E2E_BUCKET#*/}/$_NEXT_PUBLIC_WORKSPACE_ENV/$BUILD_ID"
exit 1
fi
# - id: 'save-test-videos'
# name: gcr.io/cloud-builders/gcloud
# waitFor: ['smoke-test-e2e']
# entrypoint: bash
# env:
# - '_NEXT_PUBLIC_WORKSPACE_ENV=$_NEXT_PUBLIC_WORKSPACE_ENV'
# - '_E2E_BUCKET=$_E2E_BUCKET'
# - '_E2E_BASE_URL=$_E2E_BASE_URL'
# - 'BUILD_ID=$BUILD_ID'
# args:
# - '-eEuo'
# - 'pipefail'
# - '-c'
# - |-
# if [ -d "dist/cypress/apps/fishing-map-e2e/screenshots" ] && [ "$(ls -A dist/cypress/apps/fishing-map-e2e/screenshots)" ]; then
# gsutil -m cp -r dist/cypress/apps/fishing-map-e2e gs://$_E2E_BUCKET/$_NEXT_PUBLIC_WORKSPACE_ENV/$BUILD_ID
# echo "You can see the testing videos of this deploy in: "
# echo "$_E2E_BASE_URL/${_E2E_BUCKET#*/}/$_NEXT_PUBLIC_WORKSPACE_ENV/$BUILD_ID"
# exit 1
# fi

timeout: 1800s
options:
Expand Down
51 changes: 18 additions & 33 deletions apps/fishing-map/data/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { DateTime } from 'luxon'
import { DataviewCategory, ThinningConfig } from '@globalfishingwatch/api-types'
import { ThinningLevels, THINNING_LEVELS } from '@globalfishingwatch/api-client'
import { DataviewCategory } from '@globalfishingwatch/api-types'
import { AppState, TimebarGraphs, TimebarVisualisations, UserTab, WorkspaceState } from '../types'
import { getUTCDateTime } from '../utils/dates'

Expand All @@ -13,7 +12,7 @@ export const IS_PRODUCTION_BUILD = process.env.NODE_ENV === 'production'
export const PUBLIC_WORKSPACE_ENV = process.env.NEXT_PUBLIC_WORKSPACE_ENV
export const IS_PRODUCTION_WORKSPACE_ENV =
PUBLIC_WORKSPACE_ENV === 'production' || PUBLIC_WORKSPACE_ENV === 'staging'
export const IS_PRODUCTION = IS_PRODUCTION_WORKSPACE_ENV || IS_PRODUCTION_BUILD
const IS_PRODUCTION = IS_PRODUCTION_WORKSPACE_ENV || IS_PRODUCTION_BUILD
export const PATH_BASENAME = process.env.NEXT_PUBLIC_URL || (IS_PRODUCTION ? '/map' : '')

export const REPORT_DAYS_LIMIT =
Expand All @@ -40,6 +39,11 @@ export const REPORT_ACTIVITY_GRAPH_EVOLUTION = 'evolution'
export const REPORT_ACTIVITY_GRAPH_BEFORE_AFTER = 'beforeAfter'
export const REPORT_ACTIVITY_GRAPH_PERIOD_COMPARISON = 'periodComparison'

// Local storage keys
export const HINTS = 'hints'
export const USER_SETTINGS = 'userSettings'
export const PREFERRED_FOURWINGS_VISUALISATION_MODE = 'preferredFourwingsVisualisationMode'

// TODO use it to retrieve it and store in workspace.default in deploy
export const APP_NAME = 'fishing-map'
export const PUBLIC_SUFIX = 'public'
Expand All @@ -48,7 +52,7 @@ export const USER_SUFIX = 'user'
export const PRIVATE_SUFIX = 'private'
export const AUTO_GENERATED_FEEDBACK_WORKSPACE_PREFIX = 'gfw-feedback-auto-saved'

export const DEFAULT_DATA_DELAY_DAYS = 3
const DEFAULT_DATA_DELAY_DAYS = 3
// used when no url data and no workspace data
export const LAST_DATA_UPDATE = DateTime.fromObject(
{ hour: 0, minute: 0, second: 0 },
Expand All @@ -58,7 +62,7 @@ export const LAST_DATA_UPDATE = DateTime.fromObject(
.toISO() as string

export const DEFAULT_VIEWPORT = {
zoom: 1.5,
zoom: 1.49,
latitude: 19,
longitude: 26,
}
Expand All @@ -81,10 +85,8 @@ export const DEFAULT_PAGINATION_PARAMS = {

export const BUFFER_PREVIEW_COLOR = '#F95E5E'

export const DEFAULT_ACTIVITY_CATEGORY = 'fishing'

export const FIRST_YEAR_OF_DATA = 2012
export const CURRENT_YEAR = new Date().getFullYear()
const CURRENT_YEAR = new Date().getFullYear()

export const AVAILABLE_START = new Date(Date.UTC(FIRST_YEAR_OF_DATA, 0, 1)).toISOString() as string
export const AVAILABLE_END = new Date(Date.UTC(CURRENT_YEAR, 11, 31)).toISOString() as string
Expand All @@ -96,6 +98,9 @@ export const DEFAULT_WORKSPACE: WorkspaceState & AppState = {
sidebarOpen: true,
mapAnnotationsVisible: true,
mapRulersVisible: true,
activityVisualizationMode: 'heatmap',
detectionsVisualizationMode: 'heatmap',
environmentVisualizationMode: 'heatmap-low-res',
dataviewInstances: undefined,
timebarVisualisation: TimebarVisualisations.HeatmapActivity,
visibleEvents: 'all',
Expand Down Expand Up @@ -123,35 +128,15 @@ export const EVENTS_COLORS: Record<string, string> = {
fishingLabels: '#163f89',
}

export const THINNING_LEVEL_BY_ZOOM: Record<
number,
{ user: ThinningConfig; guest: ThinningConfig }
> = {
0: {
user: THINNING_LEVELS[ThinningLevels.Insane],
guest: THINNING_LEVELS[ThinningLevels.Insane],
},
3: {
user: THINNING_LEVELS[ThinningLevels.VeryAggressive],
guest: THINNING_LEVELS[ThinningLevels.VeryAggressive],
},
6: {
user: THINNING_LEVELS[ThinningLevels.Default],
guest: THINNING_LEVELS[ThinningLevels.Aggressive],
},
}

export const THINNING_LEVEL_ZOOMS = Object.keys(THINNING_LEVEL_BY_ZOOM) as unknown as number[]

// Params to use replace instead of push for router history to make navigation easier
export const REPLACE_URL_PARAMS = ['latitude', 'longitude', 'zoom']

export const POPUP_CATEGORY_ORDER = [
DataviewCategory.Activity,
DataviewCategory.Detections,
DataviewCategory.Events,
DataviewCategory.Environment,
DataviewCategory.Context,
`${DataviewCategory.Activity}`,
`${DataviewCategory.Detections}`,
`${DataviewCategory.Events}`,
`${DataviewCategory.Environment}`,
`${DataviewCategory.Context}`,
]

export const FIT_BOUNDS_REPORT_PADDING = 30
17 changes: 17 additions & 0 deletions apps/fishing-map/data/dataviews.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {
FISHING_DATAVIEW_SLUG,
CLUSTER_ENCOUNTER_EVENTS_DATAVIEW_SLUG,
VIIRS_MATCH_DATAVIEW_SLUG,
SAR_DATAVIEW_SLUG,
PRESENCE_DATAVIEW_SLUG,
TEMPLATE_VESSEL_DATAVIEW_SLUG,
} from './workspaces'

export const LEGACY_TO_LATEST_DATAVIEWS: Record<string, string> = {
'apparent-fishing-effort': FISHING_DATAVIEW_SLUG,
'encounter-cluster-events': CLUSTER_ENCOUNTER_EVENTS_DATAVIEW_SLUG,
'viirs-match': VIIRS_MATCH_DATAVIEW_SLUG,
sar: SAR_DATAVIEW_SLUG,
'presence-activity': PRESENCE_DATAVIEW_SLUG,
'fishing-map-vessel-track': TEMPLATE_VESSEL_DATAVIEW_SLUG,
}
10 changes: 7 additions & 3 deletions apps/fishing-map/data/default-workspaces/marine-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import {
GLOBAL_CHLOROPHYL_DATAVIEW_SLUG,
MPA_DATAVIEW_INSTANCE_ID,
EEZ_DATAVIEW_INSTANCE_ID,
DEFAULT_BASEMAP_DATAVIEW_INSTANCE,
} from 'data/workspaces'

export const WIZARD_TEMPLATE_ID = 'wizard_template-public'

export const MARINE_MANAGER_DATAVIEWS = BASE_CONTEXT_LAYERS_DATAVIEW_INSTANCES.filter(
(d) => d.id === EEZ_DATAVIEW_INSTANCE_ID || d.id === MPA_DATAVIEW_INSTANCE_ID
)
export const MARINE_MANAGER_DATAVIEWS = [
DEFAULT_BASEMAP_DATAVIEW_INSTANCE,
...BASE_CONTEXT_LAYERS_DATAVIEW_INSTANCES.filter(
(d) => d.id === EEZ_DATAVIEW_INSTANCE_ID || d.id === MPA_DATAVIEW_INSTANCE_ID
),
]

export const MARINE_MANAGER_DATAVIEWS_INSTANCES = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from '@globalfishingwatch/api-types'
import { APP_NAME, DEFAULT_TIME_RANGE, DEFAULT_VIEWPORT } from 'data/config'
import { BASE_CONTEXT_LAYERS_DATAVIEW_INSTANCES } from 'data/default-workspaces/context-layers'
import { OFFSHORE_FIXED_INFRASTRUCTURE_DATAVIEW_ID } from 'data/layer-library/layers-context'
import { BATHYMETRY_DATAVIEW_INSTANCE } from 'data/layer-library/layers-environment'
import {
DEFAULT_WORKSPACE_ID,
Expand All @@ -24,6 +23,7 @@ import {
DEFAULT_WORKSPACE_CATEGORY,
} from 'data/workspaces'
import { ENCOUNTER_EVENTS_SOURCE_ID } from 'features/dataviews/dataviews.utils'
import { OFFSHORE_FIXED_INFRASTRUCTURE_LAYER_ID } from 'features/map/map.config'
import { HIGHLIGHT_DATAVIEW_INSTANCE_ID } from 'features/workspace/highlight-panel/highlight-panel.content'
import { WorkspaceState } from 'types'

Expand Down Expand Up @@ -110,7 +110,7 @@ const workspace: Workspace<WorkspaceState> = {
{
id: 'context-layer-graticules',
config: {
visible: true,
visible: false,
},
dataviewId: GRATICULES_DATAVIEW_SLUG,
},
Expand All @@ -128,7 +128,7 @@ const workspace: Workspace<WorkspaceState> = {
dataviewId: HIGH_SEAS_DATAVIEW_SLUG,
},
{
id: OFFSHORE_FIXED_INFRASTRUCTURE_DATAVIEW_ID,
id: OFFSHORE_FIXED_INFRASTRUCTURE_LAYER_ID,
config: {
visible: false,
color: '#8E24A9',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from '@globalfishingwatch/api-types'
import { APP_NAME, DEFAULT_TIME_RANGE, DEFAULT_VIEWPORT } from 'data/config'
import { BASE_CONTEXT_LAYERS_DATAVIEW_INSTANCES } from 'data/default-workspaces/context-layers'
import { OFFSHORE_FIXED_INFRASTRUCTURE_DATAVIEW_ID } from 'data/layer-library/layers-context'
import { BATHYMETRY_DATAVIEW_INSTANCE } from 'data/layer-library/layers-environment'
import {
DEFAULT_WORKSPACE_ID,
Expand All @@ -24,6 +23,7 @@ import {
DEFAULT_WORKSPACE_CATEGORY,
} from 'data/workspaces'
import { ENCOUNTER_EVENTS_SOURCE_ID } from 'features/dataviews/dataviews.utils'
import { OFFSHORE_FIXED_INFRASTRUCTURE_LAYER_ID } from 'features/map/map.config'
import { HIGHLIGHT_DATAVIEW_INSTANCE_ID } from 'features/workspace/highlight-panel/highlight-panel.content'
import { WorkspaceState } from 'types'

Expand Down Expand Up @@ -127,7 +127,7 @@ const workspace: Workspace<WorkspaceState> = {
dataviewId: HIGH_SEAS_DATAVIEW_SLUG,
},
{
id: OFFSHORE_FIXED_INFRASTRUCTURE_DATAVIEW_ID,
id: OFFSHORE_FIXED_INFRASTRUCTURE_LAYER_ID,
config: {
visible: false,
color: '#8E24A9',
Expand Down
Loading

0 comments on commit 06b28d0

Please sign in to comment.