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
This commit is contained in:
PrivateRookie 2018-09-02 23:31:17 +08:00 committed by privaterookie
parent 010859e78d
commit afa1746054
2 changed files with 27 additions and 3 deletions

View File

@ -33,6 +33,7 @@
'horizon.dashboard.container-infra.cluster-templates.details' 'horizon.dashboard.container-infra.cluster-templates.details'
]) ])
.constant('horizon.dashboard.container-infra.cluster-templates.events', events()) .constant('horizon.dashboard.container-infra.cluster-templates.events', events())
.constant('horizon.dashboard.container-infra.cluster-templates.distros', distros())
.constant( .constant(
'horizon.dashboard.container-infra.cluster-templates.resourceType', 'horizon.dashboard.container-infra.cluster-templates.resourceType',
'OS::Magnum::ClusterTemplate') '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 = [ run.$inject = [
'horizon.framework.conf.resource-type-registry.service', 'horizon.framework.conf.resource-type-registry.service',
'horizon.dashboard.container-infra.cluster-templates.service', 'horizon.dashboard.container-infra.cluster-templates.service',

View File

@ -30,10 +30,20 @@
'horizon.framework.util.i18n.gettext', 'horizon.framework.util.i18n.gettext',
'horizon.app.core.openstack-service-api.magnum', 'horizon.app.core.openstack-service-api.magnum',
'horizon.app.core.openstack-service-api.nova', '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 = { var workflow = {
init: init, init: init,
update: update update: update
@ -507,7 +517,10 @@
function onGetImages(response) { function onGetImages(response) {
images = [{value:"", name: gettext("Choose an Image")}]; images = [{value:"", name: gettext("Choose an Image")}];
angular.forEach(response.data.items, function(item) { angular.forEach(response.data.items, function(item) {
if (!angular.isUndefined(item.properties) &&
distros.indexOf(item.properties.os_distro) >= 0) {
images.push({value: item.name, name: item.name}); images.push({value: item.name, name: item.name});
}
}); });
form[0].tabs[1].items[0].items[0].items[0].titleMap = images; form[0].tabs[1].items[0].items[0].items[0].titleMap = images;
var deferred = $q.defer(); var deferred = $q.defer();