Skip to content

Commit

Permalink
Warning for multiple networks
Browse files Browse the repository at this point in the history
  • Loading branch information
vpet98 committed Mar 12, 2024
1 parent 08e04dc commit f46879a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 29 deletions.
7 changes: 7 additions & 0 deletions statsboard/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ h1 {
margin: 5px 0;
}

.networks-note {
font-size: 12px;
color: #CA2400;
font-style: italic;
margin-top: -5px;
}

.stations-note {
font-size: 13px;
color: #999;
Expand Down
64 changes: 35 additions & 29 deletions statsboard/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { makePlotsStation } from './plotsStation.js';

function App() {
const [isAuthenticated, setIsAuthenticated] = useState(false);
const [commaNets, setCommaNets] = useState(false);
const [authTokenFile, setAuthTokenFile] = useState(undefined);
const [startTime, setStartTime] = useState(new Date().getFullYear()+'-01');
const [endTime, setEndTime] = useState(undefined);
Expand Down Expand Up @@ -310,36 +311,41 @@ function App() {
)}
{(level === "network" || level === "station") && (
<div>
<Autocomplete
className="autocomplete"
sx={{ my: 1, minWidth: 300 }}
size="small"
freeSolo
multiple={isAuthenticated}
onInputChange={e => setInputNetwork(e.target.value)}
onChange={(e, nv) => {setNetwork(nv); setInputNetwork("");}}
options={optionsNet}
open={openNet}
onOpen={() => setOpenNet(true)}
onClose={() => {setOpenNet(false); setBroughtNets(false);}}
isOptionEqualToValue={(option, value) => option === value}
loading={loadingNet}
renderInput={(params) => (
<TextField
{...params}
label="Network"
InputProps={{
...params.InputProps,
endAdornment: (
<Fragment>
{loadingNet ? <CircularProgress color="inherit" size={20} /> : null}
{params.InputProps.endAdornment}
</Fragment>
),
}}
/>
<Autocomplete
className="autocomplete"
sx={{ my: 1, minWidth: 300 }}
size="small"
freeSolo
multiple={isAuthenticated}
onInputChange={e => {setInputNetwork(e.target.value); e.target.value && (network.length > 0 || e.target.value.includes(',')) ? setCommaNets(true) : setCommaNets(false)}}
onChange={(e, nv) => {setNetwork(nv); setInputNetwork(""); nv.length > 1 ? setCommaNets(true) : setCommaNets(false)}}
options={optionsNet}
open={openNet}
onOpen={() => setOpenNet(true)}
onClose={() => {setOpenNet(false); setBroughtNets(false);}}
isOptionEqualToValue={(option, value) => option === value}
loading={loadingNet}
renderInput={(params) => (
<TextField
{...params}
label="Network"
InputProps={{
...params.InputProps,
endAdornment: (
<Fragment>
{loadingNet ? <CircularProgress color="inherit" size={20} /> : null}
{params.InputProps.endAdornment}
</Fragment>
),
}}
/>
)}
/>
{commaNets && (
<div className="networks-note">
Selecting multiple network requires node operator privileges. Make sure your EIDA account is set up accordingly.
</div>
)}
/>
</div>
)}
{level === "station" && (
Expand Down

0 comments on commit f46879a

Please sign in to comment.