panels.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. from django.utils.translation import gettext_lazy as _
  2. from netbox.ui import attrs, panels
  3. class DataSourcePanel(panels.ObjectAttributesPanel):
  4. title = _('Data Source')
  5. name = attrs.TextAttr('name')
  6. type = attrs.ChoiceAttr('type')
  7. enabled = attrs.BooleanAttr('enabled')
  8. status = attrs.ChoiceAttr('status')
  9. sync_interval = attrs.ChoiceAttr('sync_interval', label=_('Sync interval'))
  10. last_synced = attrs.DateTimeAttr('last_synced', label=_('Last synced'))
  11. description = attrs.TextAttr('description')
  12. source_url = attrs.TemplatedAttr(
  13. 'source_url',
  14. label=_('URL'),
  15. template_name='core/datasource/attrs/source_url.html',
  16. )
  17. ignore_rules = attrs.TemplatedAttr(
  18. 'ignore_rules',
  19. label=_('Ignore rules'),
  20. template_name='core/datasource/attrs/ignore_rules.html',
  21. )
  22. class DataSourceBackendPanel(panels.ObjectPanel):
  23. template_name = 'core/panels/datasource_backend.html'
  24. title = _('Backend')
  25. class DataFilePanel(panels.ObjectAttributesPanel):
  26. title = _('Data File')
  27. source = attrs.RelatedObjectAttr('source', linkify=True)
  28. path = attrs.TextAttr('path', style='font-monospace', copy_button=True)
  29. last_updated = attrs.DateTimeAttr('last_updated')
  30. size = attrs.TemplatedAttr('size', template_name='core/datafile/attrs/size.html')
  31. hash = attrs.TextAttr('hash', label=_('SHA256 hash'), style='font-monospace', copy_button=True)
  32. class DataFileContentPanel(panels.ObjectPanel):
  33. template_name = 'core/panels/datafile_content.html'
  34. title = _('Content')
  35. class JobPanel(panels.ObjectAttributesPanel):
  36. title = _('Job')
  37. object_type = attrs.TemplatedAttr(
  38. 'object_type',
  39. label=_('Object type'),
  40. template_name='core/job/attrs/object_type.html',
  41. )
  42. name = attrs.TextAttr('name')
  43. status = attrs.ChoiceAttr('status')
  44. error = attrs.TextAttr('error')
  45. user = attrs.TextAttr('user', label=_('Created by'))
  46. class JobSchedulingPanel(panels.ObjectAttributesPanel):
  47. title = _('Scheduling')
  48. created = attrs.DateTimeAttr('created')
  49. scheduled = attrs.TemplatedAttr('scheduled', template_name='core/job/attrs/scheduled.html')
  50. started = attrs.DateTimeAttr('started')
  51. completed = attrs.DateTimeAttr('completed')
  52. queue = attrs.TextAttr('queue_name', label=_('Queue'))
  53. class ObjectChangePanel(panels.ObjectAttributesPanel):
  54. title = _('Change')
  55. time = attrs.DateTimeAttr('time')
  56. user = attrs.TemplatedAttr(
  57. 'user_name',
  58. label=_('User'),
  59. template_name='core/objectchange/attrs/user.html',
  60. )
  61. action = attrs.ChoiceAttr('action')
  62. changed_object_type = attrs.TextAttr(
  63. 'changed_object_type',
  64. label=_('Object type'),
  65. )
  66. changed_object = attrs.TemplatedAttr(
  67. 'object_repr',
  68. label=_('Object'),
  69. template_name='core/objectchange/attrs/changed_object.html',
  70. )
  71. message = attrs.TextAttr('message')
  72. request_id = attrs.TemplatedAttr(
  73. 'request_id',
  74. label=_('Request ID'),
  75. template_name='core/objectchange/attrs/request_id.html',
  76. )