From dba2f60ce1525eab0d100e9796844c50083154c5 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sun, 17 Sep 2017 09:50:04 +0200 Subject: [PATCH] Add app change URL feature --- src/js/yunohost/controllers/apps.js | 46 +++++++++++++++++++++++++++++ src/locales/en.json | 4 +++ src/views/app/app_changeurl.ms | 38 ++++++++++++++++++++++++ src/views/app/app_info.ms | 7 +++++ 4 files changed, 95 insertions(+) create mode 100644 src/views/app/app_changeurl.ms diff --git a/src/js/yunohost/controllers/apps.js b/src/js/yunohost/controllers/apps.js index 717ea785..c42b5020 100644 --- a/src/js/yunohost/controllers/apps.js +++ b/src/js/yunohost/controllers/apps.js @@ -572,4 +572,50 @@ ); }); + // Get app change URL page + app.get('#/apps/:app/changeurl', function (c) { + c.api('/apps/'+c.params['app']+'?raw', function(app_data) { + c.api('/domains', function(domain_data) { // http://api.yunohost.org/#!/domain/domain_list_get_2 + + // Display a list of available domains + var domains = []; + $.each(domain_data.domains, function(k, domain) { + domains.push({ + value: domain, + label: domain, + // Select current domain + selected: (domain == app_data.settings.domain ? true : false) + }); + }); + + data = { + id: c.params['app'], + label: app_data.manifest.name, + domains: domains, + // Pre-fill with current path + path: app_data.settings.path + }; + c.view('app/app_changeurl', data); + }); + }); + }); + + // Change app URL + app.post('#/apps/:app/changeurl/submit', function (c) { + c.confirm( + y18n.t('applications'), + y18n.t('confirm_app_change_url', [c.params['app']]), + function() { + params = {'domain': c.params['domain'], 'path': c.params['path']}; + c.api('/apps/' + c.params['app'] + '/changeurl', function(data) { // Call changeurl API + store.clear('slide'); + c.redirect('#/apps/'+ c.params['app']); + }, 'PUT', params); + }, + function() { + store.clear('slide'); + c.redirect('#/apps/'+ c.params['app'] + '/changeurl'); + } + ); + }); })(); diff --git a/src/locales/en.json b/src/locales/en.json index 44786813..8bdcc83a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -13,11 +13,13 @@ "app_access_removeall_btn": "Remove all access", "app_access_removeall_desc": "No users will have access to %s.", "app_access_title": "%s access", + "app_change_url": "Change URL", "app_debug_no_logs": "Application's logs are not available", "app_debug_tab": "Display debug information", "app_info_access_desc": "Manage user access. Allowed users: %s", "app_info_debug_desc": "Display debugging information for this application.", "app_info_default_desc": "Redirect domain root to this application (%s).", + "app_info_changeurl_desc": "Change the access URL of this application (domain and/or path).", "app_info_uninstall_desc": "Remove this application.", "app_install_cancel": "Installation cancelled.", "app_install_custom_no_manifest": "No manifest.json file", @@ -60,6 +62,7 @@ "confirm_access_clear": "Are you sure you want to clear all access to %s ?", "confirm_access_remove_all": "Are you sure you want to remove all access to %s ?", "confirm_access_remove_user": "Are you sure you want to remove access to %s for %s ?", + "confirm_app_change_url": "Are you sure you want to change the app access URL ?", "confirm_app_default": "Are you sure you want to make this app default ?", "confirm_change_maindomain": "Are you sure you want to change the main domain ?", "confirm_delete": "Are you sure you want to delete %s ?", @@ -206,6 +209,7 @@ "passwords_dont_match": "Passwords don't match", "passwords_too_short": "Password is too short", "path": "Path", + "path_url": "Path", "port": "Port", "ports": "Ports", "postinstall": "Post-installation", diff --git a/src/views/app/app_changeurl.ms b/src/views/app/app_changeurl.ms new file mode 100644 index 00000000..04c26c03 --- /dev/null +++ b/src/views/app/app_changeurl.ms @@ -0,0 +1,38 @@ +
+ {{t 'home'}} + + + {{label}} + {{t 'app_change_url'}} +
+ +
+ +
+
+
+

{{t 'app_change_url'}}

+
+
+
+ +
+ + {{t 'manage_domains'}} +
+ + +
+ +
+
+
+ +
+ +
+
+
+
diff --git a/src/views/app/app_info.ms b/src/views/app/app_info.ms index 32d88ae6..f7260234 100644 --- a/src/views/app/app_info.ms +++ b/src/views/app/app_info.ms @@ -48,6 +48,13 @@
+
+

{{t 'app_info_changeurl_desc' settings.domain}}

+ + {{t 'app_change_url'}} + +
+

{{t 'app_info_uninstall_desc'}}