fix2
parent
0982b4133a
commit
36c04b18d2
|
|
@ -7,7 +7,7 @@ services:
|
|||
build: .
|
||||
ports:
|
||||
- "8001:8001" # Порт для GET-запросов (веб-интерфейс)
|
||||
- "8002:8002" # Порт для POST-запросов (API)
|
||||
- "8002:8002" # Порт для POST, PUT, DELETE-запросов (API)
|
||||
volumes:
|
||||
- ./db:/db
|
||||
restart: unless-stopped
|
||||
|
|
@ -115,7 +115,8 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
const API_URL = "/api";
|
||||
const API_URL_GET = "http://10.0.0.10:8001/api"; // Для GET-запросов
|
||||
const API_URL_POST = "http://10.0.0.10:8002/api"; // Для POST, PUT, DELETE-запросов
|
||||
let selectedFolderId = null;
|
||||
let allInstalls = [];
|
||||
let selectedInstallId = null;
|
||||
|
|
@ -142,7 +143,7 @@
|
|||
|
||||
$(document).ready(function () {
|
||||
// Получаем ID папки "Несортированные" перед инициализацией дерева
|
||||
$.getJSON(`${API_URL}/folders`, function (folders) {
|
||||
$.getJSON(`${API_URL_GET}/folders`, function (folders) {
|
||||
const unsortedFolder = folders.find(f => f.name === 'Несортированные');
|
||||
const unsortedFolderId = unsortedFolder ? unsortedFolder.id : null;
|
||||
|
||||
|
|
@ -157,7 +158,7 @@
|
|||
$('#folder-tree').jstree({
|
||||
'core': {
|
||||
'data': function (node, cb) {
|
||||
$.getJSON(`${API_URL}/folders`, function (data) {
|
||||
$.getJSON(`${API_URL_GET}/folders`, function (data) {
|
||||
const treeData = [
|
||||
{ id: "root", text: "Корень", parent: "#" }
|
||||
].concat(data.map(folder => ({
|
||||
|
|
@ -212,7 +213,7 @@
|
|||
});
|
||||
|
||||
function loadInstalls(folderId) {
|
||||
$.getJSON(`${API_URL}/installs`, function (data) {
|
||||
$.getJSON(`${API_URL_GET}/installs`, function (data) {
|
||||
allInstalls = data;
|
||||
let filtered = folderId ? data.filter(i => i.folder_id == folderId) : data.filter(i => i.folder_id === null);
|
||||
displayInstalls(filtered);
|
||||
|
|
@ -306,7 +307,7 @@
|
|||
const name = prompt("Введите имя папки:");
|
||||
if (name) {
|
||||
$.ajax({
|
||||
url: `${API_URL}/folders`,
|
||||
url: `${API_URL_POST}/folders`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ name, parent_id: selectedFolderId }),
|
||||
|
|
@ -322,7 +323,7 @@
|
|||
const newName = prompt("Введите новое имя папки:", currentName);
|
||||
if (newName) {
|
||||
$.ajax({
|
||||
url: `${API_URL}/folders/${folderId}`,
|
||||
url: `${API_URL_POST}/folders/${folderId}`,
|
||||
type: 'PUT',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ name: newName }),
|
||||
|
|
@ -337,10 +338,10 @@
|
|||
function deleteFolder(folderId) {
|
||||
if (confirm("Удалить папку? Все записи будут перемещены в корень.")) {
|
||||
$.ajax({
|
||||
url: `${API_URL}/folders/${folderId}`,
|
||||
url: `${API_URL_POST}/folders/${folderId}`,
|
||||
type: 'DELETE',
|
||||
success: function () {
|
||||
$.getJSON(`${API_URL}/installs`, function (data) {
|
||||
$.getJSON(`${API_URL_GET}/installs`, function (data) {
|
||||
const folderInstalls = data.filter(i => i.folder_id == folderId);
|
||||
folderInstalls.forEach(item => {
|
||||
moveInstallToFolder(item.id, null);
|
||||
|
|
@ -374,7 +375,7 @@
|
|||
}
|
||||
|
||||
$.ajax({
|
||||
url: `${API_URL}/install`,
|
||||
url: `${API_URL_POST}/install`,
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ rust_id: rustId, computer_name: computerName, install_time: installTime, folder_id: selectedFolderId, protocol: protocol, note: note }),
|
||||
|
|
@ -410,7 +411,7 @@
|
|||
data['folder_id'] = selectedFolderId; // Добавляем folder_id для обновления
|
||||
}
|
||||
$.ajax({
|
||||
url: `${API_URL}/install/${installId}`,
|
||||
url: `${API_URL_POST}/install/${installId}`,
|
||||
type: 'PUT',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(data),
|
||||
|
|
@ -431,7 +432,7 @@
|
|||
function deleteInstall(id) {
|
||||
if (confirm("Удалить запись?")) {
|
||||
$.ajax({
|
||||
url: `${API_URL}/install/${id}`,
|
||||
url: `${API_URL_POST}/install/${id}`,
|
||||
type: 'DELETE',
|
||||
success: function () {
|
||||
loadInstalls(selectedFolderId);
|
||||
|
|
@ -442,7 +443,7 @@
|
|||
|
||||
function moveInstallToFolder(installId, folderId) {
|
||||
$.ajax({
|
||||
url: `${API_URL}/install/${installId}`,
|
||||
url: `${API_URL_POST}/install/${installId}`,
|
||||
type: 'PUT',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ folder_id: folderId }),
|
||||
|
|
@ -464,7 +465,7 @@
|
|||
|
||||
function exportCSV() {
|
||||
const folderId = $('#folder-select').val() || '';
|
||||
window.location.href = `${API_URL}/export/csv?folder_id=${folderId}`;
|
||||
window.location.href = `${API_URL_GET}/export/csv?folder_id=${folderId}`;
|
||||
}
|
||||
|
||||
function importCSV(file) {
|
||||
|
|
@ -478,7 +479,7 @@
|
|||
}
|
||||
|
||||
$.ajax({
|
||||
url: `${API_URL}/import/csv`,
|
||||
url: `${API_URL_POST}/import/csv`,
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
|
|
@ -503,7 +504,7 @@
|
|||
function saveNote() {
|
||||
const note = $('#note-textarea').val() || '';
|
||||
$.ajax({
|
||||
url: `${API_URL}/install/${selectedInstallId}`,
|
||||
url: `${API_URL_POST}/install/${selectedInstallId}`,
|
||||
type: 'PUT',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ note: note }),
|
||||
|
|
@ -549,7 +550,7 @@
|
|||
}
|
||||
|
||||
function updateFolderSelect() {
|
||||
$.getJSON(`${API_URL}/folders`, function (folders) {
|
||||
$.getJSON(`${API_URL_GET}/folders`, function (folders) {
|
||||
const $folderSelect = $('#folder-select');
|
||||
$folderSelect.empty().append('<option value="">Все папки</option>');
|
||||
folders.forEach(folder => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue