|
|
@ -1,5 +1,5 @@ |
|
|
|
import { AppBar, Autocomplete, CircularProgress, Dialog, IconButton, TextField, Toolbar } from '@mui/material' |
|
|
|
import { Fragment, useEffect, useState } from 'react' |
|
|
|
import { Fragment, useState } from 'react' |
|
|
|
import { IRegion } from '../interfaces/fuel' |
|
|
|
import { useHardwares, useStorages } from '../hooks/swrHooks' |
|
|
|
import FullFeaturedCrudGrid from './TableEditable' |
|
|
@ -10,19 +10,12 @@ import ServerData from './ServerData' |
|
|
|
|
|
|
|
export default function ServerStorage() { |
|
|
|
const [open, setOpen] = useState(false) |
|
|
|
const [options, setOptions] = useState<IRegion[]>([]) |
|
|
|
const [selectedOption, setSelectedOption] = useState<IRegion | null>(null) |
|
|
|
const { hardwares, isLoading } = useHardwares() |
|
|
|
|
|
|
|
const [serverDataOpen, setServerDataOpen] = useState(false) |
|
|
|
const [currentServerData, setCurrentServerData] = useState<any | null>(null) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if (hardwares) { |
|
|
|
setOptions([...hardwares]) |
|
|
|
} |
|
|
|
}, [hardwares]) |
|
|
|
|
|
|
|
const handleInputChange = (value: string) => { |
|
|
|
return value |
|
|
|
} |
|
|
@ -78,43 +71,43 @@ export default function ServerStorage() { |
|
|
|
{serversLoading ? |
|
|
|
<CircularProgress /> |
|
|
|
: |
|
|
|
storages && |
|
|
|
<FullFeaturedCrudGrid |
|
|
|
autoComplete={<Autocomplete |
|
|
|
open={open} |
|
|
|
onOpen={() => { |
|
|
|
setOpen(true) |
|
|
|
}} |
|
|
|
onClose={() => { |
|
|
|
setOpen(false) |
|
|
|
}} |
|
|
|
onInputChange={(_, value) => handleInputChange(value)} |
|
|
|
onChange={(_, value) => handleOptionChange(value)} |
|
|
|
filterOptions={(x) => x} |
|
|
|
isOptionEqualToValue={(option: IRegion, value: IRegion) => option.name === value.name} |
|
|
|
getOptionLabel={(option: IRegion) => option.name ? option.name : ""} |
|
|
|
options={options} |
|
|
|
loading={isLoading} |
|
|
|
value={selectedOption} |
|
|
|
renderInput={(params) => ( |
|
|
|
<TextField |
|
|
|
{...params} |
|
|
|
size='small' |
|
|
|
label="Hardware" |
|
|
|
InputProps={{ |
|
|
|
...params.InputProps, |
|
|
|
endAdornment: ( |
|
|
|
<Fragment> |
|
|
|
{isLoading ? <CircularProgress color="inherit" size={20} /> : null} |
|
|
|
{params.InputProps.endAdornment} |
|
|
|
</Fragment> |
|
|
|
) |
|
|
|
}} /> |
|
|
|
)} />} |
|
|
|
autoComplete={ |
|
|
|
<Autocomplete |
|
|
|
open={open} |
|
|
|
onOpen={() => { |
|
|
|
setOpen(true) |
|
|
|
}} |
|
|
|
onClose={() => { |
|
|
|
setOpen(false) |
|
|
|
}} |
|
|
|
onInputChange={(_, value) => handleInputChange(value)} |
|
|
|
onChange={(_, value) => handleOptionChange(value)} |
|
|
|
filterOptions={(x) => x} |
|
|
|
isOptionEqualToValue={(option: IRegion, value: IRegion) => option.name === value.name} |
|
|
|
getOptionLabel={(option: IRegion) => option.name ? option.name : ""} |
|
|
|
options={hardwares || []} |
|
|
|
loading={isLoading} |
|
|
|
value={selectedOption} |
|
|
|
renderInput={(params) => ( |
|
|
|
<TextField |
|
|
|
{...params} |
|
|
|
size='small' |
|
|
|
label="Hardware" |
|
|
|
InputProps={{ |
|
|
|
...params.InputProps, |
|
|
|
endAdornment: ( |
|
|
|
<Fragment> |
|
|
|
{isLoading ? <CircularProgress color="inherit" size={20} /> : null} |
|
|
|
{params.InputProps.endAdornment} |
|
|
|
</Fragment> |
|
|
|
) |
|
|
|
}} /> |
|
|
|
)} />} |
|
|
|
onSave={() => { |
|
|
|
}} |
|
|
|
onDelete={ServerService.removeServer} |
|
|
|
initialRows={storages} |
|
|
|
initialRows={storages || []} |
|
|
|
columns={storageColumns} |
|
|
|
actions |
|
|
|
onRowClick={(params) => { |
|
|
|