added current state to device details
This commit is contained in:
parent
6bd822f732
commit
5b33bf000f
22
action/forms.py
Normal file
22
action/forms.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from django import forms
|
||||
from .models import State
|
||||
|
||||
|
||||
class AddStateForm(forms.Form):
|
||||
add_note = forms.BooleanField(required=False)
|
||||
note = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.Textarea(attrs={'rows': 4, 'maxlength': 200, 'placeholder': 'Max 200 characters'}),
|
||||
)
|
||||
state_id = forms.IntegerField(required=True, widget=forms.HiddenInput())
|
||||
snapshot_uuid = forms.UUIDField(required=True, widget=forms.HiddenInput())
|
||||
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
add_note = cleaned_data.get('add_note')
|
||||
note = cleaned_data.get('note')
|
||||
|
||||
if add_note == True and not note:
|
||||
self.add_error('note', 'Please enter a note if you checked "Add a note".')
|
||||
return cleaned_data
|
|
@ -63,77 +63,91 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-content pt-2">
|
||||
<div class="tab-content pt-4">
|
||||
<div class="tab-pane fade show active" id="details">
|
||||
<h5 class="card-title">{% trans 'Details' %}</h5>
|
||||
<div class="row mb-3">
|
||||
<div class="col-lg-3 col-md-4 label">Phid</div>
|
||||
<div class="col-lg-9 col-md-8">{{ object.id }}</div>
|
||||
</div>
|
||||
|
||||
{% if object.is_eraseserver %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-lg-3 col-md-4 label">
|
||||
{% trans 'Is a erase server' %}
|
||||
<div class="row">
|
||||
<!-- Device Details -->
|
||||
<div class="col-lg-6">
|
||||
<h5 class="card-title">{% trans 'Details' %}</h5>
|
||||
<hr>
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Phid' %}</div>
|
||||
<div class="col-sm-8">{{ object.id }}</div>
|
||||
</div>
|
||||
<div class="col-lg-9 col-md-8"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row mb-1">
|
||||
<div class="col-lg-3 col-md-4 label">Type</div>
|
||||
<div class="col-lg-9 col-md-8">{{ object.type }}</div>
|
||||
</div>
|
||||
{% if object.is_eraseserver %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Is an erase server' %}</div>
|
||||
<div class="col-sm-8">{% trans 'Yes' %}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if object.is_websnapshot and object.last_user_evidence %}
|
||||
{% for k, v in object.last_user_evidence %}
|
||||
<div class="row mb-1">
|
||||
<div class="col-lg-3 col-md-4 label">{{ k }}</div>
|
||||
<div class="col-lg-9 col-md-8">{{ v|default:'' }}</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Type' %}</div>
|
||||
<div class="col-sm-8">{{ object.type }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="row mb-1">
|
||||
<div class="col-lg-3 col-md-4 label">
|
||||
{% trans 'Manufacturer' %}
|
||||
|
||||
{% if object.is_websnapshot and object.last_user_evidence %}
|
||||
{% for k, v in object.last_user_evidence.items %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{{ k }}</div>
|
||||
<div class="col-sm-8">{{ v|default:'' }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Manufacturer' %}</div>
|
||||
<div class="col-sm-8">{{ object.manufacturer|default:'' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Model' %}</div>
|
||||
<div class="col-sm-8">{{ object.model|default:'' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Serial Number' %}</div>
|
||||
<div class="col-sm-8">{{ object.serial_number|default:'' }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Identifiers' %}</div>
|
||||
<div class="col-sm-8">
|
||||
{% for chid in object.hids %}
|
||||
<div>{{ chid|default:'' }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-9 col-md-8">{{ object.manufacturer|default:'' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-1">
|
||||
<div class="col-lg-3 col-md-4 label">
|
||||
{% trans 'Model' %}
|
||||
</div>
|
||||
<div class="col-lg-9 col-md-8">{{ object.model|default:'' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-1">
|
||||
<div class="col-lg-3 col-md-4 label">
|
||||
{% trans 'Version' %}
|
||||
<!-- Device Current State -->
|
||||
<div class="col-lg-6">
|
||||
<h5 class="card-title">{% trans 'Current State' %}</h5>
|
||||
<hr>
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'State' %}</div>
|
||||
<div class="col-sm-8">{{ device_states.0.state }}</div>
|
||||
</div>
|
||||
<div class="col-lg-9 col-md-8">{{ object.version|default:'' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-1">
|
||||
<div class="col-lg-3 col-md-4 label">
|
||||
{% trans 'Serial Number' %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Date' %}</div>
|
||||
<div class="col-sm-8">{{ device_states.0.date|date:"SHORT_DATETIME_FORMAT" }}</div>
|
||||
</div>
|
||||
<div class="col-lg-9 col-md-8">{{ object.serial_number|default:'' }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-lg-3 col-md-4 label">
|
||||
{% trans 'Identifiers' %}
|
||||
<!-- TODO: display last note? -->
|
||||
{% if last_note %}
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-4 text-muted fw-bold">{% trans 'Note' %}</div>
|
||||
<div class="col-sm-8">{{ object.last_state.note }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% for chid in object.hids %}
|
||||
<div class="row mb-3">
|
||||
<div class="col">{{ chid|default:'' }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- End of Details -->
|
||||
|
||||
<div class="tab-pane fade" id="user_properties">
|
||||
<div class="btn-group mt-1 mb-3">
|
||||
|
@ -174,14 +188,14 @@
|
|||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- pop up modal for delete confirmation -->
|
||||
<!-- pop up modal for delete confirmation -->
|
||||
{% for a in object.get_user_properties %}
|
||||
<div class="modal fade" id="deleteModal{{ a.id }}" tabindex="-1" aria-labelledby="deleteModalLabel{{ a.id }}" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
|
@ -234,7 +248,7 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
@ -370,14 +384,14 @@
|
|||
<i class="bi bi-arrow-right-circle text-danger me-2"></i>
|
||||
|
||||
<span class="text-danger fw-bold me-2">{% trans "From:" %}</span>
|
||||
<span class="text-danger fw-italic">state_placeholder</span>
|
||||
<span class="text-danger fw-italic">state_placeholder</span>
|
||||
</div>
|
||||
<div class="d-flex align-items-center mt-2">
|
||||
<i class="bi bi-arrow-right-circle text-success me-2"></i>
|
||||
<span class="text-success fw-bold me-2">{% trans "To:" %}</span>
|
||||
<span class="text-success fw-italic">{{ state.state }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch mt-3 d-flex justify-content-end">
|
||||
<label class="form-check-label font-monospace" for="addNoteCheckbox{{ state.id }}">
|
||||
|
@ -385,22 +399,23 @@
|
|||
</label>
|
||||
<input class="form-check-input ms-2" type="checkbox" id="addNoteCheckbox{{ state.id }}" data-bs-toggle="collapse" data-bs-target="#collapseInput{{ state.id }}" name="add_note">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mb-3 mt-2 collapse" id="collapseInput{{ state.id }}">
|
||||
<textarea type="text" class="form-control" id="stateNote{{ state.id }}" name="note" rows="4" maxlength="200" placeholder="{% trans "Max 200 characters" %}"></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="state_id" value="{{ state.id }}">
|
||||
<input type="hidden" name="snapshot_uuid" value="{{ object.last_uuid }}">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
|
||||
<button type="submit" class="btn btn-primary">{% trans "Add State" %}</button>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
|
@ -13,7 +13,7 @@ from django.views.generic.edit import (
|
|||
DeleteView,
|
||||
)
|
||||
from django.views.generic.base import TemplateView
|
||||
from action.models import StateDefinition
|
||||
from action.models import StateDefinition, State
|
||||
from dashboard.mixins import DashboardView, Http403
|
||||
from evidence.models import UserProperty, SystemProperty, Property
|
||||
from lot.models import LotTag
|
||||
|
@ -117,12 +117,15 @@ class DetailsView(DashboardView, TemplateView):
|
|||
uuid__in=self.object.uuids,
|
||||
type=PROOF_TYPE["IssueDPP"]
|
||||
)
|
||||
last_evidence= self.object.get_last_evidence(),
|
||||
uuid=self.object.last_uuid()
|
||||
context.update({
|
||||
'object': self.object,
|
||||
'snapshot': self.object.get_last_evidence(),
|
||||
'snapshot': last_evidence,
|
||||
'lot_tags': lot_tags,
|
||||
'dpps': dpps,
|
||||
"state_definitions": StateDefinition.objects.filter(institution=self.request.user.institution).order_by('order'),
|
||||
"device_states": State.objects.filter(snapshot_uuid=uuid).order_by('date'),
|
||||
})
|
||||
return context
|
||||
|
||||
|
|
Loading…
Reference in a new issue