Commit 71d6d4d5 authored by Christophe Benz's avatar Christophe Benz

Separate legacy functions

parent 5bfd695a
{% from "macros.html" import job_icon %}
{% from "macros.html" import local_time %}
{% macro legacy_job_tooltip(job) %}
{% if job.gitlab_job.ref != MASTER %}
branch: {{ job.gitlab_job.ref }}
<br>
{% endif %}
id: {{ job.gitlab_job.id }}
<br>
name: {{ job.gitlab_job.name }}
<br>
status: {{ job.get_status() }}
<br>
{% if job.errors_description %}
completion: {{ job.errors_description }}
<br>
{% endif %}
duration: {{ humanfriendly.format_timespan(job.gitlab_job.duration) if job.gitlab_job.duration else "?" }}
<br>
created: {{ local_time(job.gitlab_job.created_at) if job.gitlab_job.created_at else "?" }}
<br>
started: {{ local_time(job.gitlab_job.started_at) if job.gitlab_job.started_at else "?" }}
<br>
finished: {{ local_time(job.gitlab_job.finished_at) if job.gitlab_job.finished_at else "?" }}
<br>
{% if job.git_push is not none %}
git push: {{ str(job.git_push).lower() }}
<br>
{% endif %}
{% endmacro %}
{% macro legacy_job_icon(job) %}
{# Add background when jobs are not triggered from master #}
{% set style = "background-color: yellow;" if job.gitlab_job.ref != MASTER else "" %}
{% if job.is_fetcher_job and job.success_rate is not none and job.success_rate < 100 %}
{# When completion information is available and fetcher did not process all data, display a progress bar. #}
<a href="{{ job.gitlab_job.web_url }}" class="w-100 mr-2" style="{{ style }}">
<div class="progress border border-dark" title="{{ legacy_job_tooltip(job) }}" data-toggle="tooltip" data-html="true" style="min-width: 3em;">
<div role="progressbar" style="width: {{ job.success_rate }}%" aria-valuenow="{{ job.success_rate }}" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-success"></div>
</div>
</a>
{% else %}
<a href="{{ job.gitlab_job.web_url }}" class="mr-1" data-toggle="tooltip" data-html="true" data-placement="auto" title="{{ legacy_job_tooltip(job) }}" style="{{ style }}">
<i class="fas {{ job.get_job_icon_classes() }}"></i>
</a>
{% endif %}
{% endmacro %}
{% macro render_legacy_pipeline_jobs(fetcher, solr_project, data_model_project) %}
<div class="d-flex align-items-center mr-4">
<span class="mr-2">Download</span>
{% for job in fetcher.download_jobs %}
{{ job_icon(fetcher.project, job) }}
{{ legacy_job_icon(job) }}
{% else %}
<a href="{{ jobs_url(args.gitlab_base_url, fetcher.project) }}" data-toggle="tooltip" data-placement="auto" title="No download job found in the latest jobs of {{ fetcher.project.path }}">
<i class="fas fa-question-circle text-warning"></i>
......@@ -14,7 +60,7 @@
<div class="d-flex align-items-center mr-4">
<span class="mr-2">Convert</span>
{% for job in fetcher.convert_jobs %}
{{ job_icon(fetcher.project, job) }}
{{ legacy_job_icon(job) }}
{% else %}
<a href="{{ jobs_url(args.gitlab_base_url, fetcher.project) }}" data-toggle="tooltip" data-placement="auto" title="No convert job found in the latest jobs of {{ fetcher.project.path }}">
<i class="fas fa-question-circle text-warning"></i>
......@@ -24,7 +70,7 @@
<div class="d-flex align-items-center mr-4">
<span class="mr-2">Index</span>
{% for job in fetcher.index_jobs %}
{{ job_icon(solr_project, job) }}
{{ legacy_job_icon(job) }}
{% else %}
<a href="{{ jobs_url(args.gitlab_base_url, solr_project) }}" data-toggle="tooltip" data-placement="auto" title="No index job found in the latest jobs of {{ solr_project.path }}">
<i class="fas fa-question-circle text-warning"></i>
......@@ -34,7 +80,7 @@
<div class="d-flex align-items-center">
<span class="mr-2">Validate</span>
{% for job in fetcher.validate_jobs %}
{{ job_icon(data_model_project, job) }}
{{ legacy_job_icon(job) }}
{% else %}
<a href="{{ jobs_url(args.gitlab_base_url, data_model_project) }}" data-toggle="tooltip" data-placement="auto" title="No validate job found in the latest jobs of {{ data_model_project.path }}">
<i class="fas fa-question-circle text-warning"></i>
......
......@@ -16,10 +16,6 @@
{% endmacro %}
{% macro job_tooltip(job) %}
{% if job.gitlab_job.ref != MASTER %}
branch: {{ job.gitlab_job.ref }}
<br>
{% endif %}
id: {{ job.gitlab_job.id }}
<br>
name: {{ job.gitlab_job.name }}
......@@ -58,18 +54,16 @@
updated: {{ local_time(pipeline.updated_at) if pipeline.updated_at else "?" }}
{% endmacro %}
{% macro job_icon(project, job) %}
{# Add background when jobs are not triggered from master #}
{% set style = "background-color: yellow;" if job.gitlab_job.ref != MASTER else "" %}
{% macro job_icon(job) %}
{% if job.is_fetcher_job and job.success_rate is not none and job.success_rate < 100 %}
{# When completion information is available and fetcher did not process all data, display a progress bar. #}
<a href="{{ job.gitlab_job.web_url }}" class="w-100 mr-2" style="{{ style }}">
<a href="{{ job.gitlab_job.web_url }}" class="w-100 mr-2">
<div class="progress border border-dark" title="{{ job_tooltip(job) }}" data-toggle="tooltip" data-html="true" style="min-width: 3em;">
<div role="progressbar" style="width: {{ job.success_rate }}%" aria-valuenow="{{ job.success_rate }}" aria-valuemin="0" aria-valuemax="100" class="progress-bar bg-success"></div>
</div>
</a>
{% else %}
<a href="{{ job.gitlab_job.web_url }}" class="mr-1" data-toggle="tooltip" data-html="true" data-placement="auto" title="{{ job_tooltip(job) }}" style="{{ style }}">
<a href="{{ job.gitlab_job.web_url }}" class="mr-1" data-toggle="tooltip" data-html="true" data-placement="auto" title="{{ job_tooltip(job) }}">
<i class="fas {{ job.get_job_icon_classes() }}"></i>
</a>
{% endif %}
......@@ -85,7 +79,7 @@
<span class="mr-4">
<span class="mr-2">{{ stage | capitalize }}</span>
{% for job in jobs %}
{{ job_icon(fetcher.project, job) }}
{{ job_icon(job) }}
{% endfor %}
</span>
{% endfor %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment