Skip to content

Commit

Permalink
filter sizes on ec2 based on virtual type of selected image
Browse files Browse the repository at this point in the history
  • Loading branch information
fakiolinho committed Mar 10, 2016
1 parent 9df819c commit e98905b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/mist/io/static/js/app/controllers/machine_add.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ define('app/controllers/machine_add', ['ember', 'yamljs'],
newMachineLibvirtDiskSize: 4,
newMachineLibvirtImagePath: null,

//
// Computed properties
//

newMachineSizesOptions: Ember.computed('newMachineProvider', 'newMachineImage', function() {
var provider = this.get('newMachineProvider.provider'),
image = this.get('newMachineImage');

if (provider && provider.indexOf('ec2') > -1 && image && image.extra) {
var virtualization_type = image.extra.virtualization_type;
if (virtualization_type) {
console.log('ec2');
var filteredSizes = this.get('newMachineProvider.sizes.model').filter(function(size, index) {
return size.extra.virtualizationTypes.indexOf(virtualization_type) > -1;
}, this);

return filteredSizes;
}
}

return this.get('newMachineProvider.sizes.model');
}),

//
// Methods
Expand Down
2 changes: 1 addition & 1 deletion src/mist/io/static/js/app/templates/machine_add.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<h4>{{Mist.machineAddController.newMachineSize.name}}</h4>

<ul data-role="listview" >
{{#each Mist.machineAddController.newMachineProvider.sizes.model as |size|}}
{{#each Mist.machineAddController.newMachineSizesOptions as |size|}}
<li data-icon="false">
<a {{action "selectSize" size target=view}} title="{{size.name}} - disk:{{size.disk}}, ram:{{size.ram}}">{{size.name}}
<span class="size-decription">
Expand Down

0 comments on commit e98905b

Please sign in to comment.