Download:
child 25:52cac2f85af5
parent 23:9f9b68ad5068
24:16c6f6907c16
Anton Shestakov <av6@dwimlabs.net>, Wed, 15 Jun 2016 22:13:58 +0800
viewer: show badges for checks (using a UI module)

5 файлов изменено, 29 вставок(+), 2 удалений(-) [+]
candolint/uimodules.py file | annotate | diff | comparison | revisions
static/main.css file | annotate | diff | comparison | revisions
templates/index.html file | annotate | diff | comparison | revisions
templates/project.html file | annotate | diff | comparison | revisions
templates/ui/badges.html file | annotate | diff | comparison | revisions
--- a/candolint/uimodules.py Wed Jun 15 22:12:55 2016 +0800
+++ b/candolint/uimodules.py Wed Jun 15 22:13:58 2016 +0800
@@ -6,3 +6,8 @@
datetime = value.isoformat() + 'Z'
text = value.strftime('%Y-%m-%d %H:%M:%S') + ' UTC'
return self.render_string('ui/time.html', datetime=datetime, title=text, text=text)
+
+
+class Badges(UIModule):
+ def render(self, check):
+ return self.render_string('ui/badges.html', check=check)
--- a/static/main.css Wed Jun 15 22:12:55 2016 +0800
+++ b/static/main.css Wed Jun 15 22:13:58 2016 +0800
@@ -7,6 +7,10 @@
}
}
+.uk-badge-unknown {
+ background: #898989;
+}
+
.check-log {
background: #3c3c3c;
color: white;
--- a/templates/index.html Wed Jun 15 22:12:55 2016 +0800
+++ b/templates/index.html Wed Jun 15 22:13:58 2016 +0800
@@ -11,7 +11,7 @@
{% set project = check.project %}
{% set change = check.change %}
<tr>
- <td>{{ check.errors }} error(s), {{ check.warnings }} warning(s)</td>
+ <td>{% module Badges(check=check) %}</td>
<td>
<a href="/{{ project.domain }}/{{ project.user or '-' }}/{{ project.name }}/{{ check.ordinal }}">
#{{ check.ordinal }}
--- a/templates/project.html Wed Jun 15 22:12:55 2016 +0800
+++ b/templates/project.html Wed Jun 15 22:13:58 2016 +0800
@@ -16,7 +16,7 @@
{% for check in checks %}
{% set change = check.change %}
<tr>
- <td>{{ check.errors }} error(s), {{ check.warnings }} warning(s)</td>
+ <td>{% module Badges(check=check) %}</td>
<td>
<a href="/{{ project.domain }}/{{ project.user or '-' }}/{{ project.name }}/{{ check.ordinal }}">
#{{ check.ordinal }}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/ui/badges.html Wed Jun 15 22:13:58 2016 +0800
@@ -0,0 +1,18 @@
+{% if not check.success %}
+ <span class="uk-badge uk-badge-unknown uk-text-large" title="checking failed">?</span>
+{% elif check.errors or check.warnings %}
+ {% if check.errors %}
+ <span class="uk-badge uk-badge-danger uk-text-large"
+ title="{{ locale.translate('{} error', '{} errors', check.errors).format(check.errors) }}">
+ {{ check.errors }}
+ </span>
+ {% end %}
+ {% if check.warnings %}
+ <span class="uk-badge uk-badge-warning uk-text-large"
+ title="{{ locale.translate('{} warning', '{} warnings', check.warnings).format(check.warnings) }}">
+ {{ check.warnings }}
+ </span>
+ {% end %}
+{% else %}
+ <span class="uk-badge uk-badge-success uk-text-large" title="no lint found">OK</span>
+{% end %}