Skip to content

Commit

Permalink
Create visualizations dashboard (#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
YukaUU authored Aug 22, 2024
1 parent c3274b0 commit b0d5db7
Show file tree
Hide file tree
Showing 12 changed files with 898 additions and 5 deletions.
38 changes: 33 additions & 5 deletions apps/Info.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<link rel="stylesheet" href="./table.css" />
<link rel="stylesheet" href="./info.css" />
<link rel="shortcut icon" type="image/x-icon" href="/apps/landing/favicon.png">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>

<body>
Expand Down Expand Up @@ -103,6 +104,7 @@ <h4 class="card-title text-center">Synopsis</h4><hr class="mt-0">
</div>
</div>
</div>

<div class="alert alert-info" role="alert">

<h4 style="text-align:center">Annotations</h4><hr class="mt-0">
Expand Down Expand Up @@ -209,11 +211,37 @@ <h3 class="text-center h3 mb-2" style="margin-top:8px;margin-bottom:10px;">Infor
else{
heatdisp="<i class='fas fa-check' style='color:green;'></i>"
}
var button = `<td> <button class=\"btn btn-primary\" data-id='${allSlides.length}' onclick='openDetails(this)'>Details</button></td>`
var markup = "<tr><td>"+JSONdata.id+"</td><td>"+JSONdata.name+"</td><td>"+annodisp+"</td><td>"+heatdisp+"</td>"+button+"</tr>"
var button = `<td> <button class=\"btn btn-primary btn-sm\" data-id='${allSlides.length}' onclick='openDetails(this)'>Details</button></td>`
const visualization_button = `<td>
<button class="btn btn-success btn-sm" data-id='${JSONdata.id}' onclick='openView(this)'>VisualGraph</span></button>
</button></td>`
var markup = "<tr><td>"+JSONdata.id+"</td><td>"+JSONdata.name+"</td><td>"+annodisp+"</td><td>"+heatdisp+"</td><td>"+button+visualization_button+"</td></tr>"
table.append(markup);
}

function openView(e) {
const oid = e.dataset.id;
console.log(oid);
if (oid) {
window.location.href = `./visualization-dashboard.html?slideId=${sanitize(oid)}`;
} else {
alert('No Data Id');
}
}

function sanitize(string) {
string = string || '';
const map = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
'\'': '&#x27;',
'/': '&#x2F;',
};
const reg = /[&<>"'/]/ig;
return string.replace(reg, (match) => (map[match]));
}
function openDetails(tag){
document.getElementById('detail-dialog').style.display = 'block';
document.getElementById('detail-dialog').style.opacity = '1';
Expand All @@ -231,9 +259,9 @@ <h3 class="text-center h3 mb-2" style="margin-top:8px;margin-bottom:10px;">Infor
table.append(content);
addAnnotations(allSlides[count].annotations);
addHeatmaps(allSlides[count].heatmap);
console.log(allSlides[count]);
console.log(allSlides[count],count);
}

function addAnnotations(content){
if(content.length===0){
return;
Expand Down Expand Up @@ -443,7 +471,7 @@ <h3 class="text-center h3 mb-2" style="margin-top:8px;margin-bottom:10px;">Infor
addbody(JSONdata);
});
});
// console.log(JSONdata);
// console.log(JSONdata);
}
});
}
Expand Down
10 changes: 10 additions & 0 deletions apps/visualization-dashboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
body {
background-color: #cff4fc;
margin: 0;
font-family: Arial, sans-serif;
}

.material-icons {
font-size: 24px;
vertical-align: middle;
}
78 changes: 78 additions & 0 deletions apps/visualization-dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="keywords" content="camicroscope, quip" />
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<title>Responsive Cards with Modal Expansion</title>
<link rel="stylesheet" href="visualization-dashboard.css">
<link rel="stylesheet" href="../components/visualization-dashboard/navbar.css">
<link rel="stylesheet" href="../components/visualization-dashboard/cardContainer.css">
<link rel="stylesheet" href="../components/visualization-dashboard/modal.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <!-- Loading Chart.js -->
</head>
<body>
<script src="../core/Store.js"></script>
<script src="../common/util.js"></script>
<script type="text/javascript" src="../components/visualization-dashboard/navbar.js"></script>
<script type="text/javascript" src="../components/visualization-dashboard/chartData.js"></script>
<script type="text/javascript" src="../components/visualization-dashboard/chartSetup.js"></script>
<script type="text/javascript" src="../components/visualization-dashboard/modal.js"></script>
<script type="text/javascript" src="../components/visualization-dashboard/visualization-init.js"></script>
<script>
var getVisualizationData = {};

async function init() {
try {
console.log('Before initialization getVisualizationData:', getVisualizationData);
await initialize(); // Wait for asynchronous process to complete
console.log('After initialization getVisualizationData:', getVisualizationData);

// After asynchronous process is complete, dynamically add other scripts
loadScripts();
} catch (error) {
console.error('Error:', error);
}
}

function loadScripts() {
const scripts = [
'../components/visualization-dashboard/cardContainer.js'
];

// Manage script loading with Promises
const loadScriptPromises = scripts.map(src => {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.type = "text/javascript";
script.src = src;
script.onload = () => {
// console.log(`${src} loaded successfully.`);
resolve();
};
script.onerror = () => {
reject(new Error(`Failed to load script ${src}`));
};
document.body.appendChild(script);
});
});

// Execute after all scripts have been loaded
Promise.all(loadScriptPromises)
.then(() => {
// console.log('All scripts loaded successfully');
})
.catch(error => {
console.error('Error loading scripts:', error);
});
}

// Execute init function after the page has loaded
document.addEventListener('DOMContentLoaded', init);
</script>
<script>
</script>
</body>
</html>
185 changes: 185 additions & 0 deletions components/visualization-dashboard/cardContainer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/* Expand button */
.expand-btn {
position: absolute;
top: 10px;
right: 10px;
background-color: #f8f9fa;
color: #515555;
border: none;
padding: 5px 10px;
cursor: pointer;
border-radius: 5px;
font-size: 14px;
}

.expand-btn:hover {
background-color: #a0a0a0;
}

/* Background color of the entire screen */
body {
background-color: #ddd;
margin: 0;
font-family: Arial, sans-serif;
}

/* Container for cards */
.card-container {
padding: 20px;
box-sizing: border-box;
margin: 0 auto;
}

/* Style for rows */
.row {
display: flex;
justify-content: space-between;
}

/* Common style for each card */
.card {
background-color: #fcfcfc;
border: 1px solid #ddd;
border-radius: 2px;
padding: 20px;
box-sizing: border-box;
text-align: left;
margin: 4px;
overflow: hidden;
position: relative;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
}

/* Style for cards in the upper row */
.card-1 {
width: 40%;
display: flex;
flex-direction: column;
justify-content: space-between;
}

.card-2, .card-3, .card-4 {
width: 20%;
}

.card-2, .card-3 {
align-items: center;
justify-content: center;
}

/* Style for cards in the lower row */
.card-5, .card-6 {
width: 50%;
height: 80%;
display: flex;
flex-direction: column;
justify-content: flex-start;
}

/* Text positioning adjustments */
.card-1 {
margin-bottom: 5px;
}
.card h3 {
margin-bottom: 18px;
text-align: left;
}

.card h4 {
margin: 0;
text-align: left;
}

/* Text overflow handling */
.card h4, .card h1, .card h2, .card h3 {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.card:hover h4, .card:hover h1, .card:hover h2 {
white-space: normal;
}

/* Number display style */
.number {
font-size: 80px;
font-weight: bold;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}

/* Expand button */
.expand-btn {
position: absolute;
top: 10px;
right: 10px;
background-color: #f8f9fa;
color: #515555;
border: none;
padding: 5px 10px;
cursor: pointer;
border-radius: 5px;
font-size: 14px;
}

.expand-btn:hover {
background-color: #a0a0a0;
}

.card-expand-icon {
color: #515555;
}

/* Centered content with red background in card */
.card-content {
width: 100%;
display: flex;
justify-content: center;
margin-top: 10px;
}

.centered-content-small {
background-color: #fcfcfc;
color: #fcfcfc;
padding: 10px;
border-radius: 4px;
width: 80%;
text-align: center;
margin: 10px 0;
}

.centered-content {
background-color: #fcfcfc;
color: #fcfcfc;
padding: 10px;
border-radius: 4px;
width: 80%;
height: 35vh;
text-align: center;
margin: 10px auto;
align-self: center;
}

/* Media query for displaying in a single column on smartphones and iPads */
@media (max-width: 768px) {
.row {
flex-direction: column;
align-items: center;
}

.card {
margin: 10px 0;
width: 90%;
max-width: 400px;
min-width: 300px;
}
}
Loading

0 comments on commit b0d5db7

Please sign in to comment.