From cc2e1887eaedbb9a09464ddd892326cb7ad2f246 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 18 Jun 2018 03:35:25 +0200 Subject: [PATCH 01/10] [enh] increase version number of handlebars.js --- src/bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From df213fba3f02c0d2f6c26a77ca7aab1a890782af Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 18 Jun 2018 03:35:57 +0200 Subject: [PATCH 02/10] [enh] add handlebars 'eq' and 'in' helpers --- src/js/yunohost/main.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/js/yunohost/main.js b/src/js/yunohost/main.js index fd566a82..be18e2f5 100644 --- a/src/js/yunohost/main.js +++ b/src/js/yunohost/main.js @@ -60,6 +60,21 @@ + ''); }); + // equality stuff because mustache/Handlebars is lame + // source https://stackoverflow.com/a/31632215 + Handlebars.registerHelper('eq', 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 From 8d9028356e92ef3fd04a19ca4e70eb7d5e44ff6b Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 18 Jun 2018 03:36:42 +0200 Subject: [PATCH 03/10] [enh] display app config panel --- src/js/yunohost/controllers/apps.js | 7 +++ src/views/app/app_config-panel.ms | 70 +++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/views/app/app_config-panel.ms diff --git a/src/js/yunohost/controllers/apps.js b/src/js/yunohost/controllers/apps.js index 2dd11cf9..42708dfd 100644 --- a/src/js/yunohost/controllers/apps.js +++ b/src/js/yunohost/controllers/apps.js @@ -160,6 +160,13 @@ }); }); + // 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); + }); + }); + // 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/views/app/app_config-panel.ms b/src/views/app/app_config-panel.ms new file mode 100644 index 00000000..205c75b8 --- /dev/null +++ b/src/views/app/app_config-panel.ms @@ -0,0 +1,70 @@ + + +
+ +{{#if config_panel}} + +
+{{#config_panel}} +

{{name}}

+
+{{#panel}} +
+ +
+
+
+ {{#sections}} +
+

{{name}} {{help}}

+
+
    + {{#options}} +
    + +
    + {{#if (in type "number" "text" "password" "color" "date" "datetime-local" "email" "month number" "range" "search" "tel" "time" "url" "week")}} + + {{ help }} + {{else if (eq type "bool")}} + yes + no + {{ help }} + {{/if}} +
    +
    + {{/options}} +
+ +
+
+ {{/sections}} + +
+
+
+
+
+
+{{/panel}} +{{/config_panel}} +
+ +{{else}} +
+ + {{t 'app_config_panel_no_panel'}} +
+{{/if}} From 02698404faf8d566286f94672dafa9fa5d64f551 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 18 Jun 2018 04:08:25 +0200 Subject: [PATCH 04/10] [enh] open first config panel panel by default --- src/js/yunohost/main.js | 4 ++++ src/views/app/app_config-panel.ms | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/js/yunohost/main.js b/src/js/yunohost/main.js index be18e2f5..969ee85f 100644 --- a/src/js/yunohost/main.js +++ b/src/js/yunohost/main.js @@ -66,6 +66,10 @@ 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) { diff --git a/src/views/app/app_config-panel.ms b/src/views/app/app_config-panel.ms index 205c75b8..7598bdaf 100644 --- a/src/views/app/app_config-panel.ms +++ b/src/views/app/app_config-panel.ms @@ -23,7 +23,7 @@ -
+
{{#sections}} From 0e24afd0d210064163ad1d972f82a7ae376d10e3 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 18 Jun 2018 04:08:59 +0200 Subject: [PATCH 05/10] [enh] display app name on config panel --- src/views/app/app_config-panel.ms | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/views/app/app_config-panel.ms b/src/views/app/app_config-panel.ms index 7598bdaf..ff2b8597 100644 --- a/src/views/app/app_config-panel.ms +++ b/src/views/app/app_config-panel.ms @@ -1,8 +1,8 @@
@@ -11,7 +11,7 @@
{{#config_panel}} -

{{name}}

+

{{../app_name}} configuration panel


{{#panel}}
From bacc9c5e7c13b8eca6feab0bb7e44b38ae561825 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 18 Jun 2018 04:09:35 +0200 Subject: [PATCH 06/10] [mod] trailing spaces --- src/js/yunohost/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/yunohost/main.js b/src/js/yunohost/main.js index 969ee85f..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( From 1444883b9a73fadbf8339e8c28d34394246f730e Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 18 Jun 2018 04:19:46 +0200 Subject: [PATCH 07/10] [enh] modifying a section of a config panel works --- src/js/yunohost/controllers/apps.js | 21 +++++++++++++++++++++ src/views/app/app_config-panel.ms | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/js/yunohost/controllers/apps.js b/src/js/yunohost/controllers/apps.js index 42708dfd..2da7f490 100644 --- a/src/js/yunohost/controllers/apps.js +++ b/src/js/yunohost/controllers/apps.js @@ -167,6 +167,27 @@ }); }); + 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/views/app/app_config-panel.ms b/src/views/app/app_config-panel.ms index ff2b8597..34417f8f 100644 --- a/src/views/app/app_config-panel.ms +++ b/src/views/app/app_config-panel.ms @@ -25,7 +25,7 @@
- + {{#sections}}

{{name}} {{help}}

@@ -36,7 +36,7 @@
{{#if (in type "number" "text" "password" "color" "date" "datetime-local" "email" "month number" "range" "search" "tel" "time" "url" "week")}} - + {{ help }} {{else if (eq type "bool")}} yes From 2dc80c445c1319527ad1378b520bcea96733d01b Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Fri, 22 Jun 2018 04:21:52 +0200 Subject: [PATCH 08/10] [fix] bug in synchronisation of collapse on config-panel page --- src/views/app/app_config-panel.ms | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/app/app_config-panel.ms b/src/views/app/app_config-panel.ms index 34417f8f..0ed4b038 100644 --- a/src/views/app/app_config-panel.ms +++ b/src/views/app/app_config-panel.ms @@ -23,7 +23,7 @@
-
+
{{#sections}} From 4c20f5bad9fe1d6a1cdeca491d161943e4acc37d Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Fri, 22 Jun 2018 04:24:17 +0200 Subject: [PATCH 09/10] [enh] add experimental warning for config-panel --- src/locales/en.json | 1 + src/views/app/app_config-panel.ms | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/locales/en.json b/src/locales/en.json index 8fc55239..b4715959 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 index 0ed4b038..3d00f64c 100644 --- a/src/views/app/app_config-panel.ms +++ b/src/views/app/app_config-panel.ms @@ -7,6 +7,9 @@
+ + + {{#if config_panel}}
From df67dd6a440ce1d2bc69798a75103a1b1b79127a Mon Sep 17 00:00:00 2001 From: frju365 <19982894+frju365@users.noreply.github.com> Date: Fri, 22 Jun 2018 15:58:17 +0200 Subject: [PATCH 10/10] [enh] Add ynh.fr (#199) * Update postinstall.js * Update domains.js --- src/js/yunohost/controllers/domains.js | 2 +- src/js/yunohost/controllers/postinstall.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/yunohost/controllers/domains.js b/src/js/yunohost/controllers/domains.js index 94096d4b..259b8b08 100644 --- a/src/js/yunohost/controllers/domains.js +++ b/src/js/yunohost/controllers/domains.js @@ -40,7 +40,7 @@ c.params.ddomains = data.map(function(dom){return '.'+dom;}); }) .fail(function() { - c.params.ddomains = ['.nohost.me', '.noho.st']; + c.params.ddomains = ['.nohost.me', '.noho.st', '.ynh.fr']; }) .always(function() { var data = { diff --git a/src/js/yunohost/controllers/postinstall.js b/src/js/yunohost/controllers/postinstall.js index 8f9834be..3760920c 100644 --- a/src/js/yunohost/controllers/postinstall.js +++ b/src/js/yunohost/controllers/postinstall.js @@ -28,7 +28,7 @@ c.params['ddomains'] = data.map(function(dom){return '.'+dom;}); }) .fail(function() { - c.params['ddomains'] = ['.nohost.me', '.noho.st']; + c.params['ddomains'] = ['.nohost.me', '.noho.st', '.ynh.fr']; }) .always(function() { c.view('postinstall/postinstall_2', c.params, function() { @@ -102,4 +102,4 @@ } }); -})(); \ No newline at end of file +})();