refactor: Flatten directory structure
Move project files from uzdb/ subdirectory to root directory for cleaner project structure.
Changes:
- Move frontend/ to root
- Move internal/ to root
- Move build/ to root
- Move all config files (go.mod, wails.json, etc.) to root
- Remove redundant uzdb/ subdirectory nesting
Project structure is now:
├── frontend/ # React application
├── internal/ # Go backend
├── build/ # Wails build assets
├── doc/ # Design documentation
├── main.go # Entry point
└── ...
🤖 Generated with Qoder
This commit is contained in:
232
frontend/src/mock/queryResults.ts
Normal file
232
frontend/src/mock/queryResults.ts
Normal file
@@ -0,0 +1,232 @@
|
||||
/**
|
||||
* Mock Query Results Data
|
||||
*
|
||||
* Sample data for development and testing purposes.
|
||||
*/
|
||||
|
||||
import { QueryResult, QueryTab } from '../components/MainArea/QueryEditor';
|
||||
import { TableColumn, Index, ForeignKey, TableInfo } from '../components/MainArea/TableStructure';
|
||||
import { Column, DataRow } from '../components/MainArea/DataGrid';
|
||||
|
||||
/**
|
||||
* Sample query results
|
||||
*/
|
||||
export const mockQueryResults: QueryResult = {
|
||||
columns: ['id', 'name', 'email', 'created_at', 'active', 'role'],
|
||||
rows: [
|
||||
[1, 'Alice Johnson', 'alice@example.com', '2024-01-15 10:30:00', true, 'admin'],
|
||||
[2, 'Bob Smith', 'bob@example.com', '2024-01-16 14:22:00', true, 'user'],
|
||||
[3, 'Carol Williams', 'carol@example.com', '2024-01-17 09:15:00', false, 'user'],
|
||||
[4, 'David Brown', 'david@example.com', '2024-01-18 16:45:00', true, 'moderator'],
|
||||
[5, 'Eve Davis', 'eve@example.com', '2024-01-19 11:00:00', true, 'user'],
|
||||
[6, 'Frank Miller', 'frank@example.com', '2024-01-20 08:30:00', true, 'user'],
|
||||
[7, 'Grace Wilson', 'grace@example.com', '2024-01-21 13:20:00', true, 'user'],
|
||||
[8, 'Henry Moore', 'henry@example.com', '2024-01-22 15:10:00', false, 'user'],
|
||||
[9, 'Ivy Taylor', 'ivy@example.com', '2024-01-23 10:45:00', true, 'admin'],
|
||||
[10, 'Jack Anderson', 'jack@example.com', '2024-01-24 12:00:00', true, 'user'],
|
||||
],
|
||||
rowCount: 127,
|
||||
executionTime: 0.045,
|
||||
message: '127 rows affected',
|
||||
};
|
||||
|
||||
/**
|
||||
* Sample error query result
|
||||
*/
|
||||
export const mockErrorResult: QueryResult = {
|
||||
columns: [],
|
||||
rows: [],
|
||||
error: "ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELEC * FROM users' at line 1",
|
||||
};
|
||||
|
||||
/**
|
||||
* Sample query tabs
|
||||
*/
|
||||
export const mockQueryTabs: QueryTab[] = [
|
||||
{
|
||||
id: 'tab-1',
|
||||
title: 'query_1.sql',
|
||||
content: `-- Get active users with their orders
|
||||
SELECT
|
||||
u.id,
|
||||
u.name,
|
||||
u.email,
|
||||
COUNT(o.id) as order_count
|
||||
FROM users u
|
||||
LEFT JOIN orders o ON u.id = o.user_id
|
||||
WHERE u.active = true
|
||||
AND u.created_at >= '2024-01-01'
|
||||
GROUP BY u.id, u.name, u.email
|
||||
HAVING COUNT(o.id) > 0
|
||||
ORDER BY order_count DESC
|
||||
LIMIT 100;`,
|
||||
isDirty: false,
|
||||
},
|
||||
{
|
||||
id: 'tab-2',
|
||||
title: 'unsaved_query.sql',
|
||||
content: `SELECT * FROM products WHERE price > 100;`,
|
||||
isDirty: true,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Sample table columns
|
||||
*/
|
||||
export const mockTableColumns: TableColumn[] = [
|
||||
{
|
||||
name: 'id',
|
||||
type: 'INT',
|
||||
nullable: false,
|
||||
isPrimaryKey: true,
|
||||
extra: 'auto_increment',
|
||||
},
|
||||
{
|
||||
name: 'name',
|
||||
type: 'VARCHAR(100)',
|
||||
nullable: false,
|
||||
},
|
||||
{
|
||||
name: 'email',
|
||||
type: 'VARCHAR(255)',
|
||||
nullable: false,
|
||||
isUnique: true,
|
||||
},
|
||||
{
|
||||
name: 'created_at',
|
||||
type: 'TIMESTAMP',
|
||||
nullable: true,
|
||||
defaultValue: 'NOW()',
|
||||
},
|
||||
{
|
||||
name: 'active',
|
||||
type: 'BOOLEAN',
|
||||
nullable: false,
|
||||
defaultValue: 'TRUE',
|
||||
},
|
||||
{
|
||||
name: 'role',
|
||||
type: 'ENUM(\'user\', \'admin\', \'moderator\')',
|
||||
nullable: false,
|
||||
defaultValue: "'user'",
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Sample indexes
|
||||
*/
|
||||
export const mockIndexes: Index[] = [
|
||||
{
|
||||
name: 'PRIMARY',
|
||||
type: 'BTREE',
|
||||
columns: ['id'],
|
||||
isUnique: true,
|
||||
method: 'BTREE',
|
||||
},
|
||||
{
|
||||
name: 'idx_email',
|
||||
type: 'BTREE',
|
||||
columns: ['email'],
|
||||
isUnique: true,
|
||||
method: 'BTREE',
|
||||
},
|
||||
{
|
||||
name: 'idx_created_at',
|
||||
type: 'BTREE',
|
||||
columns: ['created_at'],
|
||||
isUnique: false,
|
||||
method: 'BTREE',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Sample foreign keys
|
||||
*/
|
||||
export const mockForeignKeys: ForeignKey[] = [
|
||||
{
|
||||
name: 'fk_user_role',
|
||||
column: 'role_id',
|
||||
referencesTable: 'roles',
|
||||
referencesColumn: 'id',
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'SET NULL',
|
||||
},
|
||||
{
|
||||
name: 'fk_user_department',
|
||||
column: 'department_id',
|
||||
referencesTable: 'departments',
|
||||
referencesColumn: 'id',
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'RESTRICT',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Sample table info
|
||||
*/
|
||||
export const mockTableInfo: TableInfo = {
|
||||
engine: 'InnoDB',
|
||||
collation: 'utf8mb4_unicode_ci',
|
||||
rowCount: 1247,
|
||||
size: '256 KB',
|
||||
autoIncrement: 1248,
|
||||
comment: 'User accounts table',
|
||||
};
|
||||
|
||||
/**
|
||||
* Sample data grid columns
|
||||
*/
|
||||
export const mockDataGridColumns: Column[] = [
|
||||
{ id: 'id', name: 'ID', type: 'INT', width: 80, sortable: true },
|
||||
{ id: 'name', name: 'Name', type: 'VARCHAR', width: 200, sortable: true, editable: true },
|
||||
{ id: 'email', name: 'Email', type: 'VARCHAR', width: 250, sortable: true, editable: true },
|
||||
{ id: 'created_at', name: 'Created At', type: 'TIMESTAMP', width: 180, sortable: true },
|
||||
{ id: 'active', name: 'Active', type: 'BOOLEAN', width: 80, sortable: true, editable: true },
|
||||
{ id: 'role', name: 'Role', type: 'ENUM', width: 120, sortable: true, editable: true },
|
||||
];
|
||||
|
||||
/**
|
||||
* Sample data grid rows
|
||||
*/
|
||||
export const mockDataGridRows: DataRow[] = [
|
||||
{ id: 1, name: 'Alice Johnson', email: 'alice@example.com', created_at: '2024-01-15', active: true, role: 'admin' },
|
||||
{ id: 2, name: 'Bob Smith', email: 'bob@example.com', created_at: '2024-01-16', active: true, role: 'user' },
|
||||
{ id: 3, name: 'Carol Williams', email: 'carol@example.com', created_at: '2024-01-17', active: false, role: 'user' },
|
||||
{ id: 4, name: 'David Brown', email: 'david@example.com', created_at: '2024-01-18', active: true, role: 'moderator' },
|
||||
{ id: 5, name: 'Eve Davis', email: 'eve@example.com', created_at: '2024-01-19', active: true, role: 'user' },
|
||||
{ id: 6, name: 'Frank Miller', email: 'frank@example.com', created_at: '2024-01-20', active: true, role: 'user' },
|
||||
{ id: 7, name: 'Grace Wilson', email: 'grace@example.com', created_at: '2024-01-21', active: true, role: 'user' },
|
||||
{ id: 8, name: 'Henry Moore', email: 'henry@example.com', created_at: '2024-01-22', active: false, role: 'user' },
|
||||
{ id: 9, name: 'Ivy Taylor', email: 'ivy@example.com', created_at: '2024-01-23', active: true, role: 'admin' },
|
||||
{ id: 10, name: 'Jack Anderson', email: 'jack@example.com', created_at: '2024-01-24', active: true, role: 'user' },
|
||||
];
|
||||
|
||||
/**
|
||||
* Generate more rows for testing pagination
|
||||
*/
|
||||
export const generateMockRows = (count: number): DataRow[] => {
|
||||
const roles = ['user', 'admin', 'moderator'];
|
||||
const firstNames = ['Alice', 'Bob', 'Carol', 'David', 'Eve', 'Frank', 'Grace', 'Henry', 'Ivy', 'Jack'];
|
||||
const lastNames = ['Johnson', 'Smith', 'Williams', 'Brown', 'Davis', 'Miller', 'Wilson', 'Moore', 'Taylor', 'Anderson'];
|
||||
|
||||
return Array.from({ length: count }, (_, i) => ({
|
||||
id: i + 1,
|
||||
name: `${firstNames[i % firstNames.length]} ${lastNames[i % lastNames.length]}`,
|
||||
email: `user${i + 1}@example.com`,
|
||||
created_at: `2024-01-${((i % 31) + 1).toString().padStart(2, '0')}`,
|
||||
active: i % 5 !== 0,
|
||||
role: roles[i % roles.length],
|
||||
}));
|
||||
};
|
||||
|
||||
export default {
|
||||
mockQueryResults,
|
||||
mockErrorResult,
|
||||
mockQueryTabs,
|
||||
mockTableColumns,
|
||||
mockIndexes,
|
||||
mockForeignKeys,
|
||||
mockTableInfo,
|
||||
mockDataGridColumns,
|
||||
mockDataGridRows,
|
||||
};
|
||||
Reference in New Issue
Block a user