Skip to content

Commit a27f224

Browse files
author
serhii.zahuba
committed
FEATURE/queries-via-UI
1 parent 945442a commit a27f224

File tree

8 files changed

+295
-279
lines changed

8 files changed

+295
-279
lines changed

frontend/package-lock.json

Lines changed: 16 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"tailwindcss": "^4.1.7"
2323
},
2424
"devDependencies": {
25-
"@eslint/js": "^9.25.0",
25+
"@eslint/js": "^9.35.0",
2626
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
2727
"@types/react": "^19.1.2",
2828
"@types/react-dom": "^19.1.2",
Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
// src/entity/api/sqlQueryApi.ts
2-
import { apiHelper } from '../../../shared/api/apiHelper';
3-
import RequestOptions from '../../../shared/api/RequestOptions';
4-
import type { ExecuteResponse } from '../model/ExecuteResponse';
5-
6-
export type ExecuteRequest = {
7-
databaseId: string; // was database_id
8-
sql: string;
9-
maxRows?: number; // was max_rows
10-
timeoutSec?: number; // was timeout_sec
11-
};
12-
13-
14-
export const sqlQueryApi = {
15-
execute: async (payload: ExecuteRequest): Promise<ExecuteResponse> => {
16-
const opts = new RequestOptions().setBody(JSON.stringify(payload));
17-
return apiHelper.fetchPostJson<ExecuteResponse>('/api/v1/sqlquery/execute', opts);
18-
},
19-
};
1+
// src/entity/api/sqlQueryApi.ts
2+
import RequestOptions from '../../../shared/api/RequestOptions';
3+
import { apiHelper } from '../../../shared/api/apiHelper';
4+
import type { ExecuteResponse } from '../model/ExecuteResponse';
5+
6+
export type ExecuteRequest = {
7+
databaseId: string; // was database_id
8+
sql: string;
9+
maxRows?: number; // was max_rows
10+
timeoutSec?: number; // was timeout_sec
11+
};
12+
13+
export const sqlQueryApi = {
14+
execute: async (payload: ExecuteRequest): Promise<ExecuteResponse> => {
15+
const opts = new RequestOptions().setBody(JSON.stringify(payload));
16+
return apiHelper.fetchPostJson<ExecuteResponse>('/api/v1/sqlquery/execute', opts);
17+
},
18+
};

frontend/src/entity/query/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// src/entity/query/index.ts
2-
export * from './api/sqlQueryApi';
3-
export * from './model/ExecuteResponse';
1+
// src/entity/query/index.ts
2+
export * from './api/sqlQueryApi';
3+
export * from './model/ExecuteResponse';
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export interface ExecuteResponse {
2-
columns: string[];
3-
rows: unknown[][];
4-
rowCount: number; // was row_count
5-
truncated: boolean;
6-
executionMs: number; // was execution_ms
7-
}
1+
export interface ExecuteResponse {
2+
columns: string[];
3+
rows: unknown[][];
4+
rowCount: number; // was row_count
5+
truncated: boolean;
6+
executionMs: number; // was execution_ms
7+
}

frontend/src/features/databases/ui/DatabaseComponent.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { type Database, databaseApi } from '../../../entity/databases';
66
import { BackupsComponent } from '../../backups';
77
import { HealthckeckAttemptsComponent } from '../../healthcheck';
88
import { MetricsComponent } from '../../monitoring/metrics';
9-
import { DatabaseConfigComponent } from './DatabaseConfigComponent';
109
//import { SqlQueryComponent } from '../../query/postgresql/SqlQueryComponent';
1110
import { SqlQueryComponent } from '../../sqlquery';
11+
import { DatabaseConfigComponent } from './DatabaseConfigComponent';
1212

1313
interface Props {
1414
contentHeight: number;
@@ -23,7 +23,9 @@ export const DatabaseComponent = ({
2323
onDatabaseChanged,
2424
onDatabaseDeleted,
2525
}: Props) => {
26-
const [currentTab, setCurrentTab] = useState<'config' | 'backups' | 'metrics' | 'sqlquery' >('backups');
26+
const [currentTab, setCurrentTab] = useState<'config' | 'backups' | 'metrics' | 'sqlquery'>(
27+
'backups',
28+
);
2729

2830
const [database, setDatabase] = useState<Database | undefined>();
2931
const [editDatabase, setEditDatabase] = useState<Database | undefined>();
@@ -66,13 +68,12 @@ export const DatabaseComponent = ({
6668
Metrics
6769
</div>
6870

69-
< div
70-
className={`cursor-pointer rounded-tl-md rounded-tr-md px-6 py-2 ${currentTab === 'sqlquery' ? 'bg-white' : 'bg-gray-200'}`}
71-
onClick={() => setCurrentTab('sqlquery')}
71+
<div
72+
className={`cursor-pointer rounded-tl-md rounded-tr-md px-6 py-2 ${currentTab === 'sqlquery' ? 'bg-white' : 'bg-gray-200'}`}
73+
onClick={() => setCurrentTab('sqlquery')}
7274
>
7375
SqlQuery
7476
</div>
75-
7677
</div>
7778

7879
{currentTab === 'config' && (
@@ -92,11 +93,11 @@ export const DatabaseComponent = ({
9293
</>
9394
)}
9495
{currentTab === 'metrics' && <MetricsComponent databaseId={database.id} />}
95-
{currentTab === 'sqlquery' && (
96-
<div className="mt-4">
97-
<SqlQueryComponent databaseId={database.id} />
98-
</div>
99-
)}
96+
{currentTab === 'sqlquery' && (
97+
<div className="mt-4">
98+
<SqlQueryComponent databaseId={database.id} />
99+
</div>
100+
)}
100101
</div>
101102
);
102-
};
103+
};
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// src/features/sqlquery/index.ts
2-
export { SqlQueryComponent } from './ui/SqlQueryComponent';
1+
// src/features/sqlquery/index.ts
2+
export { SqlQueryComponent } from './ui/SqlQueryComponent';

0 commit comments

Comments
 (0)