From 71055e7cd0ffd56008160d4116d4cdbf05a0be18 Mon Sep 17 00:00:00 2001 From: cracklesparkle Date: Thu, 19 Dec 2024 16:53:50 +0900 Subject: [PATCH] Types cleanup; type safe refactoring; Remove unused clickhouse service; ems: GET all lines; Roles types; --- client/src/interfaces/create.ts | 19 ++------------ client/src/interfaces/user.ts | 1 + client/src/pages/Roles.tsx | 43 +++++++++----------------------- client/src/utils/format.ts | 44 --------------------------------- docker-compose.yml | 15 ----------- ems/src/api/gis/index.ts | 5 +--- 6 files changed, 16 insertions(+), 111 deletions(-) delete mode 100644 client/src/utils/format.ts diff --git a/client/src/interfaces/create.ts b/client/src/interfaces/create.ts index 9edb66c..50b495c 100644 --- a/client/src/interfaces/create.ts +++ b/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; diff --git a/client/src/interfaces/user.ts b/client/src/interfaces/user.ts index 3fcaeb3..46ed51c 100644 --- a/client/src/interfaces/user.ts +++ b/client/src/interfaces/user.ts @@ -7,4 +7,5 @@ export interface IUser { name: string; surname: string; is_active: boolean; + role_id: number; } \ No newline at end of file diff --git a/client/src/pages/Roles.tsx b/client/src/pages/Roles.tsx index cff0204..0b3d18b 100644 --- a/client/src/pages/Roles.tsx +++ b/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() { ))} - {roles.map((role: any) => ( - - {columns.map(column => ( - {role[column.field]} - ))} - - ))} + + {roles.map((role: IRole) => ( + + {columns.map(column => ( + {role[column.field as keyof IRole]} + ))} + + ))} + - - {/* { - return updatedRow - }} - - onProcessRowUpdateError={() => { - }} - /> */} ) } \ No newline at end of file diff --git a/client/src/utils/format.ts b/client/src/utils/format.ts deleted file mode 100644 index 9f6811a..0000000 --- a/client/src/utils/format.ts +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index cb69d90..f3dbb43 100644 --- a/docker-compose.yml +++ b/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 diff --git a/ems/src/api/gis/index.ts b/ems/src/api/gis/index.ts index 1aa16b6..8ac428f 100644 --- a/ems/src/api/gis/index.ts +++ b/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)