From b942d3da2b8c07413d70eb4b1a2fc24b250f417c Mon Sep 17 00:00:00 2001
From: Vermaas <vermaas@astron.nl>
Date: Fri, 14 Apr 2023 11:39:46 +0200
Subject: [PATCH] also add plot images to quality page

---
 .gitignore                               |  1 +
 atdb/taskdatabase/services/algorithms.py | 12 ++++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 5f4486cc..4d9e05e6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 /atdb/logs/
+R:\source\django\atdb-ldv\atdb\logs\atdb.log
\ No newline at end of file
diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py
index bdcdc4ce..00aba5ad 100644
--- a/atdb/taskdatabase/services/algorithms.py
+++ b/atdb/taskdatabase/services/algorithms.py
@@ -711,7 +711,12 @@ def construct_inspectionplots(task,source='task_id'):
                 results += '<tr><td><a href="' + url + '" target="_blank">'+ basename + '</a></td></tr>'
 
                 if basename.endswith('png'):
-                    results += '<tr><td><a href="' + url + '" target="_blank"><img width="800" src="' + url + '" alt="' + basename + '"/></a></td></tr>'
+                    # retrieve the url and add the binary data to the html
+                    response = requests.get(url)
+                    content_as_string = base64.b64encode(response.content).decode("utf-8")
+                    img_html = '<img width="800" src = "data:image/png;base64,' + content_as_string + '">'
+                    results += '<tr><td><a href="' + url + '" alt="' + basename + '" target="_blank">' + img_html + '</a></td></tr>'
+                    #results += '<tr><td><a href="' + url + '" target="_blank"><img width="800" src="' + url + '" alt="' + basename + '"/></a></td></tr>'
 
                 plot_files.append(basename)
 
@@ -749,14 +754,13 @@ def construct_inspectionplots(task,source='task_id'):
                         results += '<tr><td><a href="' + url + '" target="_blank">' + basename + '</a></td></tr>'
 
                         if basename.endswith('png'):
-                            # retrieve and evaluate the url first
-                            #logger.info('retrieve '+url)
+                            # retrieve the url and add the binary data to the html
                             response = requests.get(url)
                             content_as_string = base64.b64encode(response.content).decode("utf-8")
                             img_html = '<img width="800" src = "data:image/png;base64,' + content_as_string + '">'
 
 #                            results += '<tr><td><a href="' + url + '" target="_blank"><img width="800" src="' + url + '" alt="'+basename+'"/></a></td></tr>'
-                            results += '<tr><td><a href="' + url + '" target="_blank">' + img_html+ '</a></td></tr>'
+                            results += '<tr><td><a href="' + url + '" alt="'+basename+'" target="_blank">' + img_html+ '</a></td></tr>'
 
                         plot_files.append(plot_file)
 
-- 
GitLab