live and export fix
This commit is contained in:
parent
fb53bddd37
commit
e602828d5d
24
server.js
24
server.js
@ -138,17 +138,17 @@ app.post("/videos/restart", async (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// const DB_User = process.env.DB_USER;
|
const DB_User = process.env.DB_USER;
|
||||||
// const DB_Password = process.env.DB_PASSWORD;
|
const DB_Password = process.env.DB_PASSWORD;
|
||||||
// const DB_Host = process.env.DB_HOST;
|
const DB_Host = process.env.DB_HOST;
|
||||||
// const DB_Port = process.env.DB_PORT;
|
const DB_Port = process.env.DB_PORT;
|
||||||
// const DB_Name = process.env.DB_NAME;
|
const DB_Name = process.env.DB_NAME;
|
||||||
|
|
||||||
const DB_User = "postgres";
|
// const DB_User = "postgres";
|
||||||
const DB_Password = process.env.POSTGRES_PASSWORD;
|
// const DB_Password = process.env.POSTGRES_PASSWORD;
|
||||||
const DB_Host = "postgres";
|
// const DB_Host = "postgres";
|
||||||
const DB_Port = "5432";
|
// const DB_Port = "5432";
|
||||||
const DB_Name = "postgres";
|
// const DB_Name = "postgres";
|
||||||
|
|
||||||
async function index(req, res) {
|
async function index(req, res) {
|
||||||
if (req.session.userId === undefined) {
|
if (req.session.userId === undefined) {
|
||||||
@ -4993,7 +4993,7 @@ async function videoExport(req, res) {
|
|||||||
|
|
||||||
// Выполняем запрос, чтобы получить все данные из таблицы registrars
|
// Выполняем запрос, чтобы получить все данные из таблицы registrars
|
||||||
const queryRegistrars = `
|
const queryRegistrars = `
|
||||||
SELECT id, serial, channels, lastkeepalive, "group", name, plate, sim, ip, port, number
|
SELECT id, serial, channels, lastkeepalive, "group", name, plate, sim, ip, port, number, our_registrator
|
||||||
FROM registrars ${!templateData.isAdmin ? "WHERE serial = ANY($1)" : ""}
|
FROM registrars ${!templateData.isAdmin ? "WHERE serial = ANY($1)" : ""}
|
||||||
ORDER BY id
|
ORDER BY id
|
||||||
`;
|
`;
|
||||||
@ -5022,6 +5022,7 @@ async function videoExport(req, res) {
|
|||||||
ip: registrar.ip,
|
ip: registrar.ip,
|
||||||
port: registrar.port,
|
port: registrar.port,
|
||||||
number: registrar.number,
|
number: registrar.number,
|
||||||
|
ourreg: registrar.our_registrator,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -5037,6 +5038,7 @@ async function videoExport(req, res) {
|
|||||||
sim: registrar.sim,
|
sim: registrar.sim,
|
||||||
ip: registrar.ip,
|
ip: registrar.ip,
|
||||||
port: registrar.port,
|
port: registrar.port,
|
||||||
|
ourreg: registrar.our_registrator,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
templateData.Groups = Object.keys(groupedRegistrars).map((groupName) => ({
|
templateData.Groups = Object.keys(groupedRegistrars).map((groupName) => ({
|
||||||
|
@ -407,33 +407,33 @@
|
|||||||
|
|
||||||
flvPlayers.push(flvPlayer);
|
flvPlayers.push(flvPlayer);
|
||||||
|
|
||||||
let hasStarted = false;
|
// let hasStarted = false;
|
||||||
|
|
||||||
const checkStarted = () => {
|
// const checkStarted = () => {
|
||||||
if (!hasStarted && videoElement.readyState >= 2) {
|
// if (!hasStarted && videoElement.readyState >= 2) {
|
||||||
hasStarted = true;
|
// hasStarted = true;
|
||||||
console.log(`Трансляция началась для камеры ${i}`);
|
// console.log(`Трансляция началась для камеры ${i}`);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
const checkInterval = setInterval(checkStarted, 1000);
|
// const checkInterval = setInterval(checkStarted, 10000);
|
||||||
|
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
clearInterval(checkInterval);
|
// clearInterval(checkInterval);
|
||||||
if (!hasStarted) {
|
// if (!hasStarted) {
|
||||||
console.log(`Трансляция для камеры ${i} не началась, запрашиваем повторно...`);
|
// console.log(`Трансляция для камеры ${i} не началась, запрашиваем повторно...`);
|
||||||
flvPlayer.unload();
|
// flvPlayer.unload();
|
||||||
flvPlayer.load();
|
// flvPlayer.load();
|
||||||
flvPlayer.play();
|
// flvPlayer.play();
|
||||||
// if (i > 0) {
|
// // if (i > 0) {
|
||||||
// i--;
|
// // i--;
|
||||||
// }
|
// // }
|
||||||
}
|
// }
|
||||||
}, 3000);
|
// }, 10000);
|
||||||
|
|
||||||
videoElementIndex++;
|
videoElementIndex++;
|
||||||
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +127,7 @@
|
|||||||
<img>
|
<img>
|
||||||
<input type="number" id="channels-{{this.serial}}" value="{{this.channels}}" hidden>
|
<input type="number" id="channels-{{this.serial}}" value="{{this.channels}}" hidden>
|
||||||
<input type="radio" name="camera-serial" id="radio-{{this.serial}}" class="radio-input" value="{{this.serial}}" hidden>
|
<input type="radio" name="camera-serial" id="radio-{{this.serial}}" class="radio-input" value="{{this.serial}}" hidden>
|
||||||
|
<input type="text" id="ourreg-{{this.serial}}" value="{{this.ourreg}}" hidden>
|
||||||
<label for="radio-{{this.serial}}" class="radio-label active-{{this.status}}">
|
<label for="radio-{{this.serial}}" class="radio-label active-{{this.status}}">
|
||||||
{{#if this.number}}
|
{{#if this.number}}
|
||||||
{{this.number}}
|
{{this.number}}
|
||||||
@ -873,38 +874,43 @@ endVideoTimeInput.addEventListener("blur", sendPostRequest);
|
|||||||
alert('Пожалуйста, выберите камеру из списка.');
|
alert('Пожалуйста, выберите камеру из списка.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!HasData) {
|
|
||||||
alert('Пожалуйста, выберите другой временной период.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (videoTimeInput.value > endVideoTimeInput.value) {
|
if (videoTimeInput.value > endVideoTimeInput.value) {
|
||||||
alert('Конечное время не может быть больше начального.');
|
alert('Конечное время не может быть больше начального.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
document.getElementById("exportLoading").style.display = 'flex';
|
|
||||||
|
|
||||||
const startTimeInput = document.getElementById('video-time');
|
|
||||||
const endTimeInput = document.getElementById('video-end-time');
|
|
||||||
const selectedDateInput = document.getElementById('selectedDate');
|
|
||||||
const startTime = formatTime(startTimeInput.value);
|
|
||||||
const endTime = formatTime(endTimeInput.value);
|
|
||||||
const selectedDate = formatDate(selectedDateInput.value);
|
|
||||||
|
|
||||||
const reqDate = document.getElementById("selectedDate").value;
|
|
||||||
const reqTime = document.getElementById("video-time").value;
|
|
||||||
const reqSerial = document.querySelector('input[name="camera-serial"]:checked').value;
|
|
||||||
|
|
||||||
|
|
||||||
const finalResponse = await fetch(`/getData?serial=${reqSerial}&selectedDate=${formatDate(reqDate)}&selectedTime=${formatTime(reqTime)}&selectedChannel=${channel}`);
|
|
||||||
|
|
||||||
const resData = await finalResponse.json();
|
|
||||||
|
|
||||||
|
|
||||||
const serial = selectedDevice.value;
|
const serial = selectedDevice.value;
|
||||||
|
|
||||||
const url = `http://localhost:8081/export?url=https%3A%2F%2F{{VIRTUAL_HOST}}%2Fhttp%2Fdownload.flv%3Fserial%3D${serial}%26channel%3D${channel}%26queryTime%3D${selectedDate}%26startTime%3D${startTime}%26endTime%3D${endTime}%26recordID%3D${resData.dataId}`;
|
if ($(`#ourreg-${serial}`).val() == "true") {
|
||||||
document.getElementById("exportLoading").style.display = 'none';
|
|
||||||
window.open(url, '_blank');
|
} else {
|
||||||
|
if (!HasData) {
|
||||||
|
alert('Пожалуйста, выберите другой временной период.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.getElementById("exportLoading").style.display = 'flex';
|
||||||
|
|
||||||
|
const startTimeInput = document.getElementById('video-time');
|
||||||
|
const endTimeInput = document.getElementById('video-end-time');
|
||||||
|
const selectedDateInput = document.getElementById('selectedDate');
|
||||||
|
const startTime = formatTime(startTimeInput.value);
|
||||||
|
const endTime = formatTime(endTimeInput.value);
|
||||||
|
const selectedDate = formatDate(selectedDateInput.value);
|
||||||
|
|
||||||
|
const reqDate = document.getElementById("selectedDate").value;
|
||||||
|
const reqTime = document.getElementById("video-time").value;
|
||||||
|
const reqSerial = document.querySelector('input[name="camera-serial"]:checked').value;
|
||||||
|
|
||||||
|
|
||||||
|
const finalResponse = await fetch(`/getData?serial=${reqSerial}&selectedDate=${formatDate(reqDate)}&selectedTime=${formatTime(reqTime)}&selectedChannel=${channel}`);
|
||||||
|
|
||||||
|
const resData = await finalResponse.json();
|
||||||
|
|
||||||
|
|
||||||
|
const url = `http://localhost:8081/export?url=https%3A%2F%2F{{VIRTUAL_HOST}}%2Fhttp%2Fdownload.flv%3Fserial%3D${serial}%26channel%3D${channel}%26queryTime%3D${selectedDate}%26startTime%3D${startTime}%26endTime%3D${endTime}%26recordID%3D${resData.dataId}`;
|
||||||
|
document.getElementById("exportLoading").style.display = 'none';
|
||||||
|
window.open(url, '_blank');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user