after review changes

This commit is contained in:
root 2018-09-20 15:33:53 +00:00 committed by elie
parent 1a1ec8fd8f
commit 7062911366
4 changed files with 38 additions and 56 deletions

View file

@ -598,7 +598,7 @@ input[type='radio'].nice-radio {
} }
.panel-body { .app-card .panel-body {
padding: 1.5rem; padding: 1.5rem;
h3 { h3 {

View file

@ -35,9 +35,6 @@
if (state === "working" || state === "validated") { if (state === "working" || state === "validated") {
return 'success'; return 'success';
} }
else if (state === "inprogress") {
return 'warning';
}
else { else {
return 'danger'; return 'danger';
} }
@ -55,43 +52,27 @@
} }
} }
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) {
var state = dataraw[v['id']]['state']; var state = dataraw[v['id']]['state'];
var levelFormatted = parseInt(dataraw[v['id']]['level']); var levelFormatted = parseInt(dataraw[v['id']]['level']);
var isWorking = (state === 'working' || state === 'validated') && levelFormatted > 0; var isWorking = (state === 'working' || state === 'validated') && levelFormatted > 0;
// Keep only the first instance of each app and remove community not working apps // Keep only the first instance of each app and remove community not working apps
if (!v['id'].match(/__[0-9]{1,5}$/) && (dataraw[v['id']]['repository'] === 'yunohost' || state !== 'notworking')) { if (!v['id'].match(/__[0-9]{1,5}$/) && (dataraw[v['id']]['repository'] === 'yunohost' || state !== 'notworking')) {
dataraw[v['id']]['installable'] = (!v['installed'] || dataraw[v['id']].manifest.multi_instance) dataraw[v['id']]['installable'] = (!v['installed'] || dataraw[v['id']].manifest.multi_instance)
dataraw[v['id']]['status'] = (dataraw[v['id']]['repository'] === 'yunohost') ? 'official' : 'community'; dataraw[v['id']]['isCommunity'] = !(dataraw[v['id']]['repository'] === 'yunohost');
dataraw[v['id']]['levelFormatted'] = isNaN(levelFormatted) ? '?' : levelFormatted; dataraw[v['id']]['levelFormatted'] = isNaN(levelFormatted) ? '?' : levelFormatted;
dataraw[v['id']]['levelColor'] = levelToColor(levelFormatted); dataraw[v['id']]['levelColor'] = levelToColor(levelFormatted);
dataraw[v['id']]['stateColor'] = stateToColor(state); dataraw[v['id']]['stateColor'] = stateToColor(state);
dataraw[v['id']]['installColor'] = combineColors(dataraw[v['id']]['stateColor'], dataraw[v['id']]['levelColor']); dataraw[v['id']]['installColor'] = combineColors(dataraw[v['id']]['stateColor'], dataraw[v['id']]['levelColor']);
dataraw[v['id']]['displayLicense'] = (dataraw[v['id']]['manifest']['license'] !== undefined dataraw[v['id']]['displayLicense'] = (dataraw[v['id']]['manifest']['license'] !== undefined
&& dataraw[v['id']]['manifest']['license'] !== 'free'); && dataraw[v['id']]['manifest']['license'] !== 'free');
dataraw[v['id']]['updateDate'] = timeConverter(dataraw[v['id']]['lastUpdate']); dataraw[v['id']]['updateDate'] = dataraw[v['id']]['lastUpdate'] * 1000;
dataraw[v['id']]['isSafe'] = (dataraw[v['id']]['installColor'] !== 'danger'); dataraw[v['id']]['isSafe'] = (dataraw[v['id']]['installColor'] !== 'danger');
dataraw[v['id']]['isWorking'] = isWorking ? "isworking" : "notFullyWorking"; dataraw[v['id']]['isWorking'] = isWorking ? "isworking" : "notFullyWorking";
@ -103,42 +84,42 @@
// Sort app list // Sort app list
c.arraySortById(apps); c.arraySortById(apps);
// setup filtering of apps once the view is loaded // setup filtering of apps once the view is loaded
function setupFilterEvents () { function setupFilterEvents () {
// Uses plugin isotope to filter apps (we could had ordering to) // Uses plugin isotope to filter apps (we could had ordering to)
var cardGrid = jQuery('.grid').isotope({ var cardGrid = jQuery('.grid').isotope({
itemSelector: '.app-card', itemSelector: '.app-card',
layoutMode: 'fitRows', layoutMode: 'fitRows',
transitionDuration: 200 transitionDuration: 200
}); });
filterByClassAndName = function () { filterByClassAndName = function () {
var input = jQuery("#filter-app-cards").val().toLowerCase(); var input = jQuery("#filter-app-cards").val().toLowerCase();
var inputMatch = (jQuery(this).find('.app-title').text().toLowerCase().indexOf(input) > -1); var inputMatch = (jQuery(this).find('.app-title').text().toLowerCase().indexOf(input) > -1);
var filterClass = jQuery("#dropdownFilter").attr("data-filter"); var filterClass = jQuery("#dropdownFilter").attr("data-filter");
var classMatch = (filterClass === '*') ? true : jQuery(this).hasClass(filterClass); var classMatch = (filterClass === '*') ? true : jQuery(this).hasClass(filterClass);
return inputMatch && classMatch; return inputMatch && classMatch;
}, },
// Keep only official apps at first render // Keep only official apps at first render
cardGrid.isotope({ filter: '.official' }); cardGrid.isotope({ filter: '.isworking' });
jQuery('.dropdownFilter').on('click', function() { jQuery('.dropdownFilter').on('click', function() {
// change dropdown label // change dropdown label
jQuery('#app-cards-list-filter-text').text(jQuery(this).find('.menu-item').text()); jQuery('#app-cards-list-filter-text').text(jQuery(this).find('.menu-item').text());
// change filter attribute // change filter attribute
jQuery('#dropdownFilter').attr("data-filter", jQuery(this).attr("data-filter")); jQuery('#dropdownFilter').attr("data-filter", jQuery(this).attr("data-filter"));
// filter ! // filter !
cardGrid.isotope({ filter: filterByClassAndName }); cardGrid.isotope({ filter: filterByClassAndName });
}); });
jQuery("#filter-app-cards").on("keyup", function() { jQuery("#filter-app-cards").on("keyup", function() {
cardGrid.isotope({ filter: filterByClassAndName }); cardGrid.isotope({ filter: filterByClassAndName });
}); });
}; };
// render // render
c.view('app/app_list_install', {apps: apps}, setupFilterEvents); c.view('app/app_list_install', {apps: apps}, setupFilterEvents);
}); });

View file

@ -182,6 +182,7 @@
"ipv6": "IPv6", "ipv6": "IPv6",
"label": "Label", "label": "Label",
"label_for_manifestname": "Label for %s", "label_for_manifestname": "Label for %s",
"level": "level",
"loading": "Loading …", "loading": "Loading …",
"local_archives": "Local archives", "local_archives": "Local archives",
"local_ip": "Local IP", "local_ip": "Local IP",
@ -219,7 +220,7 @@
"no_user_to_add": "No more users to add.", "no_user_to_add": "No more users to add.",
"non_compatible_api": "Non-compatible API", "non_compatible_api": "Non-compatible API",
"ok": "OK", "ok": "OK",
"only_official_apps": "Only official apps", "only_validated_apps": "Only validated apps",
"only_working_apps": "Only working apps", "only_working_apps": "Only working apps",
"open": "Open", "open": "Open",
"operations": "Operations", "operations": "Operations",

View file

@ -19,12 +19,12 @@
<span class="input-group-addon"><i class="fas fa-search"></i></span> <span class="input-group-addon"><i class="fas fa-search"></i></span>
<input type="text" id="filter-app-cards" class="form-control" role="textbox" placeholder="{{t 'search_for_apps'}}" aria-describedby="basic-addon0"/> <input type="text" id="filter-app-cards" class="form-control" role="textbox" placeholder="{{t 'search_for_apps'}}" aria-describedby="basic-addon0"/>
<div class="input-group-btn"> <div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <button type="button" role="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span id="app-cards-list-filter-text">{{t 'only_official_apps'}}</span> <span class="caret"></span> <span id="app-cards-list-filter-text">{{t 'only_working_apps'}}</span> <span class="caret"></span>
</button> </button>
<ul id="dropdownFilter" class="dropdown-menu" data-filter="official" role="menu"> <ul id="dropdownFilter" class="dropdown-menu" data-filter="isworking" role="menu">
<li class="button dropdownFilter" data-filter="official"><a class="menu-item" role="menu-item" tabindex="-1">{{t 'only_official_apps'}}</a></li>
<li role="presentation" class="button dropdownFilter" data-filter="isworking"><a class="menu-item" role="menu-item" tabindex="-1">{{t 'only_working_apps'}}</a></li> <li role="presentation" class="button dropdownFilter" data-filter="isworking"><a class="menu-item" role="menu-item" tabindex="-1">{{t 'only_working_apps'}}</a></li>
<li role="presentation" class="button dropdownFilter" data-filter="validated"><a class="menu-item" role="menu-item" tabindex="-1">{{t 'only_validated_apps'}}</a></li>
<li role="presentation" class="button dropdownFilter" data-filter="*"><a class="menu-item" role="menu-item" tabindex="-1">{{t 'all_apps'}}</a></li> <li role="presentation" class="button dropdownFilter" data-filter="*"><a class="menu-item" role="menu-item" tabindex="-1">{{t 'all_apps'}}</a></li>
</ul> </ul>
</div> </div>
@ -38,15 +38,15 @@
<div class="panel-body"> <div class="panel-body">
<h2 class="app-title">{{name}}</h2> <h2 class="app-title">{{name}}</h2>
<div class="category"> <div class="category">
<a target="_BLANK" href="https://yunohost.org/#/packaging_apps_levels_fr"><span class="label label-{{levelColor}} label-as-badge app-level" title="{{t 'app_level'}}">{{levelFormatted}}</span></a>
<span class="label label-info label-as-badge app-status">{{t status}}</span>
<span class="label label-{{stateColor}} label-as-badge app-state">{{t state}}</span> <span class="label label-{{stateColor}} label-as-badge app-state">{{t state}}</span>
{{#isCommunity}} <span class="label label-info label-as-badge app-status">{{t 'community'}}</span>{{/isCommunity}}
<a target="_BLANK" href="https://yunohost.org/#/packaging_apps_levels_fr"><span class="label label-{{levelColor}} label-as-badge app-level" title="{{t 'app_level'}}">{{t 'level'}} {{levelFormatted}}</span></a>
{{#displayLicense}}<span class="label label-default app-license" title="{{t 'app_license'}}">{{license}}</span>{{/displayLicense}} {{#displayLicense}}<span class="label label-default app-license" title="{{t 'app_license'}}">{{license}}</span>{{/displayLicense}}
</div> </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> {{updateDate}} - <i class="fas fa-sync"></i>{{formatDate updateDate day="numeric" month="long" year="numeric"}} -
{{#maintained}}<span title="{{t 'current_maintainer_title'}}" class="maintained"></span><i class="fa-user"></i> {{manifest.maintainer.name}}</span>{{/maintained}} {{#maintained}}<span title="{{t 'current_maintainer_title'}}" class="maintained"></span><i class="fa-user"></i> {{manifest.maintainer.name}}</span>{{/maintained}}
{{^maintained}}<i class="fas fa-warning"></i> {{t 'unmaintained'}}{{/maintained}} {{^maintained}}<i class="fas fa-warning"></i> {{t 'unmaintained'}}{{/maintained}}
</div> </div>
@ -63,7 +63,7 @@
</a> </a>
{{/installable}} {{/installable}}
{{^installable}} {{^installable}}
<span href="#/apps/install/{{id}}" type="button" class="btn btn-default col-sm-4 active disabled"> {{t 'installed'}}</span> <span type="button" class="btn btn-default col-sm-4 active disabled"> {{t 'installed'}}</span>
{{/installable}} {{/installable}}
</div> </div>
</div> </div>