Skip to content

Commit

Permalink
Merge pull request #43 from RENCI/layer-selection
Browse files Browse the repository at this point in the history
Cleaning up the removal functionality.
  • Loading branch information
PhillipsOwen authored May 16, 2024
2 parents 60b6cdc + 24a1ddb commit ca40ec3
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 49 deletions.
92 changes: 92 additions & 0 deletions src/components/model-selection/modelSelectionForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import React, { Fragment } from 'react';
import {Button, Input, Stack, Tabs, TabList, Tab, TabPanel, Divider} from '@mui/joy';
import { useLayers } from "@context";

// import {LayerCard} from "@components/trays/layers/layer-card";

/**
* This component renders the layer selection form
*
* @returns {JSX.Element}
* @constructor
*/
export const ModelSelectionForm = () => {
// get references to the filtered layer state
const {
//filteredModelLayers
} = useLayers();

// render the form
return (
<Fragment>
<Tabs aria-label="Type tabs" defaultValue={0}>
<TabList>
<Tab>Tropical</Tab>
<Tab>Synoptic</Tab>
</TabList>
<TabPanel value={0}>
<form onSubmit = { formHandler }>
<Stack spacing={1}>
<Input name="tropical-storm-name" placeholder="Tropical storm name control" />
<Input name="tropical-advisory" placeholder="Tropical advisory control" />
<Input name="tropical-grid" placeholder="Tropical grid control" />
<Input name="tropical-instance" placeholder="Tropical instance control" />

<Button type="submit">Submit</Button>
<Button type="reset">Reset</Button>
</Stack>

<Divider sx={{m: 2}} />

<Stack sx={{ maxHeight: "400px", overflow: "auto" }}>
{/* list of search results goes here
may be able to leverage trays/layers/layer-card />
*/}
</Stack>
</form>
</TabPanel>
<TabPanel value={1}>
<form onSubmit={ formHandler }>
<Stack spacing={1}>
<Input name="synoptic-date" placeholder="Synoptic date control" />
<Input name="synoptic-cycle" placeholder="Synoptic cycle control" />
<Input name="synoptic-grid" placeholder="Synoptic grid control" />
<Input name="synoptic-instance" placeholder="Synoptic instance control" />

<Button type="submit">Submit</Button>
<Button type="reset">Reset</Button>
</Stack>

<Divider sx={{m: 2}} />

<Stack sx={{ maxHeight: "400px", overflow: "auto" }}>
{/* list of search results goes here
may be able to leverage trays/layers/layer-card />
*/}
</Stack>
</form>
</TabPanel>
</Tabs>
</Fragment>
);
};

/**
* this method populates the controls on the form.
*
*/
// const dataLoader = () => {
//
// };

/**
* method to initiate a model search with the filter selections on the form
*
* @param event
*/
const formHandler = (event) => {
event.preventDefault();
const formData = new FormData(event.target);
const formJson = Object.fromEntries(formData.entries());
alert(JSON.stringify(formJson));
};
6 changes: 1 addition & 5 deletions src/components/sidebar/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import React from 'react';
import { Fragment, useCallback, useState } from 'react';
import {
List,
Sheet,
useTheme,
} from '@mui/joy';
import { List, Sheet, useTheme } from '@mui/joy';
import { Tray } from './tray';
import { MenuItem } from './menu-item';
import SidebarTrays from '../trays';
Expand Down
13 changes: 2 additions & 11 deletions src/components/sidebar/tray.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
DialogContent,
DialogTitle,
Divider,
IconButton,
Sheet,
Stack,
} from '@mui/joy';
import {
KeyboardDoubleArrowLeft as CloseTrayIcon,
} from '@mui/icons-material';
import { DialogContent, DialogTitle, Divider, IconButton, Sheet, Stack } from '@mui/joy';
import { KeyboardDoubleArrowLeft as CloseTrayIcon } from '@mui/icons-material';

const TRAY_WIDTH = '500px';

Expand Down
10 changes: 6 additions & 4 deletions src/components/trays/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import * as layers from './layers';
import * as hurricanes from './hurricanes';
import * as removeObservationSelections from './observations';
import * as layers from './layers';
import * as model_selection from './model-selection';
import * as remove_items from './remove';
import * as settings from './settings';

export default {
layers,
hurricanes,
settings,
removeObservationSelections
model_selection,
remove_items,
settings
};

/*
Expand Down
23 changes: 23 additions & 0 deletions src/components/trays/model-selection/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { Stack } from '@mui/joy';
import { Checklist as ModelSelectionIcon} from '@mui/icons-material';

// import the component that will allow the user to make model selections
import { ModelSelection } from "./model-selection.js";

// get an icon for the tray
export const icon = <ModelSelectionIcon />;

// create a title for this tray element
export const title = 'ADCIRC Model selection';

/**
* render the removal component
*
* @returns {JSX.Element}
*/
export const trayContents = () => (
<Stack gap={ 2 } p={ 2 }>
<ModelSelection />
</Stack>
);
17 changes: 17 additions & 0 deletions src/components/trays/model-selection/model-selection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { Fragment } from 'react';
import { ModelSelectionForm } from "@model-selection/modelSelectionForm.js";

/**
* component that handles the selection of layers for the map.
*
* @returns {JSX.Element}
* @constructor
*/
export const ModelSelection = () => {
// render the layer selection component
return (
<Fragment>
<ModelSelectionForm />
</Fragment>
);
};
23 changes: 0 additions & 23 deletions src/components/trays/observations/index.js

This file was deleted.

25 changes: 25 additions & 0 deletions src/components/trays/remove/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import { Stack } from '@mui/joy';
import { Delete as RemoveIcon} from '@mui/icons-material';

// import the components that will remove selected items from state
import { RemoveObservations } from "./remove-observations";
import { RemoveModels } from "./remove-models";

// get an icon for the tray
export const icon = <RemoveIcon />;

// create a title for this tray element
export const title = 'Remove items';

/**
* render the tray
*
* @returns {JSX.Element}
*/
export const trayContents = () => (
<Stack gap={ 2 } p={ 2 }>
<RemoveObservations />
<RemoveModels />
</Stack>
);
30 changes: 30 additions & 0 deletions src/components/trays/remove/remove-models.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { Fragment } from 'react';
import { Button } from '@mui/joy';
import {useLayers} from "@context";

/**
* component that handles the removal of models.
*
* @returns {JSX.Element}
* @constructor
*/
export const RemoveModels = () => {
// get references to the model data/list
const {

} = useLayers();

/**
* remove the observation selections from state and map
*/
function removeModels() {
alert("Not ready yet.");
}

// render the button
return (
<Fragment>
<Button color="primary" onClick={() => removeModels()}>Remove selected models</Button>
</Fragment>
);
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { Fragment } from 'react';
import { Button } from '@mui/joy';

import {useLayers} from "@context";

/**
* component that handles the removal of all observation selections from the map.
* component that handles the removal of observations.
*
* @returns {JSX.Element}
* @constructor
Expand All @@ -20,7 +19,7 @@ export const RemoveObservations = () => {
/**
* remove the observation selections from state and map
*/
function removeAllObservations() {
function removeObservations() {
// remove all the targets on the map
map.eachLayer((layer) => {
// if this is an observation selection marker
Expand All @@ -37,7 +36,7 @@ export const RemoveObservations = () => {
// render the button
return (
<Fragment>
<Button color="primary" onClick={() => removeAllObservations()}>Remove all observation selections</Button>
<Button color="primary" onClick={() => removeObservations()}>Remove selected observations</Button>
</Fragment>
);
};
5 changes: 3 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ module.exports = {
'@components': path.resolve(__dirname, 'src/components/'),
'@content': path.resolve(__dirname, 'src/content/'),
'@context': path.resolve(__dirname, 'src/context/'),
'@dialog': path.resolve(__dirname, 'src/components/dialog'),
'@hooks': path.resolve(__dirname, 'src/hooks/'),
'@images': path.resolve(__dirname, 'src/images/'),
'@utils': path.resolve(__dirname, 'src/utils/'),
'@dialog': path.resolve(__dirname, 'src/components/dialog')
'@model-selection': path.resolve(__dirname, 'src/components/model-selection'),
'@utils': path.resolve(__dirname, 'src/utils/')
}
},

Expand Down

0 comments on commit ca40ec3

Please sign in to comment.