cameras parameters
This commit is contained in:
parent
59e7511293
commit
7c41027cc9
72
server.js
72
server.js
@ -2733,6 +2733,78 @@ app.put('/ai-parameters', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/cameras-parameters', async (req, res) => {
|
||||
if (req.session.userId === undefined) {
|
||||
return res.redirect("/signin");
|
||||
}
|
||||
const userInfo = await getUserInfo(req.session.userId);
|
||||
if (!userInfo.EditTransport) {
|
||||
return res.redirect("/devices");
|
||||
}
|
||||
try {
|
||||
const { serial } = req.body;
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
|
||||
|
||||
const requestResponse = await axios.get(`http://${process.env.SERVER_IP}:8080/http/parameters/request?serial=${serial}`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: JSON.stringify({
|
||||
"FIELDS": [
|
||||
"AR"
|
||||
]
|
||||
}),
|
||||
});
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
|
||||
const getResponse = await axios.get(`http://${process.env.SERVER_IP}:8080/http/parameters/get?serial=${serial}`);
|
||||
|
||||
res.json(getResponse.data);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
});
|
||||
|
||||
app.put('/cameras-parameters', async (req, res) => {
|
||||
if (req.session.userId === undefined) {
|
||||
return res.redirect("/signin");
|
||||
}
|
||||
const userInfo = await getUserInfo(req.session.userId);
|
||||
if (!userInfo.EditTransport) {
|
||||
return res.redirect("/devices");
|
||||
}
|
||||
|
||||
const requestData = req.body;
|
||||
const { serial } = req.query;
|
||||
|
||||
const {
|
||||
VEC
|
||||
} = requestData;
|
||||
|
||||
const requestBody = {
|
||||
"AR": {
|
||||
"VEC": VEC
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
try {
|
||||
const response = await axios.get(`http://${process.env.SERVER_IP}:8080/http/parameters/set?serial=${serial}`, {
|
||||
data: JSON.stringify(requestBody),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
res.status(response.status).send(response.data);
|
||||
} catch (error) {
|
||||
res.status(500).send('Произошла ошибка при отправке GET запроса.');
|
||||
}
|
||||
});
|
||||
|
||||
app.put('/install-parameters', async (req, res) => {
|
||||
if (req.session.userId === undefined) {
|
||||
return res.redirect("/signin");
|
||||
|
@ -6,7 +6,8 @@ const content2 = document.getElementById("ethernet");
|
||||
const content3 = document.getElementById("wifi");
|
||||
const content4 = document.getElementById("communication");
|
||||
const content5 = document.getElementById("install");
|
||||
const content6 = document.getElementById("ai");;
|
||||
const content6 = document.getElementById("ai");
|
||||
const content7 = document.getElementById("cameras");
|
||||
const radioButtons = document.querySelectorAll(
|
||||
'input[type="radio"][name="newStage"]'
|
||||
);
|
||||
@ -61,6 +62,7 @@ function fadeOut(element, callback) {
|
||||
}
|
||||
|
||||
var givenData;
|
||||
var camerasData;
|
||||
|
||||
function encodeCHValue(channels) {
|
||||
let CH = 0;
|
||||
@ -293,6 +295,8 @@ for (let radioButton of radioButtons) {
|
||||
|
||||
document.getElementById('parameters-bg').style.display = 'none';
|
||||
|
||||
document.getElementById("system-ai").value = 0;
|
||||
|
||||
camerasData = data;
|
||||
|
||||
console.log(data.DATA);
|
||||
@ -355,6 +359,51 @@ for (let radioButton of radioButtons) {
|
||||
|
||||
$("select").trigger("input");
|
||||
|
||||
})
|
||||
.catch(error => console.error('Ошибка:', error));
|
||||
} else if (radioButton.value === "cameras") {
|
||||
switchContent(content7);
|
||||
document.getElementById('parameters-bg').style.display = 'flex';
|
||||
|
||||
fetch('/cameras-parameters', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(requestBody)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
|
||||
document.getElementById('parameters-bg').style.display = 'none';
|
||||
|
||||
document.getElementById("cameras-id").value = 0;
|
||||
|
||||
console.log(data.DATA);
|
||||
|
||||
camerasData = data.DATA.AR.VEC;
|
||||
|
||||
function updateFields(selectedIndex) {
|
||||
const selectedData = camerasData[selectedIndex];
|
||||
|
||||
document.getElementById("cameras-quality").value = selectedData.QLT;
|
||||
document.getElementById("cameras-bitrate").value = selectedData.BR;
|
||||
document.getElementById("cameras-video").value = selectedData.RST;
|
||||
document.getElementById("cameras-alert").value = selectedData.ALT;
|
||||
document.getElementById("cameras-ven").value = selectedData.VEN;
|
||||
document.getElementById("cameras-aen").value = selectedData.AEN;
|
||||
document.getElementById("cameras-framerate").value = selectedData.FR;
|
||||
}
|
||||
|
||||
document.getElementById("cameras-id").addEventListener("change", function () {
|
||||
const selectedIndex = parseInt(this.value);
|
||||
updateFields(selectedIndex);
|
||||
});
|
||||
|
||||
updateFields(0);
|
||||
|
||||
$("select").trigger("input");
|
||||
|
||||
})
|
||||
.catch(error => console.error('Ошибка:', error));
|
||||
}
|
||||
@ -390,3 +439,19 @@ function updateDataInArray() {
|
||||
|
||||
givenData[selectedIndex] = selectedDataRow;
|
||||
}
|
||||
|
||||
function updateCamerasInArray() {
|
||||
const selectedIndex = parseInt(document.getElementById("cameras-id").value);
|
||||
const selectedDataRow = camerasData[selectedIndex];
|
||||
|
||||
|
||||
selectedDataRow.QLT = parseInt(document.getElementById("cameras-quality").value);
|
||||
selectedDataRow.BR = parseInt(document.getElementById("cameras-bitrate").value);
|
||||
selectedDataRow.RST = parseInt(document.getElementById("cameras-video").value);
|
||||
selectedDataRow.ALT = parseInt(document.getElementById("cameras-alert").value);
|
||||
selectedDataRow.VEN = parseInt(document.getElementById("cameras-ven").value);
|
||||
selectedDataRow.AEN = parseInt(document.getElementById("cameras-aen").value);
|
||||
selectedDataRow.FR = parseInt(document.getElementById("cameras-framerate").value);
|
||||
|
||||
camerasData[selectedIndex] = selectedDataRow;
|
||||
}
|
||||
|
@ -142,6 +142,8 @@
|
||||
<input autocomplete="off" name="newStage" type="radio" value="install" id="stage-install"><label for="stage-install">Установка сервера</label>
|
||||
<div class="vertical-line" style="background: transparent;"></div>
|
||||
<input autocomplete="off" name="newStage" type="radio" value="ai" id="stage-ai"><label for="stage-ai">Тревоги</label>
|
||||
<div class="vertical-line" style="background: transparent;"></div>
|
||||
<input autocomplete="off" name="newStage" type="radio" value="cameras" id="stage-cameras"><label for="stage-cameras">Камеры</label>
|
||||
</section>
|
||||
</section>
|
||||
<section id="add-new-container" class="add-new">
|
||||
@ -225,7 +227,7 @@
|
||||
<option value="0">GPS</option>
|
||||
<option value="1">BEIDO</option>
|
||||
<option value="2">GALILEO</option>
|
||||
<option value="3">GLENAS</option>
|
||||
<option value="3">ГЛОНАСС</option>
|
||||
<option value="4">Смешанное</option>
|
||||
</select>
|
||||
</div>
|
||||
@ -584,6 +586,103 @@
|
||||
|
||||
<button onclick="sendPutRequest('ai');" type="button">Сохранить</button>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="cameras" class="new-parameters">
|
||||
|
||||
<h1>Настройки камер</h1>
|
||||
<h2>Выберите нужную камеру и выставьте параметры</h2>
|
||||
|
||||
<div class="horizontal-line"></div>
|
||||
<label autocomplete="off" style="width: 100%;" for="cameras-id">Номер камеры</label>
|
||||
<select style="width: 100%;" name="cameras-id" id="cameras-id">
|
||||
<option value="0">Камера 1</option>
|
||||
<option value="1">Камера 2</option>
|
||||
<option value="2">Камера 3</option>
|
||||
<option value="3">Камера 4</option>
|
||||
<option value="4">Камера 5</option>
|
||||
<option value="5">Камера 6</option>
|
||||
<option value="6">Камера 7</option>
|
||||
<option value="7">Камера 8</option>
|
||||
<option value="8">Камера 9</option>
|
||||
<option value="9">Камера 10</option>
|
||||
<option value="10">Камера 11</option>
|
||||
<option value="11">Камера 12</option>
|
||||
<option value="12">Камера 13</option>
|
||||
<option value="13">Камера 14</option>
|
||||
<option value="14">Камера 15</option>
|
||||
<option value="15">Камера 16</option>
|
||||
</select>
|
||||
|
||||
<div class="horizontal-line"></div>
|
||||
|
||||
|
||||
<div class="parameters-inputs">
|
||||
|
||||
|
||||
<div class="parameters-input">
|
||||
<label for="cameras-quality">Качество видео</label>
|
||||
<select name="QLT" id="cameras-quality">
|
||||
<option value="1">Максимальное</option>
|
||||
<option value="2">Скорее максимальное</option>
|
||||
<option value="3">Скорее минимальное</option>
|
||||
<option value="4">Минимальное</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="parameters-input">
|
||||
<label for="cameras-bitrate">Максимальный битрейт</label>
|
||||
<input name="BR" type="text" id="cameras-bitrate" placeholder="Максимальный битрейт видео">
|
||||
</div>
|
||||
<div class="parameters-input">
|
||||
<label for="cameras-video">Разрешение видео</label>
|
||||
<select name="RST" id="cameras-video">
|
||||
<option value="0">352 x 288</option>
|
||||
<option value="1">352 x 576</option>
|
||||
<option value="2">704 x 576</option>
|
||||
<option value="3">176 x 144</option>
|
||||
<option value="4">320 × 240</option>
|
||||
<option value="5">640 × 480</option>
|
||||
<option value="6">1280 x 720</option>
|
||||
<option value="7">1920 × 1080</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="parameters-input">
|
||||
<label for="cameras-alert">Качество видео при предупреждении</label>
|
||||
<select name="ALT" id="cameras-alert">
|
||||
<option value="1">Максимальное</option>
|
||||
<option value="2">Скорее максимальное</option>
|
||||
<option value="3">Скорее минимальное</option>
|
||||
<option value="4">Минимальное</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="parameters-input">
|
||||
<label for="cameras-ven">Нужно ли видео</label>
|
||||
<select name="VEN" id="cameras-ven">
|
||||
<option value="0">Нет</option>
|
||||
<option value="1">Да</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="parameters-input">
|
||||
<label for="cameras-aen">Нужно ли аудио</label>
|
||||
<select name="AEN" id="cameras-aen">
|
||||
<option value="0">Нет</option>
|
||||
<option value="1">Да</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="parameters-input">
|
||||
<label for="cameras-framerate">Фреймрейт</label>
|
||||
<input name="FR" type="text" id="cameras-framerate" placeholder="Фреймрейт видео">
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="horizontal-line"></div>
|
||||
|
||||
|
||||
<button onclick="sendPutRequest('cameras');" type="button">Сохранить</button>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
@ -1176,6 +1275,55 @@ const response = await fetch(`/ai-parameters?serial=${serial}`, {
|
||||
body: JSON.stringify(requestData),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
var formContainer = $("#form-bg");
|
||||
var form = $("#form");
|
||||
formContainer.removeClass("active");
|
||||
form.removeClass("form-animation");
|
||||
$("body").css("overflow", "auto");
|
||||
showMessage("Данные успешно обновлены", true);
|
||||
console.log('PUT запрос выполнен успешно');
|
||||
} else {
|
||||
showMessage("Не удалось обновить данные", false);
|
||||
console.error('Ошибка при выполнении PUT запроса');
|
||||
}
|
||||
} catch (error) {
|
||||
showMessage("Не удалось обновить данные", false);
|
||||
console.error('Произошла ошибка при отправке PUT запроса:', error);
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 'cameras') {
|
||||
|
||||
const deleteConfirmation = document.getElementById("addInformation");
|
||||
const loader = document.getElementById("loader");
|
||||
const status = document.getElementById("status");
|
||||
const closeButton = document.getElementById("closeButton");
|
||||
const mark = document.getElementById("success-mark");
|
||||
|
||||
loader.style.display = "block";
|
||||
closeButton.style.display = "none";
|
||||
deleteConfirmation.style.display = "flex";
|
||||
mark.style.display = "none";
|
||||
|
||||
updateCamerasInArray();
|
||||
|
||||
const VEC = camerasData;
|
||||
console.log(VEC);
|
||||
|
||||
const requestData = {
|
||||
VEC
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch(`/cameras-parameters?serial=${serial}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
var formContainer = $("#form-bg");
|
||||
var form = $("#form");
|
||||
|
Loading…
Reference in New Issue
Block a user