Merge pull request #248 from YunoHost/move-applist-management-to-tools

[mod] Move applist management to Tools section
This commit is contained in:
Alexandre Aubin 2019-06-22 14:49:11 +02:00 committed by GitHub
commit 1fbffc27c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 116 additions and 187 deletions

View file

@ -199,96 +199,6 @@
}); });
}); });
// 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/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 // Get app information
app.get('#/apps/:app', function (c) { app.get('#/apps/:app', function (c) {
c.api('/apps/'+c.params['app']+'?raw', function(data) { // http://api.yunohost.org/#!/app/app_info_get_9 c.api('/apps/'+c.params['app']+'?raw', function(data) { // http://api.yunohost.org/#!/app/app_info_get_9

View file

@ -208,13 +208,6 @@
}); });
// Packages version
app.get('#/tools/versions', function (c) {
c.api('/diagnosis', function(diagnosis) {
c.view('tools/tools_versions', {'versions' : diagnosis.packages });
});
});
// Reboot or shutdown button // Reboot or shutdown button
app.get('#/tools/reboot', function (c) { app.get('#/tools/reboot', function (c) {
c.view('tools/tools_reboot'); c.view('tools/tools_reboot');
@ -371,4 +364,86 @@
); );
}); });
// List available apps lists
app.get('#/tools/appslists', function (c) {
c.api('/appslists', function(data) {
list = [];
$.each(data, function(listname, listinfo) {
list.push({
'name': listname,
'url': listinfo['url'],
'lastUpdate': listinfo['lastUpdate']
});
});
c.view('tools/tools_appslists_list', {
appslists: list
});
}, 'GET');
});
// Add a new apps list
app.post('#/tools/appslists', function (c) {
list = {
'name' : c.params['appslist_name'],
'url' : c.params['appslist_url']
}
c.api('/appslists', function(data) {
store.clear('slide');
c.redirect('#/tools/appslists/' + list.name);
}, 'PUT', list);
});
// Show appslist info and operations
app.get('#/tools/appslists/: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('tools/tools_appslists_info', {appslist: list});
}
else {
c.flash('warning', y18n.t('appslists_unknown_list', [c.params['appslist']]));
store.clear('slide');
c.redirect('#/tools/appslists');
}
}, 'GET');
});
// Refresh available apps list
app.get('#/tools/appslists/refresh', function (c) {
c.api('/appslists', function(data) {
// c.redirect(store.get('path'));
c.redirect('#/apps/install');
}, 'PUT');
});
// Refresh specific apps list
app.get('#/tools/appslists/:appslist/refresh', function (c) {
c.api('/appslists', function(data) {
c.redirect('#/tools/appslists');
}, 'PUT', {'name' : c.params['appslist']});
});
// Remove apps list
app.get('#/tools/appslists/:appslist/remove', function (c) {
c.confirm(
y18n.t('appslist'),
y18n.t('appslists_confirm_remove', [c.params['app']]),
function() {
c.api('/appslists', function() {
c.redirect('#/tools/appslists');
}, 'DELETE', {'name' : c.params['appslist']});
},
function() {
store.clear('slide');
c.redirect('#/tools/appslists/'+ c.params['appslist']);
}
);
});
})(); })();

View file

@ -2,6 +2,7 @@
"action": "Action", "action": "Action",
"active": "Active", "active": "Active",
"add": "Add", "add": "Add",
"advanced": "Advanced",
"remove": "Remove", "remove": "Remove",
"administration_password": "Administration password", "administration_password": "Administration password",
"allowed_users": "Allowed users", "allowed_users": "Allowed users",
@ -426,11 +427,7 @@
"appslists_info_remove_desc": "Applications from this list will not be available anymore.", "appslists_info_remove_desc": "Applications from this list will not be available anymore.",
"appslists_last_update": "Last update", "appslists_last_update": "Last update",
"appslists_unknown_list": "Unknown apps list: %s", "appslists_unknown_list": "Unknown apps list: %s",
"appslists_community_list": "Community applications list",
"name": "Name", "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'>yunohost.org/apps</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.",
"purge_user_data_checkbox": "Purge %s's data? (This will remove the content of it's home and mail directories.)", "purge_user_data_checkbox": "Purge %s's data? (This will remove the content of it's home and mail directories.)",
"purge_user_data_warning": "Purging user's data is not reversible. Be sure you know what you're doing!" "purge_user_data_warning": "Purging user's data is not reversible. Be sure you know what you're doing!"
} }

View file

@ -4,15 +4,6 @@
<a href="#/apps/install">{{t 'install'}}</a> <a href="#/apps/install">{{t 'install'}}</a>
</div> </div>
<div class="actions-group">
<a href="#/apps/lists" role="button" class="btn btn-success">
<span class="fa-list"></span> {{t 'appslists_manage'}}
</a>
<a href="#/apps/lists/refresh" role="button" class="btn btn-info">
<span class="fa-refresh"></span> {{t 'refresh_app_list'}}
</a>
</div>
<div class="separator"></div> <div class="separator"></div>
<div class="input-group" id="app-filter-input"> <div class="input-group" id="app-filter-input">
@ -78,13 +69,6 @@
<span class="fa-warning"></span> <span class="fa-warning"></span>
{{t 'confirm_install_custom_app'}} {{t 'confirm_install_custom_app'}}
</p> </p>
<div class="alert alert-info">
<p><span class="fa-lightbulb-o"></span>
{{t 'install_custom_app_appslists_info'}}</p>
<p>
<a role="button" href="#/apps/lists" class="btn btn-info">{{t 'appslists_manage'}}</a>
</p>
</div>
<form action="#/apps/install/custom" method="POST" class="form-horizontal"> <form action="#/apps/install/custom" method="POST" class="form-horizontal">
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<label for="url" class="col-sm-12">{{t 'url'}}</label> <label for="url" class="col-sm-12">{{t 'url'}}</label>

View file

@ -1,8 +1,8 @@
<div class="btn-breadcrumb"> <div class="btn-breadcrumb">
<a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a> <a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a>
<a href="#/apps">{{t 'applications'}}</a> <a href="#/tools">{{t 'tools'}}</a>
<a href="#/apps/lists">{{t 'appslists'}}</a> <a href="#/tools/appslists">{{t 'appslists'}}</a>
<a href="#/apps/lists/{{name}}">{{appslist.name}}</a> <a href="#/tools/appslists/{{name}}">{{appslist.name}}</a>
</div> </div>
<div class="separator"></div> <div class="separator"></div>
@ -32,7 +32,7 @@
<div class="panel-body"> <div class="panel-body">
<div class="container"> <div class="container">
<p>{{t 'appslists_info_refresh_desc'}}</p> <p>{{t 'appslists_info_refresh_desc'}}</p>
<a href="#/apps/lists/{{appslist.name}}/refresh" role="button" class="btn btn-info slide"> <a href="#/tools/appslists/{{appslist.name}}/refresh" role="button" class="btn btn-info slide">
<span class="fa-refresh"></span> {{t 'refresh_app_list'}} <span class="fa-refresh"></span> {{t 'refresh_app_list'}}
</a> </a>
</div> </div>
@ -40,7 +40,7 @@
<hr> <hr>
<div class="container"> <div class="container">
<p>{{t 'appslists_info_remove_desc'}}</p> <p>{{t 'appslists_info_remove_desc'}}</p>
<a role="button" href="#/apps/lists/{{appslist.name}}/remove" class="btn btn-danger slide back"> <a role="button" href="#/tools/appslists/{{appslist.name}}/remove" class="btn btn-danger slide back">
<span class="fa-trash-o"></span> {{t 'remove'}} <span class="fa-trash-o"></span> {{t 'remove'}}
</a> </a>
</div> </div>

View file

@ -1,7 +1,7 @@
<div class="btn-breadcrumb"> <div class="btn-breadcrumb">
<a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a> <a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a>
<a href="#/apps">{{t 'applications'}}</a> <a href="#/tools">{{t 'tools'}}</a>
<a href="#/apps/lists">{{t 'appslists'}}</a> <a href="#/tools/appslists">{{t 'appslists'}}</a>
</div> </div>
<div class="separator"></div> <div class="separator"></div>
@ -13,7 +13,7 @@
<div class="list-group"> <div class="list-group">
{{#appslists}} {{#appslists}}
<a href="#/apps/lists/{{name}}" class="list-group-item"> <a href="#/tools/appslists/{{name}}" class="list-group-item">
<span class="fa-chevron-right pull-right"></span> <span class="fa-chevron-right pull-right"></span>
<h2 class="list-group-item-heading"> <h2 class="list-group-item-heading">
{{name}} {{name}}
@ -29,35 +29,12 @@
</div> </div>
</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 panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-plus"></span> {{t 'appslists_custom'}}</h2> <h2 class="panel-title"><span class="fa-fw fa-plus"></span> {{t 'appslists_custom'}}</h2>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<form action="#/apps/lists" method="POST" class="form-horizontal"> <form action="#/tools/appslists" method="POST" class="form-horizontal">
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<label for="appslist_name" class="col-md-2 col-sm-12 control-label">{{t 'name'}}</label> <label for="appslist_name" class="col-md-2 col-sm-12 control-label">{{t 'name'}}</label>
<div class="col-md-10 col-sm-12"> <div class="col-md-10 col-sm-12">
@ -67,7 +44,7 @@
<div class="form-group has-feedback"> <div class="form-group has-feedback">
<label for="appslist_url" class="col-md-2 col-sm-12 control-label">{{t 'url'}}</label> <label for="appslist_url" class="col-md-2 col-sm-12 control-label">{{t 'url'}}</label>
<div class="col-md-10 col-sm-12"> <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 /> <input type="url" id="appslist_url" name="appslist_url" class="form-control" value="" placeholder="https://some.domain.tld/somelist.json" required />
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">

View file

@ -5,7 +5,6 @@
<div class="separator"></div> <div class="separator"></div>
<div class="list-group"> <div class="list-group">
<a href="#/tools/diagnosis" class="list-group-item slide clearfix"> <a href="#/tools/diagnosis" class="list-group-item slide clearfix">
<span class="pull-right fa-chevron-right"></span> <span class="pull-right fa-chevron-right"></span>
@ -19,6 +18,22 @@
<span class="pull-right fa-chevron-right"></span> <span class="pull-right fa-chevron-right"></span>
<h2 class="list-group-item-heading">{{t 'migrations'}}</h2> <h2 class="list-group-item-heading">{{t 'migrations'}}</h2>
</a> </a>
<a href="#/tools/reboot" class="list-group-item slide clearfix">
<span class="pull-right fa-chevron-right"></span>
<h2 class="list-group-item-heading">{{t 'tools_shutdown_reboot'}}</h2>
</a>
<a href="#/tools/adminpw" class="list-group-item slide">
<span class="fa-chevron-right pull-right"></span>
<h2 class="list-group-item-heading">{{t 'tools_adminpw'}}</h2>
</a>
</div>
<div class="separator"></div>
<div class="separator"></div>
<h2 style="font-weight:600; padding-left:0.5em;">{{t 'advanced'}}</h2>
<div class="list-group">
<a href="#/tools/monitor" class="list-group-item slide clearfix"> <a href="#/tools/monitor" class="list-group-item slide clearfix">
<span class="pull-right fa-chevron-right"></span> <span class="pull-right fa-chevron-right"></span>
<h2 class="list-group-item-heading">{{t 'monitoring'}}</h2> <h2 class="list-group-item-heading">{{t 'monitoring'}}</h2>
@ -27,24 +42,17 @@
<span class="pull-right fa-chevron-right"></span> <span class="pull-right fa-chevron-right"></span>
<h2 class="list-group-item-heading">{{t 'firewall'}}</h2> <h2 class="list-group-item-heading">{{t 'firewall'}}</h2>
</a> </a>
<a href="#/tools/adminpw" class="list-group-item slide"> <a href="#/tools/security-feed" class="list-group-item slide">
<span class="fa-chevron-right pull-right"></span> <span class="fa-chevron-right pull-right"></span>
<h2 class="list-group-item-heading">{{t 'tools_adminpw'}}</h2> <h2 class="list-group-item-heading">{{t 'tools_security_feed'}}</h2>
</a>
<a href="#/tools/appslists" class="list-group-item slide clearfix">
<span class="pull-right fa-chevron-right"></span>
<h2 class="list-group-item-heading">{{t 'appslists'}}</h2>
</a> </a>
<a href="#/tools/ca" class="list-group-item slide"> <a href="#/tools/ca" class="list-group-item slide">
<span class="fa-chevron-right pull-right"></span> <span class="fa-chevron-right pull-right"></span>
<h2 class="list-group-item-heading">{{t 'tools_download_ca'}}</h2> <h2 class="list-group-item-heading">{{t 'tools_download_ca'}}</h2>
</a> </a>
<a href="#/tools/security-feed" class="list-group-item slide">
<span class="fa-chevron-right pull-right"></span>
<h2 class="list-group-item-heading">{{t 'tools_security_feed'}}</h2>
</a>
<a href="#/tools/reboot" class="list-group-item slide clearfix">
<span class="pull-right fa-chevron-right"></span>
<h2 class="list-group-item-heading">{{t 'tools_shutdown_reboot'}}</h2>
</a>
<a href="#/tools/versions" class="list-group-item slide clearfix">
<span class="pull-right fa-chevron-right"></span>
<h2 class="list-group-item-heading">{{t 'versions'}}</h2>
</a>
</div> </div>

View file

@ -1,22 +0,0 @@
<div class="btn-breadcrumb">
<a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a>
<a href="#/tools">{{t 'tools'}}</a>
<a href="#/tools/versions">{{t 'versions'}}</a>
</div>
<div class="separator"></div>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-cogs"></span> {{t 'versions'}}</h2>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
{{#each versions}}
<dt>{{@key}}</dt>
<dd>{{version}} ({{repo}})</dd>
{{/each}}
</dl>
<a role="button" href="#/update" class="btn btn-success pull-right">{{t 'system_update'}}</a>
</div>
</div>