From e319c3230db5c960449d98c3092ac71f272e23f2 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Fri, 12 Jan 2024 16:26:45 -0600 Subject: [PATCH 1/4] remove rasterDataset --- src/actions/index.js | 2 - src/components/children/NestedInfoTable.jsx | 47 --- src/types/data.d.ts | 13 +- src/utils/flowtype.js | 336 -------------------- 4 files changed, 2 insertions(+), 396 deletions(-) delete mode 100644 src/utils/flowtype.js diff --git a/src/actions/index.js b/src/actions/index.js index eb56cb92..e14dc915 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -1,5 +1,3 @@ -// @flow - import Cookies from "universal-cookie"; import config from "../app.config"; diff --git a/src/components/children/NestedInfoTable.jsx b/src/components/children/NestedInfoTable.jsx index ec1dd010..cd27db00 100644 --- a/src/components/children/NestedInfoTable.jsx +++ b/src/components/children/NestedInfoTable.jsx @@ -35,7 +35,6 @@ class NestedInfoTable extends React.Component { return regexErgo.test(datatype) || regexIncore.test(datatype); }; const renderDataRows = (data, classes, onClick) => { - const keysToExclude = ["hazardDatasets", "rasterDataset", "datasetId"]; return Object.keys(data).map((key) => { if (key === "hazardDatasets" && data[key].length > 0) { return ( @@ -68,52 +67,6 @@ class NestedInfoTable extends React.Component { ); - } else if (key === "rasterDataset" && data[key] && data[key].datasetId) { - return ( - - {key} - - - - - {data[key].datasetId} - - - - - - ); - } else if (key === "datasetId" && data[key]) { - return ( - - {key} - - - - - {data[key]} - - - - - - ); } else if (data[key]) { return ( diff --git a/src/types/data.d.ts b/src/types/data.d.ts index d8ad8f48..edf576cd 100644 --- a/src/types/data.d.ts +++ b/src/types/data.d.ts @@ -118,15 +118,6 @@ interface VisualizationParameters { amplifyHazard: boolean; } -interface RasterDataset { - hazardType: string; - datasetId: string; - demandType: string; - demandUnits: string; - period: number; - eqParameters: EqParameters; -} - interface DeterministicEarthquake { eqType: string; id: string; @@ -138,7 +129,7 @@ interface DeterministicEarthquake { visualizationParameters: VisualizationParameters; defaultSiteClass: string; siteAmplicfication: string; - rasterDataset: RasterDataset; + hazardDatasets: HazardDataset[]; } interface ProbabilisticEarthquake { @@ -175,8 +166,8 @@ interface Tornado { tornadoParameters: TornadoParameters; tornadoWidth: number[]; efBoxes: EfBox[]; - tornadoDatasetId: string; privileges: Privileges; + hazardDatasets: HazardDataset[]; } /* Hurricane */ diff --git a/src/utils/flowtype.js b/src/utils/flowtype.js deleted file mode 100644 index 85b13f2a..00000000 --- a/src/utils/flowtype.js +++ /dev/null @@ -1,336 +0,0 @@ -export type Dispatch = (action: any) => null; - -export type AnalysisInput = { - id: string; - name: string; - description: string; - required: boolean; - advanced: boolean; - multiple: boolean; - type: string; -}; - -export type AnalysisOutput = { - name: string; - type: string; - description: string; -}; - -export type AnalysisParameter = { - id: string; - name: string; - description: string; - required: boolean; - advanced: boolean; - multiple: boolean; - type: string; -}; - -export type Analysis = { - id: string; - description: string; - name: string; - category: string; - helpContext: string; - tag: string; - datasets: AnalysisInput[]; - outputs: AnalysisOutput[]; - parameter: AnalysisParameter[]; -}; - -export type Analyses = Analysis[]; - -export type AnalysisMetadata = { - id: string; - description: string; - name: string; - category: string; - helpContext: string; -}; - -export type AnalysesMetadata = AnalysisMetadata[]; - -export type AnalysesState = { - analysisMetadata: AnalysesMetadata; -}; - -export type FileDescriptor = { - id: string; - deleted: boolean; - filename: string; - mimeType: string; - size: number; - dataURL: string; - md5sum: string; -}; - -// Semantic types -export type SemanticId = { - timestamp: number; - date: number; -}; -export type SemanticContext = { - "@language": string; - "gml": string; - "iwfs": string; - "xlink": string; - "xsd": string; - "qudt": string; - "unit": string; - "openvocab": string; - -} - -export type SemanticColumn = { - name: string; - titles: string; - "dc:description": string; - datatype: string; - required: string; - "qudt:unit": string; -} - -export type Semantic = { - _id: SemanticId; - "@context": (string | SemanticContext)[]; - "dc:license": { - "@id": string; - }; - "dc:title": string; - "dc:description": string; - url: string; - "openvocab:versionnumber": string; - tableSchema: { - columns: SemanticColumn[]; - } -}; - -export type Semantics = Semantic[]; - -export type SemanticState = { - semantics: Semantics; -}; - -export type Dataset = { - id: string; - deleted: boolean; - title: string; - description: string; - date: Date; - fileDescriptors: FileDescriptor[]; - contributors: string[]; - creator: string; - type: string; - storedUrl: string; - format: string; - sourceDataset: string; - spaces: string[]; -}; - -/* Earthquakes */ -export type HazardDataset = { - hazardType: string; - datasetId: string; - demandType: string; - demandUnits: string; - period: number; - recurrenceInterval: number; - recurrenceUnit: string; - absTime: Date; -}; - -export type EqParameters = { - srcLatitude: Number; - srcLongitude: Number; - magnitude: Number; - coseismicRuptureDepth: Number; - dipAngle: Number; - azimuthAngle: Number; - rakeAngle: Number; - seismogenicDepth: Number; - depth: Number; - depth2p5KmPerSecShearWaveVelocity: Number; - shearWaveDepth1p0: Number; - faultTypeMap: Object; - region: string; -}; - -export type Privileges = { - userPrivileges: Object; - groupPrivileges: Object; -}; - -export type VisualizationParameters = { - demandType: string; - demandUnits: string; - minX: number; - minY: number; - maxX: number; - maxY: number; - numPoints: number; - amplifyHazard: boolean; -}; - -export type RasterDataset = { - hazardType: string; - datasetId: string; - demandType: string; - demandUnits: string; - period: number; - eqParameters: EqParameters; -}; - -export type DeterministicEarthquake = { - eqType: string; - id: string; - privileges: Privileges; - name: string; - description: string; - attenuations: Object; - eqParameters: EqParameters; - visualizationParameters: VisualizationParameters; - defaultSiteClass: string; - siteAmplicfication: string; - rasterDataset: RasterDataset; -}; - -export type ProbabilisticEarthquake = { - eqType: string; - id: string; - privileges: Privileges; - name: string; - description: string; - hazardDatasets: HazardDataset[]; -}; - -export type Earthquake = DeterministicEarthquake | ProbabilisticEarthquake; - -/* Tornado */ -export type TornadoParameters = { - efRating: string; - maxWindSpeed: number; - startLatitude: number; - startLongitude: number; - randomSeed: number; - windSpeedMethod: number; - numSimulations: number; - endLatitude: number[]; - endLongitude: number[]; -}; - -export type EfBox = { - efBoxWidths: number[]; -}; - -export type Tornado = { - id: string; - tornadoModel: string; - tornadoParameters: TornadoParameters; - tornadoWidth: number[]; - efBoxes: EfBox[]; - tornadoDatasetId: string; - privileges: Privileges; -}; - -/* Hurricane */ -export type Hurricane = { - id: string; - privileges: Privileges; - name: string; - description: string; - gridResolution: number; - gridResolutionUnits: string; - rasterResolution: number; - rasterResolutionUnits: string; - transD: number; - transDUnits: string; - landfallLocation: string; - modelUsed: string; - coast: string; - category: number; - velocityUnits: string; - gridPoints: number; - rfMethod: string; - times: Date[]; - hazardDatasets: HazardDataset[]; -}; - -export type Hazards = Earthquake[] | Tornado[] | Hurricane[]; - -export type HazardState = { - hazards: Hazards; -}; - -export type Datasets = Dataset[]; - -/* DFR3 */ -export type DFR3Curve2D = { - className: string; - description: name; - alpha: number; - beta: number; - curveType: string; - periodParam2: number; - periodParam1: number; - periodParam0: number; - periodEqnType: number; -}; - -export type DFR3Curve3D = { - className: string; - description: name; - expression: string; -}; - -export type DFR3Curve = { - id: string; - legacyId: string; - description: string; - authors: string[]; - paperReference: string; - resultUnit: string; - resultType: string; - demandTypes: string[]; - demandUnits: string[]; - hazardType: string; - inventoryType: string; - fragilityCurves: DFR3Curve2D[] | DFR3Curve3D[]; - privileges: Privileges; - creator: string; -}; - -export type DFR3Curves = DFR3Curve[]; - -export type DFR3CurvesState = { - DFR3Curves: DFR3Curves; -}; - -export type DFR3Mappings = { - id: string; - name: string; - authors: string[]; - hazardType: string; - inventoryType: string; - mappings: Object[]; - mappingType: string; -}; - -export type DFR3MappingsState = { - DFR3Mappings: DFR3Mappings; -}; - -/* Dataset */ -export type DatasetState = { - datasets: Dataset[]; -}; - -export type ExecutionState = { - executionId: string; -}; - -export type GetState = () => Object; - -export type UserState = { - Authorization: string; - loginError: boolean; -}; From a204d64648aefa90172dba72ab2c19f39b0d7082 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Fri, 12 Jan 2024 16:31:31 -0600 Subject: [PATCH 2/4] remove everything related to flow --- .babelrc | 9 ++------- package.json | 2 -- src/reducers/datasets.js | 10 +--------- src/reducers/dfr3Curves.js | 9 +-------- src/reducers/dfr3Mappings.js | 9 +-------- src/reducers/hazards.js | 9 +-------- src/reducers/semantics.js | 10 +--------- 7 files changed, 7 insertions(+), 51 deletions(-) diff --git a/.babelrc b/.babelrc index 8d4bf1df..6e9df02f 100644 --- a/.babelrc +++ b/.babelrc @@ -2,16 +2,12 @@ "presets": [ "@babel/preset-env", "@babel/preset-typescript", - "@babel/preset-react", - "@babel/preset-flow" + "@babel/preset-react" ], "plugins": [ [ "root-import" ], - [ - "@babel/plugin-transform-flow-strip-types" - ], "@babel/plugin-syntax-dynamic-import", "@babel/plugin-syntax-import-meta", "@babel/plugin-proposal-class-properties", @@ -44,8 +40,7 @@ "presets": [ "@babel/preset-env", "@babel/preset-typescript", - "@babel/preset-react", - "@babel/preset-flow" + "@babel/preset-react" ] }, "production": { diff --git a/package.json b/package.json index 99d96564..89627928 100644 --- a/package.json +++ b/package.json @@ -69,11 +69,9 @@ "@babel/plugin-proposal-throw-expressions": "^7.14.5", "@babel/plugin-syntax-dynamic-import": "^7.8.3", "@babel/plugin-syntax-import-meta": "^7.10.4", - "@babel/plugin-transform-flow-strip-types": "^7.14.5", "@babel/plugin-transform-react-constant-elements": "^7.14.5", "@babel/polyfill": "^7.12.1", "@babel/preset-env": "^7.14.5", - "@babel/preset-flow": "^7.14.5", "@babel/preset-react": "^7.14.5", "@babel/preset-typescript": "^7.18.6", "@babel/register": "^7.14.5", diff --git a/src/reducers/datasets.js b/src/reducers/datasets.js index e4124138..591a7ad1 100644 --- a/src/reducers/datasets.js +++ b/src/reducers/datasets.js @@ -8,18 +8,10 @@ import { DELETE_ERROR, RESET_ERROR } from "../actions"; -import {DatasetState, Datasets, Dataset} from "../utils/flowtype"; - -type DatasetAction = { - type: RECEIVE_DATASETS, - datasets: Datasets, - item: Dataset, - loading: boolean -} const defaultState = {datasets: [], loading: false}; -const datasets = (state:DatasetState = defaultState, action:DatasetAction) => { +const datasets = (state = defaultState, action) => { switch(action.type) { case RECEIVE_DATASETS: return Object.assign({}, state, {datasets: action.datasets}); diff --git a/src/reducers/dfr3Curves.js b/src/reducers/dfr3Curves.js index ac17b62d..475c5a91 100644 --- a/src/reducers/dfr3Curves.js +++ b/src/reducers/dfr3Curves.js @@ -1,15 +1,8 @@ import {DFR3CURVE_LOADING, DFR3CURVE_LOAD_COMPLETE, RECEIVE_DFR3_CURVES, DELETE_ITEM, DELETE_ERROR, RESET_ERROR} from "../actions"; -import {DFR3CurvesState, DFR3Curve} from "../utils/flowtype"; -type DFR3Action = { - type: RECEIVE_DFR3_CURVES, - dfr3Curves: DFR3Curve[], - item: DFR3Curve, - loading: boolean -} const defaultState = {dfr3Curves: [], loading: false}; -const dfr3Curves = (state: DFR3CurvesState = defaultState, action: DFR3Action) => { +const dfr3Curves = (state = defaultState, action) => { switch(action.type) { case RECEIVE_DFR3_CURVES: return Object.assign({}, state, {dfr3Curves: action.dfr3Curves}); diff --git a/src/reducers/dfr3Mappings.js b/src/reducers/dfr3Mappings.js index 9d9c244e..e519c87f 100644 --- a/src/reducers/dfr3Mappings.js +++ b/src/reducers/dfr3Mappings.js @@ -7,17 +7,10 @@ import { RECEIVE_DFR3_MAPPINGS, RESET_ERROR } from "../actions"; -import {DFR3Mappings, DFR3MappingsState} from "../utils/flowtype"; -type dfr3Action = { - type: RECEIVE_DFR3_MAPPINGS, - dfr3Mappings: DFR3Mappings[], - item: DFR3Mappings, - loading: boolean -} const defaultState = {dfr3Mappings: [], loading: false}; -const dfr3Mappings = (state: DFR3MappingsState = defaultState, action: dfr3Action) => { +const dfr3Mappings = (state = defaultState, action) => { switch (action.type) { case RECEIVE_DFR3_MAPPINGS: return Object.assign({}, state, {dfr3Mappings: action.dfr3Mappings}); diff --git a/src/reducers/hazards.js b/src/reducers/hazards.js index bf776aa2..a097def7 100644 --- a/src/reducers/hazards.js +++ b/src/reducers/hazards.js @@ -1,15 +1,8 @@ import {HAZARD_LOAD_COMPLETE, HAZARD_LOADING, LOGIN_ERROR, RECEIVE_HAZARDS, DELETE_ITEM, DELETE_ERROR, RESET_ERROR} from "../actions"; -import {HazardState, Hazards} from "../utils/flowtype"; -type HazardAction = { - type: RECEIVE_HAZARDS, - hazards: Hazards, - item: Object, - loading: boolean -} const defaultState = {hazards: [], loading: false}; -const hazards = (state: HazardState = defaultState, action: HazardAction) => { +const hazards = (state = defaultState, action) => { switch(action.type) { case RECEIVE_HAZARDS: return Object.assign({}, state, {hazards: action.hazards}); diff --git a/src/reducers/semantics.js b/src/reducers/semantics.js index 563d28f1..89bc8434 100644 --- a/src/reducers/semantics.js +++ b/src/reducers/semantics.js @@ -8,18 +8,10 @@ import { DELETE_ERROR, RESET_ERROR } from "../actions"; -import {SemanticState, Semantics, Semantic} from "../utils/flowtype"; - -type SemanticAction = { - type: RECEIVE_SEMANTICS, - semantics: Semantics, - item: Semantic, - loading: boolean -} const defaultState = {semantics: [], loading: false}; -const semantics = (state:SemanticState = defaultState, action:SemanticAction) => { +const semantics = (state = defaultState, action) => { switch(action.type) { case RECEIVE_SEMANTICS: return Object.assign({}, state, {semantics: action.semantics}); From d8014c6c87e55f2092161c844e1c64b5c423b6f5 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Fri, 12 Jan 2024 16:36:14 -0600 Subject: [PATCH 3/4] only typescript can do types --- src/actions/index.js | 106 ++++++++++++++++---------------- src/components/children/Map.jsx | 2 +- src/reducers/datatypes.js | 6 +- src/reducers/spaces.js | 6 +- 4 files changed, 56 insertions(+), 64 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index e14dc915..35233ed8 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -14,8 +14,8 @@ export const resetError = { type: RESET_ERROR }; -export function receiveAnalyses(api: string, json: AnalysesMetadata) { - return (dispatch: Dispatch) => { +export function receiveAnalyses(api, json) { + return (dispatch) => { dispatch({ type: RECEIVE_ANALYSES, analyses: json, @@ -26,8 +26,8 @@ export function receiveAnalyses(api: string, json: AnalysesMetadata) { export const RECEIVE_ANALYSIS = "RECEIVE_ANALYSIS"; -export function receiveAnalysis(api: string, json: Analysis) { - return (dispatch: Dispatch) => { +export function receiveAnalysis(api, json) { + return (dispatch) => { dispatch({ type: RECEIVE_ANALYSIS, analysis: json, @@ -38,8 +38,8 @@ export function receiveAnalysis(api: string, json: Analysis) { export const RECEIVE_DATASETS = "RECEIVE_DATASETS"; -export function receiveDatasets(type: string, json: Datasets) { - return (dispatch: Dispatch) => { +export function receiveDatasets(type, json) { + return (dispatch) => { dispatch({ type: type, datasets: json, @@ -51,7 +51,7 @@ export function receiveDatasets(type: string, json: Datasets) { export const RECEIVE_USAGE = "RECEIVE_USAGE"; export const RECEIVE_LAB_USAGE = "RECEIVE_LAB_USAGE"; export function receieveUsage(type, json) { - return (dispatch: Dispatch) => { + return (dispatch) => { dispatch({ type: type, usage: json, @@ -60,8 +60,8 @@ export function receieveUsage(type, json) { }; } -export function deleteItem(type: string, json) { - return (dispatch: Dispatch) => { +export function deleteItem(type, json) { + return (dispatch) => { dispatch({ type: type, item: json, @@ -91,7 +91,7 @@ export function deleteItemById(resourceType, id) { ) { endpoint = `${config.hazardServiceBase}${resourceType}/${id}`; } - return (dispatch: Dispatch) => { + return (dispatch) => { return fetch(endpoint, { mode: "cors", method: "DELETE", headers: getHeader() }).then((response) => { if (response.status === 200) { response.json().then((json) => { @@ -109,8 +109,8 @@ export function deleteItemById(resourceType, id) { export const RECEIVE_HAZARDS = "RECEIVE_HAZARDS"; -export function receiveHazards(type: string, json: Hazards) { - return (dispatch: Dispatch) => { +export function receiveHazards(type, json) { + return (dispatch) => { dispatch({ type: type, hazards: json, @@ -121,8 +121,8 @@ export function receiveHazards(type: string, json: Hazards) { export const RECEIVE_DFR3_CURVES = "RECEIVE_DFR3_CURVES"; -export function receiveDFR3Curves(type: string, json: DFR3Curves) { - return (dispatch: Dispatch) => { +export function receiveDFR3Curves(type, json) { + return (dispatch) => { dispatch({ type: type, dfr3Curves: json, @@ -133,8 +133,8 @@ export function receiveDFR3Curves(type: string, json: DFR3Curves) { export const RECEIVE_DFR3_MAPPINGS = "RECEIVE_DFR3_MAPPINGS"; -export function receiveDFR3Mappings(type: string, json: DFR3Mappings) { - return (dispatch: Dispatch) => { +export function receiveDFR3Mappings(type, json) { + return (dispatch) => { dispatch({ type: type, dfr3Mappings: json, @@ -145,8 +145,8 @@ export function receiveDFR3Mappings(type: string, json: DFR3Mappings) { export const RECEIVE_SPACES = "RECEIVE_SPACES"; -export function receiveSpaces(type: string, json) { - return (dispatch: Dispatch) => { +export function receiveSpaces(type, json) { + return (dispatch) => { dispatch({ type: type, spaces: json, @@ -157,8 +157,8 @@ export function receiveSpaces(type: string, json) { export const RECEIVE_DATATYPES = "RECEIVE_DATATYPES"; -export function receiveDatatypes(type: string, json) { - return (dispatch: Dispatch) => { +export function receiveDatatypes(type, json) { + return (dispatch) => { dispatch({ type: type, datatypes: json, @@ -170,7 +170,7 @@ export function receiveDatatypes(type: string, json) { export function fetchAnalyses() { const endpoint = `${config.maestroService}/api/analyses?full=false`; - return (dispatch: Dispatch) => { + return (dispatch) => { return fetch(endpoint, { headers: getHeader() }) @@ -179,11 +179,11 @@ export function fetchAnalyses() { }; } -export function getAnalysisById(id: String) { +export function getAnalysisById(id) { //TODO: Move to a configuration file const endpoint = `${config.maestroService}/api/analyses/${id}`; - return (dispatch: Dispatch) => { + return (dispatch) => { return fetch(endpoint, { headers: getHeader() }) @@ -194,7 +194,7 @@ export function getAnalysisById(id: String) { export function searchDatasets(keyword, limit, offset) { let endpoint = `${config.dataService}/search?excludeHazard=true&limit=${limit}&skip=${offset}&text=${keyword}`; - return (dispatch: Dispatch) => { + return (dispatch) => { dispatch(loading(DATA_LOADING)); return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { dispatch(loadComplete(DATA_LOAD_COMPLETE)); @@ -221,7 +221,7 @@ export function fetchDatasets(dataType, space, limit, offset) { endpoint = `${endpoint}&space=${space}`; } - return (dispatch: Dispatch) => { + return (dispatch) => { dispatch(loading(DATA_LOADING)); return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { dispatch(loadComplete(DATA_LOAD_COMPLETE)); @@ -241,7 +241,7 @@ export function fetchDatasets(dataType, space, limit, offset) { export function fetchUsage() { let endpoint = `${config.spaceServiceBase}usage`; - return (dispatch: Dispatch) => { + return (dispatch) => { return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { if (response.status === 200) { response.json().then((json) => { @@ -259,7 +259,7 @@ export function fetchUsage() { export function fetchLabUsage() { // TODO implment - return (dispatch: Dispatch) => { + return (dispatch) => { let json = { user: "commresilience", total_number_of_datasets: 50, @@ -272,7 +272,7 @@ export function fetchLabUsage() { export function fetchSpaces() { const endpoint = config.spaceService; - return (dispatch: Dispatch) => { + return (dispatch) => { return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { if (response.status === 200) { response.json().then((json) => { @@ -291,7 +291,7 @@ export function fetchSpaces() { export const RECEIVE_ALLOCATIONS = "RECEIVE_ALLOCATIONS"; export function fetchAllocations() { const endpoint = `${config.spaceServiceBase}allocations`; - return (dispatch: Dispatch) => { + return (dispatch) => { return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { if (response.status === 200) { response.json().then((json) => { @@ -321,7 +321,7 @@ export function fetchAllocations() { export function fetchUniqueDatatypes() { let endpoint = `${config.dataServiceBase}datatypes`; - return (dispatch: Dispatch) => { + return (dispatch) => { return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { if (response.status === 200) { response.json().then((json) => { @@ -339,7 +339,7 @@ export function fetchUniqueDatatypes() { export function searchDFR3Curves(dfr3_type, keyword, limit, offset) { let endpoint = `${config.dfr3ServiceBase}${dfr3_type}/search?limit=${limit}&skip=${offset}&text=${keyword}`; - return (dispatch: Dispatch) => { + return (dispatch) => { dispatch(loading(DFR3CURVE_LOADING)); return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { dispatch(loadComplete(DFR3CURVE_LOAD_COMPLETE)); @@ -357,7 +357,7 @@ export function searchDFR3Curves(dfr3_type, keyword, limit, offset) { }; } -export function fetchDFR3Curves(dfr3_type: string, space: string, inventory: string, hazard: string, limit, offset) { +export function fetchDFR3Curves(dfr3_type, space, inventory, hazard, limit, offset) { let endpoint = `${config.dfr3ServiceBase}${dfr3_type}?limit=${limit}&skip=${offset}`; if (space !== null && space !== "All") { endpoint = `${endpoint}&space=${space}`; @@ -368,7 +368,7 @@ export function fetchDFR3Curves(dfr3_type: string, space: string, inventory: str if (hazard !== null && hazard !== "All") { endpoint = `${endpoint}&hazard=${hazard}`; } - return (dispatch: Dispatch) => { + return (dispatch) => { dispatch(loading(DFR3CURVE_LOADING)); return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { dispatch(loadComplete(DFR3CURVE_LOAD_COMPLETE)); @@ -387,7 +387,7 @@ export function fetchDFR3Curves(dfr3_type: string, space: string, inventory: str } //TODO: Move this to app.config? -export function getMappingTypeFromDFR3Url(dfr3_type: string) { +export function getMappingTypeFromDFR3Url(dfr3_type) { switch (dfr3_type.toLowerCase()) { case "fragilities": return "fragility"; @@ -398,7 +398,7 @@ export function getMappingTypeFromDFR3Url(dfr3_type: string) { } } -export function fetchDFR3Mappings(dfr3_type: string, space: string, inventory: string, hazard: string, limit, offset) { +export function fetchDFR3Mappings(dfr3_type, space, inventory, hazard, limit, offset) { let endpoint = `${config.dfr3ServiceBase}mappings?limit=${limit}&skip=${offset}`; if (dfr3_type !== null && dfr3_type !== "All") { @@ -416,7 +416,7 @@ export function fetchDFR3Mappings(dfr3_type: string, space: string, inventory: s endpoint = `${endpoint}&hazard=${hazard}`; } - return (dispatch: Dispatch) => { + return (dispatch) => { dispatch(loading(DFR3MAPPING_LOADING)); return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { dispatch(loadComplete(DFR3MAPPING_LOAD_COMPLETE)); @@ -443,7 +443,7 @@ export function searchDFR3Mappings(dfr3_type, keyword, limit, offset) { endpoint = `${endpoint}&mappingType=${dfr3_type}`; } - return (dispatch: Dispatch) => { + return (dispatch) => { dispatch(loading(DFR3MAPPING_LOADING)); return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { dispatch(loadComplete(DFR3MAPPING_LOAD_COMPLETE)); @@ -463,7 +463,7 @@ export function searchDFR3Mappings(dfr3_type, keyword, limit, offset) { export function searchHazards(hazard_type, keyword, limit, offset) { let endpoint = `${config.hazardServiceBase}${hazard_type}/search?limit=${limit}&skip=${offset}&text=${keyword}`; - return (dispatch: Dispatch) => { + return (dispatch) => { dispatch(loading(HAZARD_LOADING)); return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { dispatch(loadComplete(HAZARD_LOAD_COMPLETE)); @@ -481,12 +481,12 @@ export function searchHazards(hazard_type, keyword, limit, offset) { }; } -export function fetchHazards(hazard_type: string, space: string, limit, offset) { +export function fetchHazards(hazard_type, space, limit, offset) { let endpoint = `${config.hazardServiceBase}${hazard_type}?limit=${limit}&skip=${offset}`; if (space !== null && space !== "All") { endpoint = `${endpoint}&space=${space}`; } - return (dispatch: Dispatch) => { + return (dispatch) => { dispatch(loading(HAZARD_LOADING)); return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { dispatch(loadComplete(HAZARD_LOAD_COMPLETE)); @@ -530,7 +530,7 @@ export const LOGIN_ERROR = "LOGIN_ERROR"; export const SET_USER = "SET_USER"; export function login(username, password) { - return async (dispatch: Dispatch) => { + return async (dispatch) => { const json = await loginHelper(username, password); if (json["access_token"] !== undefined) { cookies.set("Authorization", `bearer ${json["access_token"]}`, { maxAge: json["expires_in"] }); @@ -549,7 +549,7 @@ export function login(username, password) { export const LOGOUT = "LOGOUT"; export function logout() { - return (dispatch: Dispatch) => { + return (dispatch) => { cookies.remove("Authorization"); return dispatch({ type: LOGOUT @@ -569,7 +569,7 @@ export const SEMANTIC_LOADING = "SEMANTIC_LOADING"; export const SEMANTIC_LOAD_COMPLETE = "SEMANTIC_LOAD_COMPLETE"; export function loading(component) { - return (dispatch: Dispatch) => { + return (dispatch) => { return dispatch({ type: component }); @@ -577,7 +577,7 @@ export function loading(component) { } export function loadComplete(component) { - return (dispatch: Dispatch) => { + return (dispatch) => { return dispatch({ type: component }); @@ -590,7 +590,7 @@ export function receiveDatawolfResponse(json) { // Get the id of the layers in geoserver to display in the map // Get the info from a table to display - return (dispatch: Dispatch) => { + return (dispatch) => { dispatch({ type: RECEIVE_EXECUTION_ID, executionId: json, @@ -599,7 +599,7 @@ export function receiveDatawolfResponse(json) { }; } -async function getOutputDatasetHelper(executionId: String) { +async function getOutputDatasetHelper(executionId) { const datawolfUrl = `${config.dataWolf}executions/${executionId}`; const headers = getDatawolfHeader(); const datawolf_execution_fetch = await fetch(datawolfUrl, { @@ -628,8 +628,8 @@ async function getOutputDatasetHelper(executionId: String) { export const RECEIVE_OUTPUT = "RECEIVE_OUTPUT"; -export function getOutputDataset(executionId: String) { - return async (dispatch: Dispatch) => { +export function getOutputDataset(executionId) { + return async (dispatch) => { const data = await getOutputDatasetHelper(executionId); dispatch({ type: RECEIVE_OUTPUT, @@ -642,8 +642,8 @@ export function getOutputDataset(executionId: String) { // Semantic Functions export const RECEIVE_SEMANTICS = "RECEIVE_SEMANTICS"; -export function receiveSemantics(type: string, json) { - return (dispatch: Dispatch) => { +export function receiveSemantics(type, json) { + return (dispatch) => { dispatch({ type: type, semantics: json, @@ -660,7 +660,7 @@ export function fetchSemantics(space, limit, offset) { endpoint = `${endpoint}&space=${space}`; } - return (dispatch: Dispatch) => { + return (dispatch) => { dispatch(loading(SEMANTIC_LOADING)); return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { dispatch(loadComplete(SEMANTIC_LOAD_COMPLETE)); @@ -680,7 +680,7 @@ export function fetchSemantics(space, limit, offset) { export function searchSemantics(keyword, limit, offset) { let endpoint = `${config.semanticServiceType}/search?text=${keyword}&limit=${limit}&skip=${offset}`; - return (dispatch: Dispatch) =>{ + return (dispatch) =>{ dispatch(loading(SEMANTIC_LOADING)); return fetch(endpoint, { mode: "cors", headers: getHeader() }).then((response) => { dispatch(loadComplete(SEMANTIC_LOAD_COMPLETE)); @@ -724,7 +724,7 @@ export async function executeDatawolfWorkflowHelper(workflowid, creatorid, title } export function executeDatawolfWorkflow(workflowid, creatorid, title, description, parameters, datasets) { - return async (dispatch: Dispatch) => { + return async (dispatch) => { const json = await executeDatawolfWorkflowHelper( workflowid, creatorid, diff --git a/src/components/children/Map.jsx b/src/components/children/Map.jsx index 7c48ff6d..a5778ee4 100644 --- a/src/components/children/Map.jsx +++ b/src/components/children/Map.jsx @@ -16,7 +16,7 @@ let tileAttribution = "Tiles © ArcGIS — National Geographic, Esri, DeLorme, NAVTEQ, " + "UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC"; -async function fetchExtent(name: string) { +async function fetchExtent(name) { let parser = new WMSCapabilities(); try { diff --git a/src/reducers/datatypes.js b/src/reducers/datatypes.js index e0168177..1b875913 100644 --- a/src/reducers/datatypes.js +++ b/src/reducers/datatypes.js @@ -1,12 +1,8 @@ import {RECEIVE_DATATYPES} from "../actions"; -type DatatypeAction = { - type: RECEIVE_DATATYPES, - datatypes: [] -} const defaultState = {datatypes: []}; -const datatypes = (state=defaultState, action: DatatypeAction) => { +const datatypes = (state=defaultState, action) => { switch(action.type) { case RECEIVE_DATATYPES: return Object.assign({}, state, {datatypes: action.datatypes}); diff --git a/src/reducers/spaces.js b/src/reducers/spaces.js index eab42157..3573d039 100644 --- a/src/reducers/spaces.js +++ b/src/reducers/spaces.js @@ -1,12 +1,8 @@ import {RECEIVE_SPACES} from "../actions"; -type SpaceAction = { - type: RECEIVE_SPACES, - spaces: [] -} const defaultState = {spaces: []}; -const spaces = (state=defaultState, action: SpaceAction) => { +const spaces = (state=defaultState, action) => { switch(action.type) { case RECEIVE_SPACES: return Object.assign({}, state, {spaces: action.spaces}); From e5d68a2891e2e0baa6c7194024badabc3627a332 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Fri, 12 Jan 2024 16:40:20 -0600 Subject: [PATCH 4/4] update the library to remove flow --- CHANGELOG.md | 3 +++ package-lock.json | 11 ----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2b82008..1263f4bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [Unreleased] +### Changed +- Hazard viewer previewing hazard datasets [#172](https://github.com/IN-CORE/incore-ui/pull/172) ## [1.9.1] - 2023-12-14 diff --git a/package-lock.json b/package-lock.json index ae4e406a..f75d0642 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1583,17 +1583,6 @@ } } }, - "@babel/preset-flow": { - "version": "7.23.3", - "resolved": "https://registry.npmjs.org/@babel/preset-flow/-/preset-flow-7.23.3.tgz", - "integrity": "sha512-7yn6hl8RIv+KNk6iIrGZ+D06VhVY35wLVf23Cz/mMu1zOr7u4MMP4j0nZ9tLf8+4ZFpnib8cFYgB/oYg9hfswA==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.22.5", - "@babel/helper-validator-option": "^7.22.15", - "@babel/plugin-transform-flow-strip-types": "^7.23.3" - } - }, "@babel/preset-modules": { "version": "0.1.6-no-external-plugins", "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz",