mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 17:38:37 -06:00
Adds image preview back on the table (#12739)
* adds image preview on image attachment #12627 * adds bootstrap initialization for hx-trigger=load #12627 --------- Co-authored-by: jeremystretch <jstretch@netboxlabs.com>
This commit is contained in:
parent
1f71d3570a
commit
9b9a559e0c
@ -22,6 +22,14 @@ __all__ = (
|
|||||||
'WebhookTable',
|
'WebhookTable',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IMAGEATTACHMENT_IMAGE = '''
|
||||||
|
{% if record.image %}
|
||||||
|
<a class="image-preview" href="{{ record.image.url }}" target="_blank">{{ record }}</a>
|
||||||
|
{% else %}
|
||||||
|
—
|
||||||
|
{% endif %}
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
class CustomFieldTable(NetBoxTable):
|
class CustomFieldTable(NetBoxTable):
|
||||||
name = tables.Column(
|
name = tables.Column(
|
||||||
@ -96,6 +104,9 @@ class ImageAttachmentTable(NetBoxTable):
|
|||||||
parent = tables.Column(
|
parent = tables.Column(
|
||||||
linkify=True
|
linkify=True
|
||||||
)
|
)
|
||||||
|
image = tables.TemplateColumn(
|
||||||
|
template_code=IMAGEATTACHMENT_IMAGE,
|
||||||
|
)
|
||||||
size = tables.Column(
|
size = tables.Column(
|
||||||
orderable=False,
|
orderable=False,
|
||||||
verbose_name='Size (bytes)'
|
verbose_name='Size (bytes)'
|
||||||
|
BIN
netbox/project-static/dist/netbox.js
vendored
BIN
netbox/project-static/dist/netbox.js
vendored
Binary file not shown.
BIN
netbox/project-static/dist/netbox.js.map
vendored
BIN
netbox/project-static/dist/netbox.js.map
vendored
Binary file not shown.
@ -2,9 +2,10 @@ import { getElements, isTruthy } from './util';
|
|||||||
import { initButtons } from './buttons';
|
import { initButtons } from './buttons';
|
||||||
import { initSelect } from './select';
|
import { initSelect } from './select';
|
||||||
import { initObjectSelector } from './objectSelector';
|
import { initObjectSelector } from './objectSelector';
|
||||||
|
import { initBootstrap } from './bs';
|
||||||
|
|
||||||
function initDepedencies(): void {
|
function initDepedencies(): void {
|
||||||
for (const init of [initButtons, initSelect, initObjectSelector]) {
|
for (const init of [initButtons, initSelect, initObjectSelector, initBootstrap]) {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,4 +23,8 @@ export function initHtmx(): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const element of getElements('[hx-trigger=load]')) {
|
||||||
|
element.addEventListener('htmx:afterSettle', initDepedencies);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user