This commit is contained in:
2026-03-18 17:48:16 +07:00
parent a9020b0388
commit ad117fe837
2 changed files with 59 additions and 1 deletions

View File

@@ -362,6 +362,58 @@ SELECT * FROM users LIMIT 10;"></textarea>
</div>
</div>
<!-- Column Modal -->
<div id="columnModal" class="hidden fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-2xl shadow-2xl w-full max-w-md fade-in">
<div class="p-6 border-b border-slate-200 flex items-center justify-between">
<h3 id="columnModalTitle" class="text-xl font-bold text-slate-800">Добавить колонку</h3>
<button onclick="app.closeModal('columnModal')" class="p-2 hover:bg-slate-100 rounded-lg transition-colors">
<i data-lucide="x" class="w-5 h-5 text-slate-500"></i>
</button>
</div>
<div class="p-6 space-y-4">
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Название колонки</label>
<input type="text" id="columnName" class="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 outline-none">
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Тип</label>
<select id="columnType" class="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 outline-none">
<option value="VARCHAR(255)">VARCHAR(255)</option>
<option value="TEXT">TEXT</option>
<option value="INTEGER">INTEGER</option>
<option value="BIGINT">BIGINT</option>
<option value="DECIMAL">DECIMAL</option>
<option value="BOOLEAN">BOOLEAN</option>
<option value="DATE">DATE</option>
<option value="TIMESTAMP">TIMESTAMP</option>
<option value="UUID">UUID</option>
<option value="JSON">JSON</option>
<option value="JSONB">JSONB</option>
</select>
</div>
<div class="flex items-center gap-4">
<label class="flex items-center gap-2">
<input type="checkbox" id="columnNullable" class="w-4 h-4 text-blue-600 rounded focus:ring-blue-500">
<span class="text-sm text-slate-700">NULL</span>
</label>
<label class="flex items-center gap-2">
<input type="checkbox" id="columnPrimary" class="w-4 h-4 text-blue-600 rounded focus:ring-blue-500">
<span class="text-sm text-slate-700">Первичный ключ</span>
</label>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Значение по умолчанию</label>
<input type="text" id="columnDefault" class="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 outline-none">
</div>
</div>
<div class="p-6 border-t border-slate-200 bg-slate-50 flex justify-end gap-3">
<button onclick="app.closeModal('columnModal')" class="px-4 py-2 text-slate-600 hover:bg-slate-200 rounded-lg">Отмена</button>
<button onclick="app.saveColumn()" class="px-6 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg">Сохранить</button>
</div>
</div>
</div>
<!-- Create Index Modal -->
<div id="createIndexModal" class="hidden fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white rounded-2xl shadow-2xl w-full max-w-md fade-in">
@@ -668,6 +720,7 @@ SELECT * FROM users LIMIT 10;"></textarea>
if (data.success) {
this.showToast('Запись удалена', 'success');
this.loadTableData();
this.loadTables();
} else {
this.showToast('Ошибка удаления', 'error');
}
@@ -807,6 +860,10 @@ SELECT * FROM users LIMIT 10;"></textarea>
this.showToast(this.editingRecord ? 'Запись обновлена' : 'Запись добавлена', 'success');
this.closeModal('recordModal');
this.loadTableData();
// Refresh table list counts when rows change (new insert/delete)
if (!this.editingRecord) {
this.loadTables();
}
this.editingRecord = null;
} else {
this.showToast(result.error || 'Ошибка сохранения', 'error');

View File

@@ -204,7 +204,8 @@ app.get('/api/tables/:tableName/data', requireAuth, async (req, res) => {
if (value && value.trim()) {
params.push(`%${value}%`);
paramIndex++;
return `"${column}" ILIKE $${paramIndex - 1}`;
// Use CAST to TEXT to support UUID and other non-text column types
return `CAST("${column}" AS TEXT) ILIKE $${paramIndex - 1}`;
}
return null;
}).filter(c => c);