Basic structure of the freezer web ui integrated in horizon

This commit add to the repo the basic structure of the web ui
integrated with Horizon. There currently nothing under the Freezer
tab, this is only a base point to start to develop the Freezer
ui content.

Basic installation instructionr are available in the file
horizon_web_ui/README.rst

Change-Id: I6e1ef399c869494ec1c5c9dd52a6d9adfd9360c9
LAUNCHPAD: https://blueprints.launchpad.net/freezer/+spec/horizon-webui
This commit is contained in:
Fausto Marzi 2014-10-27 16:17:44 +00:00
commit dbfdee6487
17 changed files with 187 additions and 0 deletions

26
README.rst Normal file
View File

@ -0,0 +1,26 @@
========================
Freezer - Horizon Web UI
=======================
Freezer now has basic support for a Web UI integrated with OpenStack Horizon.
In the installation procedure we'll assume your main Horizon dashboard
directory is /opt/stack/horizon/openstack_dashboard/dashboards/.
To install the horizon web ui you need to do the following::
# git clone https://github.com/stackforge/freezer
# cd freezer/horizon_web_ui
# cp -r devfreezer /opt/stack/horizon/openstack_dashboard/dashboards/
# cp _50_devfreezer.py /opt/stack/horizon/openstack_dashboard/enabled/
# cd /opt/stack/horizon/
# ./run_tests.sh --runserver 0.0.0.0:8878
Now a new Tab is available in the dashboard lists on the left,
called "Backup as a Service" and a sub tab called "Freezer".

10
_50_devfreezer.py Normal file
View File

@ -0,0 +1,10 @@
# The name of the dashboard to be added to HORIZON['dashboards']. Required.
DASHBOARD = 'devfreezer'
# If set to True, this dashboard will not be added to the settings.
DISABLED = False
# A list of applications to be added to INSTALLED_APPS.
ADD_INSTALLED_APPS = [
'openstack_dashboard.dashboards.devfreezer',
]

0
devfreezer/__init__.py Normal file
View File

13
devfreezer/dashboard.py Normal file
View File

@ -0,0 +1,13 @@
from django.utils.translation import ugettext_lazy as _
import horizon
class Devfreezer(horizon.Dashboard):
name = _("Backup as a Service")
slug = "devfreezer"
panels = ('freezerweb',) # Add your panels here.
default_panel = 'freezerweb' # Specify the slug of the dashboard's default panel.
horizon.register(Devfreezer)

View File

View File

@ -0,0 +1,3 @@
"""
Stub file to work around django bug: https://code.djangoproject.com/ticket/7198
"""

View File

@ -0,0 +1,13 @@
from django.utils.translation import ugettext_lazy as _
import horizon
from openstack_dashboard.dashboards.devfreezer import dashboard
class Freezerweb(horizon.Panel):
name = _("Freezer")
slug = "freezerweb"
dashboard.Devfreezer.register(Freezerweb)

View File

@ -0,0 +1,15 @@
from django.utils.translation import ugettext_lazy as _
from horizon import tables
class InstancesTable(tables.DataTable):
name = tables.Column("name", verbose_name=_("Name"))
status = tables.Column("status", verbose_name=_("Status"))
zone = tables.Column('availability_zone',
verbose_name=_("Availability Zone"))
image_name = tables.Column('image_name', verbose_name=_("Image Name"))
class Meta:
name = "instances"
verbose_name = _("Instances")

View File

@ -0,0 +1,39 @@
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
from openstack_dashboard import api
from openstack_dashboard.dashboards.devfreezer.freezerweb import tables
class InstanceTab(tabs.TableTab):
name = _("Instances Tab")
slug = "instances_tab"
table_classes = (tables.InstancesTable,)
template_name = ("horizon/common/_detail_table.html")
preload = False
def has_more_data(self, table):
return self._has_more
def get_instances_data(self):
try:
marker = self.request.GET.get(
tables.InstancesTable._meta.pagination_param, None)
instances, self._has_more = api.nova.server_list(
self.request,
search_opts={'marker': marker, 'paginate': True})
return instances
except Exception:
self._has_more = False
error_message = _('Unable to get instances')
exceptions.handle(self.request, error_message)
class MypanelTabs(tabs.TabGroup):
slug = "mypanel_tabs"
tabs = (InstanceTab,)
sticky = True

View File

@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Freezer Web Interface" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Freezer Web Interface") %}
{% endblock page_header %}
{% block devfreezer_main %}
<div class="row">
<div class="col-sm-12">
{{ tab_group.render }}
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,7 @@
from horizon.test import helpers as test
class FreezerwebTests(test.TestCase):
# Unit tests for freezerweb.
def test_me(self):
self.assertTrue(1 + 1 == 2)

View File

@ -0,0 +1,12 @@
from django.conf.urls import patterns
from django.conf.urls import url
from .views import IndexView
from openstack_dashboard.dashboards.devfreezer.freezerweb import views
urlpatterns = patterns('',
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^\?tab=mypanel_tabs_tab$',
views.IndexView.as_view(), name='mypanel_tabs')
)

View File

@ -0,0 +1,16 @@
from horizon import views
from horizon import tabs
from openstack_dashboard.dashboards.devfreezer.freezerweb \
import tabs as mydashboard_tabs
class IndexView(tabs.TabbedTableView):
tab_group_class = mydashboard_tabs.MypanelTabs
# A very simple class-based view...
template_name = 'devfreezer/freezerweb/index.html'
def get_data(self, request, context, *args, **kwargs):
# Add data to the context here...
return context

3
devfreezer/models.py Normal file
View File

@ -0,0 +1,3 @@
"""
Stub file to work around django bug: https://code.djangoproject.com/ticket/7198
"""

View File

@ -0,0 +1 @@
/* Additional CSS for devfreezer. */

View File

@ -0,0 +1 @@
/* Additional JavaScript for devfreezer. */

View File

@ -0,0 +1,11 @@
{% extends 'base.html' %}
{% block sidebar %}
{% include 'horizon/common/_sidebar.html' %}
{% endblock %}
{% block main %}
{% include "horizon/_messages.html" %}
{% block devfreezer_main %}{% endblock %}
{% endblock %}