Mercurial > repos > goeckslab > ludwig_evaluate
annotate utils.py @ 6:cbea2960cca2 draft default tip
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
| author | goeckslab |
|---|---|
| date | Sat, 22 Nov 2025 01:16:50 +0000 |
| parents | 70a4d910f09a |
| children |
| rev | line source |
|---|---|
|
0
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
1 import base64 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
2 import json |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
3 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
4 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
5 def get_html_template(): |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
6 return """ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
7 <html> |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
8 <head> |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
9 <title>Galaxy-Ludwig Report</title> |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
10 <style> |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
11 body { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
12 font-family: Arial, sans-serif; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
13 margin: 0; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
14 padding: 20px; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
15 background-color: #f4f4f4; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
16 } |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
17 .container { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
18 max-width: 800px; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
19 margin: auto; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
20 background: white; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
21 padding: 20px; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
22 box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
23 overflow-x: auto; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
24 } |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
25 h1 { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
26 text-align: center; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
27 color: #333; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
28 } |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
29 h2 { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
30 border-bottom: 2px solid #4CAF50; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
31 color: #4CAF50; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
32 padding-bottom: 5px; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
33 } |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
34 table { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
35 border-collapse: collapse; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
36 margin: 20px 0; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
37 width: 100%; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
38 table-layout: fixed; /* Enforces consistent column widths */ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
39 } |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
40 table, th, td { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
41 border: 1px solid #ddd; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
42 } |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
43 th, td { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
44 padding: 8px; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
45 text-align: center; /* Center-align text */ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
46 vertical-align: middle; /* Center-align content vertically */ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
47 word-wrap: break-word; /* Break long words to avoid overflow */ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
48 } |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
49 th:first-child, td:first-child { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
50 width: 5%; /* Smaller width for the first column */ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
51 } |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
52 th:nth-child(2), td:nth-child(2) { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
53 width: 50%; /* Wider for the metric/description column */ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
54 } |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
55 th:last-child, td:last-child { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
56 width: 25%; /* Value column gets remaining space */ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
57 } |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
58 th { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
59 background-color: #4CAF50; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
60 color: white; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
61 } |
|
6
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
62 /* feature importance layout tweaks */ |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
63 table.feature-importance-table { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
64 table-layout: auto; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
65 } |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
66 table.feature-importance-table th, |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
67 table.feature-importance-table td { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
68 white-space: nowrap; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
69 word-break: normal; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
70 } |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
71 /* sortable tables */ |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
72 .sortable-table th.sortable { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
73 cursor: pointer; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
74 position: relative; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
75 user-select: none; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
76 } |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
77 .sortable-table th.sortable::after { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
78 content: '⇅'; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
79 position: absolute; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
80 right: 12px; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
81 top: 50%; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
82 transform: translateY(-50%); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
83 font-size: 0.8em; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
84 color: #eaf5ea; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
85 text-shadow: 0 0 1px rgba(0,0,0,0.15); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
86 } |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
87 .sortable-table th.sortable.sorted-none::after { content: '⇅'; color: #eaf5ea; } |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
88 .sortable-table th.sortable.sorted-asc::after { content: '↑'; color: #ffffff; } |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
89 .sortable-table th.sortable.sorted-desc::after { content: '↓'; color: #ffffff; } |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
90 .scroll-rows-30 { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
91 max-height: 900px; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
92 overflow-y: auto; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
93 overflow-x: auto; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
94 } |
|
0
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
95 .plot { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
96 text-align: center; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
97 margin: 20px 0; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
98 } |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
99 .plot img { |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
100 max-width: 100%; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
101 height: auto; |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
102 } |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
103 </style> |
|
6
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
104 <script> |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
105 (function() { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
106 if (window.__sortableInit) return; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
107 window.__sortableInit = true; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
108 |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
109 function initSortableTables() { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
110 document.querySelectorAll('table.sortable-table tbody').forEach(tbody => { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
111 Array.from(tbody.rows).forEach((row, i) => { row.dataset.originalOrder = i; }); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
112 }); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
113 |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
114 const getText = td => (td?.innerText || '').trim(); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
115 const cmp = (idx, asc) => (a, b) => { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
116 const v1 = getText(a.children[idx]); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
117 const v2 = getText(b.children[idx]); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
118 const n1 = parseFloat(v1), n2 = parseFloat(v2); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
119 if (!isNaN(n1) && !isNaN(n2)) return asc ? n1 - n2 : n2 - n1; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
120 return asc ? v1.localeCompare(v2) : v2.localeCompare(v1); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
121 }; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
122 |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
123 document.querySelectorAll('table.sortable-table th.sortable').forEach(th => { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
124 th.classList.remove('sorted-asc','sorted-desc'); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
125 th.classList.add('sorted-none'); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
126 |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
127 th.addEventListener('click', () => { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
128 const table = th.closest('table'); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
129 const headerRow = th.parentNode; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
130 const allTh = headerRow.querySelectorAll('th.sortable'); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
131 const tbody = table.querySelector('tbody'); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
132 |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
133 const isAsc = th.classList.contains('sorted-asc'); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
134 const isDesc = th.classList.contains('sorted-desc'); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
135 |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
136 allTh.forEach(x => x.classList.remove('sorted-asc','sorted-desc','sorted-none')); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
137 |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
138 let next; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
139 if (!isAsc && !isDesc) { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
140 next = 'asc'; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
141 } else if (isAsc) { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
142 next = 'desc'; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
143 } else { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
144 next = 'none'; |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
145 } |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
146 th.classList.add('sorted-' + next); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
147 |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
148 const rows = Array.from(tbody.rows); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
149 if (next === 'none') { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
150 rows.sort((a, b) => (a.dataset.originalOrder - b.dataset.originalOrder)); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
151 } else { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
152 const idx = Array.from(headerRow.children).indexOf(th); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
153 rows.sort(cmp(idx, next === 'asc')); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
154 } |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
155 rows.forEach(r => tbody.appendChild(r)); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
156 }); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
157 }); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
158 } |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
159 |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
160 if (document.readyState === 'loading') { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
161 document.addEventListener('DOMContentLoaded', initSortableTables); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
162 } else { |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
163 initSortableTables(); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
164 } |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
165 })(); |
|
cbea2960cca2
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit e2ab4c0f9ce8b7a0a48f749ef5dd9899d6c2b1f8
goeckslab
parents:
0
diff
changeset
|
166 </script> |
|
0
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
167 </head> |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
168 <body> |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
169 <div class="container"> |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
170 """ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
171 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
172 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
173 def get_html_closing(): |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
174 return """ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
175 </div> |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
176 </body> |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
177 </html> |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
178 """ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
179 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
180 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
181 def encode_image_to_base64(image_path): |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
182 """Convert an image file to a base64 encoded string.""" |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
183 with open(image_path, "rb") as img_file: |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
184 return base64.b64encode(img_file.read()).decode("utf-8") |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
185 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
186 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
187 def json_to_nested_html_table(json_data, depth=0): |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
188 """ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
189 Convert JSON object to an HTML nested table. |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
190 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
191 Parameters: |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
192 json_data (dict or list): The JSON data to convert. |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
193 depth (int): Current depth level for indentation. |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
194 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
195 Returns: |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
196 str: HTML string for the nested table. |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
197 """ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
198 # Base case: if JSON is a simple key-value pair dictionary |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
199 if isinstance(json_data, dict) and all( |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
200 not isinstance(v, (dict, list)) for v in json_data.values() |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
201 ): |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
202 # Render a flat table |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
203 rows = [ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
204 f"<tr><th>{key}</th><td>{value}</td></tr>" |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
205 for key, value in json_data.items() |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
206 ] |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
207 return f"<table>{''.join(rows)}</table>" |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
208 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
209 # Base case: if JSON is a list of simple values |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
210 if isinstance(json_data, list) and all( |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
211 not isinstance(v, (dict, list)) for v in json_data |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
212 ): |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
213 rows = [ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
214 f"<tr><th>Index {i}</th><td>{value}</td></tr>" |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
215 for i, value in enumerate(json_data) |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
216 ] |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
217 return f"<table>{''.join(rows)}</table>" |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
218 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
219 # Recursive case: if JSON contains nested structures |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
220 if isinstance(json_data, dict): |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
221 rows = [ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
222 f"<tr><th style='padding-left:{depth * 20}px;'>{key}</th>" |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
223 f"<td>{json_to_nested_html_table(value, depth + 1)}</td></tr>" |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
224 for key, value in json_data.items() |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
225 ] |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
226 return f"<table>{''.join(rows)}</table>" |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
227 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
228 if isinstance(json_data, list): |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
229 rows = [ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
230 f"<tr><th style='padding-left:{depth * 20}px;'>[{i}]</th>" |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
231 f"<td>{json_to_nested_html_table(value, depth + 1)}</td></tr>" |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
232 for i, value in enumerate(json_data) |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
233 ] |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
234 return f"<table>{''.join(rows)}</table>" |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
235 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
236 # Base case: simple value |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
237 return f"{json_data}" |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
238 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
239 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
240 def json_to_html_table(json_data): |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
241 """ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
242 Convert JSON to a vertically oriented HTML table. |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
243 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
244 Parameters: |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
245 json_data (str or dict): JSON string or dictionary. |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
246 |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
247 Returns: |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
248 str: HTML table representation. |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
249 """ |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
250 if isinstance(json_data, str): |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
251 json_data = json.loads(json_data) |
|
70a4d910f09a
planemo upload for repository https://github.com/goeckslab/Galaxy-Ludwig.git commit bdea9430787658783a51cc6c2ae951a01e455bb4
goeckslab
parents:
diff
changeset
|
252 return json_to_nested_html_table(json_data) |
