[enh] Manage appslists. #875 (#158)

* [enh] Manage appslist. #875
* [enh] Link to appslist page in the custom app installation form.
* [fix] Wrong url.
* [fix] Always use appslists plural form for translation strings consistency.
* [enh] Add one-click button to install community list.
* [enh] Add explicit warning message about community list status.
* [enh] Add more fear.
* [fix] Back to warning alert about community appslist.
* [enh] Handle case with no appslists.
* [fix] Remove duplicate id attributes.
* [fix] Full width block.
* [fix] Add missing 'remove' string.
This commit is contained in:
opi 2017-06-12 16:57:52 +02:00 committed by Alexandre Aubin
parent 75193404fe
commit 3ca9535656
6 changed files with 244 additions and 6 deletions

View file

@ -40,14 +40,96 @@
});
});
// List available apps lists
app.get('#/apps/lists', function (c) {
c.api('/appslists', function(data) {
list = [];
var has_community_list = false;
$.each(data, function(listname, listinfo) {
list.push({
'name': listname,
'url': listinfo['url'],
'lastUpdate': listinfo['lastUpdate']
});
// Check for community list
if (listname == 'community' || listinfo['url'] == 'https://app.yunohost.org/community.json') {
has_community_list = true;
}
});
c.view('app/app_appslists_list', {
appslists: list,
has_community_list: has_community_list
});
}, 'GET');
});
// Add a new apps list
app.post('#/apps/lists', function (c) {
list = {
'name' : c.params['appslist_name'],
'url' : c.params['appslist_url']
}
c.api('/appslists', function(data) {
store.clear('slide');
c.redirect('#/apps/lists/' + list.name);
}, 'PUT', list);
});
// Show appslist info and operations
app.get('#/apps/lists/:appslist', function (c) {
c.api('/appslists', function(data) {
if (typeof data[c.params['appslist']] !== 'undefined') {
list = {
'name' : c.params['appslist'],
'url': data[c.params['appslist']]['url'],
'lastUpdate': data[c.params['appslist']]['lastUpdate'],
'removable' : (c.params['appslist'] !== 'yunohost') ? true : false // Do not remove default apps list
};
c.view('app/app_appslists_info', {appslist: list});
}
else {
c.flash('warning', y18n.t('appslists_unknown_list', [c.params['appslist']]));
store.clear('slide');
c.redirect('#/apps/lists');
}
}, 'GET');
});
// Refresh available apps list
app.get('#/apps/refresh', function (c) {
c.api('/appslists', function(data) { // http://api.yunohost.org/#!/app/app_fetchlist_put_5
app.get('#/apps/lists/refresh', function (c) {
c.api('/appslists', function(data) {
// c.redirect(store.get('path'));
c.redirect('#/apps/install');
}, 'PUT');
});
// Refresh specific apps list
app.get('#/apps/lists/:appslist/refresh', function (c) {
c.api('/appslists', function(data) {
c.redirect('#/apps/lists');
}, 'PUT', {'name' : c.params['appslist']});
});
// Remove apps list
app.get('#/apps/lists/:appslist/remove', function (c) {
c.confirm(
y18n.t('appslist'),
y18n.t('appslists_confirm_remove', [c.params['app']]),
function() {
c.api('/appslists', function() {
c.redirect('#/apps/lists');
}, 'DELETE', {'name' : c.params['appslist']});
},
function() {
store.clear('slide');
c.redirect('#/apps/lists/'+ c.params['appslist']);
}
);
});
// Get app information
app.get('#/apps/:app', function (c) {
c.api('/apps/'+c.params['app']+'?raw', function(data) { // http://api.yunohost.org/#!/app/app_info_get_9

View file

@ -25,6 +25,10 @@
Handlebars.registerHelper('humanTime', function(time) {
return Math.round(time) + 's';
});
Handlebars.registerHelper('timestampToDate', function(timestamp) {
var date = new Date(timestamp * 1000);
return date.toLocaleString();
});
Handlebars.registerHelper('bitRate', function(bytes, time) {
var sizes = ['b', 'Kb', 'Mb', 'Gb', 'Tb'];
if (time === 0) return 'n/a';

View file

@ -1,6 +1,7 @@
{
"action": "Action",
"add": "Add",
"remove": "Remove",
"administration_password": "Administration password",
"allowed_users": "Allowed users",
"api_not_responding": "API is not responding",
@ -328,6 +329,20 @@
"regenerate_selfsigned_cert_message" : "If you want, you can regenerate the self-signed certificate.",
"regenerate_selfsigned_cert" : "Regenerate self-signed certificate",
"revert_to_selfsigned_cert_message" : "If you really want to, you can reinstall a self-signed certificate. (Not recommended)",
"revert_to_selfsigned_cert" : "Revert to a self-signed certificate"
"revert_to_selfsigned_cert" : "Revert to a self-signed certificate",
"appslists" : "Applications lists",
"appslists_no_lists" : "No applications lists",
"appslists_custom" : "Custom applications list",
"appslists_manage" : "Manage applications lists",
"appslists_confirm_remove" : "Are you sure you want to remove this applications list?",
"appslists_info_refresh_desc" : "Refresh applications status from this list.",
"appslists_info_remove_desc" : "Applications from this list will not be available anymore.",
"appslists_last_update" : "Last update",
"appslists_unknown_list" : "Unknown apps list: %s",
"appslists_community_list" : "Community applications list",
"name" : "Name",
"install_community_appslists_info" : "Community applications list allows you to install community maintained applications.<br />See the full list on <a href='https://yunohost.org/apps_in_progress'>yunohost.org/apps_in_progress</a>.",
"install_community_appslists_warning" : "Note that these applications packages are <strong>not</strong> official and not maintained by the YunoHost team.<br />Installing these applications is at your own risk and could break your system.",
"install_custom_app_appslists_info" : "Note that you can use alternative applications lists to install some other apps maintained by the YunoHost community."
}

View file

@ -0,0 +1,49 @@
<div class="btn-breadcrumb">
<a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a>
<a href="#/apps">{{t 'applications'}}</a>
<a href="#/apps/lists">{{t 'appslists'}}</a>
<a href="#/apps/lists/{{name}}">{{appslist.name}}</a>
</div>
<div class="separator"></div>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-info-circle"></span> {{t 'infos'}}</h2>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt>{{t 'name'}}</dt>
<dd>{{appslist.name}}</dd>
<dt>{{t 'url'}}</dt>
<dd>{{appslist.url}}</dd>
<dt>{{t 'appslists_last_update'}}</dt>
<dd>{{timestampToDate appslist.lastUpdate}}</dd>
</dl>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
<span class="fa-fw fa-wrench"></span> {{t 'operations'}}
</h2>
</div>
<div class="panel-body">
<div class="container">
<p>{{t 'appslists_info_refresh_desc'}}</p>
<a href="#/apps/lists/{{appslist.name}}/refresh" class="btn btn-info slide">
<span class="fa-refresh"></span> {{t 'refresh_app_list'}}
</a>
</div>
{{#appslist.removable}}
<hr>
<div class="container">
<p>{{t 'appslists_info_remove_desc'}}</p>
<a href="#/apps/lists/{{appslist.name}}/remove" class="btn btn-danger slide back">
<span class="fa-trash-o"></span> {{t 'remove'}}
</a>
</div>
{{/appslist.removable}}
</div>
</div>

View file

@ -0,0 +1,80 @@
<div class="btn-breadcrumb">
<a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a>
<a href="#/apps">{{t 'applications'}}</a>
<a href="#/apps/lists">{{t 'appslists'}}</a>
</div>
<div class="separator"></div>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-list"></span> {{t 'appslists'}}</h2>
</div>
<div class="list-group">
{{#appslists}}
<a href="#/apps/lists/{{name}}" class="list-group-item">
<span class="fa-chevron-right pull-right"></span>
<h2 class="list-group-item-heading">
{{name}}
</h2>
</a>
{{/appslists}}
{{^appslists}}
<p class="list-group-item text-warning">
<span class="fa-exclamation-triangle"></span>
{{t 'appslists_no_lists'}}
</p>
{{/appslists}}
</div>
</div>
{{^has_community_list}}
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-plus"></span> {{t 'appslists_community_list'}}</h2>
</div>
<div class="panel-body">
<form action="#/apps/lists" method="POST" class="form-horizontal">
<input type="hidden" name="appslist_name" value="community" required />
<input type="hidden" name="appslist_url" value="https://app.yunohost.org/community.json" required />
<div class="form-group">
<div class="col-md-12 col-sm-12">
<p>{{t 'install_community_appslists_info'}}</p>
<p class="alert alert-warning">
<span class="fa-warning"></span> {{t 'install_community_appslists_warning'}}
</p>
<input type="submit" class="btn btn-success slide" value="{{t 'add'}}">
</div>
</div>
</form>
</div>
</div>
{{/has_community_list}}
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-plus"></span> {{t 'appslists_custom'}}</h2>
</div>
<div class="panel-body">
<form action="#/apps/lists" method="POST" class="form-horizontal">
<div class="form-group has-feedback">
<label for="appslist_name" class="col-md-2 col-sm-12 control-label">{{t 'name'}}</label>
<div class="col-md-10 col-sm-12">
<input type="text" id="appslist_name" name="appslist_name" class="form-control" value="" required />
</div>
</div>
<div class="form-group has-feedback">
<label for="appslist_url" class="col-md-2 col-sm-12 control-label">{{t 'url'}}</label>
<div class="col-md-10 col-sm-12">
<input type="url" id="appslist_url" name="appslist_url" class="form-control" value="" placeholder="https://app.yunohost.org/community.json" required />
</div>
</div>
<div class="form-group">
<div class="col-md-10 col-md-push-2 col-sm-12">
<input type="submit" class="btn btn-success slide" value="{{t 'add'}}">
</div>
</div>
</form>
</div>
</div>

View file

@ -5,7 +5,10 @@
</div>
<div class="actions-group">
<a href="#/apps/refresh" class="btn btn-info">
<a href="#/apps/lists" class="btn btn-success">
<span class="fa-list"></span> {{t 'appslists_manage'}}
</a>
<a href="#/apps/lists/refresh" class="btn btn-info">
<span class="fa-refresh"></span> {{t 'refresh_app_list'}}
</a>
</div>
@ -29,8 +32,6 @@
{{/apps}}
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-download"></span> {{t 'custom_app_install'}}</h2>
@ -40,6 +41,13 @@
<span class="fa-warning"></span>
{{t 'confirm_install_custom_app'}}
</p>
<div class="alert alert-info">
<p><span class="fa-lightbulb-o"></span>
{{t 'install_custom_app_appslists_info'}}</p>
<p>
<a href="#/apps/lists" class="btn btn-info">{{t 'appslists_manage'}}</a>
</p>
</div>
<form action="#/apps/install/custom" method="POST" class="form-horizontal">
<div class="form-group has-feedback">
<label for="url" class="col-sm-12">{{t 'url'}}</label>