load more infos on card

This commit is contained in:
elie 2018-08-30 16:03:26 +02:00
parent 74712cc30b
commit 26765973a8
2 changed files with 42 additions and 18 deletions

View file

@ -19,27 +19,47 @@
function levelToColor(level) { function levelToColor(level) {
if (level > 6) { if (level > 6) {
return 'success' return 'success';
} }
else if (level > 2) { else if (level > 2) {
return 'warning' return 'warning';
} }
else { else {
return 'danger' return 'danger';
} }
} }
function timeConverter(UNIX_timestamp) {
var a = new Date(UNIX_timestamp*1000);
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
if (hour < 10) { hour = '0' + hour; }
if (min < 10) { min = '0' + min; }
var time = date+' '+month+' '+year;//+' at '+hour+':'+min
return time;
}
// List available apps // List available apps
app.get('#/apps/install', function (c) { app.get('#/apps/install', function (c) {
c.api('/apps', function (data) { // http://api.yunohost.org/#!/app/app_list_get_8 c.api('/apps', function (data) { // http://api.yunohost.org/#!/app/app_list_get_8
c.api('/apps?raw', function (dataraw) { // http://api.yunohost.org/#!/app/app_list_get_8 c.api('/apps?raw', function (dataraw) { // http://api.yunohost.org/#!/app/app_list_get_8
var apps = []; var apps = []
$.each(data['apps'], function(k, v) { $.each(data['apps'], function(k, v) {
// Keep only uninstalled apps, or multi-instance apps // Keep only uninstalled apps, or multi-instance apps
if ((!v['installed'] || dataraw[v['id']].manifest.multi_instance) && !v['id'].match(/__[0-9]{1,5}$/)) { if ((!v['installed'] || dataraw[v['id']].manifest.multi_instance) && !v['id'].match(/__[0-9]{1,5}$/)) {
// Check app source // Check app source
dataraw[v['id']]['official'] = (dataraw[v['id']]['repository'] == 'yunohost'); dataraw[v['id']]['official'] = (dataraw[v['id']]['repository'] === 'yunohost');
dataraw[v['id']]['color'] = levelToColor(dataraw[v['id']]['level']) dataraw[v['id']]['color'] = levelToColor(dataraw[v['id']]['level']);
dataraw[v['id']]['displayLicense'] = (dataraw[v['id']]['manifest']['license'] !== undefined
&& dataraw[v['id']]['manifest']['license'] !== 'free');
dataraw[v['id']]['updateDate'] = timeConverter(dataraw[v['id']]['lastUpdate']);
jQuery.extend(dataraw[v['id']], v); jQuery.extend(dataraw[v['id']], v);
apps.push(dataraw[v['id']]); apps.push(dataraw[v['id']]);

View file

@ -20,20 +20,24 @@
<div class="app-card panel panel-default"> <div class="app-card panel panel-default">
<div class="panel-body"> <div class="panel-body">
<h3>{{name}}</h3> <h3>{{name}}</h3>
<div class="category"> <span class="label label-{{color}} label-as-badge">{{level}}</span> <div class="category">
<span class="label label-success label-as-badge app-validated">validated</span> <span class="label label-{{color}} label-as-badge">{{level}}</span>
<span class="label label-default">AGPL-3.0</span></div> {{^official}}<span class="label label-info label-as-badge app-validated">{{t 'community'}}</span>{{/official}}
{{#official}}<span class="label label-success label-as-badge app-validated">{{t 'official'}}</span>{{/official}}
{{#displayLicense}}<span class="label label-default">{{license}}</span>{{/displayLicense}}
</div>
<div class="app-card-desc">{{description}}</div> <div class="app-card-desc">{{description}}</div>
</div> </div>
<div class="app-card-date-maintainer"> <div class="app-card-date-maintainer">
<i class="fas fa-sync"></i> 10 April 2018 - <i class="fas fa-sync"></i> {{updateDate}} -
<span title="Current maintainer of this package" class="maintained"></span><i class="fa-user"></i> aymhce</span> {{#maintained}}<span title="Current maintainer of this package" class="maintained"></span><i class="fa-user"></i> {{manifest.maintainer.name}}</span>{{/maintained}}
{{^maintained}}<i class="fas fa-warning"></i> {{t 'Unmaintained'}}{{/maintained}}
</div> </div>
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<a href="github.com" target="_BLANK" type="button" class="btn btn-default col-sm-4"> <a href="{{git.url}}" target="_BLANK" type="button" class="btn btn-default col-sm-4">
<i class="fa-globe"></i> Code <i class="fa-globe"></i> Code
</a> </a>
<a href="#/app_ampache_en" target="_BLANK" type="button" class="btn btn-default col-sm-4"> <a href="{{git.url}}/blob/master/README.md" target="_BLANK" type="button" class="btn btn-default col-sm-4">
<i class="fa-book"></i> Doc <i class="fa-book"></i> Doc
</a> </a>
<a href="#/apps/install/{{id}}" type="button" class="btn btn-{{color}} col-sm-4 active"> <a href="#/apps/install/{{id}}" type="button" class="btn btn-{{color}} col-sm-4 active">