Skip to content

Commit 3c1be40

Browse files
committed
Better style for policies, start of filter option
1 parent 65d44e5 commit 3c1be40

6 files changed

Lines changed: 186 additions & 24 deletions

File tree

public/.hermes/process/transport.json

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"timestamp": "2025-03-18T13:28:37.657148",
2020
"harvester": "codemeta"
2121
},
22-
{"conflict": "Policy 1"}
22+
{"conflict": "None"}
2323
],
2424
"author": [
2525
{
@@ -349,7 +349,7 @@
349349
"timestamp": "2025-03-18T13:28:37.657148",
350350
"harvester": "cff"
351351
},
352-
{"conflict": "Policy 1"}
352+
{"conflict": "policy3"}
353353
],
354354
"givenName": ["Kernchen",
355355
{
@@ -358,7 +358,7 @@
358358
"timestamp": "2025-03-18T13:28:37.657148",
359359
"harvester": "cff"
360360
},
361-
{"conflict": "Policy 1"}
361+
{"conflict": "policy3"}
362362
],
363363
"email":["sophie.kernchen@dlr.de",
364364
{
@@ -439,14 +439,14 @@
439439
}
440440

441441
],
442-
"description": ["Cool tool",
442+
"description": ["Proof-of-concept implementation of the Software CaRD workflow.",
443443
{
444444
"plugin": "cff",
445445
"local_path": "CITATION.cff",
446446
"timestamp": "2025-03-18T13:28:37.657148",
447447
"harvester": "cff"
448448
},
449-
{"conflict": "None"}
449+
{"conflict": "policy2"}
450450
],
451451
"license": ["https://spdx.org/licenses/Apache-2.0",
452452
{
@@ -482,8 +482,12 @@
482482
{"conflict": "Curation"}
483483
],
484484

485-
"policies": [{"Policy 1": {"conforms": true}},
486-
{"Policy 2": {"conforms": false,
485+
"policies": [{"policy1": {
486+
"name": "Policy 1",
487+
"conforms": true}},
488+
{"policy2": {
489+
"name": "Policy 2",
490+
"conforms": false,
487491
"resultMessage": "String length not >= Literal(\"100\", datatype=xsd:integer)" ,
488492
"resultPath": "https://schema.org/description" ,
489493
"resultSeverity": "Violation" ,
@@ -493,9 +497,23 @@
493497
"minLength": 100 ,
494498
"name": "Long description" ,
495499
"path": "https://schema.org/description" },
496-
"value": "Proof-of-concept implementation of the HERMES workflow."
500+
"value": "Proof-of-concept implementation of the Software CaRD workflow."
501+
}},
502+
{"policy3": {
503+
"name": "Policy 3",
504+
"conforms": false,
505+
"resultMessage": "Name does not match the mapping" ,
506+
"resultPath": [["https://schema.org/familyName", "https://schema.org/givenName"]] ,
507+
"resultSeverity": "Violation" ,
508+
"sourceConstraintComponent": "MappingError" ,
509+
"sourceShape": { "datatype": "string" ,
510+
"description": "The names have to be in right order",
511+
"name": "Name order" ,
512+
"path": [["https://schema.org/familyName", "https://schema.org/givenName"]] },
513+
"value": [["Sophie", "Kernchen"]]
497514
}}
498515

516+
499517
]
500518
}
501519

public/curation/click.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function showFilter() {
2+
document.getElementById("filterDropdown").classList.toggle("show");
3+
}
4+
5+
function filterFunction() {
6+
var input, filter, ul, li, a, i;
7+
input = document.getElementById("myInput");
8+
filter = input.value.toUpperCase();
9+
div = document.getElementById("filterDropdown");
10+
a = div.getElementsByTagName("a");
11+
for (i = 0; i < a.length; i++) {
12+
txtValue = a[i].textContent || a[i].innerText;
13+
if (txtValue.toUpperCase().indexOf(filter) > -1) {
14+
a[i].style.display = "";
15+
} else {
16+
a[i].style.display = "none";
17+
}
18+
}
19+
}

public/curation/curation.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ export function displayJSON(json_document){
88
fetch(json_document)
99
.then(response => response.json())
1010
.then(data => {
11+
const colorPalette = ["rgb(34, 198, 227)", "purple", "rgb(23, 124, 207)", "rgb(116, 75, 196)", "pink"];
12+
let colorPolicies = {"Curation": "red"};
13+
if(data["policies"]){
14+
for(let i=0; i<data["policies"].length;i++){
15+
colorPolicies[Object.keys(data["policies"][i])] = colorPalette[i];
16+
}}
17+
console.log(colorPolicies);
1118
//Get data snippet from url
1219
const params = new URLSearchParams(location.search);
1320
if(params.has("id")){
@@ -29,6 +36,7 @@ export function displayJSON(json_document){
2936
const policyTemp = document.querySelector("#policy"),
3037
policyDiv = document.querySelector("#sw-policies");
3138

39+
3240

3341
const header = document.querySelector("#header-policies");
3442
header.style.display = "none";
@@ -46,10 +54,17 @@ export function displayJSON(json_document){
4654
const policy = document.importNode(policyTemp.content, true);
4755
const tbodyPol = policy.querySelector("tbody"),
4856
polname = policy.querySelector("#policy-name"),
57+
polcolor = policy.querySelector("#color"),
4958
pconforms = policy.querySelector("#policy-conforms");
5059
const policyId = Object.keys(pol)[0];
51-
polname.textContent = `${policyId}`;
60+
console.log(policyId);
61+
polname.textContent = `${pol[policyId]["name"]}`;
62+
//const randColor = '#'+(0x1000000+Math.random()*0xffffff).toString(16).slice(1,7);
63+
polcolor.id += '_'+policyId;
64+
polcolor.style.background = colorPolicies[policyId];
65+
console.log(colorPolicies);
5266
policyDiv.appendChild(policy);
67+
5368
const policyReportTemp = document.querySelector("#policy-report");
5469
const polKeys = Object.keys(pol[policyId]);
5570
polKeys.forEach(report =>{
@@ -59,8 +74,8 @@ export function displayJSON(json_document){
5974
pvalue = prow.querySelector("#pvalue");
6075

6176
if(report=="conforms"){
62-
pconforms.innerText = `${policyId} ${(pol[policyId][report]) ? 'is' : 'is not'} conform.`;
63-
pconforms.style.color = (pol[policyId][report]) ? 'black' : 'red';
77+
pconforms.innerText = `${pol[policyId]["name"]} ${(pol[policyId][report]) ? 'is' : 'is not'} conform.`;
78+
pconforms.style.color = (pol[policyId][report]) ? 'green' : 'red';
6479
}
6580
pkey.textContent = `${report}`;
6681
extract_info(pvalue, pol[policyId][report]);
@@ -79,7 +94,7 @@ export function displayJSON(json_document){
7994
mtag = row.querySelector("#tag");
8095

8196
mkey.textContent = `${element}`;
82-
extract_info(mvalue, data[element], mtag);
97+
extract_info(mvalue, data[element], mtag, colorPolicies);
8398

8499
tbody.appendChild(row);
85100
})

public/curation/extract.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
function extract_info(cell, obj, tag, category){
1+
function extract_info(cell, obj, tag, colorPolicies){
22
if(!Array.isArray(obj)){
33
obj = [obj];
44
}
55
if(typeof obj[0] === "string" || typeof obj[0] == "number" || typeof obj[0] == "boolean"){
6-
if(obj[2] && obj[2]["conflict"] == "Curation"){
6+
if(obj[2] && obj[2]["conflict"]){
77
const element = document.createElement("div");
8-
element.className += " error";
8+
element.style.color = colorPolicies[obj[2]["conflict"]];
99
element.appendChild(document.createTextNode(` ${obj[0]}`));
1010
cell.appendChild(element);
1111
}else{
@@ -16,7 +16,7 @@ function extract_info(cell, obj, tag, category){
1616
else if(!Array.isArray(obj[0]) && Object.keys(obj[0]).includes("familyName")){
1717
obj.forEach(e =>{
1818
const element = document.createElement("div");
19-
extract_person(e, element, tag);
19+
extract_person(e, element, tag, colorPolicies);
2020
cell.appendChild(element);
2121

2222
})}
@@ -37,7 +37,7 @@ function extract_info(cell, obj, tag, category){
3737
div.appendChild(document.createTextNode(`${key}: ${(obj[0][key])}`));
3838
}else{
3939
div.appendChild(document.createTextNode(`${key}: `));
40-
extract_info(div, obj[0][key], tag, key);
40+
extract_info(div, obj[0][key], tag, colorPolicies);
4141
}
4242
div.appendChild(document.createElement("br"));
4343
}
@@ -52,7 +52,7 @@ function extract_info(cell, obj, tag, category){
5252

5353
}
5454

55-
function extract_person(e, element, tag){
55+
function extract_person(e, element, tag, colorPolicies){
5656
const tooltip = document.createElement("div");
5757
const tooltiptag = document.createElement("div");
5858
tooltip.classList.add("tooltip");
@@ -74,19 +74,23 @@ function extract_info(cell, obj, tag, category){
7474
const pair_in_list = document.createElement("p");
7575
names.push(`${k}:${key}: ${e[k][key][0]}`);
7676
pair_in_list.appendChild(document.createTextNode(`${k}:${key}: ${e[k][key][0]}`));
77-
if(e[k][key][2] && e[k][key][2]["conflict"] == "Curation"){
78-
pair_in_list.className += " error";
79-
tooltiptag.className += " error";
77+
if(e[k][key][2] && e[k][key][2]["conflict"]){
78+
pair_in_list.style.color = colorPolicies[e[k][key][2]["conflict"]];
79+
tooltiptag.style.color = colorPolicies[e[k][key][2]["conflict"]];
80+
/*pair_in_list.className += " error";
81+
tooltiptag.className += " error";*/
8082
}
8183
pair.appendChild(pair_in_list);
8284
}
8385
}else{
8486
names.push(`${k}: ${e[k][0]}`);
8587
pair.appendChild(document.createTextNode(`${k}: ${e[k][0]}`));
8688

87-
if(e[k][2] && e[k][2]["conflict"] == "Curation"){
88-
pair.className += " error";
89-
tooltiptag.className += " error";
89+
if(e[k][2] && e[k][2]["conflict"]){
90+
pair.style.color = colorPolicies[e[k][2]["conflict"]];
91+
tooltiptag.style.color = colorPolicies[e[k][2]["conflict"]];
92+
//pair.className += " error";
93+
//tooltiptag.className += " error";
9094
}
9195
}
9296
tooltiptext.appendChild(pair);

public/curation/index.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,24 @@ <h1><a href="../">Software CaRD</a>
2121
</div>
2222

2323
<p id="project-name"><b>Metadata</b></p>
24+
<div class="operators">
25+
26+
27+
28+
<div class="dropdown">
29+
<button onclick="showFilter()" class="dropbtn">Filter</button>
30+
<div id="filterDropdown" class="dropdown-content">
31+
<input type="text" placeholder="Search.." id="myInput" onkeyup="filterFunction()">
32+
<a>&#10004; Conflicts</a>
33+
<a>&#10004; Policy 1</a>
34+
<a>&#10004; Policy 2</a>
35+
<a>&#10004; Policy 3</a>
36+
</div>
37+
</div>
38+
2439
<input type="checkbox" id="extended" name="extended" value=1 checked>
2540
<label for="extended">Extended view</label><br>
41+
</div>
2642

2743
<div id="content">
2844
<div id="hermes">
@@ -49,7 +65,10 @@ <h1><a href="../">Software CaRD</a>
4965
<div id="sw-policies">
5066
<h3 id="header-policies">Policy Report</h3>
5167
<template id="policy">
68+
<div class="policy-header">
69+
<div class="policy-color" id="color"></div>
5270
<b id="policy-name"></b>
71+
</div>
5372
<p id="policy-conforms"></p>
5473
<table>
5574
<tbody>
@@ -67,6 +86,7 @@ <h3 id="header-policies">Policy Report</h3>
6786

6887

6988
<script type="module" src="./script.js"></script>
89+
<script src="./click.js"></script>
7090

7191
</body>
7292
</html>

public/style.css

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ button{
5252
justify-content: center;
5353
}
5454

55+
.conflict-operators{
56+
display: flex;
57+
flex-direction: row;
58+
align-items: center;
59+
justify-content: flex-end;
60+
}
61+
5562
.tooltip {
5663
position: relative;
5764
border-bottom: 1px dotted black;
@@ -106,3 +113,82 @@ button{
106113
color: red;
107114
border-color:black;
108115
}
116+
.policy-header{
117+
display: flex;
118+
align-items: center;
119+
justify-content: center;
120+
121+
}
122+
.policy-color{
123+
width:10px;
124+
height:10px;
125+
border-radius: 5px;
126+
background-color: blue;
127+
margin: 7px;
128+
}
129+
130+
/* Dropdown Button */
131+
.dropbtn {
132+
font-size: 16px;
133+
border: none;
134+
cursor: pointer;
135+
width: 100px;
136+
height: 30px;
137+
text-align: center;
138+
background-image: none;
139+
background-color: #ddd;
140+
color:black
141+
142+
}
143+
144+
/* Dropdown button on hover & focus */
145+
.dropbtn:hover, .dropbtn:focus {
146+
background-color: rgb(23, 124, 207);
147+
}
148+
149+
/* The search field */
150+
#myInput {
151+
box-sizing: border-box;
152+
background-image: url('searchicon.png');
153+
background-position: 14px 12px;
154+
background-repeat: no-repeat;
155+
font-size: 16px;
156+
padding: 10px;
157+
border: none;
158+
border-bottom: 1px solid #ddd;
159+
}
160+
161+
/* The search field when it gets focus/clicked on */
162+
#myInput:focus {outline: 3px solid #ddd;}
163+
164+
.dropdown {
165+
position: relative;
166+
display: inline-block;
167+
left: 41%;
168+
top: -15px;
169+
}
170+
171+
/* Dropdown Content (Hidden by Default) */
172+
.dropdown-content {
173+
display: none;
174+
position: absolute;
175+
top: 35px;
176+
background-color: #f6f6f6;
177+
min-width: 50px;
178+
border: 1px solid #ddd;
179+
z-index: 1;
180+
}
181+
182+
/* Links inside the dropdown */
183+
.dropdown-content a {
184+
color: black;
185+
padding: 5px;
186+
text-decoration: none;
187+
display: block;
188+
}
189+
190+
/* Change color of dropdown links on hover */
191+
.dropdown-content a:hover {background-color: #f1f1f1}
192+
193+
/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */
194+
.show {display:block;}

0 commit comments

Comments
 (0)