Add Servers table
Change-Id: Ib8cbe11a86efd5c38678aa2cb56a106f601ce5a8
This commit is contained in:
parent
d60f86eff8
commit
a8af4b2972
mogan_ui
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
from django.views import generic
|
from django.views import generic
|
||||||
|
|
||||||
from mogan_ui.api import client
|
from mogan_ui.api import mogan
|
||||||
|
|
||||||
from openstack_dashboard.api.rest import urls
|
from openstack_dashboard.api.rest import urls
|
||||||
from openstack_dashboard.api.rest import utils as rest_utils
|
from openstack_dashboard.api.rest import utils as rest_utils
|
||||||
@ -30,5 +30,5 @@ class Servers(generic.View):
|
|||||||
:param request: HTTP request.
|
:param request: HTTP request.
|
||||||
:return: servers.
|
:return: servers.
|
||||||
"""
|
"""
|
||||||
servers = client.server_list(request)
|
servers = mogan.server_list(request)
|
||||||
return {'servers': [s.to_dict() for s in servers]}
|
return {'servers': [s.to_dict() for s in servers]}
|
||||||
|
34
mogan_ui/content/servers/tables.py
Normal file
34
mogan_ui/content/servers/tables.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Copyright 2017 Huawei Technologies Co.,LTD.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from horizon import tables
|
||||||
|
|
||||||
|
|
||||||
|
class ServersTable(tables.DataTable):
|
||||||
|
|
||||||
|
name = tables.WrappingColumn(
|
||||||
|
"name",
|
||||||
|
verbose_name=_("Name"))
|
||||||
|
status = tables.Column("status",
|
||||||
|
verbose_name=_("Status"))
|
||||||
|
|
||||||
|
def get_object_id(self, obj):
|
||||||
|
return obj.uuid
|
||||||
|
|
||||||
|
class Meta(object):
|
||||||
|
name = "servers"
|
||||||
|
verbose_name = _("Servers")
|
7
mogan_ui/content/servers/templates/servers/index.html
Normal file
7
mogan_ui/content/servers/templates/servers/index.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block title %}{% trans "Servers" %}{% endblock %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
{{ table.render }}
|
||||||
|
{% endblock %}
|
@ -14,10 +14,8 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from mogan_ui.content.servers import views
|
||||||
from horizon.browsers import views
|
|
||||||
|
|
||||||
title = _("Servers")
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url('', views.AngularIndexView.as_view(title=title), name='index'),
|
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||||
]
|
]
|
||||||
|
37
mogan_ui/content/servers/views.py
Normal file
37
mogan_ui/content/servers/views.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# Copyright 2017 Huawei Technologies Co.,LTD.
|
||||||
|
# All Rights Reserved.
|
||||||
|
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from mogan_ui.api import mogan
|
||||||
|
from mogan_ui.content.servers.tables import ServersTable
|
||||||
|
|
||||||
|
from horizon import exceptions
|
||||||
|
from horizon import tables
|
||||||
|
|
||||||
|
|
||||||
|
class IndexView(tables.DataTableView):
|
||||||
|
table_class = ServersTable
|
||||||
|
template_name = 'project/servers/index.html'
|
||||||
|
page_title = _("Servers")
|
||||||
|
|
||||||
|
def get_data(self):
|
||||||
|
try:
|
||||||
|
servers = mogan.server_list(self.request)
|
||||||
|
except Exception:
|
||||||
|
servers = []
|
||||||
|
msg = _('Unable to retrieve servers.')
|
||||||
|
exceptions.handle(self.request, msg)
|
||||||
|
return servers
|
Loading…
x
Reference in New Issue
Block a user