Add level filters

This commit is contained in:
Alexandre Aubin 2018-05-22 00:18:14 +00:00
parent 4b8eb8291b
commit 262f3f0204
3 changed files with 52 additions and 12 deletions

View file

@ -35,6 +35,7 @@ class AppList(db.Model):
for app in apps_for_ci: for app in apps_for_ci:
app['url'] = app["url"].strip('/')
name = os.path.basename(app["url"]).replace("_ynh", "") name = os.path.basename(app["url"]).replace("_ynh", "")
# Try to find an app for this name # Try to find an app for this name
@ -326,8 +327,11 @@ class Github():
repo = app.repo.replace("https://github.com/", "") repo = app.repo.replace("https://github.com/", "")
j = self.request('repos/{}/issues'.format(repo)) j = self.request('repos/{}/issues'.format(repo))
try:
nb_issues = len([ i for i in j if not "pull_request" in i.keys() ]) nb_issues = len([ i for i in j if not "pull_request" in i.keys() ])
nb_prs = len([ i for i in j if "pull_request" in i.keys() ]) nb_prs = len([ i for i in j if "pull_request" in i.keys() ])
except:
import pdb; pdb.set_trace()
return { "nb_issues": nb_issues, return { "nb_issues": nb_issues,
"nb_prs": nb_prs } "nb_prs": nb_prs }

View file

@ -7,7 +7,40 @@
<div class="row"> <div class="row">
<div class="mx-auto"> <div class="mx-auto">
<div style="text-align:center;"> <div style="text-align:center;">
<button id="filter_onlyOfficials" type="button" class="btn btn-default btn-lg" href="javascript:void(0)" onclick="toggle(this)">Show only officials</button> <label for="level-all">Level : </label>
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-sm btn-light active">
<input type="radio" name="options" level="all" id="filter_level-all" autocomplete="off" checked> All
</label>
<label class="btn btn-sm btn-light">
<input type="radio" name="options" level="?" autocomplete="off"> ?
</label>
<label class="btn btn-sm btn-light">
<input type="radio" name="options" level="0" autocomplete="off"> 0
</label>
<label class="btn btn-sm btn-light">
<input type="radio" name="options" level="1" autocomplete="off"> 1
</label>
<label class="btn btn-sm btn-light">
<input type="radio" name="options" level="2" autocomplete="off"> 2
</label>
<label class="btn btn-sm btn-light">
<input type="radio" name="options" level="3" autocomplete="off"> 3
</label>
<label class="btn btn-sm btn-light">
<input type="radio" name="options" level="4" autocomplete="off"> 4
</label>
<label class="btn btn-sm btn-light">
<input type="radio" name="options" level="5" autocomplete="off"> 5
</label>
<label class="btn btn-sm btn-light">
<input type="radio" name="options" level="6" autocomplete="off"> 6
</label>
<label class="btn btn-sm btn-light">
<input type="radio" name="options" level="7" autocomplete="off"> 7
</label>
</div>
<button id="filter_onlyOfficials" type="button" class="btn btn-light btn-sm" href="javascript:void(0)" onclick="toggle(this)" style="margin-left:30px;">Show only officials</button>
</div> </div>
<div> <div>
<table class="table table-responsive ci-app-table"> <table class="table table-responsive ci-app-table">
@ -24,7 +57,7 @@
</thead> </thead>
<tbody> <tbody>
{% for result in app_results %} {% for result in app_results %}
<tr app="{{ result.app.name }}" class="resultline {% if result.app.list.name == "official" %}official{% endif %}"> <tr app="{{ result.app.name }}" class="resultline {% if result.app.list.name == "official" %}official{% endif %}" level="{{ result.level if result.level >= 0 else "?" }}">
<td class="ci-app-row-title"> <td class="ci-app-row-title">
{% if result.app.list.name == "official" %} {% if result.app.list.name == "official" %}
<span class="official-star oi oi-star" title="Official" aria-hidden="true"></span> <span class="official-star oi oi-star" title="Official" aria-hidden="true"></span>
@ -109,21 +142,24 @@ window.onload = function () {
}] }]
}); });
chart.render(); chart.render();
$("input[type='radio']").change(function() { update_filters(); });
update_filters(); update_filters();
} }
function toggle(e) { function toggle(e) {
$(e).toggleClass("btn-default"); $(e).toggleClass("btn-light");
$(e).toggleClass("btn-primary"); $(e).toggleClass("btn-primary");
update_filters(); update_filters();
} }
function update_filters() { function update_filters() {
var onlyOfficials = $("#filter_onlyOfficials").hasClass("btn-primary"); var onlyOfficials = $("#filter_onlyOfficials").hasClass("btn-primary");
var levelFilter = $("input[type='radio']:checked").attr("level");
$(".resultline").show(); $(".resultline").show();
if (onlyOfficials) { $(".resultline:not(.official)").hide(); } if (onlyOfficials) { $(".resultline:not(.official)").hide(); }
if (levelFilter != "all") { $(".resultline[level!='"+levelFilter+"']").hide(); }
} }
</script> </script>
{% endblock %} {% endblock %}

View file

@ -6,9 +6,9 @@
<div class="row"> <div class="row">
<div class="mx-auto"> <div class="mx-auto">
<div> <div style="text-align:center;">
<button id="filter_onlyDiffs" type="button" class="btn btn-primary btn-lg" href="javascript:void(0)" onclick="toggle(this)">Show only diffs</button> <button id="filter_onlyDiffs" type="button" class="btn btn-primary btn-sm" href="javascript:void(0)" onclick="toggle(this)">Show only diffs</button>
<button id="filter_onlyOfficials" type="button" class="btn btn-default btn-lg" href="javascript:void(0)" onclick="toggle(this)">Show only officials</button> <button id="filter_onlyOfficials" type="button" class="btn btn-light btn-sm" href="javascript:void(0)" onclick="toggle(this)">Show only officials</button>
</div> </div>
<div> <div>
<table class="table table-responsive ci-app-table"> <table class="table table-responsive ci-app-table">
@ -83,7 +83,7 @@ window.onload = function () {
} }
function toggle(e) { function toggle(e) {
$(e).toggleClass("btn-default"); $(e).toggleClass("btn-light");
$(e).toggleClass("btn-primary"); $(e).toggleClass("btn-primary");
update_filters(); update_filters();
} }