* custom device field web display and edit * make display work; relies on T::T calling dict slot or method with same syntax * add storing port custom fields * use resultset method instead, use cf_ prefix * update Pg min ver for jsonb * allow override of position and default for port custom fields * support hidden for custom fields * update description of Objects API class * allow left and mid position for custom fields * add custom fields in csv * change port control sidebar label * fix default missing bug on backend jobs
		
			
				
	
	
		
			282 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			282 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| [% SET user_can_port_control = user_has_role('port_control') %]
 | |
| <table class="table table-condensed table-striped">
 | |
|   <tbody>
 | |
|     <tr>
 | |
|       <td>System Name</td>
 | |
|       <td>[% d.name | html_entity %]</td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Canonical IP</td>
 | |
|       <td>[% d.ip | html_entity %]</td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Location
 | |
|       [% IF user_can_port_control %]
 | |
|       <i class="icon-edit nd_edit-icon nd_device-details-edit"></i>
 | |
|       [% END %]
 | |
|       </td>
 | |
|       [% IF user_can_port_control %]
 | |
|       <td class="nd_editable-cell" contenteditable="true"
 | |
|         data-field="location" data-for-device="[% d.ip | html_entity %]">
 | |
|           [% d.location | html_entity %]
 | |
|       </td>
 | |
|       [% ELSE %]
 | |
|       <td>
 | |
|         <a rel="tooltip" data-placement="top" data-offset="5" data-title="Find Similar Devices"
 | |
|         href="[% search_device | none %]&q=[% d.location | uri %]&location=[% d.location | uri %]">[% d.location | html_entity %]</a>
 | |
|       </td>
 | |
|       [% END %]
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Contact
 | |
|       [% IF user_can_port_control %]
 | |
|       <i class="icon-edit nd_edit-icon nd_device-details-edit"></i>
 | |
|       [% END %]
 | |
|       </td>
 | |
|       [% IF user_can_port_control %]
 | |
|       <td class="nd_editable-cell" contenteditable="true"
 | |
|         data-field="contact" data-for-device="[% d.ip | html_entity %]">
 | |
|           [% d.contact | html_entity %]
 | |
|       </td>
 | |
|       [% ELSE %]
 | |
|       <td>[% d.contact | html_entity %]</td>
 | |
|       [% END %]
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Vendor / Model</td>
 | |
|       <td>
 | |
|         <a rel="tooltip" data-placement="top" data-offset="5" data-title="Find Similar Devices"
 | |
|         href="[% search_device | none %]&q=[% d.vendor | uri %]&vendor=[% d.vendor | uri %]">[% d.vendor | html_entity %]</a>
 | |
|         /
 | |
|         <a rel="tooltip" data-placement="top" data-offset="5" data-title="Find Similar Devices"
 | |
|         href="[% search_device | none %]&q=[% d.model | uri %]&model=[% d.model | uri %]">[% d.model | html_entity %]</a>
 | |
|       </td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>OS / Version</td>
 | |
|       <td>
 | |
|         <a rel="tooltip" data-placement="top" data-offset="5" data-title="Find Similar Devices"
 | |
|         href="[% search_device | none %]&q=[% d.os | uri %]&os=[% d.os | uri %]">[% d.os | html_entity %]</a>
 | |
|         /
 | |
|         <a rel="tooltip" data-placement="top" data-offset="5" data-title="Find Similar Devices"
 | |
|         href="[% search_device | none %]&q=[% d.os_ver | uri %]&os_ver=[% d.os_ver | uri %]">[% d.os_ver | html_entity %]</a>
 | |
|       </td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Serial Number</td>
 | |
|       <td>[% d.serial | html_entity %]</td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Chassis ID</td>
 | |
|       <td>[% d.chassis_id | html_entity %]</td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Description</td>
 | |
|       <td>[% d.description | html_entity | html_line_break %]</td>
 | |
|     </tr>
 | |
|     [% IF settings._extra_device_details.size %]
 | |
|     [% FOREACH config IN settings._extra_device_details %]
 | |
|     <tr>
 | |
|       <td>
 | |
|           [% config.label | html_entity %]
 | |
|           [% IF config.editable AND user_can_port_control %]
 | |
|           <i class="icon-edit nd_edit-icon nd_device-details-edit"></i>
 | |
|           [% END %]
 | |
|       </td>
 | |
|       [% TRY %]
 | |
|         <td>
 | |
|         [% INCLUDE "plugin/${config.name}/device_details.tt" %]
 | |
|         </td>
 | |
|       [% CATCH %]
 | |
|         [% CLEAR %]
 | |
|         [% IF config.editable AND user_can_port_control %]
 | |
|           <td class="nd_editable-cell" contenteditable="true"
 | |
|             data-field="[% config.field | html_entity %]" data-for-device="[% d.ip | html_entity %]">
 | |
|         [% ELSE %]
 | |
|           <td>
 | |
|         [% END %]
 | |
|           [% d.${config.field} | html_entity %]
 | |
|           </td>
 | |
|       [% END %]
 | |
|     </tr>
 | |
|     [% END %]
 | |
|     [% END %]
 | |
|     <tr>
 | |
|       <td>Administration</td>
 | |
|       <td>
 | |
|         <a href="ssh://[% d.ip | uri %]" target="_blank">
 | |
|           <span class="label label-info"><i class="icon-keyboard"></i> SSH</span></a>
 | |
|         <a href="telnet://[% d.ip | uri %]" target="_blank">
 | |
|           <span class="label label-info"><i class="icon-keyboard"></i> Telnet</span></a>
 | |
|         <a href="https://[% d.ip | uri %]/" target="_blank">
 | |
|           <span class="label label-info"><i class="icon-external-link"></i> Web</span></a>
 | |
|       </td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>SNMP Class</td>
 | |
|       <td><a target="_blank" href="https://metacpan.org/pod/[% d.snmp_class | uri %]">[% d.snmp_class | html_entity %]</a></td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Uptime</td>
 | |
|       <td>[% d.uptime_age | html_entity %]</td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Layers</td>
 | |
|       <td>
 | |
|         [% (d.layers.substr(7,1) ? '<span class="badge badge-success">1</span>' : '<span class="badge"> </span>') | none %]
 | |
|         [% (d.layers.substr(6,1) ? '<span class="badge badge-success">2</span>' : '<span class="badge"> </span>') | none %]
 | |
|         [% (d.layers.substr(5,1) ? '<span class="badge badge-success">3</span>' : '<span class="badge"> </span>') | none %]
 | |
|         [% (d.layers.substr(4,1) ? '<span class="badge badge-success">4</span>' : '<span class="badge"> </span>') | none %]
 | |
|         [% (d.layers.substr(3,1) ? '<span class="badge badge-success">5</span>' : '<span class="badge"> </span>') | none %]
 | |
|         [% (d.layers.substr(2,1) ? '<span class="badge badge-success">6</span>' : '<span class="badge"> </span>') | none %]
 | |
|         [% (d.layers.substr(1,1) ? '<span class="badge badge-success">7</span>' : '<span class="badge"> </span>') | none %]
 | |
|       </td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Last Discover</td>
 | |
|       <td>[% d.last_discover_stamp | html_entity %]</td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Last Arpnip</td>
 | |
|       <td>[% d.last_arpnip_stamp | html_entity %]</td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Last Macsuck</td>
 | |
|       <td>[% d.last_macsuck_stamp | html_entity %]</td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>Hardware Status</td>
 | |
|       <td>Fan: [% d.fan | html_entity %]
 | |
|         <br/>PS1 [[% d.ps1_type | html_entity %]]: [% d.ps1_status | html_entity %]
 | |
|         <br/>PS2 [[% d.ps2_type | html_entity %]]: [% d.ps2_status | html_entity %]</td>
 | |
|     </tr>
 | |
|     [% IF p.size %]
 | |
|     <tr>
 | |
|       <td>PoE Status</td>
 | |
|       <td>
 | |
|       [% FOREACH m IN p %]
 | |
|         [% UNLESS m.module == 1 %]
 | |
|           <br/>
 | |
|         [% END %]
 | |
|         Module [% m.module | html_entity %]: [% m.status | html_entity %], [% m.poe_capable_ports | html_entity %] power-capable ports, [% m.poe_powered_ports | html_entity %] powered ([% m.poe_disabled_ports | html_entity %] admin disabled, [% m.poe_errored_ports | html_entity %] errors), [% m.poe_power_committed | html_entity %]/[% m.power | html_entity %] watts committed.
 | |
|       [% END %]
 | |
|       </td>
 | |
|     </tr>
 | |
|     [% END %]
 | |
|     <tr>
 | |
|       <td>MAC Address</td>
 | |
|       <td>[% d.mac | html_entity %]</td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|       <td>VTP Domain</td>
 | |
|       <td>[% d.vtp_domain | html_entity %]</td>
 | |
|     </tr>
 | |
|     [% IF user_has_role('admin') %]
 | |
|     <tr data-for-device="[% d.ip | html_entity %]">
 | |
|       <td>Admin Tasks</td>
 | |
|       <td>
 | |
|         <input type="hidden" data-form="discover" value="[% d.ip | html_entity %]" name="device"/>
 | |
|         <button class="btn btn-info btn-small nd_adminbutton" name="discover">Discover</button>
 | |
| 
 | |
|         [% IF d.layers.substr(5,1) %]
 | |
|         <input type="hidden" data-form="arpnip" value="[% d.ip | html_entity %]" name="device"/>
 | |
|         <button class="btn btn-info btn-small nd_adminbutton" name="arpnip">Arpnip</button>
 | |
|         [% ELSE %]
 | |
|         <button class="btn btn-default btn-small disabled">Arpnip</button>
 | |
|         [% END %]
 | |
| 
 | |
|         [% IF d.layers.substr(6,1) %]
 | |
|         <input type="hidden" data-form="macsuck" value="[% d.ip | html_entity %]" name="device"/>
 | |
|         <button class="btn btn-info btn-small nd_adminbutton" name="macsuck">Macsuck</button>
 | |
|         [% ELSE %]
 | |
|         <button class="btn btn-default btn-small disabled">Macsuck</button>
 | |
|         [% END %]
 | |
| 
 | |
|         <input type="hidden" data-form="nbtstat" value="[% d.ip | html_entity %]" name="device"/>
 | |
|         <button class="btn btn-info btn-small nd_adminbutton" name="nbtstat">NBTstat</button>
 | |
| 
 | |
|         [% IF NOT d.is_pseudo %]
 | |
|         <span class="dropdown">
 | |
|           <button class="nd_snap_btn btn [% d.has_snapshot ? 'btn-success' : 'btn-info' %] btn-small dropdown-toggle" type="button" id="snapshotmenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
 | |
|             Snapshot
 | |
|             <span class="caret"></span>
 | |
|           </button>
 | |
|           <ul class="dropdown-menu" aria-labelledby="snapshotmenu">
 | |
|             <input type="hidden" data-form="snapshot_req" value="[% d.ip | html_entity %]" name="device"/>
 | |
|             <li><a href="#" class="nd_adminbutton" name="snapshot_req"><i class="icon-edit"></i> Create</a></li>
 | |
| 
 | |
|             <li class='nd_snap_func [% 'disabled' UNLESS d.has_snapshot %]'><a href="[% uri_for('/ajax/content/admin/snapshot_get') | none %]?device=[% d.ip | uri %]"><i class="icon-download-alt"></i> Download</a></li>
 | |
| 
 | |
|             <input type="hidden" data-form="snapshot_del" value="[% d.ip | html_entity %]" name="device"/>
 | |
|             <li class='nd_snap_func [% 'disabled' UNLESS d.has_snapshot %]'><a href="#" class="nd_adminbutton" name="snapshot_del"><i class="icon-trash"></i> Delete</a></li>
 | |
|           </ul>
 | |
|         </span>
 | |
|         [% END %]
 | |
| 
 | |
|         <button class="btn btn-danger btn-small pull-right"
 | |
|           data-toggle="modal" data-target="#nd_devdel" type="button">Delete</button>
 | |
| 
 | |
|         <button class="btn btn-danger btn-small pull-right nd_pull-right-admin-button"
 | |
|           data-toggle="modal" data-target="#nd_devrenumber" type="button">Change IP</button>
 | |
| 
 | |
| 
 | |
|         <div id="nd_devdel" class="nd_modal nd_deep-horizon modal hide fade" tabindex="-1"
 | |
|           role="dialog" aria-labelledby="nd_devdel-label" aria-hidden="true">
 | |
|           <div class="modal-header">
 | |
|             <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
 | |
|             <h3 id="nd_devdel-label">Confirm Delete: [% d.dns || d.ip | html_entity %]</h3>
 | |
|           </div>
 | |
|           <div class="modal-body">
 | |
|             <blockquote>
 | |
|               <ul>
 | |
|                 <li><p>This action is immediate and not reversible</p></li>
 | |
|                 <li><p>All associated Nodes may be removed from the database</p></li>
 | |
|               </ul>
 | |
|             </blockquote>
 | |
|             <textarea id="nd_devdel-log" class="input-block-level" rows="2" data-form="delete"
 | |
|               placeholder="Enter a log message" name="log"></textarea>
 | |
|             <label class="checkbox">
 | |
|               <input id="nd_devdel-archive" type="checkbox" data-form="delete" name="archive">
 | |
|               <h4 class="nd_unbolden">Archive Nodes</h4>
 | |
|             </label>
 | |
|             <input type="hidden" data-form="delete" value="[% d.ip | html_entity %]" name="device"/>
 | |
|           </div>
 | |
|           <div class="modal-footer">
 | |
|             <button class="btn btn-success" data-dismiss="modal" aria-hidden="true">Cancel</button>
 | |
|             <button class="btn btn-danger nd_adminbutton" name="delete" data-dismiss="modal">Confirm</button>
 | |
|           </div>
 | |
|         </div>
 | |
| 
 | |
|         <div id="nd_devrenumber" class="nd_modal nd_deep-horizon modal hide fade" tabindex="-1"
 | |
|           role="dialog" aria-labelledby="nd_devrenumber-label" aria-hidden="true">
 | |
|           <div class="modal-header">
 | |
|             <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
 | |
|             <h3 id="nd_devrenumber-label">Confirm Renumber: [% d.dns || d.ip | html_entity %]</h3>
 | |
|           </div>
 | |
|           <div class="modal-body">
 | |
|             <blockquote>
 | |
|               <ul>
 | |
|                 <li><p>This action is run immediately</p></li>
 | |
|                 <li><p>You can to change to an existing interface IP or a new IP</p></li>
 | |
|                 <li><p>No check is made as to whether the new IP is reachable</p></li>
 | |
|               </ul>
 | |
|             </blockquote>
 | |
|             <label>Enter new IP address: <input list="interfaces" name="newip" data-form="renumber"/></label>
 | |
|             <datalist id="interfaces">
 | |
|               [% FOREACH i IN interfaces %]
 | |
|               <option value="[% i.alias | html_entity %]">[% i.dns | html_entity %]</option>
 | |
|               [% END %]
 | |
|             </datalist>
 | |
|             <input type="hidden" data-form="renumber" value="[% d.ip | html_entity %]" name="device"/>
 | |
|           </div>
 | |
|           <div class="modal-footer">
 | |
|             <button class="btn btn-success" data-dismiss="modal" aria-hidden="true">Cancel</button>
 | |
|             <button class="btn btn-danger nd_adminbutton" name="renumber" data-dismiss="modal">Confirm</button>
 | |
|           </div>
 | |
|         </div>
 | |
|       </td>
 | |
|     </tr>
 | |
|     [% END %]
 | |
|   </tbody>
 | |
| </table>
 |