forked from VinokurovVE/tests
Add edit ToolType; Users type; Reports cleanup; Type safery
This commit is contained in:
@ -114,7 +114,7 @@ const ObjectList = ({
|
|||||||
return (
|
return (
|
||||||
<NavLink onClick={() => {
|
<NavLink onClick={() => {
|
||||||
setSelectedObjectType(id)
|
setSelectedObjectType(id)
|
||||||
}} rightSection={<IconChevronDown size={14} />} p={0} label={`${id} ${label} ${count ? `(${count})` : ''}`}>
|
}} rightSection={<IconChevronDown size={14} />} p={0} label={`${label} ${count ? `(${count})` : ''}`}>
|
||||||
{Array.isArray(data) && data.map((type) => (
|
{Array.isArray(data) && data.map((type) => (
|
||||||
<NavLink key={type.object_id} label={type.caption ? type.caption : 'Без названия'} p={0} onClick={() => setCurrentObjectId(type.object_id)} />
|
<NavLink key={type.object_id} label={type.caption ? type.caption : 'Без названия'} p={0} onClick={() => setCurrentObjectId(type.object_id)} />
|
||||||
))}
|
))}
|
||||||
|
@ -9,7 +9,6 @@ export interface ICity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IBoiler {
|
export interface IBoiler {
|
||||||
id: string;
|
|
||||||
id_object: string;
|
id_object: string;
|
||||||
boiler_name: string;
|
boiler_name: string;
|
||||||
boiler_code: string;
|
boiler_code: string;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useBoilers } from '../hooks/swrHooks'
|
import { useBoilers } from '../hooks/swrHooks'
|
||||||
import { Badge, ScrollAreaAutosize, Table, Text } from '@mantine/core'
|
import { Badge, ScrollAreaAutosize, Table, Text } from '@mantine/core'
|
||||||
|
import { IBoiler } from '../interfaces/fuel'
|
||||||
|
|
||||||
function Boilers() {
|
function Boilers() {
|
||||||
const [boilersPage, setBoilersPage] = useState(1)
|
const [boilersPage, setBoilersPage] = useState(1)
|
||||||
@ -47,7 +48,7 @@ function Boilers() {
|
|||||||
</Table.Tr>
|
</Table.Tr>
|
||||||
</Table.Thead>
|
</Table.Thead>
|
||||||
<Table.Tbody>
|
<Table.Tbody>
|
||||||
{boilers.map((boiler: {id_object: string, activity: boolean}) => (
|
{boilers.map((boiler: IBoiler) => (
|
||||||
<Table.Tr key={boiler.id_object}>
|
<Table.Tr key={boiler.id_object}>
|
||||||
{boilersColumns.map(column => {
|
{boilersColumns.map(column => {
|
||||||
if (column.field === 'activity') {
|
if (column.field === 'activity') {
|
||||||
@ -69,7 +70,7 @@ function Boilers() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
else return (
|
else return (
|
||||||
<Table.Td key={`${boiler.id_object}-${boiler[column.field]}`}>{boiler[column.field]}</Table.Td>
|
<Table.Td key={`${boiler.id_object}-${column.field}`}>{boiler[column.field as keyof IBoiler]}</Table.Td>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</Table.Tr>
|
</Table.Tr>
|
||||||
|
@ -4,7 +4,7 @@ import { Card, Flex } from '@mantine/core';
|
|||||||
function CardComponent({
|
function CardComponent({
|
||||||
url,
|
url,
|
||||||
is_alive
|
is_alive
|
||||||
}: { url: any, is_alive: any }) {
|
}: { url: string, is_alive: boolean }) {
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
<Flex p='sm' direction='column'>
|
<Flex p='sm' direction='column'>
|
||||||
@ -16,7 +16,7 @@ function CardComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function MonitorPage() {
|
export default function MonitorPage() {
|
||||||
const [servers, setServers] = useState<any>([])
|
const [servers, setServers] = useState([])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const eventSource = new EventSource(`${import.meta.env.VITE_API_MONITOR_URL}/watch`);
|
const eventSource = new EventSource(`${import.meta.env.VITE_API_MONITOR_URL}/watch`);
|
||||||
@ -39,7 +39,7 @@ export default function MonitorPage() {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Flex direction='column' gap='sm'>
|
<Flex direction='column' gap='sm'>
|
||||||
{servers.length > 0 && servers.map((server: any) => (
|
{servers.length > 0 && servers.map((server: { name: string, status: boolean }) => (
|
||||||
<CardComponent url={server.name} is_alive={server.status} />
|
<CardComponent url={server.name} is_alive={server.status} />
|
||||||
))}
|
))}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -65,32 +65,6 @@ export default function Reports() {
|
|||||||
}
|
}
|
||||||
value={search}
|
value={search}
|
||||||
/>
|
/>
|
||||||
{/* <Autocomplete
|
|
||||||
fullWidth
|
|
||||||
onInputChange={(_, value) => setSearch(value)}
|
|
||||||
onChange={(_, value) => setSelectedOption(value)}
|
|
||||||
isOptionEqualToValue={(option: ICity, value: ICity) => option.id === value.id}
|
|
||||||
getOptionLabel={(option: ICity) => option.name ? option.name : ""}
|
|
||||||
options={cities || []}
|
|
||||||
loading={isLoading}
|
|
||||||
value={selectedOption}
|
|
||||||
renderInput={(params) => (
|
|
||||||
<TextField
|
|
||||||
{...params}
|
|
||||||
size='small'
|
|
||||||
label="Населенный пункт"
|
|
||||||
InputProps={{
|
|
||||||
...params.InputProps,
|
|
||||||
endAdornment: (
|
|
||||||
<Fragment>
|
|
||||||
{isLoading ? <CircularProgress color="inherit" size={20} /> : null}
|
|
||||||
{params.InputProps.endAdornment}
|
|
||||||
</Fragment>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/> */}
|
|
||||||
|
|
||||||
<ActionIcon size='auto' variant='transparent' onClick={() => refreshReport()}>
|
<ActionIcon size='auto' variant='transparent' onClick={() => refreshReport()}>
|
||||||
<IconRefresh />
|
<IconRefresh />
|
||||||
@ -159,48 +133,6 @@ export default function Reports() {
|
|||||||
</Table.Tbody>
|
</Table.Tbody>
|
||||||
</Table>
|
</Table>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{/* <DataGrid
|
|
||||||
autoHeight
|
|
||||||
style={{ width: "100%" }}
|
|
||||||
loading={reportLoading}
|
|
||||||
rows={
|
|
||||||
report ?
|
|
||||||
[...new Set(Object.keys(report).flatMap(key => Object.keys(report[key])))].map(id => {
|
|
||||||
const row: any = { id: Number(id) };
|
|
||||||
Object.keys(report).forEach(key => {
|
|
||||||
row[key] = report[key][id];
|
|
||||||
});
|
|
||||||
return row;
|
|
||||||
})
|
|
||||||
:
|
|
||||||
[]
|
|
||||||
}
|
|
||||||
columns={[
|
|
||||||
{ field: 'id', headerName: '№', width: 70 },
|
|
||||||
...Object.keys(report).map(key => ({
|
|
||||||
field: key,
|
|
||||||
headerName: key.charAt(0).toUpperCase() + key.slice(1),
|
|
||||||
width: 150
|
|
||||||
}))
|
|
||||||
]}
|
|
||||||
initialState={{
|
|
||||||
pagination: {
|
|
||||||
paginationModel: { page: 0, pageSize: 10 },
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
pageSizeOptions={[10, 20, 50, 100]}
|
|
||||||
checkboxSelection={false}
|
|
||||||
disableRowSelectionOnClick
|
|
||||||
|
|
||||||
processRowUpdate={(updatedRow) => {
|
|
||||||
return updatedRow
|
|
||||||
}}
|
|
||||||
|
|
||||||
onProcessRowUpdateError={() => {
|
|
||||||
}}
|
|
||||||
/> */}
|
|
||||||
</ScrollAreaAutosize>
|
</ScrollAreaAutosize>
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -6,13 +6,14 @@ import UserService from "../services/UserService"
|
|||||||
import FormFields from "../components/FormFields"
|
import FormFields from "../components/FormFields"
|
||||||
import { Badge, Button, Flex, Loader, Modal, Pagination, ScrollAreaAutosize, Select, Table } from "@mantine/core"
|
import { Badge, Button, Flex, Loader, Modal, Pagination, ScrollAreaAutosize, Select, Table } from "@mantine/core"
|
||||||
import { useDisclosure } from "@mantine/hooks"
|
import { useDisclosure } from "@mantine/hooks"
|
||||||
|
import { IUser } from "../interfaces/user"
|
||||||
|
|
||||||
export default function Users() {
|
export default function Users() {
|
||||||
const { users, isError, isLoading } = useUsers()
|
const { users, isError, isLoading } = useUsers()
|
||||||
|
|
||||||
const { roles } = useRoles()
|
const { roles } = useRoles()
|
||||||
|
|
||||||
const [roleOptions, setRoleOptions] = useState<any>()
|
const [roleOptions, setRoleOptions] = useState<{ label: string, value: string }[]>()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Array.isArray(roles)) {
|
if (Array.isArray(roles)) {
|
||||||
@ -54,7 +55,7 @@ export default function Users() {
|
|||||||
Произошла ошибка при получении данных.
|
Произошла ошибка при получении данных.
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<Flex direction='column' align='flex-start' gap='sm' p='sm'>
|
<Flex direction='column' align='flex-start' gap='sm' p='sm'>
|
||||||
@ -86,7 +87,7 @@ export default function Users() {
|
|||||||
</Table.Tr>
|
</Table.Tr>
|
||||||
</Table.Thead>
|
</Table.Thead>
|
||||||
<Table.Tbody>
|
<Table.Tbody>
|
||||||
{users.map((user: any) => (
|
{users.map((user: IUser) => (
|
||||||
<Table.Tr
|
<Table.Tr
|
||||||
key={user.id}
|
key={user.id}
|
||||||
//bg={selectedRows.includes(element.position) ? 'var(--mantine-color-blue-light)' : undefined}
|
//bg={selectedRows.includes(element.position) ? 'var(--mantine-color-blue-light)' : undefined}
|
||||||
@ -100,7 +101,6 @@ export default function Users() {
|
|||||||
Активен
|
Активен
|
||||||
</Badge>
|
</Badge>
|
||||||
</Table.Td>
|
</Table.Td>
|
||||||
|
|
||||||
) : (
|
) : (
|
||||||
<Table.Td key={column.field}>
|
<Table.Td key={column.field}>
|
||||||
<Badge color="gray" fullWidth variant="light">
|
<Badge color="gray" fullWidth variant="light">
|
||||||
@ -123,7 +123,7 @@ export default function Users() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
else return (
|
else return (
|
||||||
<Table.Td key={column.field}>{user[column.field]}</Table.Td>
|
<Table.Td key={column.field}>{user[column.field as keyof IUser]}</Table.Td>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</Table.Tr>
|
</Table.Tr>
|
||||||
|
@ -10,4 +10,5 @@ export type ToolType =
|
|||||||
"Circle" |
|
"Circle" |
|
||||||
"Measure" |
|
"Measure" |
|
||||||
"Mover" |
|
"Mover" |
|
||||||
|
"Edit" |
|
||||||
null
|
null
|
Reference in New Issue
Block a user