Skia has proposed merging ~hyask/autopkgtest-cloud:skia/web_ui_improvements 
into autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~hyask/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/462068
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of 
~hyask/autopkgtest-cloud:skia/web_ui_improvements into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/browse.cgi b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
index f71b406..dafa1b3 100755
--- a/charms/focal/autopkgtest-web/webcontrol/browse.cgi
+++ b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
@@ -371,6 +371,51 @@ def package_release_arch(package, release, arch, _=None):
             )
         )
 
+    # Add running jobs if any
+    for _, running_jobs in get_running_jobs().get(package, {}).items():
+        job = running_jobs.get(release, {}).get(arch, {})
+        if job:
+            results.insert(
+                0,
+                (
+                    "N/A",
+                    job[0].get("triggers"),
+                    "N/A",
+                    human_date(job[0].get("submit-time")),
+                    human_sec(int(job[1])),
+                    job[0].get("requester", "-"),
+                    "running",
+                    "",
+                    False,
+                    "",
+                    job[0].get("uuid", "-"),
+                ),
+            )
+
+    # Add queued jobs if any
+    (_, _, queues_info) = get_queues_info()
+    for _, queue in queues_info.items():
+        queue_items = queue.get(release, {}).get(arch, [0, []])[1]
+        for item in queue_items:
+            if item.startswith(package + "\n"):
+                item_info = json.loads(item.split("\n")[1])
+                results.insert(
+                    0,
+                    (
+                        "N/A",
+                        item_info.get("triggers"),
+                        "N/A",
+                        human_date(item_info.get("submit-time")),
+                        "N/A",
+                        "-",
+                        "queued",
+                        "",
+                        False,
+                        "",
+                        "N/A",
+                    ),
+                )
+
     return render(
         "browse-results.html",
         package=package,
@@ -536,21 +581,21 @@ def invalid(inv_exception, code=400):
     return render("browse-error.html", error=inv_exception, code=code)
 
 
-@app.errorhandler(Exception)
-def all_exception_handler(error):
-    # If the exception doesn't have the exit_code method, it's not an expected
-    # exception defined in helpers/exceptions.py
-    try:
-        return invalid(error, error.exit_code())
-    except Exception as e:
-        return render(
-            "browse-error.html",
-            error=f"Error {e} during handling of {error}",
-            code=500,
-        )
+if __name__ == "__main__":
 
+    @app.errorhandler(Exception)
+    def all_exception_handler(error):
+        # If the exception doesn't have the exit_code method, it's not an expected
+        # exception defined in helpers/exceptions.py
+        try:
+            return invalid(error, error.exit_code())
+        except Exception as e:
+            return render(
+                "browse-error.html",
+                error=f"Error {e} during handling of {error}",
+                code=500,
+            )
 
-if __name__ == "__main__":
     app.config["DEBUG"] = True
     init_config()
     CGIHandler().run(app)
diff --git a/charms/focal/autopkgtest-web/webcontrol/helpers/tests.py b/charms/focal/autopkgtest-web/webcontrol/helpers/tests.py
index de23699..1c26fb9 100644
--- a/charms/focal/autopkgtest-web/webcontrol/helpers/tests.py
+++ b/charms/focal/autopkgtest-web/webcontrol/helpers/tests.py
@@ -55,8 +55,9 @@ def populate_dummy_amqp_cache(path):
                     "ubuntu": {
                         supported_releases[0]: {
                             "amd64": {
-                                "size": 1,
+                                "size": 2,
                                 "requests": [
+                                    'hello\n{"triggers": ["hello/1.2.3ubuntu2"], "submit-time": "2024-02-22 01:56:14"}',
                                     'hello\n{"triggers": ["hello/1.2.3ubuntu1"], "submit-time": "2024-02-22 01:55:03"}',
                                 ],
                             }
@@ -105,7 +106,26 @@ def populate_dummy_running_cache(path):
         json.dump(
             {
                 "hello": {
-                    "hash1": {
+                    "hello-hash0": {
+                        supported_releases[0]: {
+                            "amd64": [
+                                {
+                                    "submit-time": "2024-02-21 11:00:51",
+                                    "triggers": [
+                                        "hello/1.2.3",
+                                        "hello2/2.2.2",
+                                    ],
+                                    "uuid": "01345a9c-ac08-46a3-a5fd-6247d0d2021c",
+                                },
+                                3204,
+                                """
+3192s hello/test_XYZ.hello ..................                       [ 84%]
+3193s hello/test_XYZ.hello ............................             [ 94%]
+""",
+                            ]
+                        }
+                    },
+                    "hello-hash1": {
                         supported_releases[0]: {
                             "amd64": [
                                 {
@@ -128,7 +148,7 @@ def populate_dummy_running_cache(path):
                             ]
                         }
                     },
-                    "hash2": {
+                    "hello-hash2": {
                         supported_releases[1]: {
                             "amd64": [
                                 {
@@ -153,7 +173,7 @@ def populate_dummy_running_cache(path):
                     },
                 },
                 "hello2": {
-                    "hash1": {
+                    "hello-hash1": {
                         supported_releases[4]: {
                             "amd64": [
                                 {
diff --git a/charms/focal/autopkgtest-web/webcontrol/static/style.css b/charms/focal/autopkgtest-web/webcontrol/static/style.css
index d02727a..9012ab1 100644
--- a/charms/focal/autopkgtest-web/webcontrol/static/style.css
+++ b/charms/focal/autopkgtest-web/webcontrol/static/style.css
@@ -1,3 +1,38 @@
+.queued:before {
+  content: ".";
+  display: inline-block;
+  margin: 5px;
+  font-size: 1.3em;
+  vertical-align: top;
+  line-height: 14px;
+  width: 14px;
+  height: 14px;
+  animation: bounce 2s linear infinite;
+}
+
+@keyframes bounce {
+  0% { transform: translate(0px); }
+  50% { transform: translate(0px, -14px); }
+  100% { transform: translate(0px); }
+}
+
+.running:before {
+  content: "⚙";
+  display: inline-block;
+  margin: 5px;
+  font-size: 1.3em;
+  vertical-align: top;
+  line-height: 14px;
+  width: 14px;
+  height: 14px;
+  animation: spin 1.2s linear infinite;
+}
+
+@keyframes spin {
+  0% { transform: rotate(0deg); }
+  100% { transform: rotate(360deg); }
+}
+
 .pass:before {
   content: "✔ ";
   color: #8ae234;
@@ -38,6 +73,27 @@
   font-size: 130%;
 }
 
+/* external links to launchpad, excuses, ... */
+
+.external-links {
+  list-style-type: none;
+  padding: 0em;
+  margin: 0em;
+}
+
+.external-links li {
+  display: inline;
+}
+
+.external-links li a {
+  padding: 0.5em;
+}
+
+.icon {
+  height: 1em;
+  margin: 0.5em;
+}
+
 /* package browsing by prefix */
 
 .list-inline h5 a {
@@ -68,3 +124,7 @@ th.sticky-table-headers {
     /* Displayed on top of other rows when scrolling */
     z-index: 9999;
 }
+
+.unfinished {
+  color: grey;
+}
diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html
index ea59f0f..165cfd8 100644
--- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html
+++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-package.html
@@ -3,9 +3,14 @@
 
 {% block content %}
   <h2>{{package}}</h2>
-  {{ macros.launchpad_link(package) }}
-  |
-  {{ macros.excuses_link(package) }}
+  <ul class="external-links">
+    <li>
+      {{ macros.launchpad_link(package) }}
+    </li>
+    <li>
+      {{ macros.excuses_link(package) }}
+    </li>
+  </ul>
 
   <table class="table" style='width: auto'>
     <tr>
diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html
index fd300f7..05a3c2e 100644
--- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html
+++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-results.html
@@ -3,9 +3,14 @@
 
 {% block content %}
   <h2><a href="{{base_url}}packages/{{package}}">{{package}}</a> <small>[{{release}}/{{arch}}]</small></h2>
-  {{ macros.launchpad_link(package, release) }}
-  |
-  {{ macros.excuses_link(package, release) }}
+  <ul class="external-links">
+    <li>
+      {{ macros.launchpad_link(package, release) }}
+    </li>
+    <li>
+      {{ macros.excuses_link(package, release) }}
+    </li>
+  </ul>
 
   <table class="table">
     <tr>
@@ -21,7 +26,7 @@
     </tr>
 
   {% for row in package_results %}
-    <tr>
+    <tr {% if row[6] in ["running", "queued"] %}class="unfinished"{% endif %}>
       <td>{{row[0]}}</td>
       <td>{{row[1]}}</td>
       <td>{{row[2]}}</td>
@@ -34,11 +39,13 @@
           {{row[5]}}
         {% endif %}
       </td>
-      <td class="{{row[6]}}">{{row[6]}}</td>
+      <td class="nowrap {{row[6]}}" title={{ row[6] }}>{{row[6]}}</td>
       <td>{{row[10]}}</td>
       <td class="nowrap">
+        {% if row[6] not in ["running", "queued"] %}
         <a href="{{row[7]}}/log.gz">log</a> &emsp;
         <a href="{{row[7]}}/artifacts.tar.gz">artifacts</a> &emsp;
+        {% endif %}
       </td>
       <td class="nowrap">
         {% if row[8] %}
diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/macros.html b/charms/focal/autopkgtest-web/webcontrol/templates/macros.html
index 8995301..941dc77 100644
--- a/charms/focal/autopkgtest-web/webcontrol/templates/macros.html
+++ b/charms/focal/autopkgtest-web/webcontrol/templates/macros.html
@@ -60,5 +60,5 @@
 {% if release != "" %}
 {% set release = release + "/" %}
 {% endif %}
-<a href="https://launchpad.net/ubuntu/{{ release }}+source/{{ package_name }}"><img src="{{ url_for('static', filename='launchpad.ico') }}" style="height: 1em;">Launchpad</a>
+<a href="https://launchpad.net/ubuntu/{{ release }}+source/{{ package_name }}"><img src="{{ url_for('static', filename='launchpad.ico') }}" class="icon">Launchpad</a>
 {%- endmacro %}
-- 
Mailing list: https://launchpad.net/~canonical-ubuntu-qa
Post to     : canonical-ubuntu-qa@lists.launchpad.net
Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa
More help   : https://help.launchpad.net/ListHelp

Reply via email to