Просмотр исходного кода

#6372: Simplify & streamline table config & table filter elements

checktheroads 4 лет назад
Родитель
Сommit
ae5c2d49c6

+ 1 - 5
netbox/templates/dcim/device/consoleports.html

@@ -6,11 +6,7 @@
 {% block content %}
   <form method="post">
     {% csrf_token %}
-    <div class="float-end noprint">
-      {% if request.user.is_authenticated %}
-        <button type="button" class="btn btn-outline-dark btn-sm" data-bs-toggle="modal" data-bs-target="#DeviceConsolePortTable_config" title="Configure table"><i class="mdi mdi-cog"></i> Configure</button>
-      {% endif %}
-    </div>
+    {% include 'inc/table_controls.html' with table_modal="DeviceConsolePortTable_config" %}
     {% render_table consoleport_table 'inc/table.html' %}
     <div class="noprint">
         {% if perms.dcim.change_consoleport %}

+ 1 - 5
netbox/templates/dcim/device/consoleserverports.html

@@ -6,11 +6,7 @@
 {% block content %}
   <form method="post">
     {% csrf_token %}
-    <div class="float-end noprint">
-      {% if request.user.is_authenticated %}
-        <button type="button" class="btn btn-outline-dark btn-sm" data-bs-toggle="modal" data-bs-target="#DeviceConsoleServerPortTable_config" title="Configure table"><i class="mdi mdi-cog"></i> Configure</button>
-      {% endif %}
-    </div>
+    {% include 'inc/table_controls.html' with table_modal="DeviceConsoleServerPortTable_config" %}
     {% render_table consoleserverport_table 'inc/table.html' %}
     <div class="noprint">
         {% if perms.dcim.change_consoleserverport %}

+ 1 - 5
netbox/templates/dcim/device/devicebays.html

@@ -6,11 +6,7 @@
 {% block content %}
   <form method="post">
     {% csrf_token %}
-    <div class="float-end noprint">
-      {% if request.user.is_authenticated %}
-        <button type="button" class="btn btn-outline-dark btn-sm" data-bs-toggle="modal" data-bs-target="#DeviceDeviceBayTable_config" title="Configure table"><i class="mdi mdi-cog"></i> Configure</button>
-      {% endif %}
-    </div>
+    {% include 'inc/table_controls.html' with table_modal="DeviceDeviceBayTable_config" %}
     {% render_table devicebay_table 'inc/table.html' %}
     <div class="noprint">
         {% if perms.dcim.change_devicebay %}

+ 1 - 5
netbox/templates/dcim/device/frontports.html

@@ -6,11 +6,7 @@
 {% block content %}
   <form method="post">
     {% csrf_token %}
-    <div class="float-end noprint">
-      {% if request.user.is_authenticated %}
-        <button type="button" class="btn btn-outline-dark btn-sm" data-bs-toggle="modal" data-bs-target="#DeviceFrontPortTable_config" title="Configure table"><i class="mdi mdi-cog"></i> Configure</button>
-      {% endif %}
-    </div>
+    {% include 'inc/table_controls.html' with table_modal="DeviceFrontPortTable_config" %}
     {% render_table frontport_table 'inc/table.html' %}
     <div class="noprint">
         {% if perms.dcim.change_frontport %}

+ 19 - 13
netbox/templates/dcim/device/interfaces.html

@@ -6,26 +6,32 @@
 {% block content %}
   <form method="post">
     {% csrf_token %}
-    <div class="float-end col-md-4 noprint table-controls mw-33">
-        <div class="input-group input-group-sm">
-            <input type="text" class="form-control interface-filter" placeholder="Filter" title="Filter text (regular expressions supported)" />
-            <button class="btn btn-sm btn-outline-dark dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
-                <i class="mdi mdi-table-cog"></i>
-            </button>
-            <ul class="dropdown-menu">
+    <div class="row mb-3 justify-content-between">
+        <div class="col col-md-2 float-end noprint table-controls mb-0 mw-33">
+            <div class="input-group input-group-sm">
                 {% if request.user.is_authenticated %}
                     <button
                         type="button"
-                        class="dropdown-item"
+                        class="btn btn-sm btn-outline-dark"
                         data-bs-toggle="modal"
                         data-bs-target="#DeviceInterfaceTable_config"
                         title="Configure Table">
-                        Configure Table
+                        <i class="mdi mdi-cog"></i> Configure Table
                     </button>
-                {% endif %}
-                <button type="button" class="dropdown-item toggle-enabled" data-state="show">Hide Enabled</button>
-                <button type="button" class="dropdown-item toggle-disabled" data-state="show">Hide Disabled</button>
-            </ul>
+                    {% endif %}
+                <button class="btn btn-sm btn-outline-dark dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
+                    <i class="mdi mdi-eye"></i>
+                </button>
+                <ul class="dropdown-menu">
+                    <button type="button" class="dropdown-item toggle-enabled" data-state="show">Hide Enabled</button>
+                    <button type="button" class="dropdown-item toggle-disabled" data-state="show">Hide Disabled</button>
+                </ul>
+            </div>
+        </div>
+        <div class="col col-md-4 float-end noprint table-controls mw-33">
+            <div class="input-group input-group-sm">
+                <input type="text" class="form-control interface-filter" placeholder="Filter" title="Filter text (regular expressions supported)" />
+            </div>
         </div>
     </div>
     {% render_table interface_table 'inc/table.html' %}

+ 1 - 5
netbox/templates/dcim/device/inventory.html

@@ -6,11 +6,7 @@
 {% block content %}
   <form method="post">
     {% csrf_token %}
-    <div class="float-end noprint">
-      {% if request.user.is_authenticated %}
-        <button type="button" class="btn btn-outline-dark btn-sm" data-bs-toggle="modal" data-bs-target="#DeviceInventoryItemTable_config" title="Configure table"><i class="mdi mdi-cog"></i> Configure</button>
-      {% endif %}
-    </div>
+    {% include 'inc/table_controls.html' with table_modal="DeviceInventoryItemTable_config" %}
     {% render_table inventoryitem_table 'inc/table.html' %}
     <div class="noprint">
         {% if perms.dcim.change_inventoryitem %}

+ 1 - 5
netbox/templates/dcim/device/poweroutlets.html

@@ -6,11 +6,7 @@
 {% block content %}
   <form method="post">
     {% csrf_token %}
-    <div class="float-end noprint">
-      {% if request.user.is_authenticated %}
-        <button type="button" class="btn btn-outline-dark btn-sm" data-bs-toggle="modal" data-bs-target="#DevicePowerOutletTable_config" title="Configure table"><i class="mdi mdi-cog"></i> Configure</button>
-      {% endif %}
-    </div>
+    {% include 'inc/table_controls.html' with table_modal="DevicePowerOutletTable_config" %}
     {% render_table poweroutlet_table 'inc/table.html' %}
     <div class="noprint">
         {% if perms.dcim.change_powerport %}

+ 1 - 5
netbox/templates/dcim/device/powerports.html

@@ -6,11 +6,7 @@
 {% block content %}
   <form method="post">
     {% csrf_token %}
-    <div class="float-end noprint">
-      {% if request.user.is_authenticated %}
-        <button type="button" class="btn btn-outline-dark btn-sm" data-bs-toggle="modal" data-bs-target="#DevicePowerPortTable_config" title="Configure table"><i class="mdi mdi-cog"></i> Configure</button>
-      {% endif %}
-    </div>
+    {% include 'inc/table_controls.html' with table_modal="DevicePowerPortTable_config" %}
     {% render_table powerport_table 'inc/table.html' %}
     <div class="noprint">
         {% if perms.dcim.change_powerport %}

+ 1 - 5
netbox/templates/dcim/device/rearports.html

@@ -6,11 +6,7 @@
 {% block content %}
   <form method="post">
     {% csrf_token %}
-    <div class="float-end noprint">
-      {% if request.user.is_authenticated %}
-        <button type="button" class="btn btn-outline-dark btn-sm" data-bs-toggle="modal" data-bs-target="#DeviceRearPortTable_config" title="Configure table"><i class="mdi mdi-cog"></i> Configure</button>
-      {% endif %}
-    </div>
+    {% include 'inc/table_controls.html' with table_modal="DeviceRearPortTable_config" %}
     {% render_table rearport_table 'inc/table.html' %}
     <div class="noprint">
         {% if perms.dcim.change_rearport %}

+ 1 - 21
netbox/templates/generic/object_list.html

@@ -58,27 +58,7 @@
 {% endif %}
 
 {# Object list filter, table config #}
-<div class="row mb-3">
-  <div class="col col-md-4 offset-md-8 d-flex noprint table-controls">
-    <div class="input-group input-group-sm">
-      <input type="text" class="form-control object-filter" placeholder="Filter" title="Filter text (regular expressions supported)" />
-      {% if request.user.is_authenticated and table_config_form %}
-        <button type="button" class="btn btn-outline-dark btn-sm" data-bs-toggle="modal" data-bs-target="#ObjectTable_config" title="Configure Table">
-          <i class="mdi mdi-table-eye"></i>
-        </button>
-      {% endif %}
-      {% if filter_form %}
-      <button
-        type="button"
-        class="btn btn-sm btn-outline-dark"
-        data-bs-toggle="collapse"
-        data-bs-target="#advanced-search-content">
-        Advanced Search
-      </button>
-    {% endif %}
-    </div>
-  </div>
-</div>
+{% include 'inc/table_controls.html' with table_modal="ObjectTable_config" %}
 
 {# Object table #}
 <div class="row">

+ 37 - 0
netbox/templates/inc/table_controls.html

@@ -0,0 +1,37 @@
+<div class="row mb-3 justify-content-between">
+    <div class="col col-md-2 mb-0 d-flex noprint table-controls">
+        {% if request.user.is_authenticated %}
+            <div class="input-group input-group-sm">
+                <button
+                    type="button"
+                    data-bs-toggle="modal"
+                    title="Configure Table"
+                    data-bs-target="#{{ table_modal }}"
+                    class="btn btn-sm btn-outline-dark"
+                    >
+                    <i class="mdi mdi-cog"></i> Configure Table
+                </button>
+            </div>
+        {% endif %}
+    </div>
+    <div class="col col-md-4 d-flex noprint table-controls">
+        <div class="input-group input-group-sm">
+            <input
+                type="text"
+                class="form-control object-filter"
+                placeholder="Filter"
+                title="Filter text (regular expressions supported)"
+            />
+            {% if filter_form %}
+                <button
+                    type="button"
+                    class="btn btn-sm btn-outline-dark"
+                    data-bs-toggle="collapse"
+                    data-bs-target="#advanced-search-content"
+                >
+                    Advanced Search
+                </button>
+            {% endif %}
+        </div>
+    </div>
+</div>

+ 1 - 8
netbox/templates/virtualization/virtualmachine/interfaces.html

@@ -6,14 +6,7 @@
 {% block content %}
   <form method="post">
     {% csrf_token %}
-    <div class="float-end col-md-4 noprint table-controls mw-33">
-        <div class="input-group input-group-sm">
-            <input type="text" class="form-control interface-filter" placeholder="Filter" title="Filter text (regular expressions supported)" />
-            {% if request.user.is_authenticated %}
-                <button type="button" class="btn btn-outline-dark btn-sm" data-bs-toggle="modal" data-bs-target="#VirtualMachineVMInterfaceTable_config" title="Configure Table"><i class="mdi mdi-table-eye"></i></button>
-            {% endif %}
-        </div>
-    </div>
+    {% include 'inc/table_controls.html' with table_modal="VirtualMachineVMInterfaceTable_config" %}
     {% render_table interface_table 'inc/table.html' %}
     <div class="noprint">
         {% if perms.virtualization.change_vminterface %}