From afa174605400421d68a5490797d6254ee569b90a Mon Sep 17 00:00:00 2001 From: PrivateRookie <996514515@qq.com> Date: Sun, 2 Sep 2018 23:31:17 +0800 Subject: [PATCH] When selecting a image for cluster, many invalid images are shown. If a project has a lot of images, options can be quite long, and cause wrong selctiong by mistake. So I add a filter after fetching images, now images that has "os_distro" property and it's value is one of "fedora-atomic", "coreos" and "ubuntu" are shown Story: 2003614 Task: 25739 Change-Id: I8db4422f4cf528da0ec592525851cc2c709fff7c --- .../cluster-templates.module.js | 11 +++++++++++ .../workflow/workflow.service.js | 19 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/cluster-templates.module.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/cluster-templates.module.js index a1054c66..a8959523 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/cluster-templates.module.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/cluster-templates.module.js @@ -33,6 +33,7 @@ 'horizon.dashboard.container-infra.cluster-templates.details' ]) .constant('horizon.dashboard.container-infra.cluster-templates.events', events()) + .constant('horizon.dashboard.container-infra.cluster-templates.distros', distros()) .constant( 'horizon.dashboard.container-infra.cluster-templates.resourceType', 'OS::Magnum::ClusterTemplate') @@ -52,6 +53,16 @@ }; } + /** + * @ngdoc constant + * @name distros + * @return [distros] available image distros + * @description A list available image distros for magnum + */ + function distros() { + return ["fedora-atomic", "coreos", "ubuntu"]; + } + run.$inject = [ 'horizon.framework.conf.resource-type-registry.service', 'horizon.dashboard.container-infra.cluster-templates.service', diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/workflow/workflow.service.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/workflow/workflow.service.js index 44fad6c7..dcc1dfad 100644 --- a/magnum_ui/static/dashboard/container-infra/cluster-templates/workflow/workflow.service.js +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/workflow/workflow.service.js @@ -30,10 +30,20 @@ 'horizon.framework.util.i18n.gettext', 'horizon.app.core.openstack-service-api.magnum', 'horizon.app.core.openstack-service-api.nova', - 'horizon.app.core.openstack-service-api.glance' + 'horizon.app.core.openstack-service-api.glance', + 'horizon.dashboard.container-infra.cluster-templates.distros' ]; - function ClusterTemplateWorkflow($q, basePath, workflowService, gettext, magnum, nova, glance) { + function ClusterTemplateWorkflow( + $q, + basePath, + workflowService, + gettext, + magnum, + nova, + glance, + distros + ) { var workflow = { init: init, update: update @@ -507,7 +517,10 @@ function onGetImages(response) { images = [{value:"", name: gettext("Choose an Image")}]; angular.forEach(response.data.items, function(item) { - images.push({value: item.name, name: item.name}); + if (!angular.isUndefined(item.properties) && + distros.indexOf(item.properties.os_distro) >= 0) { + images.push({value: item.name, name: item.name}); + } }); form[0].tabs[1].items[0].items[0].items[0].titleMap = images; var deferred = $q.defer();