This commit is contained in:
2025-03-05 10:45:32 +03:00
parent 30ae8b76b6
commit 2442599757
2 changed files with 92 additions and 2 deletions
+37
View File
@@ -23,6 +23,10 @@
.sort-arrow { font-size: 12px; margin-left: 5px; }
.protocol-icon { margin-right: 5px; height: 16px; width: 16px; vertical-align: middle; }
.connection-link { color: blue; text-decoration: underline; cursor: pointer; }
#import-form { margin-top: 10px; }
#import-file { display: none; }
#import-label { cursor: pointer; background: #007bff; color: white; padding: 5px 10px; border-radius: 5px; }
#import-label:hover { background: #0056b3; }
</style>
</head>
<body>
@@ -41,6 +45,13 @@
<input type="radio" id="search-all" name="search-scope" value="all">
<label for="search-all">Все папки</label>
</div>
<div style="margin-top: 10px;">
<button onclick="exportCSV()">Экспорт CSV</button>
<form id="import-form" enctype="multipart/form-data">
<input type="file" id="import-file" accept=".csv" onchange="importCSV(this.files[0])">
<label for="import-file" id="import-label">Импорт CSV</label>
</form>
</div>
</div>
<div class="form-container">
<h2>Добавить запись</h2>
@@ -344,6 +355,32 @@
window.location.href = link;
}
}
function exportCSV() {
window.location.href = `${API_URL}/export/csv`;
}
function importCSV(file) {
if (!file) return;
const formData = new FormData();
formData.append('file', file);
$.ajax({
url: `${API_URL}/import/csv`,
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function (response) {
alert(response.message);
loadInstalls(selectedFolderId);
},
error: function (xhr, status, error) {
alert(`Ошибка импорта: ${xhr.responseJSON.detail || error}`);
}
});
}
</script>
</body>
</html>