Fix button links of device_list & page titles

This commit is contained in:
Santiago L 2022-02-02 12:21:30 +01:00
parent c9a46128df
commit f22fd4ebcb
7 changed files with 37 additions and 43 deletions

View File

@ -47,15 +47,18 @@ class DeviceListView(View):
class DeviceDetailView(View): class DeviceDetailView(View):
decorators = [login_required] decorators = [login_required]
template_name = 'inventory/device_details.html' template_name = 'inventory/device_detail.html'
def dispatch_request(self, id): def dispatch_request(self, id):
lots = Lot.query.filter(Lot.owner_id == current_user.id) lots = Lot.query.filter(Lot.owner_id == current_user.id)
device = Device.query.filter( device = Device.query.filter(
Device.owner_id == current_user.id).filter(Device.devicehub_id == id).one() Device.owner_id == current_user.id).filter(Device.devicehub_id == id).one()
context = {'device': device, context = {
'lots': lots} 'device': device,
'lots': lots,
'page_title': 'Device {}'.format(device.devicehub_id),
}
return flask.render_template(self.template_name, **context) return flask.render_template(self.template_name, **context)
@ -139,20 +142,22 @@ class UploadSnapshotView(View):
template_name = 'inventory/upload_snapshot.html' template_name = 'inventory/upload_snapshot.html'
def dispatch_request(self): def dispatch_request(self):
context = {'page_title': 'Upload Snapshot'}
lots = Lot.query.filter(Lot.owner_id == current_user.id).all() lots = Lot.query.filter(Lot.owner_id == current_user.id).all()
form = UploadSnapshotForm() form = UploadSnapshotForm()
if form.validate_on_submit(): if form.validate_on_submit():
form.save() form.save()
return flask.render_template(self.template_name, form=form, lots=lots) return flask.render_template(self.template_name, form=form, lots=lots, **context)
class CreateDeviceView(View): class DeviceCreateView(View):
methods = ['GET', 'POST'] methods = ['GET', 'POST']
decorators = [login_required] decorators = [login_required]
template_name = 'inventory/create_device.html' template_name = 'inventory/device_create.html'
def dispatch_request(self): def dispatch_request(self):
context = {'page_title': 'New Device'}
lots = Lot.query.filter(Lot.owner_id == current_user.id).all() lots = Lot.query.filter(Lot.owner_id == current_user.id).all()
form = NewDeviceForm() form = NewDeviceForm()
if form.validate_on_submit(): if form.validate_on_submit():
@ -160,7 +165,7 @@ class CreateDeviceView(View):
next_url = url_for('inventory.devices.devicelist') next_url = url_for('inventory.devices.devicelist')
return flask.redirect(next_url) return flask.redirect(next_url)
return flask.render_template(self.template_name, form=form, lots=lots) return flask.render_template(self.template_name, form=form, lots=lots, **context)
class TagListView(View): class TagListView(View):
@ -227,10 +232,10 @@ class TagDetailView(View):
return flask.render_template(self.template_name, **context) return flask.render_template(self.template_name, **context)
class TagDeviceAddView(View): class TagLinkDeviceView(View):
methods = ['POST'] methods = ['POST']
decorators = [login_required] decorators = [login_required]
template_name = 'inventory/device_list.html' # template_name = 'inventory/device_list.html'
def dispatch_request(self): def dispatch_request(self):
form = TagDeviceForm() form = TagDeviceForm()
@ -240,10 +245,10 @@ class TagDeviceAddView(View):
return flask.redirect(request.referrer) return flask.redirect(request.referrer)
class TagDeviceDeleteView(View): class TagUnlinkDeviceView(View):
methods = ['POST', 'GET'] methods = ['POST', 'GET']
decorators = [login_required] decorators = [login_required]
template_name = 'inventory/removeDevicestag.html' template_name = 'inventory/tag_unlink_device.html'
def dispatch_request(self, id): def dispatch_request(self, id):
form = TagDeviceForm(delete=True, device=id) form = TagDeviceForm(delete=True, device=id)
@ -265,10 +270,10 @@ devices.add_url_rule('/lot/add/', view_func=LotCreateView.as_view('lot_add'))
devices.add_url_rule('/lot/<string:id>/del/', view_func=LotDeleteView.as_view('lot_del')) devices.add_url_rule('/lot/<string:id>/del/', view_func=LotDeleteView.as_view('lot_del'))
devices.add_url_rule('/lot/<string:id>/', view_func=LotUpdateView.as_view('lot_edit')) devices.add_url_rule('/lot/<string:id>/', view_func=LotUpdateView.as_view('lot_edit'))
devices.add_url_rule('/upload-snapshot/', view_func=UploadSnapshotView.as_view('upload_snapshot')) devices.add_url_rule('/upload-snapshot/', view_func=UploadSnapshotView.as_view('upload_snapshot'))
devices.add_url_rule('/device/add/', view_func=CreateDeviceView.as_view('device_add')) devices.add_url_rule('/device/add/', view_func=DeviceCreateView.as_view('device_add'))
devices.add_url_rule('/tag/', view_func=TagListView.as_view('taglist')) devices.add_url_rule('/tag/', view_func=TagListView.as_view('taglist'))
devices.add_url_rule('/tag/add/', view_func=TagAddView.as_view('tag_add')) devices.add_url_rule('/tag/add/', view_func=TagAddView.as_view('tag_add'))
devices.add_url_rule('/tag/unnamed/add/', view_func=TagAddUnnamedView.as_view('tag_unnamed_add')) devices.add_url_rule('/tag/unnamed/add/', view_func=TagAddUnnamedView.as_view('tag_unnamed_add'))
devices.add_url_rule('/tag/<string:id>/', view_func=TagDetailView.as_view('tag_details')) devices.add_url_rule('/tag/<string:id>/', view_func=TagDetailView.as_view('tag_details'))
devices.add_url_rule('/tag/devices/add/', view_func=TagDeviceAddView.as_view('tag_devices_add')) devices.add_url_rule('/tag/devices/add/', view_func=TagLinkDeviceView.as_view('tag_devices_add'))
devices.add_url_rule('/tag/devices/<int:id>/del/', view_func=TagDeviceDeleteView.as_view('tag_devices_del')) devices.add_url_rule('/tag/devices/<int:id>/del/', view_func=TagUnlinkDeviceView.as_view('tag_devices_del'))

View File

@ -2,11 +2,11 @@
{% block main %} {% block main %}
<div class="pagetitle"> <div class="pagetitle">
<h1>{{ title }}</h1> <h1>{{ page_title }}</h1>
<nav> <nav>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Inventory</a></li> <li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item">New Device</li> <li class="breadcrumb-item">{{ page_title }}</li>
</ol> </ol>
</nav> </nav>
</div><!-- End Page Title --> </div><!-- End Page Title -->
@ -19,7 +19,6 @@
<div class="card-body"> <div class="card-body">
<div class="pt-4 pb-2"> <div class="pt-4 pb-2">
<h5 class="card-title text-center pb-0 fs-4">New Device</h5>
{% if form.form_errors %} {% if form.form_errors %}
<p class="text-danger"> <p class="text-danger">
{% for error in form.form_errors %} {% for error in form.form_errors %}

View File

@ -7,8 +7,7 @@
<nav> <nav>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.devicelist')}}">Inventory</a></li> <li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item active">Details device</li> <li class="breadcrumb-item active">{{ page_title }}</li>
<li class="breadcrumb-item active">{{ device.devicehub_id }}</li>
</ol> </ol>
</nav> </nav>
</div><!-- End Page Title --> </div><!-- End Page Title -->

View File

@ -61,13 +61,13 @@
<li> <li>
<a href="javascript:void()" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#addingLotModal"> <a href="javascript:void()" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#addingLotModal">
<i class="bi bi-plus"></i> <i class="bi bi-plus"></i>
Adding to a lot Add selected Devices to a lot
</a> </a>
</li> </li>
<li> <li>
<a href="javascript:void()" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#removeLotModal"> <a href="javascript:void()" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#removeLotModal">
<i class="bi bi-x"></i> <i class="bi bi-x"></i>
Removing from a lot Remove selected devices from a lot
</a> </a>
</li> </li>
</ul> </ul>
@ -164,15 +164,8 @@
</button> </button>
<ul class="dropdown-menu" aria-labelledby="btnExport"> <ul class="dropdown-menu" aria-labelledby="btnExport">
<li> <li>
<a href="javascript:openAdd()" class="dropdown-item"> <a href="#" class="dropdown-item">
<i class="bi bi-plus"></i> TODO: Not implemented
Añadir dispositivos a lotes
</a>
</li>
<li>
<a href="javascript:openRemove()" class="dropdown-item">
<i class="fa fa-fw fa-minus"></i>
Eliminar dispisitvos de lotes
</a> </a>
</li> </li>
</ul> </ul>
@ -187,13 +180,13 @@
<li> <li>
<a href="javascript:void()" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#addingTagModal"> <a href="javascript:void()" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#addingTagModal">
<i class="bi bi-plus"></i> <i class="bi bi-plus"></i>
Adding Tag Add Tag to selected Devices
</a> </a>
</li> </li>
<li> <li>
<a href="javascript:removeTag()" class="dropdown-item"> <a href="javascript:removeTag()" class="dropdown-item">
<i class="bi bi-x"></i> <i class="bi bi-x"></i>
Remove Tag Remove Tag from selected Devices
</a> </a>
</li> </li>
</ul> </ul>

View File

@ -5,7 +5,8 @@
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
<nav> <nav>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Inventory</a></li> <!-- TODO@slamora replace with lot list URL when exists -->
<li class="breadcrumb-item"><a href="#TODO-lot-list">Lots</a></li>
<li class="breadcrumb-item">Lot</li> <li class="breadcrumb-item">Lot</li>
</ol> </ol>
</nav> </nav>

View File

@ -2,13 +2,10 @@
{% block main %} {% block main %}
<div class="pagetitle"> <div class="pagetitle">
<h1>{{ title }}</h1>
<nav> <nav>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Inventory</a></li> <li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item">Tag</li> <li class="breadcrumb-item">Unlink Tag from Device</li>
<li class="breadcrumb-item">Device</li>
<li class="breadcrumb-item">Remove</li>
</ol> </ol>
</nav> </nav>
</div><!-- End Page Title --> </div><!-- End Page Title -->
@ -21,7 +18,7 @@
<div class="card-body"> <div class="card-body">
<div class="pt-4 pb-2"> <div class="pt-4 pb-2">
<h5 class="card-title text-center pb-0 fs-4">Unlink tag of device</h5> <h1 class="card-title text-center pb-0 fs-4">Unlink Tag from Device</h1>
<p class="text-center small">Please enter a code for the tag.</p> <p class="text-center small">Please enter a code for the tag.</p>
{% if form.form_errors %} {% if form.form_errors %}
<p class="text-danger"> <p class="text-danger">

View File

@ -2,11 +2,11 @@
{% block main %} {% block main %}
<div class="pagetitle"> <div class="pagetitle">
<h1>{{ title }}</h1> <h1>Inventory</h1>
<nav> <nav>
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Inventory</a></li> <li class="breadcrumb-item"><a href="{{ url_for('inventory.devices.devicelist')}}">Inventory</a></li>
<li class="breadcrumb-item">Upload Snapshot</li> <li class="breadcrumb-item active">{{ page_title }}</li>
</ol> </ol>
</nav> </nav>
</div><!-- End Page Title --> </div><!-- End Page Title -->