diff --git a/css/style.css b/css/style.css index 29a434d0..23dd23e9 100644 --- a/css/style.css +++ b/css/style.css @@ -104,4 +104,10 @@ th h4 { font-weight: bold; } th h4 {font-size: 16px;} -th h4 small {font-size: 12px;} \ No newline at end of file +th h4 small {font-size: 12px;} + + +select option[default] { + color: #999; + font-style: italic; +} \ No newline at end of file diff --git a/js/app.js b/js/app.js index 3b0a7fc2..eab7eda5 100644 --- a/js/app.js +++ b/js/app.js @@ -221,8 +221,22 @@ app = Sammy('#main', function (sam) { * Filters * */ - sam.before({except: {path: ['#/login', '#/postinstall']}}, function (req) { + sam.before(['#/apps/install/:app'], function (req){ + // Preload domains list. + req.params.domains = []; + req.api('/domains', function(data) { + req.params.domains = data.Domains; + }); + }); + sam.before(['#/apps/install/:app'], function (req){ + // Preload users lists. + req.params.users = []; + req.api('/users', function(data) { + req.params.users = data.Users; + }); + }); + sam.before({except: {path: ['#/login', '#/postinstall']}}, function (req) { // Store path for further redirections store.set('path-1', store.get('path')); store.set('path', req.path); @@ -505,7 +519,37 @@ app = Sammy('#main', function (sam) { sam.get('#/apps/install/:app', function (c) { c.api('/apps?raw=true', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8 - c.view('app_install', data[c.params['app']]); + appData = data[c.params['app']]; + + $.each(appData.manifest.arguments.install, function(k, v) { + appData.manifest.arguments.install[k].allowedValues = []; + + // Special case for domain input. + // Display a list of available domains + if (v.name == 'domain') { + $.each(c.params.domains, function(key, domain){ + appData.manifest.arguments.install[k].allowedValues.push({ + value: domain, + label: domain, + }); + }) + appData.manifest.arguments.install[k].help = "Manage domains"; + } + + // Special case for admin input. + // Display a list of available users + if (v.name == 'admin') { + $.each(c.params.users, function(key, user){ + appData.manifest.arguments.install[k].allowedValues.push({ + value: user.Username, + label: user.Fullname+' ('+user.Mail+')' + }); + }) + appData.manifest.arguments.install[k].help = "Manage users"; + } + }); + + c.view('app_install', appData); }); }); diff --git a/views/app_install.ms b/views/app_install.ms index a7c065f1..6d2a6d4e 100644 --- a/views/app_install.ms +++ b/views/app_install.ms @@ -37,7 +37,18 @@
+ {{#if allowedValues}} + + {{else}} + {{/if}} + + {{#if help}} + {{{help}}} + {{/if}}
{{/manifest.arguments.install}}