#844 [frontend] sortable tables for importing, pending and running status pages
Merged 4 years ago by msuchy. Opened 4 years ago by thrnciar.
copr/ thrnciar/copr running-tasks-sort  into  master

@@ -632,3 +632,55 @@ 

    });

    </script>

  {% endmacro %}

+ 

+ {% macro status_info(type, tasks) %}

+   <table class="datatable table table-striped table-bordered">

+       <thead>

+         <tr>

+           <th>

+             {% if type == 'importing' %}

+               Waiting

+             {% elif type == 'pending' %}

+               Pending

+             {% else %}

+               Running

+             {% endif %}

+           </th>

+           <th>Project</th>

+           <th>Build</th>

+           {% if type != 'importing' %}

+             <th>Package Name</th>

+             <th>Package Version</th>

+             <th>Chroot</th>

+           {% endif %}

+         </tr>

+       </thead>

+       <tbody>

+         {% for task in tasks %}

+           {% set build_chroot = task if type == 'importing' else task.build %}

+           <tr>

+             {% if type != 'running' %}

+               <td data-order="{{ build_chroot.submitted_on }}">{{ build_chroot.submitted_on | time_ago }}</td>

+             {% else %}

+               <td data-order="{{ build_chroot.started_on }}">{{ build_chroot.started_on | time_ago }}</td>

+             {% endif %}

+               <td data-order="{{ build_chroot.copr }}">

+                 <a href="{{ copr_details_href(build_chroot.copr) }}">

+                   {{ copr_name(build_chroot.copr) }}

+                 </a>

+               </td>

+               <td data-order="{{ build_chroot.id }}">

+                 <a href="{{ build_href(build_chroot) }}">

+                   {{ build_chroot.id }}

+                 </a>

+               </td>

+             {% if type != 'importing' %}

+               <td data-order="{{ task.build.package.name }}">{{ task.build.package.name }} </td>

+               <td data-order="{{ task.build.pkg_version }}">{{ task.build.pkg_version }} </td>

+               <td data-order="{{ task.mock_chroot.name }}">{{ task.mock_chroot.name }}</td>

+             {% endif %}

+           </tr>

+         {% endfor %}

+       </tbody>

+     </table>

+ {% endmacro %}

@@ -1,5 +1,5 @@ 

  {% extends "status.html" %}

- {% from "_helpers.html" import build_href, copr_name, copr_details_href %}

+ {% from "_helpers.html" import build_href, copr_name, copr_details_href, initialize_datatables, status_info %}

  {% block importing_selected %}active{% endblock %}

  {%block status_breadcrumb %}

  <li class="active">
@@ -20,30 +20,7 @@ 

      (+ {{ bg_tasks_cnt }} others with lower priority)

  </h2>

  

- <table class="table table-striped table-bordered">

-   <thead>

-     <tr>

-       <th>Waiting</th>

-       <th>Project</th>

-       <th>Build</th>

-     </tr>

-   </thead>

-   <tbody>

-   {% for task in tasks %}

-     <tr>

-       <td>

-         {{ task.submitted_on | time_ago }}

-       </td>

-       <td><a href="{{ copr_details_href(task.copr) }}">

-         {{ copr_name(task.copr) }}

-       </a>

-       </td>

-       <td><a href="{{ build_href(task) }}">

-         {{ task.id }}

-       </a></td>

-     </tr>

-     {% endfor %}

-   </tbody>

- </table>

+ {{ status_info(type="importing", tasks=tasks) }}

  

- {% endblock %}

+ {{ initialize_datatables(order="desc") }}

+ {% endblock %} 

\ No newline at end of file

@@ -1,5 +1,5 @@ 

  {% extends "status.html" %}

- {% from "_helpers.html" import build_href, copr_name, copr_details_href %}

+ {% from "_helpers.html" import build_href, copr_name, copr_details_href, initialize_datatables, status_info %}

  {% block pending_selected %}active{% endblock %}

  {%block status_breadcrumb %}

  <li class="active">
@@ -20,40 +20,7 @@ 

  	(+{{ bg_tasks_cnt }} others with lower priority)

  </h2>

  

- <table class="table table-striped table-bordered">

-   <thead>

-     <tr>

-       <th>Pending</th>

-       <th>Project</th>

-       <th>Build</th>

-       <th>Package Name</th>

-       <th>Package Version</th>

-       <th>Chroot</th>

-     </tr>

-   </thead>

-   <tbody>

-   {% for task in tasks %}

-     <tr>

-       <td>

-       {% if task.state == "starting" %}

-         <span class="build-starting">starting</span>

-       {% else %}

-         {{ task.build.submitted_on | time_ago }}

-       {% endif %}

-       </td>

-       <td><a href="{{ copr_details_href(task.build.copr) }}">

-         {{ copr_name(task.build.copr) }}

-       </a>

-       </td>

-       <td><a href="{{ build_href(task.build) }}">

-         {{ task.build_id }}

-       </a></td>

-       <td>{{ task.build.package.name }} </td>

-       <td>{{ task.build.pkg_version }} </td>

-       <td>{{ task.mock_chroot.name }}</td>

-     </tr>

-     {% endfor %}

-   </tbody>

- </table>

+ {{ status_info(type="pending", tasks=tasks) }}

  

+ {{ initialize_datatables(order="desc") }}

  {% endblock %}

@@ -1,5 +1,5 @@ 

  {% extends "status.html" %}

- {% from "_helpers.html" import build_href, copr_name, copr_details_href %}

+ {% from "_helpers.html" import build_href, copr_name, copr_details_href, initialize_datatables, status_info %}

  {% block running_selected %}active{% endblock %}

  {%block status_breadcrumb %}

  <li class="active">
@@ -19,35 +19,7 @@ 

      are running

  </h2>

  

+ {{ status_info(type="running", tasks=tasks) }}

  

- <table class="table table-striped table-bordered">

-   <thead>

-     <tr>

-       <th>Running</th>

-       <th>Project</th>

-       <th>Build</th>

-       <th>Package Name</th>

-       <th>Package Version</th>

-       <th>Chroot</th>

-     </tr>

-   </thead>

-   <tbody>

-   {% for task in tasks %}

-     <tr>

-       <td>{{ task.started_on | time_ago }}</td>

-       <td><a href="{{ copr_details_href(task.build.copr) }}">

-         {{ copr_name(task.build.copr) }}

-       </a>

-       </td>

-       <td><a href="{{ build_href(task.build) }}">

-         {{ task.build_id }}

-       </a></td>

-       <td>{{ task.build.package.name }} </td>

-       <td>{{ task.build.pkg_version }} </td>

-       <td>{{ task.mock_chroot.name }}</td>

-     </tr>

-   {% endfor %}

-   </tbody>

- </table>

- 

+ {{ initialize_datatables(order="desc") }}

  {% endblock %}

1 new commit added

  • [frontend] new macro for pending and running tables
4 years ago

The last two <TD> tags seem to be C&P in if/else branch, while it could live out from the {% if %} condition.

I'd cut the tags out from the if/else condition, but it's nit.

Thanks, I like to macro version more! :-) It would be awesome to cover the "importing" by the macro as well, if reasonably possible.

It would be awesome to cover the "importing" by the macro as well, if reasonably possible.

Note that you should be able to do stuff like:

{% set build = task if type == 'importing' else task.build %}

And than you can access the build property directly ...

1 new commit added

  • [frontend] one macro covering importing, pending and running pages
4 years ago

[copr-build] pagure.io doesn't send messages: https://pagure.io/fedora-infrastructure/issue/7994

Importing tab raises:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/share/copr/coprs_frontend/coprs/rest_api/__init__.py", line 44, in error_router
    return original_handler(e)
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/share/copr/coprs_frontend/coprs/views/status_ns/status_general.py", line 33, in importing
    return render_status("importing", tasks=tasks, bg_tasks_cnt=bg_tasks_cnt)
  File "/usr/share/copr/coprs_frontend/coprs/views/status_ns/status_general.py", line 38, in render_status
    tasks=tasks, bg_tasks_cnt=bg_tasks_cnt)
  File "/usr/lib/python3.7/site-packages/flask/templating.py", line 135, in render_template
    context, ctx.app)
  File "/usr/lib/python3.7/site-packages/flask/templating.py", line 117, in _render
    rv = template.render(context)
  File "/usr/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/usr/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "/usr/share/copr/coprs_frontend/coprs/templates/status/importing.html", line 2, in top-level template code
    {% from "_helpers.html" import build_href, copr_name, copr_details_href, initialize_datatables, status_info %}
  File "/usr/share/copr/coprs_frontend/coprs/templates/status.html", line 1, in top-level template code
    {% extends "layout.html" %}
  File "/usr/share/copr/coprs_frontend/coprs/templates/layout.html", line 98, in top-level template code
    {% block body %}{% endblock %}
  File "/usr/share/copr/coprs_frontend/coprs/templates/status.html", line 41, in block "body"
    {% block status_body %}{% endblock %}
  File "/usr/share/copr/coprs_frontend/coprs/templates/status/importing.html", line 23, in block "status_body"
    {{ status_info(type="importing", tasks=tasks) }}
  File "/usr/lib/python3.7/site-packages/jinja2/runtime.py", line 579, in _invoke
    rv = self._func(*arguments)
  File "/usr/share/copr/coprs_frontend/coprs/templates/_helpers.html", line 671, in template
    <td data-order="{{ task.build.copr }}">
  File "/usr/lib/python3.7/site-packages/jinja2/environment.py", line 430, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'coprs.models.Build object' has no attribute 'build'

Otherwise looks very nice, please squash.

rebased onto 0f35c98c6d9672d085333a23002becb465ddbe8c

4 years ago

rebased onto f1aaec6

4 years ago

Pull-Request has been merged by msuchy

4 years ago