From 262f3f0204dbbfe54b9f297b2d9121ab911348f1 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 22 May 2018 00:18:14 +0000 Subject: [PATCH] Add level filters --- app/models/appci.py | 10 ++++--- app/templates/appci_branch.html | 46 ++++++++++++++++++++++++++++---- app/templates/appci_compare.html | 8 +++--- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/app/models/appci.py b/app/models/appci.py index fed27e9..4fb37a2 100644 --- a/app/models/appci.py +++ b/app/models/appci.py @@ -34,7 +34,8 @@ class AppList(db.Model): if app["state"] == self.state_for_ci ] for app in apps_for_ci: - + + app['url'] = app["url"].strip('/') name = os.path.basename(app["url"]).replace("_ynh", "") # Try to find an app for this name @@ -326,8 +327,11 @@ class Github(): repo = app.repo.replace("https://github.com/", "") j = self.request('repos/{}/issues'.format(repo)) - 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() ]) + try: + 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() ]) + except: + import pdb; pdb.set_trace() return { "nb_issues": nb_issues, "nb_prs": nb_prs } diff --git a/app/templates/appci_branch.html b/app/templates/appci_branch.html index f7a50dc..92d48a9 100644 --- a/app/templates/appci_branch.html +++ b/app/templates/appci_branch.html @@ -7,7 +7,40 @@
- + +
+ + + + + + + + + + +
+
@@ -24,7 +57,7 @@ {% for result in app_results %} - +
{% if result.app.list.name == "official" %} @@ -96,7 +129,7 @@ window.onload = function () { indexLabel: "{label} - #percent%", toolTipContent: "{label}: {y} (#percent%)", dataPoints: [ - { y: $(".ci-app-level[value=-1]").length, label: "Unknown", color:"#cccccc" }, + { y: $(".ci-app-level[value=-1]").length, label: "Unknown", color: "#cccccc" }, { y: $(".ci-app-level[value=0]").length, label: "Level 0", color: "#d9534f" }, { y: $(".ci-app-level[value=1]").length, label: "Level 1", color: "#E26D4F" }, { y: $(".ci-app-level[value=2]").length, label: "Level 2", color: "#E98D4E" }, @@ -109,21 +142,24 @@ window.onload = function () { }] }); chart.render(); + $("input[type='radio']").change(function() { update_filters(); }); update_filters(); } function toggle(e) { - $(e).toggleClass("btn-default"); + $(e).toggleClass("btn-light"); $(e).toggleClass("btn-primary"); update_filters(); } + function update_filters() { var onlyOfficials = $("#filter_onlyOfficials").hasClass("btn-primary"); + var levelFilter = $("input[type='radio']:checked").attr("level"); $(".resultline").show(); if (onlyOfficials) { $(".resultline:not(.official)").hide(); } + if (levelFilter != "all") { $(".resultline[level!='"+levelFilter+"']").hide(); } } - {% endblock %} diff --git a/app/templates/appci_compare.html b/app/templates/appci_compare.html index 9e33157..b058a2f 100644 --- a/app/templates/appci_compare.html +++ b/app/templates/appci_compare.html @@ -6,9 +6,9 @@
-
- - +
+ +
@@ -83,7 +83,7 @@ window.onload = function () { } function toggle(e) { - $(e).toggleClass("btn-default"); + $(e).toggleClass("btn-light"); $(e).toggleClass("btn-primary"); update_filters(); }