154 lines
5.8 KiB
JavaScript
154 lines
5.8 KiB
JavaScript
import { initMultiSelect } from '../utils.js';
|
||
|
||
export function initAuditoriumWorkload() {
|
||
// Initialize date input with current date
|
||
const dateInput = document.getElementById('workload-date');
|
||
if (dateInput) {
|
||
const today = new Date();
|
||
const yyyy = today.getFullYear();
|
||
const mm = String(today.getMonth() + 1).padStart(2, '0');
|
||
const dd = String(today.getDate()).padStart(2, '0');
|
||
dateInput.value = `${yyyy}-${mm}-${dd}`;
|
||
}
|
||
|
||
// Initialize Multi-Selects
|
||
initMultiSelect('building-box', 'building-menu', 'building-text', 'building-checkboxes');
|
||
initMultiSelect('capacity-box', 'capacity-menu', 'capacity-text', 'capacity-checkboxes');
|
||
initMultiSelect('equipment-box', 'equipment-menu', 'equipment-text', 'equipment-checkboxes');
|
||
|
||
// Populate Filters with Mock/Initial Data
|
||
populateFilters();
|
||
|
||
// Render Mock Data for the Grid based on the UI requested layout
|
||
renderMockGrid();
|
||
}
|
||
|
||
function populateFilters() {
|
||
// Buildings
|
||
const buildingsContainer = document.getElementById('building-checkboxes');
|
||
const buildings = [
|
||
{ id: 1, name: "Корпус 1 (Главный)" },
|
||
{ id: 2, name: "Корпус 2 (Физ-мат)" },
|
||
{ id: 3, name: "Корпус 3 (Гуманитарный)" }
|
||
];
|
||
buildingsContainer.innerHTML = buildings.map(item => `
|
||
<label class="checkbox-item">
|
||
<input type="checkbox" value="${item.id}">
|
||
<span class="checkmark"></span>
|
||
<span class="checkbox-label">${item.name}</span>
|
||
</label>
|
||
`).join('');
|
||
|
||
// Capacities
|
||
const capacityContainer = document.getElementById('capacity-checkboxes');
|
||
const capacities = [
|
||
{ id: 'small', name: "До 30 мест" },
|
||
{ id: 'medium', name: "30 - 60 мест" },
|
||
{ id: 'large', name: "60 - 100 мест" },
|
||
{ id: 'xlarge', name: "Более 100 мест" }
|
||
];
|
||
capacityContainer.innerHTML = capacities.map(item => `
|
||
<label class="checkbox-item">
|
||
<input type="checkbox" value="${item.id}">
|
||
<span class="checkmark"></span>
|
||
<span class="checkbox-label">${item.name}</span>
|
||
</label>
|
||
`).join('');
|
||
|
||
// Equipment
|
||
const equipmentContainer = document.getElementById('equipment-checkboxes');
|
||
const equipmentList = [
|
||
{ id: 1, name: "Проектор" },
|
||
{ id: 2, name: "Компьютерные места" },
|
||
{ id: 3, name: "Интерактивная доска" },
|
||
{ id: 4, name: "Микрофон" }
|
||
];
|
||
equipmentContainer.innerHTML = equipmentList.map(item => `
|
||
<label class="checkbox-item">
|
||
<input type="checkbox" value="${item.id}">
|
||
<span class="checkmark"></span>
|
||
<span class="checkbox-label">${item.name}</span>
|
||
</label>
|
||
`).join('');
|
||
}
|
||
|
||
function renderMockGrid() {
|
||
// In future this will be loaded from API
|
||
const timeslots = [
|
||
"8:00-9:30",
|
||
"9:40-11:10",
|
||
"11:40-13:10",
|
||
"13:20-14:50",
|
||
"15:00-16:30",
|
||
"16:50-18:20",
|
||
"18:30-19:50",
|
||
"20:00-21:20"
|
||
];
|
||
|
||
const auditoriums = [
|
||
"201", "202", "204", "205", "206", "207", "208"
|
||
];
|
||
|
||
// Mock schedule data mapped by room and time
|
||
// Key: "roomId_timeSlotId", Value: Lesson object
|
||
const mockSchedule = {
|
||
"201_8:00-9:30": { subject: "Физика", group: "ИБ-41м", teacher: "Атлетов А.Р." },
|
||
"201_9:40-11:10": { subject: "Физика", group: "ИВТ-21-1", teacher: "Атлетов А.Р." },
|
||
"201_11:40-13:10": { subject: "Физика", group: "ИБ-41м", teacher: "Физик В.Г." },
|
||
"201_13:20-14:50": { subject: "Физика", group: "ИБ-41м", teacher: "Физик В.Г." },
|
||
|
||
"202_9:40-11:10": { subject: "Химия", group: "ИВТ-21-1", teacher: "Химоза Я.В." },
|
||
"202_13:20-14:50": { subject: "Математика", group: "ИВТ-21-1", teacher: "Рутина Л.П." },
|
||
"202_15:00-16:30": { subject: "Химия", group: "ИВТ-21-1", teacher: "Химоза Я.В." },
|
||
"202_16:50-18:20": { subject: "Физика", group: "ИВТ-21-1", teacher: "Атлетов А.Р." },
|
||
|
||
"205_9:40-11:10": { subject: "Организация аудита ИБ", group: "ИБ-41м", teacher: "Таныгин М.О." },
|
||
};
|
||
|
||
// Render Headers
|
||
const headerRow = document.getElementById('workload-header-row');
|
||
// Start after the first fixed cell (which is already in HTML)
|
||
|
||
auditoriums.forEach(room => {
|
||
const th = document.createElement('th');
|
||
th.textContent = room;
|
||
headerRow.appendChild(th);
|
||
});
|
||
|
||
// Render Body Rows
|
||
const tbody = document.getElementById('workload-tbody');
|
||
|
||
timeslots.forEach((time) => {
|
||
const tr = document.createElement('tr');
|
||
|
||
// Add Time Cell
|
||
const tdTime = document.createElement('td');
|
||
tdTime.className = 'time-cell';
|
||
tdTime.textContent = time;
|
||
tr.appendChild(tdTime);
|
||
|
||
// Add Room Cells for this Time
|
||
auditoriums.forEach(room => {
|
||
const td = document.createElement('td');
|
||
|
||
const scheduleKey = `${room}_${time}`;
|
||
const lesson = mockSchedule[scheduleKey];
|
||
|
||
if (lesson) {
|
||
// Render lesson card
|
||
td.innerHTML = `
|
||
<div class="lesson-card">
|
||
<div class="lesson-subject">${lesson.subject}</div>
|
||
<div class="lesson-group">${lesson.group}</div>
|
||
<div class="lesson-teacher">${lesson.teacher}</div>
|
||
</div>
|
||
`;
|
||
}
|
||
|
||
tr.appendChild(td);
|
||
});
|
||
|
||
tbody.appendChild(tr);
|
||
});
|
||
}
|