Add app change URL feature

This commit is contained in:
Jimmy Monin 2017-09-17 09:50:04 +02:00
parent bd1abcb89d
commit dba2f60ce1
4 changed files with 95 additions and 0 deletions

View file

@ -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');
}
);
});
})();

View file

@ -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",

View file

@ -0,0 +1,38 @@
<div class="btn-breadcrumb">
<a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a>
<a href="#/apps" class="hidden-xs">{{t 'applications'}}</a>
<a href="#/apps" class="visible-xs">&hellip;</a>
<a href="#/apps/{{id}}">{{label}}</a>
<a href="#/apps/{{id}}/changeurl">{{t 'app_change_url'}}</a>
</div>
<div class="separator"></div>
<form action="#/apps/{{id}}/changeurl/submit" method="POST" class="form-horizontal form-app-install">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-exchange"></span> {{t 'app_change_url'}}</h2>
</div>
<div class="panel-body">
<div class="form-group">
<label for="domain" class="col-sm-12">{{t 'domain'}}</label>
<div class="col-sm-12">
<select id="domain" name="domain" required class="form-control" {{{attributes}}}>
{{#each domains}}<option value="{{this.value}}" {{#if selected}}selected{{/if}}>{{this.label}}</option>{{/each}}
</select>
<span class="help-block help-block--link"><a href='#/domains'>{{t 'manage_domains'}}</a></span>
</div>
<label for="path" class="col-sm-12">{{t 'path_url'}}</label>
<div class="col-sm-12">
<input class="col-sm-12" type="text" id="path" name="path" class="form-control" value="{{path}}" required="required">
</div>
</div>
<hr>
<input type="hidden" name="app" value="{{id}}">
<div class="text-center">
<input type="submit" class="btn btn-success slide back" value="{{t 'app_change_url'}}">
</div>
</div>
</div>
</form>

View file

@ -48,6 +48,13 @@
</a>
</div>
<hr>
<div class="container">
<p>{{t 'app_info_changeurl_desc' settings.domain}}</p>
<a href="#/apps/{{settings.id}}/changeurl" class="btn btn-info slide">
<span class="fa-exchange"></span> {{t 'app_change_url'}}
</a>
</div>
<hr>
<div class="container">
<p>{{t 'app_info_uninstall_desc'}}</p>
<a href="#/apps/{{settings.id}}/uninstall" class="btn btn-danger slide back">