Merge pull request #269 from resin-io/jviotti/feature/device-type-in-app-list

Show device types when selecting applications
This commit is contained in:
Juan Cruz Viotti 2015-11-23 23:39:34 -04:00
commit b881e23c1c
2 changed files with 23 additions and 4 deletions

View File

@ -52,7 +52,12 @@
return form.ask({
message: 'Select an application',
type: 'list',
choices: _.pluck(applications, 'app_name')
choices: _.map(applications, function(application) {
return {
name: application.app_name + " (" + application.device_type + ")",
value: application.app_name
};
})
});
});
};
@ -63,7 +68,12 @@
return;
}
return resin.models.application.getAll().then(function(applications) {
applications = _.pluck(applications, 'app_name');
applications = _.map(applications, function(application) {
return {
name: application.app_name + " (" + application.device_type + ")",
value: application.app_name
};
});
applications.unshift({
name: 'Create a new application',
value: null

View File

@ -35,13 +35,22 @@ exports.selectApplication = (filter) ->
return form.ask
message: 'Select an application'
type: 'list'
choices: _.pluck(applications, 'app_name')
choices: _.map applications, (application) ->
return {
name: "#{application.app_name} (#{application.device_type})"
value: application.app_name
}
exports.selectOrCreateApplication = ->
resin.models.application.hasAny().then (hasAnyApplications) ->
return if not hasAnyApplications
resin.models.application.getAll().then (applications) ->
applications = _.pluck(applications, 'app_name')
applications = _.map applications, (application) ->
return {
name: "#{application.app_name} (#{application.device_type})"
value: application.app_name
}
applications.unshift
name: 'Create a new application'
value: null