mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
enh filter
This commit is contained in:
parent
24b00866e3
commit
8e17641efd
2 changed files with 30 additions and 10 deletions
|
@ -77,7 +77,7 @@
|
|||
c.api('/apps?raw', function (dataraw) { // http://api.yunohost.org/#!/app/app_list_get_8
|
||||
var apps = []
|
||||
$.each(data['apps'], function(k, v) {
|
||||
// Keep only on instance of each apps
|
||||
// Keep only the first instance of each app
|
||||
if (!v['id'].match(/__[0-9]{1,5}$/)) {
|
||||
// Check app source
|
||||
dataraw[v['id']]['installable'] = (!v['installed'] || dataraw[v['id']].manifest.multi_instance)
|
||||
|
@ -104,6 +104,7 @@
|
|||
var cardGrid = jQuery('.grid').isotope({
|
||||
itemSelector: '.app-card',
|
||||
layoutMode: 'fitRows',
|
||||
transitionDuration: 200,
|
||||
getSortData: {
|
||||
name: '.app-level',
|
||||
symbol: '.app-state'
|
||||
|
@ -112,25 +113,39 @@
|
|||
|
||||
// filter functions
|
||||
var filterFns = {
|
||||
// show if number is greater than 50
|
||||
levelSufficient: function() {
|
||||
var level = jQuery(this).find('.app-level').text();
|
||||
return (parseInt( level ) > 2);
|
||||
},
|
||||
// show if name ends with -ium
|
||||
stateWorking: function() {
|
||||
return (jQuery(this).find('.app-state').text() === 'working');
|
||||
},
|
||||
nameContains: function() {
|
||||
var inputTitle = jQuery(this).find("#filter-app-cards").text().toLowerCase();
|
||||
var res = (jQuery(this).find('.app-title').text().toLowerCase().indexOf(inputTitle) > -1);
|
||||
console.log(inputTitle);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
// bind filter button click
|
||||
jQuery('#appFilters').on('click', 'button', function() {
|
||||
var filterValue = jQuery( this ).attr('data-filter');
|
||||
console.log('mouahahahaha')
|
||||
// use filterFn if matches value
|
||||
filterValue = filterFns[ filterValue ] || filterValue;
|
||||
cardGrid.isotope({ filter: filterValue });
|
||||
});
|
||||
|
||||
jQuery("#filter-app-cards").on("keyup", function() {
|
||||
// var filterValue = 'nameContains'
|
||||
// filterValue = filterFns[ filterValue ] || filterValue;
|
||||
// console.log(filterValue);
|
||||
// console.log(input)
|
||||
cardGrid.isotope({ filter: function(){
|
||||
var input = jQuery("#filter-app-cards").val().toLowerCase();
|
||||
return (jQuery(this).find('.app-title').text().toLowerCase().indexOf(input) > -1);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
{{#apps}}
|
||||
<div class="app-card panel panel-default">
|
||||
<div class="panel-body">
|
||||
<h3>{{name}}</h3>
|
||||
<h3 class="app-title">{{name}}</h3>
|
||||
<div class="category">
|
||||
<a 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>
|
||||
{{^official}}<span class="label label-info label-as-badge app-validated">{{t 'community'}}</span>{{/official}}
|
||||
|
@ -68,9 +68,14 @@
|
|||
<a href="{{git.url}}/blob/master/README.md" target="_BLANK" type="button" class="btn btn-default col-sm-4">
|
||||
<i class="fa-book"></i> Readme
|
||||
</a>
|
||||
{{#installable}}
|
||||
<a href="#/apps/install/{{id}}" type="button" class="btn btn-{{installColor}} col-sm-4 active">
|
||||
<i class="fa-plus"></i> Install {{#isSafe}}<i class="fa-warning"></i>{{/isSafe}}
|
||||
</a>
|
||||
{{/installable}}
|
||||
{{^installable}}
|
||||
<span href="#/apps/install/{{id}}" type="button" class="btn btn-default col-sm-4 active disabled"> Installed </span>
|
||||
{{/installable}}
|
||||
</div>
|
||||
</div>
|
||||
{{/apps}}
|
||||
|
|
Loading…
Add table
Reference in a new issue