forked from VinokurovVE/tests
Types cleanup; type safe refactoring; Remove unused clickhouse service; ems: GET all lines; Roles types;
This commit is contained in:
@ -1,22 +1,7 @@
|
|||||||
import { Validate } from "react-hook-form";
|
import { Validate } from "react-hook-form";
|
||||||
|
|
||||||
export interface CreateFieldTypes {
|
export type CreateFieldType = 'string' | 'number' | 'date' | 'dateTime' | 'boolean' | 'singleSelect' | 'actions' | 'custom'
|
||||||
string: 'string';
|
export type InputType = 'password'
|
||||||
number: 'number';
|
|
||||||
date: 'date';
|
|
||||||
dateTime: 'dateTime';
|
|
||||||
boolean: 'boolean';
|
|
||||||
singleSelect: 'singleSelect';
|
|
||||||
actions: 'actions';
|
|
||||||
custom: 'custom';
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface InputTypes {
|
|
||||||
password: 'password';
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CreateFieldType = CreateFieldTypes[keyof CreateFieldTypes]
|
|
||||||
export type InputType = InputTypes[keyof InputTypes]
|
|
||||||
|
|
||||||
export interface CreateField {
|
export interface CreateField {
|
||||||
key: string;
|
key: string;
|
||||||
|
@ -7,4 +7,5 @@ export interface IUser {
|
|||||||
name: string;
|
name: string;
|
||||||
surname: string;
|
surname: string;
|
||||||
is_active: boolean;
|
is_active: boolean;
|
||||||
|
role_id: number;
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ import RoleService from '../services/RoleService'
|
|||||||
import FormFields from '../components/FormFields'
|
import FormFields from '../components/FormFields'
|
||||||
import { Button, Loader, Modal, ScrollAreaAutosize, Table } from '@mantine/core'
|
import { Button, Loader, Modal, ScrollAreaAutosize, Table } from '@mantine/core'
|
||||||
import { useDisclosure } from '@mantine/hooks'
|
import { useDisclosure } from '@mantine/hooks'
|
||||||
|
import { IRole } from '../interfaces/role'
|
||||||
|
|
||||||
export default function Roles() {
|
export default function Roles() {
|
||||||
const { roles, isError, isLoading } = useRoles()
|
const { roles, isError, isLoading } = useRoles()
|
||||||
@ -45,38 +46,18 @@ export default function Roles() {
|
|||||||
))}
|
))}
|
||||||
</Table.Tr>
|
</Table.Tr>
|
||||||
</Table.Thead>
|
</Table.Thead>
|
||||||
<Table.Tbody>{roles.map((role: any) => (
|
<Table.Tbody>
|
||||||
<Table.Tr
|
{roles.map((role: IRole) => (
|
||||||
key={role.id}
|
<Table.Tr
|
||||||
//bg={selectedRows.includes(element.position) ? 'var(--mantine-color-blue-light)' : undefined}
|
key={role.id}
|
||||||
>
|
>
|
||||||
{columns.map(column => (
|
{columns.map(column => (
|
||||||
<Table.Td key={column.field}>{role[column.field]}</Table.Td>
|
<Table.Td key={column.field}>{role[column.field as keyof IRole]}</Table.Td>
|
||||||
))}
|
))}
|
||||||
</Table.Tr>
|
</Table.Tr>
|
||||||
))}</Table.Tbody>
|
))}
|
||||||
|
</Table.Tbody>
|
||||||
</Table>
|
</Table>
|
||||||
|
|
||||||
{/* <DataGrid
|
|
||||||
autoHeight
|
|
||||||
style={{ width: "100%" }}
|
|
||||||
rows={roles}
|
|
||||||
columns={columns}
|
|
||||||
initialState={{
|
|
||||||
pagination: {
|
|
||||||
paginationModel: { page: 0, pageSize: 10 },
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
pageSizeOptions={[10, 20, 50, 100]}
|
|
||||||
disableRowSelectionOnClick
|
|
||||||
|
|
||||||
processRowUpdate={(updatedRow) => {
|
|
||||||
return updatedRow
|
|
||||||
}}
|
|
||||||
|
|
||||||
onProcessRowUpdateError={() => {
|
|
||||||
}}
|
|
||||||
/> */}
|
|
||||||
</ScrollAreaAutosize>
|
</ScrollAreaAutosize>
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -1,44 +0,0 @@
|
|||||||
// CP437 Character Map
|
|
||||||
const CP437_MAP = [
|
|
||||||
'\0', '☺', '☻', '♥', '♦', '♣', '♠', '•', '◘', '○', '◙', '♂', '♀', '♪', '♫', '☼', '►',
|
|
||||||
'◄', '↕', '‼', '¶', '§', '▬', '↨', '↑', '↓', '→', '←', '∟', '↔', '▲', '▼', ' ', '!', '"',
|
|
||||||
'#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4',
|
|
||||||
'5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F',
|
|
||||||
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
|
||||||
'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
|
|
||||||
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|',
|
|
||||||
'}', '~', '⌂', 'Ç', 'ü', 'é', 'â', 'ä', 'à', 'å', 'ç', 'ê', 'ë', 'è', 'ï', 'î', 'ì', 'Ä',
|
|
||||||
'Å', 'É', 'æ', 'Æ', 'ô', 'ö', 'ò', 'û', 'ù', 'ÿ', 'Ö', 'Ü', '¢', '£', '¥', '₧', 'ƒ', 'á',
|
|
||||||
'í', 'ó', 'ú', 'ñ', 'Ñ', 'ª', 'º', '¿', '⌐', '¬', '½', '¼', '¡', '«', '»', '░', '▒', '▓',
|
|
||||||
'│', '┤', '╡', '╢', '╖', '╕', '╣', '║', '╗', '╝', '╜', '╛', '┐', '└', '┴', '┬', '├', '─',
|
|
||||||
'┼', '╞', '╟', '╚', '╔', '╩', '╦', '╠', '═', '╬', '╧', '╨', '╤', '╥', '╙', '╘', '╒', '╓',
|
|
||||||
'╫', '╪', '┘', '┌', '█', '▄', '▌', '▐', '▀', 'α', 'ß', 'Γ', 'π', 'Σ', 'σ', 'µ', 'τ', 'Φ',
|
|
||||||
'Θ', 'Ω', 'δ', '∞', 'φ', 'ε', '∩', '≡', '±', '≥', '≤', '⌠', '⌡', '÷', '≈', '°', '∙', '·',
|
|
||||||
'√', 'ⁿ', '²', '■', ' '
|
|
||||||
];
|
|
||||||
|
|
||||||
function decodeCP437ToBytes(garbledString: string) {
|
|
||||||
const bytes = [];
|
|
||||||
for (const char of garbledString) {
|
|
||||||
const byte = CP437_MAP.indexOf(char);
|
|
||||||
if (byte === -1) {
|
|
||||||
//console.warn(`Character '${char}' not found in CP437 map`);
|
|
||||||
bytes.push(63); // '?' as a placeholder
|
|
||||||
}
|
|
||||||
bytes.push(byte);
|
|
||||||
}
|
|
||||||
return Uint8Array.from(bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
function decodeWindows1251FromBytes(byteArray: any) {
|
|
||||||
const decoder = new TextDecoder('windows-1251');
|
|
||||||
return decoder.decode(byteArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function decodeDoubleEncodedString(garbledString: string) {
|
|
||||||
// Step 1: Decode from CP437 to bytes
|
|
||||||
const bytes = decodeCP437ToBytes(garbledString);
|
|
||||||
|
|
||||||
// Step 2: Decode bytes as WINDOWS-1251
|
|
||||||
return decodeWindows1251FromBytes(bytes);
|
|
||||||
}
|
|
@ -79,18 +79,3 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
start_period: 10s
|
start_period: 10s
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
clickhouse_test:
|
|
||||||
container_name: clickhouse_test
|
|
||||||
image: clickhouse/clickhouse-server
|
|
||||||
environment:
|
|
||||||
- CLICKHOUSE_DB=${CLICKHOUSE_DB}
|
|
||||||
- CLICKHOUSE_USER=${CLICKHOUSE_USER}
|
|
||||||
- CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=${CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT}
|
|
||||||
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD}
|
|
||||||
ports:
|
|
||||||
- 8123:8123
|
|
||||||
- 9000:9000
|
|
||||||
expose:
|
|
||||||
- 8123
|
|
||||||
- 9000
|
|
||||||
|
@ -51,10 +51,7 @@ router.get('/lines/all', async (req: Request, res: Response) => {
|
|||||||
const result = await tediousQuery(
|
const result = await tediousQuery(
|
||||||
`
|
`
|
||||||
SELECT * FROM ${GisDB}..lines l
|
SELECT * FROM ${GisDB}..lines l
|
||||||
JOIN ${GeneralDB}..vObjects o ON l.object_id = o.object_id WHERE o.id_city = ${city_id} AND l.year = ${year}
|
JOIN ${GeneralDB}..vObjects o ON l.object_id = o.object_id WHERE o.id_city = ${city_id} AND l.year = ${year};
|
||||||
ORDER BY l.year
|
|
||||||
OFFSET ${Number(offset) || 0} ROWS
|
|
||||||
FETCH NEXT ${Number(limit) || 10} ROWS ONLY;
|
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
res.status(200).json(result)
|
res.status(200).json(result)
|
||||||
|
Reference in New Issue
Block a user