From 9255a0da7b3d0e6b217954f0c1b3b1b0c99141f2 Mon Sep 17 00:00:00 2001 From: emersonfelipesp Date: Wed, 11 May 2022 20:21:33 +0000 Subject: [PATCH 1/2] Add navigation buttons replicating Proxmox's Folder View --- netbox_proxbox/navigation.py | 16 +++++++++ netbox_proxbox/urls.py | 31 ++++++++--------- netbox_proxbox/views.py | 64 ++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 17 deletions(-) diff --git a/netbox_proxbox/navigation.py b/netbox_proxbox/navigation.py index 59482d3..3b3af28 100755 --- a/netbox_proxbox/navigation.py +++ b/netbox_proxbox/navigation.py @@ -6,6 +6,22 @@ link="plugins:netbox_proxbox:home", link_text="Home", ), + PluginMenuItem( + link="plugins:netbox_proxbox:nodes", + link_text="Nodes", + ), + PluginMenuItem( + link="plugins:netbox_proxbox:lxc", + link_text="LXC Container", + ), + PluginMenuItem( + link="plugins:netbox_proxbox:virtual_machine", + link_text="Virtual Machine", + ), + PluginMenuItem( + link="plugins:netbox_proxbox:storage", + link_text="Storage", + ), ) ''' diff --git a/netbox_proxbox/urls.py b/netbox_proxbox/urls.py index d870873..c47dc99 100755 --- a/netbox_proxbox/urls.py +++ b/netbox_proxbox/urls.py @@ -2,34 +2,31 @@ from django.http import HttpResponse from django.urls import path -from .views import ( - HomeView, - ProxmoxVMCreateView, - ProxmoxVMDeleteView, - ProxmoxVMEditView, - ProxmoxVMListView, - ProxmoxVMView, - ProxmoxFullUpdate, -) +from . import views from netbox_proxbox import proxbox_api import json urlpatterns = [ # Home View - path('', HomeView.as_view(), name='home'), - + path('', views.HomeView.as_view(), name='home'), + path('lxc/', views.LxcListView.as_view(), name='lxc'), + path('nodes/', views.NodesListView.as_view(), name='nodes'), + path('resource-pool/', views.ResourcePoolListView.as_view(), name='resource_pool'), + path('virtual-machine/', views.VirtualMachineListView.as_view(), name='virtual_machine'), + path('virtual-machine/', views.StorageListView.as_view(), name='storage'), + # Base Views - path("list/", ProxmoxVMListView.as_view(), name="proxmoxvm_list"), + path("list/", views.ProxmoxVMListView.as_view(), name="proxmoxvm_list"), # = plugins/netbox_proxmoxvm/ | example: plugins/netbox_proxmoxvm/1/ # ProxmoxVMView.as_view() - as.view() is need so that our view class can process requests. # as_view() takes request and returns well-formed response, that is a class based view. - path("/", ProxmoxVMView.as_view(), name="proxmoxvm"), - path("add/", ProxmoxVMCreateView.as_view(), name="proxmoxvm_add"), - path("/delete/", ProxmoxVMDeleteView.as_view(), name="proxmoxvm_delete"), - path("/edit/", ProxmoxVMEditView.as_view(), name="proxmoxvm_edit"), + path("/", views.ProxmoxVMView.as_view(), name="proxmoxvm"), + path("add/", views.ProxmoxVMCreateView.as_view(), name="proxmoxvm_add"), + path("/delete/", views.ProxmoxVMDeleteView.as_view(), name="proxmoxvm_delete"), + path("/edit/", views.ProxmoxVMEditView.as_view(), name="proxmoxvm_edit"), # Proxbox API full update #path("full_update/", ProxmoxVMFullUpdate.as_view(), name="proxmoxvm_full_update") - path("full_update/", ProxmoxFullUpdate.as_view(), name="proxmoxvm_full_update") + path("full_update/", views.ProxmoxFullUpdate.as_view(), name="proxmoxvm_full_update") ] diff --git a/netbox_proxbox/views.py b/netbox_proxbox/views.py index b2584f8..bff4363 100755 --- a/netbox_proxbox/views.py +++ b/netbox_proxbox/views.py @@ -32,6 +32,70 @@ def get(self, request): ) +class LxcListView(View): + """LXC Container's List""" + template_name = 'netbox_proxbox/home.html' + + # service incoming GET HTTP requests + def get(self, request): + """Get request.""" + return render( + request, + self.template_name, + ) + + +class NodesListView(View): + """Nodes' List""" + template_name = 'netbox_proxbox/home.html' + + # service incoming GET HTTP requests + def get(self, request): + """Get request.""" + return render( + request, + self.template_name, + ) + + +class ResourcePoolListView(View): + """Resource Pool's List""" + template_name = 'netbox_proxbox/home.html' + + # service incoming GET HTTP requests + def get(self, request): + """Get request.""" + return render( + request, + self.template_name, + ) + + +class VirtualMachineListView(View): + """Virtual Machine's List""" + template_name = 'netbox_proxbox/home.html' + + # service incoming GET HTTP requests + def get(self, request): + """Get request.""" + return render( + request, + self.template_name, + ) + + +class StorageListView(View): + """Storage's List""" + template_name = 'netbox_proxbox/home.html' + + # service incoming GET HTTP requests + def get(self, request): + """Get request.""" + return render( + request, + self.template_name, + ) + class ProxmoxFullUpdate(PermissionRequiredMixin, View): """Full Update of Proxmox information on Netbox.""" From 5ea14f93cd5106d24a77cfcf0076e5e6a656381d Mon Sep 17 00:00:00 2001 From: emersonfelipesp Date: Wed, 11 May 2022 20:24:52 +0000 Subject: [PATCH 2/2] Fix 'storage' URL path --- netbox_proxbox/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox_proxbox/urls.py b/netbox_proxbox/urls.py index c47dc99..1648c33 100755 --- a/netbox_proxbox/urls.py +++ b/netbox_proxbox/urls.py @@ -14,7 +14,7 @@ path('nodes/', views.NodesListView.as_view(), name='nodes'), path('resource-pool/', views.ResourcePoolListView.as_view(), name='resource_pool'), path('virtual-machine/', views.VirtualMachineListView.as_view(), name='virtual_machine'), - path('virtual-machine/', views.StorageListView.as_view(), name='storage'), + path('storage/', views.StorageListView.as_view(), name='storage'), # Base Views path("list/", views.ProxmoxVMListView.as_view(), name="proxmoxvm_list"),