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
|
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 on instance of each apps
|
// Keep only the first instance of each app
|
||||||
if (!v['id'].match(/__[0-9]{1,5}$/)) {
|
if (!v['id'].match(/__[0-9]{1,5}$/)) {
|
||||||
// Check app source
|
// Check app source
|
||||||
dataraw[v['id']]['installable'] = (!v['installed'] || dataraw[v['id']].manifest.multi_instance)
|
dataraw[v['id']]['installable'] = (!v['installed'] || dataraw[v['id']].manifest.multi_instance)
|
||||||
|
@ -104,6 +104,7 @@
|
||||||
var cardGrid = jQuery('.grid').isotope({
|
var cardGrid = jQuery('.grid').isotope({
|
||||||
itemSelector: '.app-card',
|
itemSelector: '.app-card',
|
||||||
layoutMode: 'fitRows',
|
layoutMode: 'fitRows',
|
||||||
|
transitionDuration: 200,
|
||||||
getSortData: {
|
getSortData: {
|
||||||
name: '.app-level',
|
name: '.app-level',
|
||||||
symbol: '.app-state'
|
symbol: '.app-state'
|
||||||
|
@ -112,25 +113,39 @@
|
||||||
|
|
||||||
// filter functions
|
// filter functions
|
||||||
var filterFns = {
|
var filterFns = {
|
||||||
// show if number is greater than 50
|
|
||||||
levelSufficient: function() {
|
levelSufficient: function() {
|
||||||
var level = jQuery(this).find('.app-level').text();
|
var level = jQuery(this).find('.app-level').text();
|
||||||
return (parseInt( level ) > 2);
|
return (parseInt( level ) > 2);
|
||||||
},
|
},
|
||||||
// show if name ends with -ium
|
|
||||||
stateWorking: function() {
|
stateWorking: function() {
|
||||||
return (jQuery(this).find('.app-state').text() === 'working');
|
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
|
// bind filter button click
|
||||||
jQuery('#appFilters').on( 'click', 'button', function() {
|
jQuery('#appFilters').on('click', 'button', function() {
|
||||||
var filterValue = jQuery( this ).attr('data-filter');
|
var filterValue = jQuery( this ).attr('data-filter');
|
||||||
console.log('mouahahahaha')
|
|
||||||
// use filterFn if matches value
|
|
||||||
filterValue = filterFns[ filterValue ] || filterValue;
|
filterValue = filterFns[ filterValue ] || filterValue;
|
||||||
cardGrid.isotope({ filter: 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}}
|
{{#apps}}
|
||||||
<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 class="app-title">{{name}}</h3>
|
||||||
<div class="category">
|
<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>
|
<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}}
|
{{^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">
|
<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
|
<i class="fa-book"></i> Readme
|
||||||
</a>
|
</a>
|
||||||
|
{{#installable}}
|
||||||
<a href="#/apps/install/{{id}}" type="button" class="btn btn-{{installColor}} col-sm-4 active">
|
<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}}
|
<i class="fa-plus"></i> Install {{#isSafe}}<i class="fa-warning"></i>{{/isSafe}}
|
||||||
</a>
|
</a>
|
||||||
|
{{/installable}}
|
||||||
|
{{^installable}}
|
||||||
|
<span href="#/apps/install/{{id}}" type="button" class="btn btn-default col-sm-4 active disabled"> Installed </span>
|
||||||
|
{{/installable}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/apps}}
|
{{/apps}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue