Merge branch 'Idealizm'. 1.0.20.0

This commit is contained in:
zakhy 2025-07-10 11:05:43 +07:00
commit 389c09bea1
5 changed files with 173 additions and 25 deletions

View File

@ -40,10 +40,13 @@ def update_object(request):
try:
time_filter = datetime.fromisoformat(
time_filter.rstrip('Z')).replace(tzinfo=utc)
time_filter_minus_week = time_filter - timedelta(days=7)
latest_times = (
EquipmentTracking.objects
.filter(equipment__block=False, time__lt=time_filter)
.filter(equipment__block=False,
time__gt=time_filter_minus_week,
time__lt=time_filter)
.values('equipment_id')
.annotate(latest_time=Max('time'))
.values_list('equipment_id', 'latest_time')

View File

@ -286,7 +286,6 @@
if (globalTimeQuery !== "" && prevTimeQuery === globalTimeQuery) return
if (globalTimeQuery !== "") {
loading = true
console.log(loaderWrapper.classList.contains("d-none"))
if (loaderWrapper.classList.contains("d-none")) {
loaderWrapper.classList.remove("d-none")
}

View File

@ -59,10 +59,8 @@
</div>
</div>
<div class="form-group row">
<a href="{% url 'management:manage_icons' %}" class="btn bg-gradient-primary">Изображения</a>
</div>
<div class="form-group row">
<a href="{% url 'management:manage_danger_zone' %}" class="btn bg-gradient-primary">Опасные зоны</a>
<a href="{% url 'management:manage_danger_zone' %}" class="btn bg-gradient-primary">Опасные
зоны</a>
</div>
</div> <!-- /.card-body -->
<div class="card-footer">
@ -93,7 +91,27 @@
</div>
</div>
<div class="form-group row">
<a href="{% url "management:manage_schedules" %}" class="btn bg-gradient-primary">Управление загрузкой данных</a>
<label for="id_organization" class="col-sm-1 col-form-label">Критическая магнитуда
: </label>
<div class="col-sm-4">
<input type="text" name="seism_crit_mangitude" value='{{ seism_crit_mangitude }}'
placeholder='Критическая магнитуда' class="form-control" autofocus=""
id="id_seism_crit_mangitude">
</div>
</div>
<div class="form-group row">
<label for="id_organization" class="col-sm-1 col-form-label">Максимальная скорость
(км/ч)
: </label>
<div class="col-sm-4">
<input type="text" name="gto_speed_excess" value='{{ gto_speed_excess }}'
placeholder='Критическая магнитуда' class="form-control" autofocus=""
id="id_gto_speed_excess">
</div>
</div>
<div class="form-group row">
<a href="{% url "management:manage_schedules" %}" class="btn bg-gradient-primary">Управление
загрузкой данных</a>
</div>
</div> <!-- /.card-body -->
<div class="card-footer">
@ -131,9 +149,9 @@
<li class="paginate_button page-item"
id="mypaginator_next">
<a class="page-link" href="?module=clients&page=
{{ start_page_list|add:-1}}"
{{ start_page_list|add:-1 }}"
aria-controls="mypaginator"
data-dt-idx="{{ start_page_list|add:-1}}"
data-dt-idx="{{ start_page_list|add:-1 }}"
style="padding: .3rem .5rem;"><span>..</span></a>
</li>
@ -163,9 +181,9 @@
<li class="paginate_button page-item"
id="mypaginator_next">
<a class="page-link" href="?module=clients&page=
{{ end_page_list|add:1}}"
{{ end_page_list|add:1 }}"
aria-controls="mypaginator"
data-dt-idx="{{ end_page_list|add:1}}"
data-dt-idx="{{ end_page_list|add:1 }}"
style="padding: .3rem .5rem;"><span>..</span></a>
</li>
@ -404,7 +422,8 @@
</div>
</div>
<a href="{% url 'management:manage_gto_icons' %}" class="btn bg-gradient-primary">Настройка отображения</a>
<a href="{% url 'management:manage_gto_icons' %}" class="btn bg-gradient-primary">Настройка
отображения</a>
</div> <!-- /.card-body -->
<div class="card-footer">
@ -434,8 +453,12 @@
<div class="col-sm-4">
<select id="id_wlocationsystem" name="wlocationsystem" class="form-control select2"
style="width: 100%;">
<option {% if wlocationsystem == "Не используется" %} selected {% endif %}>Не используется </option>
<option {% if wlocationsystem == "Внешняя ссылка" %} selected {% endif %}>Внешняя ссылка</option>
<option {% if wlocationsystem == "Не используется" %} selected {% endif %}>Не
используется
</option>
<option {% if wlocationsystem == "Внешняя ссылка" %} selected {% endif %}>
Внешняя ссылка
</option>
<option {% if wlocationsystem == "RTLS" %} selected {% endif %}>RTLS</option>
<option {% if wlocationsystem == "Radiusip" %} selected {% endif %}>Radiusip
<option {% if wlocationsystem == "Hetonis" %} selected {% endif %}>Hetonis
@ -473,6 +496,9 @@
autofocus="" id="id_wtoken">{{ wtoken }}</textarea>
</div>
</div>
<div class="form-group row">
<a href="{% url 'management:manage_icons' %}" class="btn bg-gradient-primary">Изображения</a>
</div>
</div> <!-- /.card-body -->
<div class="card-footer">
<button id="btnok" type="submit" class="btn bg-gradient-primary">Сохранить</button>

View File

@ -98,10 +98,12 @@ def update_object(request, pk=None):
elif time_filter:
time_filter = datetime.fromisoformat(
time_filter.rstrip('Z')).replace(tzinfo=utc)
time_filter_minus_week = time_filter - timedelta(days=7)
latest_times = (
WorkersTracking.objects
.filter(worker__active=True, time__lt=time_filter)
.filter(worker__active=True,
time__gt=time_filter_minus_week,
time__lt=time_filter)
.values('worker_id')
.annotate(latest_time=Max('time'))
.values_list('worker_id', 'latest_time')

View File

@ -25,11 +25,8 @@ class TimeLine {
orientation: {axis: "top"},
format: {
minorLabels: {
minute: 'HH:mm',
hour: 'HH:mm',
second: 'HH:mm:ss'
},
majorLabels: function (date) {
minute: 'HH:mm', hour: 'HH:mm', second: 'HH:mm:ss'
}, majorLabels: function (date) {
return date.format("DD.MM.YY");
}
}
@ -37,6 +34,7 @@ class TimeLine {
return new vis.Timeline(this.target, items, options);
}
addTimelineEventListeners() {
this.timeline.on('rangechanged', (props) => {
const center = new Date((props.start.getTime() + props.end.getTime()) / 2);
@ -48,14 +46,12 @@ class TimeLine {
globalTimeQuery = "?time=" + iso
} else {
globalTimeQuery = ""
}
document.getElementById("current-time").textContent = "Время на карте: " + center.toLocaleDateString() + " " + center.toLocaleTimeString()
this.updateCurrentTimeDisplay(center);
this.updateFunction(globalTimeQuery);
});
setInterval(() => {
const newMax = moment().add(12, 'hours').toDate();
this.timeline.setOptions({
@ -69,4 +65,126 @@ class TimeLine {
}
}, 3000);
}
}
updateCurrentTimeDisplay(center) {
const currentTime = document.getElementById("current-time");
// Очистка currentTime
while (currentTime.firstChild) {
currentTime.removeChild(currentTime.firstChild);
}
const currentTimeSpan = document.createElement("span");
currentTimeSpan.textContent = "Время на карте: ";
const currentTimeLink = document.createElement("a");
currentTimeLink.textContent = center.toLocaleDateString() + " " + center.toLocaleTimeString();
currentTimeLink.style.zIndex = "33";
currentTimeLink.style.textDecoration = "underline";
currentTimeLink.style.cursor = "pointer";
currentTimeLink.id = "currentTimeLink"
this.currentTimeLink = currentTimeLink
// Создаем форму для выбора времени
const form = document.createElement('form');
form.id = 'timelineDatetimeSelectForm';
form.className = 'needs-validation';
form.noValidate = true;
const formGroup = document.createElement('div');
formGroup.className = 'mb-3';
const label = document.createElement('label');
label.htmlFor = 'timelineDatetimeInput';
label.className = 'form-label';
label.textContent = 'Выбор даты и времени';
const input = document.createElement('input');
input.type = 'datetime-local';
input.id = 'timelineDatetimeInput';
input.className = 'form-control';
// Устанавливаем текущее значение и максимальную дату
const setInputValues = () => {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0');
const day = String(now.getDate()).padStart(2, '0');
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const maxDateTime = `${year}-${month}-${day}T${hours}:${minutes}`;
input.max = maxDateTime;
};
const inputContainer = document.createElement('div');
inputContainer.id = 'datetimeInputContainer';
inputContainer.appendChild(input);
const resetBtn = document.createElement('button');
resetBtn.type = 'reset';
resetBtn.className = 'btn btn-outline-secondary btn-sm me-2';
resetBtn.textContent = 'Сбросить';
const submitBtn = document.createElement('button');
submitBtn.type = 'submit';
submitBtn.className = 'btn btn-primary btn-sm';
submitBtn.textContent = 'Перейти';
formGroup.appendChild(label);
formGroup.appendChild(inputContainer);
form.appendChild(formGroup);
form.appendChild(resetBtn);
form.appendChild(submitBtn);
form.addEventListener("submit", (e) => {
e.preventDefault();
const selectedDate = new Date(input.value);
if (isNaN(selectedDate.getTime())) return;
// Обновляем таймлайн
const duration = this.timeline.getWindow().end - this.timeline.getWindow().start;
const start = new Date(selectedDate.getTime() - duration / 2);
const end = new Date(selectedDate.getTime() + duration / 2);
this.timeline.setWindow(start, end);
// Обновляем URL
globalTimeQuery = "?time=" + selectedDate.toISOString();
this.updateFunction(globalTimeQuery);
// Закрываем popover
popover.hide();
});
const popover = new bootstrap.Popover(currentTimeLink, {
trigger: 'manual', html: true, content: form, placement: 'top', sanitize: false
});
this.popover = popover
// Обновляем значения поля ввода при каждом показе popover
currentTimeLink.addEventListener('click', (e) => {
e.preventDefault();
setInputValues();
if (currentTimeLink.getAttribute('aria-describedby')) {
popover.hide();
} else {
popover.show();
}
});
function disposePopover(e) {
if (e.target !== currentTimeLink &&
!currentTimeLink.contains(e.target) &&
!document.querySelector('.popover')?.contains(e.target)) {
popover.hide();
}
}
document.removeEventListener("click", disposePopover)
document.addEventListener('click', disposePopover);
currentTime.appendChild(currentTimeSpan);
currentTime.appendChild(currentTimeLink);
}
}