Skip to content

Commit

Permalink
update dashboard appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
suparious committed Jun 10, 2024
1 parent d761420 commit 8d2654f
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 21 deletions.
20 changes: 15 additions & 5 deletions app/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,40 @@ body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f4f4f9;
}

h1 {
text-align: center;
margin-bottom: 20px;
font-size: 2.5em;
color: #333;
}

#metrics {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}

.metric {
border: 1px solid #ccc;
background-color: #fff;
padding: 20px;
width: 30%;
width: 45%;
margin: 10px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
text-align: center;
}

.metric h2 {
margin: 0;
margin-bottom: 20px;
font-size: 1.5em;
color: #555;
}

.metric p {
font-size: 1.2em;
margin: 10px 0 0 0;
canvas {
width: 100% !important;
height: auto !important;
}
59 changes: 58 additions & 1 deletion app/static/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ document.addEventListener('DOMContentLoaded', function () {
borderWidth: 1,
data: []
}]
},
options: {
responsive: true,
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value) {
return value + '%';
}
}
}
}
}
});

Expand All @@ -30,6 +43,14 @@ document.addEventListener('DOMContentLoaded', function () {
borderWidth: 1,
data: []
}]
},
options: {
responsive: true,
scales: {
y: {
beginAtZero: true
}
}
}
});

Expand All @@ -44,6 +65,19 @@ document.addEventListener('DOMContentLoaded', function () {
borderWidth: 1,
data: []
}]
},
options: {
responsive: true,
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value) {
return value + '%';
}
}
}
}
}
});

Expand All @@ -58,6 +92,19 @@ document.addEventListener('DOMContentLoaded', function () {
borderWidth: 1,
data: []
}]
},
options: {
responsive: true,
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value) {
return value + '%';
}
}
}
}
}
});

Expand All @@ -72,13 +119,22 @@ document.addEventListener('DOMContentLoaded', function () {
borderWidth: 1,
data: []
}]
},
options: {
responsive: true,
scales: {
y: {
beginAtZero: true
}
}
}
});

function updateCharts() {
fetch('/metrics')
.then(response => response.json())
.then(data => {
console.log('Metrics data:', data); // Debugging information
const labels = Object.keys(data);
const cpuUsage = labels.map(label => data[label].cpu_usage);
const memoryUsage = labels.map(label => data[label].memory_usage);
Expand All @@ -105,7 +161,8 @@ document.addEventListener('DOMContentLoaded', function () {
networkChart.data.labels = labels;
networkChart.data.datasets[0].data = networkIo;
networkChart.update();
});
})
.catch(error => console.error('Error fetching metrics:', error)); // Debugging information
}

updateCharts();
Expand Down
37 changes: 22 additions & 15 deletions app/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,31 @@
<title>Performance Dashboard</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="{{ url_for('static', filename='js/dashboard.js') }}"></script>
<link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
<h1>Performance Dashboard</h1>
<div>
<canvas id="cpuChart"></canvas>
</div>
<div>
<canvas id="memoryChart"></canvas>
</div>
<div>
<canvas id="gpuChart"></canvas>
</div>
<div>
<canvas id="diskChart"></canvas>
</div>
<div>
<canvas id="networkChart"></canvas>
<div id="metrics">
<div class="metric">
<h2>CPU Usage (%)</h2>
<canvas id="cpuChart"></canvas>
</div>
<div class="metric">
<h2>Memory Usage (Bytes)</h2>
<canvas id="memoryChart"></canvas>
</div>
<div class="metric">
<h2>GPU Usage (%)</h2>
<canvas id="gpuChart"></canvas>
</div>
<div class="metric">
<h2>Disk Usage (%)</h2>
<canvas id="diskChart"></canvas>
</div>
<div class="metric">
<h2>Network I/O (Bytes)</h2>
<canvas id="networkChart"></canvas>
</div>
</div>
</body>
</html>

0 comments on commit 8d2654f

Please sign in to comment.