Browse Source

Types cleanup; type safe refactoring; Remove unused clickhouse service; ems: GET all lines; Roles types;

mantine
cracklesparkle 5 months ago
parent
commit
71055e7cd0
  1. 19
      client/src/interfaces/create.ts
  2. 1
      client/src/interfaces/user.ts
  3. 43
      client/src/pages/Roles.tsx
  4. 44
      client/src/utils/format.ts
  5. 15
      docker-compose.yml
  6. 5
      ems/src/api/gis/index.ts

19
client/src/interfaces/create.ts

@ -1,22 +1,7 @@
import { Validate } from "react-hook-form";
export interface CreateFieldTypes {
string: 'string';
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 type CreateFieldType = 'string' | 'number' | 'date' | 'dateTime' | 'boolean' | 'singleSelect' | 'actions' | 'custom'
export type InputType = 'password'
export interface CreateField {
key: string;

1
client/src/interfaces/user.ts

@ -7,4 +7,5 @@ export interface IUser {
name: string;
surname: string;
is_active: boolean;
role_id: number;
}

43
client/src/pages/Roles.tsx

@ -4,6 +4,7 @@ import RoleService from '../services/RoleService'
import FormFields from '../components/FormFields'
import { Button, Loader, Modal, ScrollAreaAutosize, Table } from '@mantine/core'
import { useDisclosure } from '@mantine/hooks'
import { IRole } from '../interfaces/role'
export default function Roles() {
const { roles, isError, isLoading } = useRoles()
@ -45,38 +46,18 @@ export default function Roles() {
))}
</Table.Tr>
</Table.Thead>
<Table.Tbody>{roles.map((role: any) => (
<Table.Tr
key={role.id}
//bg={selectedRows.includes(element.position) ? 'var(--mantine-color-blue-light)' : undefined}
>
{columns.map(column => (
<Table.Td key={column.field}>{role[column.field]}</Table.Td>
))}
</Table.Tr>
))}</Table.Tbody>
<Table.Tbody>
{roles.map((role: IRole) => (
<Table.Tr
key={role.id}
>
{columns.map(column => (
<Table.Td key={column.field}>{role[column.field as keyof IRole]}</Table.Td>
))}
</Table.Tr>
))}
</Table.Tbody>
</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>
)
}

44
client/src/utils/format.ts

@ -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);
}

15
docker-compose.yml

@ -79,18 +79,3 @@ services:
retries: 5
start_period: 10s
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

5
ems/src/api/gis/index.ts

@ -51,10 +51,7 @@ router.get('/lines/all', async (req: Request, res: Response) => {
const result = await tediousQuery(
`
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}
ORDER BY l.year
OFFSET ${Number(offset) || 0} ROWS
FETCH NEXT ${Number(limit) || 10} ROWS ONLY;
JOIN ${GeneralDB}..vObjects o ON l.object_id = o.object_id WHERE o.id_city = ${city_id} AND l.year = ${year};
`
)
res.status(200).json(result)

Loading…
Cancel
Save