diff --git a/src/bower.json b/src/bower.json index 970655e5..fc63d134 100644 --- a/src/bower.json +++ b/src/bower.json @@ -6,7 +6,7 @@ "dependencies": { "bootstrap": "3.3.6", "font-awesome": "4.5.0", - "handlebars": "1.3.0", + "handlebars": "4.0.11", "sammy": "0.7.6", "js-cookie": "2.1.0", "source-sans-pro": "git://github.com/adobe-fonts/source-sans-pro.git#2.020R-ro/1.075R-it", diff --git a/src/js/yunohost/controllers/apps.js b/src/js/yunohost/controllers/apps.js index 2dd11cf9..2da7f490 100644 --- a/src/js/yunohost/controllers/apps.js +++ b/src/js/yunohost/controllers/apps.js @@ -160,6 +160,34 @@ }); }); + // Get app config panel + app.get('#/apps/:app/config-panel', function (c) { + c.api('/apps/'+c.params['app']+'/config-panel', function(data) { + c.view('app/app_config-panel', data); + }); + }); + + app.post('#/apps/:app/config', function(c) { + // taken from app install + $.each(c.params, function(k, v) { + if (typeof(v) === 'object' && Array.isArray(v)) { + // And return only first value + c.params[k] = v[0]; + } + }); + + var app_id = c.params['app']; + delete c.params['app']; + + var params = { + 'args': c.serialize(c.params.toHash()) + } + + c.api('/apps/'+app_id+'/config', function() { // http://api.yunohost.org/#!/app/app_install_post_2 + c.redirect('#/apps/'+app_id+'/config-panel'); + }, 'POST', params); + }) + // Special case for custom app installation. app.get('#/apps/install/custom', function (c) { // If we try to GET /apps/install/custom, it means that installation fail. diff --git a/src/js/yunohost/main.js b/src/js/yunohost/main.js index fd566a82..0d87feb2 100644 --- a/src/js/yunohost/main.js +++ b/src/js/yunohost/main.js @@ -49,7 +49,7 @@ + options.fn(this) + ''); }); - + // Load tooltips on the page; needed if using tooltips Handlebars.registerHelper('load_tooltips', function() { return new Handlebars.SafeString( @@ -60,6 +60,25 @@ + ''); }); + // equality stuff because mustache/Handlebars is lame + // source https://stackoverflow.com/a/31632215 + Handlebars.registerHelper('eq', function(a, b) { + return a === b; + }); + + Handlebars.registerHelper('neq', function(a, b) { + return a !== b; + }); + + Handlebars.registerHelper('in', function(a) { + // skip first one + for (var i = 1; i < arguments.length; ++i) { + if (arguments[i] == a) + return true; + } + return false; + }); + // Look for supported type of storage to use /** * http://sammyjs.org/docs/api/0.7.4/all#Sammy.Store.LocalStorage diff --git a/src/locales/en.json b/src/locales/en.json index cce50853..effae38a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -136,6 +136,7 @@ "error_server": "Server error", "error_server_unexpected": "Unexpected server error (%s)", "everyone_has_access": "Everyone has access.", + "experimental_warning": "Warning: this feature is experimental and not consider stable, you shouldn't be using it except if you know what you are doing.", "filesystem": "Filesystem", "firewall": "Firewall", "footer_version" : "Powered by YunoHost %s (%s).", diff --git a/src/views/app/app_config-panel.ms b/src/views/app/app_config-panel.ms new file mode 100644 index 00000000..3d00f64c --- /dev/null +++ b/src/views/app/app_config-panel.ms @@ -0,0 +1,73 @@ +
+ + + +