Skip to content

Commit

Permalink
Merge "Make 'switch' between legacy and Angular Images"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Aug 8, 2016
2 parents cc76e4c + 20bc6e1 commit 1b65c53
Show file tree
Hide file tree
Showing 24 changed files with 199 additions and 147 deletions.
12 changes: 12 additions & 0 deletions doc/source/topics/settings.rst
Expand Up @@ -180,6 +180,18 @@ A dictionary containing classes of exceptions which Horizon's centralized
exception handling should be aware of. Based on these exception categories,
Horizon will handle the exception and display a message to the user.

``images_panel``
-----------

.. versionadded:: 10.0.0(Newton)

Default: ``legacy``

There are currently two panel types that may be specified: ``legacy`` and
``angular``. ``legacy`` will display the Python-based (server-side) Images
panel and ``angular`` will display the Angular-based (client-side) Images
panel.

``modal_backdrop``
------------------

Expand Down
26 changes: 17 additions & 9 deletions openstack_dashboard/dashboards/admin/images/urls.py
Expand Up @@ -16,16 +16,24 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.conf import settings
from django.conf.urls import url

from openstack_dashboard.dashboards.admin.images import views


urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^create/$', views.CreateView.as_view(), name='create'),
url(r'^(?P<image_id>[^/]+)/update/$',
views.UpdateView.as_view(), name='update'),
url(r'^(?P<image_id>[^/]+)/detail/$',
views.DetailView.as_view(), name='detail')
]
if settings.HORIZON_CONFIG['images_panel'] == 'angular':
# New angular images
urlpatterns = [
url(r'^$', views.AngularIndexView.as_view(), name='index'),
url(r'^(?P<image_id>[^/]+)/detail/$',
views.AngularIndexView.as_view(), name='detail'),
]
else:
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^create/$', views.CreateView.as_view(), name='create'),
url(r'^(?P<image_id>[^/]+)/update/$',
views.UpdateView.as_view(), name='update'),
url(r'^(?P<image_id>[^/]+)/detail/$',
views.DetailView.as_view(), name='detail')
]
5 changes: 5 additions & 0 deletions openstack_dashboard/dashboards/admin/images/views.py
Expand Up @@ -23,6 +23,7 @@
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.views import generic

from horizon import exceptions
from horizon import messages
Expand All @@ -40,6 +41,10 @@
LOG = logging.getLogger(__name__)


class AngularIndexView(generic.TemplateView):
template_name = 'angular.html'


class IndexView(tables.DataTableView):
DEFAULT_FILTERS = {'is_public': None}
table_class = project_tables.AdminImagesTable
Expand Down
21 changes: 15 additions & 6 deletions openstack_dashboard/dashboards/project/images/images/urls.py
Expand Up @@ -16,14 +16,23 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.conf import settings
from django.conf.urls import url

from openstack_dashboard.dashboards.project.images.images import views
from openstack_dashboard.dashboards.project.images import views as imgviews


urlpatterns = [
url(r'^create/$', views.CreateView.as_view(), name='create'),
url(r'^(?P<image_id>[^/]+)/update/$',
views.UpdateView.as_view(), name='update'),
url(r'^(?P<image_id>[^/]+)/$', views.DetailView.as_view(), name='detail'),
]
if settings.HORIZON_CONFIG['images_panel'] == 'angular':
urlpatterns = [
url(r'^(?P<image_id>[^/]+)/$', imgviews.AngularIndexView.as_view(),
name='detail'),
]
else:
urlpatterns = [
url(r'^create/$', views.CreateView.as_view(), name='create'),
url(r'^(?P<image_id>[^/]+)/update/$',
views.UpdateView.as_view(), name='update'),
url(r'^(?P<image_id>[^/]+)/$', views.DetailView.as_view(),
name='detail'),
]
19 changes: 14 additions & 5 deletions openstack_dashboard/dashboards/project/images/urls.py
Expand Up @@ -16,6 +16,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.conf import settings
from django.conf.urls import include
from django.conf.urls import url

Expand All @@ -26,8 +27,16 @@
from openstack_dashboard.dashboards.project.images import views


urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'', include(image_urls, namespace='images')),
url(r'', include(snapshot_urls, namespace='snapshots')),
]
if settings.HORIZON_CONFIG['images_panel'] == 'angular':
# New angular images
urlpatterns = [
url(r'^$', views.AngularIndexView.as_view(), name='index'),
url(r'', include(image_urls, namespace='images')),
url(r'', include(snapshot_urls, namespace='snapshots')),
]
else:
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'', include(image_urls, namespace='images')),
url(r'', include(snapshot_urls, namespace='snapshots')),
]
5 changes: 5 additions & 0 deletions openstack_dashboard/dashboards/project/images/views.py
Expand Up @@ -22,6 +22,7 @@
"""

from django.utils.translation import ugettext_lazy as _
from django.views import generic

from horizon import exceptions
from horizon import messages
Expand All @@ -34,6 +35,10 @@
import tables as images_tables


class AngularIndexView(generic.TemplateView):
template_name = 'angular.html'


class IndexView(tables.DataTableView):
table_class = images_tables.ImagesTable
template_name = 'project/images/index.html'
Expand Down
5 changes: 0 additions & 5 deletions openstack_dashboard/dashboards/project/instances/tests.py
Expand Up @@ -1276,11 +1276,6 @@ def test_create_instance_snapshot(self):
server.id,
"snapshot1").AndReturn(self.snapshots.first())

api.glance.image_list_detailed(IsA(http.HttpRequest),
marker=None,
paginate=True) \
.AndReturn([[], False, False])

self.mox.ReplayAll()

formData = {'instance_id': server.id,
Expand Down
Empty file.
23 changes: 0 additions & 23 deletions openstack_dashboard/dashboards/project/ngimages/panel.py

This file was deleted.

22 changes: 0 additions & 22 deletions openstack_dashboard/dashboards/project/ngimages/urls.py

This file was deleted.

19 changes: 0 additions & 19 deletions openstack_dashboard/dashboards/project/ngimages/views.py

This file was deleted.

14 changes: 14 additions & 0 deletions openstack_dashboard/enabled/_1050_project_images_panel.py
@@ -1,3 +1,17 @@
# (c) Copyright 2016 Hewlett Packard Enterprise Development Company LP
#
# 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.

# The slug of the panel to be added to HORIZON_CONFIG. Required.
PANEL = 'images'
# The slug of the dashboard the PANEL associated with. Required.
Expand Down
30 changes: 0 additions & 30 deletions openstack_dashboard/enabled/_1051_project_ng_images_panel.py

This file was deleted.

1 change: 1 addition & 0 deletions openstack_dashboard/settings.py
Expand Up @@ -79,6 +79,7 @@
'js_spec_files': [],
'external_templates': [],
'plugins': [],
'images_panel': 'legacy',
'integration_tests_support': INTEGRATION_TESTS_SUPPORT
}

Expand Down
18 changes: 17 additions & 1 deletion openstack_dashboard/static/app/core/images/images.module.js
Expand Up @@ -295,9 +295,25 @@
var path = $windowProvider.$get().STATIC_URL + 'app/core/images/';
$provide.constant('horizon.app.core.images.basePath', path);

$routeProvider.when('/project/ngimages/', {
$routeProvider.when('/project/images/:id/', {
redirectTo: goToAngularDetails
});

$routeProvider.when('/admin/images/:id/detail/', {
redirectTo: goToAngularDetails
});

$routeProvider.when('/project/images/', {
templateUrl: path + 'panel.html'
});

$routeProvider.when('/admin/images/', {
templateUrl: path + 'panel.html'
});

function goToAngularDetails(params) {
return 'project/ngdetails/OS::Glance::Image/' + params.id;
}
}

})();
3 changes: 3 additions & 0 deletions openstack_dashboard/test/integration_tests/config.py
Expand Up @@ -57,6 +57,9 @@
]

ImageGroup = [
cfg.StrOpt('panel_type',
default='legacy',
help='type/version of images panel'),
cfg.StrOpt('http_image',
default='http://download.cirros-cloud.net/0.3.1/'
'cirros-0.3.1-x86_64-uec.tar.gz',
Expand Down

0 comments on commit 1b65c53

Please sign in to comment.