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