devices, drivers, alerts and more

This commit is contained in:
Ivan
2023-07-24 07:53:11 +03:00
parent c94017820a
commit 4f34433d6b
16 changed files with 1578 additions and 1024 deletions

View File

@ -0,0 +1,114 @@
$("#continue-main").click(function () {
document.getElementById("stage-details").checked = true;
});
$("#continue-main-edit").click(function () {
document.getElementById("stage-details-edit").checked = true;
});
const container = document.getElementById("new-parameters");
const content1 = document.getElementById("main");
const content2 = document.getElementById("details");
const btn1 = document.getElementById("continue-main");
const content3 = document.getElementById("main-edit");
const content4 = document.getElementById("details-edit");
const btn2 = document.getElementById("continue-main-edit");
const radioButtons = document.querySelectorAll(
'input[type="radio"][name="newStage"]'
);
const radioButtonsEdit = document.querySelectorAll(
'input[type="radio"][name="newStageEdit"]'
);
const duration = 100;
let activeContent = content1;
function switchContent(newContent) {
fadeOut(activeContent, () => {
fadeIn(newContent);
activeContent = newContent;
});
}
function fadeIn(element) {
element.style.opacity = 0;
element.style.display = "block";
let start = performance.now();
function animate(time) {
let timeFraction = (time - start) / duration;
if (timeFraction > 1) {
element.style.opacity = 1;
} else {
element.style.opacity = timeFraction;
requestAnimationFrame(animate);
}
}
requestAnimationFrame(animate);
}
function fadeOut(element, callback) {
element.style.opacity = 1;
let start = performance.now();
function animate(time) {
let timeFraction = (time - start) / duration;
if (timeFraction > 1) {
element.style.opacity = 0;
element.style.display = "none";
if (callback) {
callback();
}
} else {
element.style.opacity = 1 - timeFraction;
requestAnimationFrame(animate);
}
}
requestAnimationFrame(animate);
}
btn1.addEventListener("click", () => {
if (activeContent === content1) {
switchContent(content2);
} else {
switchContent(content1);
}
});
btn2.addEventListener("click", () => {
if (activeContent === content3) {
switchContent(content4);
} else {
switchContent(content3);
}
});
for (let radioButton of radioButtons) {
radioButton.addEventListener("change", () => {
if (radioButton.value === "main") {
switchContent(content1);
} else if (radioButton.value === "details") {
switchContent(content2);
}
});
}
for (let radioButton of radioButtonsEdit) {
radioButton.addEventListener("change", () => {
if (radioButton.value === "main") {
switchContent(content3);
} else if (radioButton.value === "details") {
switchContent(content4);
}
});
}
function truncateText(select) {
var maxLength = 30;
var option = select.options[select.selectedIndex];
if (option.text.length > maxLength) {
option.text = option.text.substring(0, maxLength) + "...";
}
}

View File

@ -1,115 +1,115 @@
const devices = [
{
id: "2",
group: "2-device-2",
driverID: "233",
name: "Иван",
surname: "Спахов",
numberTS: "008803559E",
phone: "+7 999 123 45 67",
mail: "spahov@mail.ru",
driverCard: "RUD0000000000111",
},
{
id: "6",
group: "2-device-1",
driverID: "782",
name: "Александр",
surname: "Богаченко",
numberTS: "0088036B78",
phone: "+7 989 443 23 46",
mail: "bogachenko@mail.ru",
driverCard: "RUD0000000000111",
},
{
id: "7",
group: "2-device-4",
driverID: "2943",
name: "Михаил",
surname: "Гукасян",
numberTS: "009800852A",
phone: "+7 909 133 55 67",
mail: "agucasyan@mail.ru",
driverCard: "RUD0000000000111",
},
{
id: "8",
group: "2-device-4",
driverID: "87",
name: "Марат",
surname: "Шмидт",
numberTS: "009800858D",
phone: "+7 915 555 45 89",
mail: "shmidt@mail.ru",
driverCard: "RUD0000000000111",
},
{
id: "9",
group: "1-device-1",
driverID: "823",
name: "Никита",
surname: "Ильяшенко",
numberTS: "00980084FD",
phone: "+7 909 123 45 67",
mail: "iluashenko@mail.ru",
driverCard: "RUD0000000000111",
},
{
id: "10",
group: "2-device-4",
driverID: "15",
name: "Валерий",
surname: "Сараев",
numberTS: "0088036B7F",
phone: "+7 909 123 45 67",
mail: "saraev@mail.ru",
driverCard: "RUD0000000000111",
},
{
id: "11",
group: "2-device-3",
driverID: "423",
name: "Александр",
surname: "Курочкин",
numberTS: "00880302CD",
phone: "+7 999 123 45 67",
mail: "curochkin@mail.ru",
driverCard: "RUD0000000000111",
},
{
id: "12",
group: "1-device-2",
driverID: "6456",
name: "Екатерина",
surname: "Миненко",
numberTS: "008802A035",
phone: "+7 999 123 45 67",
mail: "minenko@mail.ru",
driverCard: "RUD0000000000111",
},
{
id: "13",
group: "3-device-1",
driverID: "887",
name: "Виталий",
surname: "Гаспарян",
numberTS: "008802A96A",
phone: "+7 999 123 45 67",
mail: "gosparyan@mail.ru",
driverCard: "RUD0000000000111",
},
{
id: "15",
group: "1-device-1",
driverID: "742",
name: "Светлана",
surname: "Амусова",
numberTS: "00880302C7",
phone: "+7 999 123 45 67",
mail: "amusova@mail.ru",
driverCard: "RUD0000000000111",
},
];
// const devices = [
// {
// id: "2",
// group: "2-device-2",
// driverID: "233",
// name: "Иван",
// surname: "Спахов",
// numberTS: "008803559E",
// phone: "+7 999 123 45 67",
// mail: "spahov@mail.ru",
// driverCard: "RUD0000000000111",
// },
// {
// id: "6",
// group: "2-device-1",
// driverID: "782",
// name: "Александр",
// surname: "Богаченко",
// numberTS: "0088036B78",
// phone: "+7 989 443 23 46",
// mail: "bogachenko@mail.ru",
// driverCard: "RUD0000000000111",
// },
// {
// id: "7",
// group: "2-device-4",
// driverID: "2943",
// name: "Михаил",
// surname: "Гукасян",
// numberTS: "009800852A",
// phone: "+7 909 133 55 67",
// mail: "agucasyan@mail.ru",
// driverCard: "RUD0000000000111",
// },
// {
// id: "8",
// group: "2-device-4",
// driverID: "87",
// name: "Марат",
// surname: "Шмидт",
// numberTS: "009800858D",
// phone: "+7 915 555 45 89",
// mail: "shmidt@mail.ru",
// driverCard: "RUD0000000000111",
// },
// {
// id: "9",
// group: "1-device-1",
// driverID: "823",
// name: "Никита",
// surname: "Ильяшенко",
// numberTS: "00980084FD",
// phone: "+7 909 123 45 67",
// mail: "iluashenko@mail.ru",
// driverCard: "RUD0000000000111",
// },
// {
// id: "10",
// group: "2-device-4",
// driverID: "15",
// name: "Валерий",
// surname: "Сараев",
// numberTS: "0088036B7F",
// phone: "+7 909 123 45 67",
// mail: "saraev@mail.ru",
// driverCard: "RUD0000000000111",
// },
// {
// id: "11",
// group: "2-device-3",
// driverID: "423",
// name: "Александр",
// surname: "Курочкин",
// numberTS: "00880302CD",
// phone: "+7 999 123 45 67",
// mail: "curochkin@mail.ru",
// driverCard: "RUD0000000000111",
// },
// {
// id: "12",
// group: "1-device-2",
// driverID: "6456",
// name: "Екатерина",
// surname: "Миненко",
// numberTS: "008802A035",
// phone: "+7 999 123 45 67",
// mail: "minenko@mail.ru",
// driverCard: "RUD0000000000111",
// },
// {
// id: "13",
// group: "3-device-1",
// driverID: "887",
// name: "Виталий",
// surname: "Гаспарян",
// numberTS: "008802A96A",
// phone: "+7 999 123 45 67",
// mail: "gosparyan@mail.ru",
// driverCard: "RUD0000000000111",
// },
// {
// id: "15",
// group: "1-device-1",
// driverID: "742",
// name: "Светлана",
// surname: "Амусова",
// numberTS: "00880302C7",
// phone: "+7 999 123 45 67",
// mail: "amusova@mail.ru",
// driverCard: "RUD0000000000111",
// },
// ];
// Получаем высоту таблицы и определяем, сколько строк помещается на странице
let currentPage = 1;
@ -151,7 +151,7 @@ const createTable = () => {
// Добавляем ячейки с данными
const driverID = document.createElement("td");
driverID.textContent = device.driverID;
driverID.textContent = device.id;
row.appendChild(driverID);
const name = document.createElement("td");
name.textContent = device.name;
@ -177,9 +177,11 @@ const createTable = () => {
trashCell.setAttribute("class", "optionsCell");
const trashButton = document.createElement("button");
trashButton.setAttribute("class", "trash");
trashButton.setAttribute("onclick", `deleteDriver(${device.id})`);
trashButton.value = `delete-device-${device.id}`;
trashButton.id = `delete-device-${device.id}`;
const optionsButton = document.createElement("button");
optionsButton.setAttribute("onclick", `openEdit(${device.id})`);
optionsButton.setAttribute("class", "options");
optionsButton.value = `options-device-${device.id}`;
optionsButton.id = `options-device-${device.id}`;

View File

@ -1,105 +1,105 @@
const devices = [
{
id: "1",
group: "0001",
name: "Разговор по телефону",
reportID: "354",
plate: "AO30877",
numberTS: "008803559E",
time: "12.03.23 17:33",
place: "59.852371, 30.344543",
},
{
id: "2",
group: "0001",
name: "Водитель зевает",
reportID: "353",
plate: "AO64377",
numberTS: "0088036B78",
time: "12.03.23 14:26",
place: "60.058236, 30.315283",
},
{
id: "3",
group: "0002",
name: "Усталость",
reportID: "352",
plate: "ГД44377",
numberTS: "009800852A",
time: "12.03.23 10:07",
place: "59.878256, 30.31962",
},
{
id: "4",
group: "0003",
name: "Водитель зевает",
reportID: "351",
plate: "УА86577",
numberTS: "009800858D",
time: "12.03.23 09:56",
place: "60.045981, 30.4134",
},
{
id: "5",
group: "0003",
name: "Разговор по телефону",
reportID: "350",
plate: В74665",
numberTS: "00980084FD",
time: "11.03.23 20:43",
place: "59.83257, 30.389893",
},
{
id: "6",
group: "0004",
name: "Разговор по телефону",
reportID: "349",
plate: У445101",
numberTS: "0088036B7F",
time: "11.03.23 19:17",
place: "59.959926, 30.42224",
},
{
id: "7",
group: "0005",
name: "Усталость",
reportID: "348",
plate: "КТ32376",
numberTS: "00880302CD",
time: "11.03.23 15:32",
place: "60.046346, 30.405688",
},
{
id: "8",
group: "0006",
name: "Курение за рулём",
reportID: "347",
plate: "ОА33277",
numberTS: "008802A035",
time: "11.03.23 15:06",
place: "59.956626, 30.234408",
},
{
id: "9",
group: "0007",
name: "Водитель отвлекся",
reportID: "346",
plate: "КЛ987102",
numberTS: "008802A96A",
time: "11.03.23 12:44",
place: "59.956626, 30.234408",
},
{
id: "10",
group: "0002",
name: "Водитель отвлекся",
reportID: "345",
plate: "АУ22377",
numberTS: "00880302C7",
time: "11.03.23 11:40",
place: "59.956626, 30.234408",
},
];
// const devices = [
// {
// id: "1",
// group: "0001",
// name: "Разговор по телефону",
// reportID: "354",
// plate: "AO30877",
// numberTS: "008803559E",
// time: "12.03.23 17:33",
// place: "59.852371, 30.344543",
// },
// {
// id: "2",
// group: "0001",
// name: "Водитель зевает",
// reportID: "353",
// plate: "AO64377",
// numberTS: "0088036B78",
// time: "12.03.23 14:26",
// place: "60.058236, 30.315283",
// },
// {
// id: "3",
// group: "0002",
// name: "Усталость",
// reportID: "352",
// plate: "ГД44377",
// numberTS: "009800852A",
// time: "12.03.23 10:07",
// place: "59.878256, 30.31962",
// },
// {
// id: "4",
// group: "0003",
// name: "Водитель зевает",
// reportID: "351",
// plate: "УА86577",
// numberTS: "009800858D",
// time: "12.03.23 09:56",
// place: "60.045981, 30.4134",
// },
// {
// id: "5",
// group: "0003",
// name: "Разговор по телефону",
// reportID: "350",
// plate: В74665",
// numberTS: "00980084FD",
// time: "11.03.23 20:43",
// place: "59.83257, 30.389893",
// },
// {
// id: "6",
// group: "0004",
// name: "Разговор по телефону",
// reportID: "349",
// plate: У445101",
// numberTS: "0088036B7F",
// time: "11.03.23 19:17",
// place: "59.959926, 30.42224",
// },
// {
// id: "7",
// group: "0005",
// name: "Усталость",
// reportID: "348",
// plate: "КТ32376",
// numberTS: "00880302CD",
// time: "11.03.23 15:32",
// place: "60.046346, 30.405688",
// },
// {
// id: "8",
// group: "0006",
// name: "Курение за рулём",
// reportID: "347",
// plate: "ОА33277",
// numberTS: "008802A035",
// time: "11.03.23 15:06",
// place: "59.956626, 30.234408",
// },
// {
// id: "9",
// group: "0007",
// name: "Водитель отвлекся",
// reportID: "346",
// plate: "КЛ987102",
// numberTS: "008802A96A",
// time: "11.03.23 12:44",
// place: "59.956626, 30.234408",
// },
// {
// id: "10",
// group: "0002",
// name: "Водитель отвлекся",
// reportID: "345",
// plate: "АУ22377",
// numberTS: "00880302C7",
// time: "11.03.23 11:40",
// place: "59.956626, 30.234408",
// },
// ];
// Получаем высоту таблицы и определяем, сколько строк помещается на странице
let currentPage = 1;
@ -143,22 +143,22 @@ const createTable = () => {
// Добавляем ячейки с данными
const name = document.createElement("td");
name.textContent = device.name;
name.textContent = device.type;
row.appendChild(name);
const reportID = document.createElement("td");
reportID.textContent = device.reportID;
reportID.textContent = device.id;
row.appendChild(reportID);
const plate = document.createElement("td");
plate.textContent = device.plate;
row.appendChild(plate);
const numberTS = document.createElement("td");
numberTS.textContent = device.numberTS;
numberTS.textContent = device.serial;
row.appendChild(numberTS);
const time = document.createElement("td");
time.textContent = device.time;
row.appendChild(time);
const place = document.createElement("td");
place.textContent = device.place;
place.textContent = device.geo;
row.appendChild(place);
// Добавляем кнопку удаления после каждого ряда
@ -243,7 +243,7 @@ const applyFilterAndSearch = () => {
filteredDevices = devices.filter((device) => {
const searchString =
`${device.group} ${device.name} ${device.reportID} ${device.place} ${device.numberTS} ${device.time} ${device.place}`.toLowerCase();
`${device.group} ${device.name} ${device.id} ${device.place} ${device.numberTS} ${device.time} ${device.place} ${device.geo} ${device.serial}`.toLowerCase();
const matchGroup =
groupFilters.length === 0 || groupFilters.includes(device.group);
const matchSearch = !searchValue || searchString.includes(searchValue);