2024-10-08 05:26:48 +00:00
{% extends 'base.html' %}
2024-07-05 13:32:07 +00:00
{% load i18n %}
{% block content %}
2024-12-05 21:31:30 +00:00
2024-12-30 18:42:29 +00:00
< div class = "position-fixed" style = "bottom: 2rem; right: 2rem; z-index: 9999; display: flex; gap: 0.5rem;" >
< button class = "btn btn-outline-warning d-flex align-items-center shadow" type = "button"
data-bs-toggle="offcanvas" data-bs-target="#notesOffcanvas" aria-controls="notesOffcanvas"
data-bs-toggle="tooltip" data-bs-placement="left" title="{% trans 'View recent notes' %}">
< i class = "bi bi-journal-text me-1" > < / i >
{% trans "Journal" %}
< / button >
< / div >
<!-- side panel for latest notes -->
< div class = "offcanvas offcanvas-end" tabindex = "-1" id = "notesOffcanvas" aria-labelledby = "notesOffcanvasLabel" >
< div class = "offcanvas-header" >
< h5 id = "notesOffcanvasLabel" > {% trans "Latest Notes" %}< / h5 >
< button type = "button" class = "btn-close" data-bs-dismiss = "offcanvas" aria-label = "Close" > < / button >
2025-01-03 06:24:08 +00:00
< / div >
2024-12-30 18:42:29 +00:00
< div class = "offcanvas-body" >
2025-01-03 06:24:08 +00:00
{% for note in device_notes|slice:":4" %}
2024-12-30 18:42:29 +00:00
< div class = "card mb-3 shadow-sm" >
< div class = "card-body" >
2025-01-03 06:24:08 +00:00
< div >
2024-12-30 18:42:29 +00:00
< small class = "text-muted" >
{{ note.date|timesince }} {% trans "ago" %}
< / small >
< / div >
2025-01-03 06:24:08 +00:00
{% if user == note.user or user.is_admin %}
< blockquote
class="blockquote mt-2 p-2 bg-light fst-italic"
contenteditable="true"
style="font-size: 1em!important"
data-note-id="{{ note.id }}"
oninput="toggleSaveLink(this)">
{% else %}
< blockquote style = "font-size: 1em!important" class = "blockquote mt-2 p-2 fst-italic" >
{% endif %}
< p data-note-id = "{{ note.id }}" >
{{ note.description }}
< / p >
< footer class = "blockquote-footer text-end mt-2" contenteditable = "false" >
< small > {{ note.user.get_full_name|default:note.user.username }}< / small >
< / footer >
< / blockquote >
{% if user == note.user or user.is_admin %}
< div class = "d-flex justify-content-end align-items-center" >
< form
id="updateNoteForm{{ note.id }}"
method="post"
action="{% url 'action:update_note' note.id %}"
class="d-inline"
>
{% csrf_token %}
< input type = "hidden" name = "description" id = "descriptionInput{{ note.id }}" value = "" >
< a
type="submit"
id="saveLink{{ note.id }}"
class="text-muted disabled me-4"
style="pointer-events: none;"
title="{% trans 'Save changes' %}"
onclick="submitUpdatedNote('{{ note.id }}'); return false;"
>
< i class = "fas fa-save" > < / i >
< / a >
< / form >
< form class = "d-inline" method = "post" action = "" >
{% csrf_token %}
< a type = "submit" class = "text-danger" onclick = "return confirm('{% trans 'Are you sure you want to delete this note?' %}')" title = "{% trans 'Delete note' %}" >
< i class = "bi bi-trash" > < / i >
< / a >
< / form >
< / div >
{% endif %}
2024-12-30 18:42:29 +00:00
< / div >
< / div >
{% empty %}
< p > {% trans "No notes available." %}< / p >
{% endfor %}
< / div >
< / div >
2025-01-03 06:24:08 +00:00
<!-- Top bar buttons -->
2024-12-05 21:31:30 +00:00
< div class = "row" >
< div class = "col" >
2024-12-19 21:17:09 +00:00
< h3 > {{ object.shortid }}< / h3 >
2024-12-05 21:31:30 +00:00
< / div >
< div class = "col text-end" >
2024-12-19 21:17:09 +00:00
< div class = "btn-group" role = "group" aria-label = "Actions" >
<!-- change state button -->
{% if state_definitions %}
< div class = "dropdown ms-2" >
< a class = "btn btn-green-admin dropdown-toggle" id = "addStateDropdown" data-bs-toggle = "dropdown" aria-expanded = "false" >
{% trans "Change state" %}
{% if device_states %}
({{ device_states.0.state }})
{% endif %}
< / a >
< ul class = "dropdown-menu" aria-labelledby = "addStateDropdown" style = "width: 100%;" >
{% for state in state_definitions %}
< li style = "width: 100%;" >
< form id = "changeStateForm{{ state.id }}" method = "post" action = "{% url 'action:change_state' %}" >
{% csrf_token %}
2024-12-20 17:38:58 +00:00
< input type = "hidden" name = "previous_state" value = "{{ device_states.0.state|default:" nil " } } " >
2024-12-19 21:17:09 +00:00
< input type = "hidden" name = "snapshot_uuid" value = "{{ object.last_uuid }}" >
< input type = "hidden" name = "new_state" value = "{{ state.state }}" >
< a class = "dropdown-item d-flex justify-content-between align-items-center" href = "#" onclick = "document.getElementById('changeStateForm{{ state.id }}').submit(); return false;" >
2024-12-20 17:41:17 +00:00
< span class = "font-monospace" > {{ state.state }}< / span >
2024-12-19 21:17:09 +00:00
< span class = "badge bg-secondary rounded-pill-sm" > {{ forloop.counter }}< / span >
2024-12-12 21:18:24 +00:00
< / a >
2024-12-19 21:17:09 +00:00
< / form >
< / li >
{% endfor %}
< / ul >
2024-12-19 23:09:29 +00:00
< / div >
2024-12-19 21:17:09 +00:00
{% else %}
< button class = "btn btn-green-admin" type = "button" disabled >
< i class = "bi bi-plus" > < / i > {% trans "Change state" %}
{% if device_states %}
2024-12-19 23:09:29 +00:00
({{ device_states.0.state }})
2024-12-19 21:17:09 +00:00
{% endif %}
< / button >
{% endif %}
<!-- Add note button -->
< button class = "btn btn-warning ms-2" type = "button" data-bs-toggle = "modal" data-bs-target = "#addNoteModal" >
< i class = "bi bi-sticky" > < / i > {% trans "Add a note" %}
2024-12-05 21:31:30 +00:00
< / button >
2024-12-19 21:17:09 +00:00
< / div >
2024-07-05 13:32:07 +00:00
< / div >
2024-12-05 21:31:30 +00:00
< / div >
2024-07-05 13:32:07 +00:00
2024-12-19 21:17:09 +00:00
2024-10-29 07:29:13 +00:00
< div class = "row" >
< div class = "col" >
< ul class = "nav nav-tabs nav-tabs-bordered" >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
< a href = "#details" class = "nav-link active" data-bs-toggle = "tab" data-bs-target = "#details" > {% trans 'General details' %}< / a >
2024-10-29 07:29:13 +00:00
< / li >
2024-12-06 22:19:49 +00:00
< li class = "nav-item" >
2024-12-06 22:48:31 +00:00
< a href = "#log" class = "nav-link" data-bs-toggle = "tab" data-bs-target = "#log" > {% trans 'Log' %}< / a >
2024-12-06 22:19:49 +00:00
< / li >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
2024-12-19 23:09:29 +00:00
< a href = "#user_properties" class = "nav-link" data-bs-toggle = "tab" data-bs-target = "#user_properties" > {% trans 'User properties' %}< / a >
2024-10-29 07:29:13 +00:00
< / li >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
< a href = "#documents" class = "nav-link" data-bs-toggle = "tab" data-bs-target = "#documents" > {% trans 'Documents' %}< / a >
2024-10-29 07:29:13 +00:00
< / li >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
< a href = "#lots" class = "nav-link" data-bs-toggle = "tab" data-bs-target = "#lots" > {% trans 'Lots' %}< / a >
2024-10-29 07:29:13 +00:00
< / li >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
< a href = "#components" class = "nav-link" data-bs-toggle = "tab" data-bs-target = "#components" > {% trans 'Components' %}< / a >
2024-10-29 07:29:13 +00:00
< / li >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
< a href = "#evidences" class = "nav-link" data-bs-toggle = "tab" data-bs-target = "#evidences" > {% trans 'Evidences' %}< / a >
2024-10-29 07:29:13 +00:00
< / li >
2024-10-29 07:25:01 +00:00
< li class = "nav-item" >
2024-10-30 15:00:23 +00:00
< a class = "nav-link" href = "{% url 'device:device_web' object.id %}" target = "_blank" > Web< / a >
2024-10-29 07:29:13 +00:00
< / li >
< / ul >
2024-07-05 13:32:07 +00:00
< / div >
< / div >
2024-12-06 20:48:06 +00:00
< div class = "tab-content pt-4" >
2024-12-06 21:21:46 +00:00
2024-12-12 19:46:39 +00:00
{% include 'tabs/general_details.html' %}
2024-11-15 21:16:45 +00:00
2024-12-12 19:46:39 +00:00
{% include 'tabs/log.html' %}
2024-11-15 21:16:45 +00:00
2024-12-12 19:46:39 +00:00
{% include 'tabs/user_properties.html' %}
2024-07-30 11:37:08 +00:00
2024-12-12 19:46:39 +00:00
{% include 'tabs/documents.html' %}
2024-07-05 13:32:07 +00:00
2024-12-12 19:46:39 +00:00
{% include 'tabs/lots.html' %}
2024-10-29 07:29:13 +00:00
2024-12-12 19:46:39 +00:00
{% include 'tabs/evidences.html' %}
2024-07-18 15:21:22 +00:00
2024-12-19 21:17:09 +00:00
< div class = "modal fade" id = "addNoteModal" tabindex = "-1" aria-labelledby = "addNoteModalLabel" aria-hidden = "true" >
< div class = "modal-dialog" >
2024-12-05 21:31:30 +00:00
< div class = "modal-content" >
< div class = "modal-header" >
2024-12-19 21:17:09 +00:00
< h5 class = "modal-title" id = "addNoteModalLabel" > {% trans "Add a Note" %}< / h5 >
< button type = "button" class = "btn-close" data-bs-dismiss = "modal" aria-label = "{% trans 'Close' %}" > < / button >
2024-12-05 21:31:30 +00:00
< / div >
2024-12-19 21:17:09 +00:00
< div class = "modal-body" >
< form method = "post" action = "{% url 'action:add_note' %}" >
{% csrf_token %}
< div class = "mb-3" >
< input type = "hidden" name = "snapshot_uuid" value = "{{ object.last_uuid }}" >
< label for = "noteDescription" class = "form-label" > {% trans "Note" %}< / label >
< textarea class = "form-control" id = "noteDescription" name = "note" placeholder = "Max 250 characters" name = "note" rows = "3" required > < / textarea >
2024-12-05 21:31:30 +00:00
< / div >
2024-12-19 21:17:09 +00:00
< div class = "modal-footer" >
< button type = "button" class = "btn btn-secondary" data-bs-dismiss = "modal" > {% trans "Cancel" %}< / button >
< button type = "submit" class = "btn btn-green-admin" > {% trans "Save Note" %}< / button >
< / div >
< / form >
2024-12-05 21:31:30 +00:00
< / div >
< / div >
2024-12-19 21:17:09 +00:00
< / div >
2024-12-05 21:31:30 +00:00
< / div >
2024-07-05 13:32:07 +00:00
{% endblock %}
2024-10-22 05:24:42 +00:00
{% block extrascript %}
< script >
document.addEventListener('DOMContentLoaded', function () {
// Obtener el hash de la URL (ejemplo: #components)
const hash = window.location.hash
// Verificar si hay un hash en la URL
if (hash) {
// Buscar el botón o enlace que corresponde al hash y activarlo
const tabTrigger = document.querySelector(`[data-bs-target="${hash}"]`)
if (tabTrigger) {
// Crear una instancia de tab de Bootstrap para activar el tab
const tab = new bootstrap.Tab(tabTrigger)
tab.show()
}
}
})
2025-01-03 06:24:08 +00:00
//Enable save button on note if changes are made to it
function toggleSaveLink(blockquoteElem) {
const saveLink = document.getElementById("saveLink" + blockquoteElem.dataset.noteId);
saveLink.classList.remove("disabled", "text-muted");
saveLink.classList.add("text-success");
saveLink.style.pointerEvents = "auto";
}
//updates note-update-form with new value from blockquote
function submitUpdatedNote(noteId) {
const noteParagraph = document.querySelector('p[data-note-id="' + noteId + '"]');
const newText = noteParagraph.innerText.trim();
const descriptionField = document.getElementById('descriptionInput' + noteId);
descriptionField.value = newText;
document.getElementById('updateNoteForm' + noteId).submit();
}
2024-10-22 05:24:42 +00:00
< / script >
{% endblock %}