Skip to content

Commit eca0eee

Browse files
Update color coding and limits for CPU, memory, frequency, and temperature bars
1 parent 2497e8b commit eca0eee

7 files changed

Lines changed: 18 additions & 21 deletions

File tree

src/static/css/style.css

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ body {
135135

136136
/* General Card Styles */
137137
.card {
138-
min-height: 160px;
138+
min-height: 190px;
139139
/* background: linear-gradient(120deg, #e3f2fd, #bbdefb); */
140140
/* background: linear-gradient(135deg, #f5f7fa, #c3cfe2); */
141141
background: linear-gradient(200deg, #f5f7fa, #c3cfe2);
@@ -197,7 +197,7 @@ body {
197197
font-weight: bold;
198198
}
199199

200-
.temp-indicator, .usage-indicator, .memory-usage-bar, .frequency-indicator {
200+
.temp-indicator, .usage-indicator, .memory-usage-bar, .frequency-indicator, .battery-indicator {
201201
width: 100%;
202202
background-color: #e2e6ea;
203203
border-radius: 5px;
@@ -209,7 +209,6 @@ body {
209209
transition: width 0.3s ease;
210210
}
211211

212-
213212
.cpu-core-visualization {
214213
display: flex;
215214
justify-content: center;
@@ -272,13 +271,6 @@ body {
272271
}
273272

274273
/* batter bar */
275-
.battery-indicator {
276-
width: 100%;
277-
background-color: #e0e0e0;
278-
border-radius: 5px;
279-
overflow: hidden;
280-
position: relative;
281-
}
282274

283275

284276
/* Battery color indicators based on percentage */
@@ -342,7 +334,7 @@ body {
342334
/* .frequency-bar */
343335

344336
.frequency-bar.low {
345-
background-color: #57d474; /* Green for low frequency */
337+
background: linear-gradient(90deg, #57d474, #41d865); /* Green for low temperature */
346338
}
347339
.frequency-bar.medium {
348340
background-color: #d7b25c; /* Yellow for medium frequency */

src/static/js/refreshCardData.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ function updateColorBars() {
9999
const barConfigs = [
100100
{ selector: '.battery-bar', dataAttr: 'data-battery', limits: [25, 75] }, // alreday in %
101101
{ selector: '.disk-bar', dataAttr: 'data-disk-usage', limits: [60, 80] }, // alreday in %
102-
{ selector: '.cpu-usage-bar', dataAttr: 'data-cpu-usage', limits: [50, 80] }, // alreday in %
103-
{ selector: '.memory-usage-bar', dataAttr: 'data-memory-usage', limits: [50, 80], maxAttr: 'data-memory-total' },
104-
{ selector: '.frequency-bar', dataAttr: 'data-cpu-frequency', limits: [50, 80], maxAttr: 'data-cpu-max-frequency' },
105-
{ selector: '.temp-bar', dataAttr: 'data-cpu-temp', limits: [20, 50], maxAttr: 'data-cpu-max-temp' }
102+
{ selector: '.cpu-usage-bar', dataAttr: 'data-cpu-usage', limits: [60, 90] }, // alreday in %
103+
{ selector: '.memory-usage-bar', dataAttr: 'data-memory-usage', limits: [60, 90], maxAttr: 'data-memory-total' },
104+
{ selector: '.frequency-bar', dataAttr: 'data-cpu-frequency', limits: [60, 90], maxAttr: 'data-cpu-max-frequency' },
105+
{ selector: '.temp-bar', dataAttr: 'data-cpu-temp', limits: [70, 90], maxAttr: 'data-cpu-max-temp' }
106106
];
107107

108108
barConfigs.forEach(({ selector, dataAttr, limits, maxAttr }) => {
@@ -111,22 +111,21 @@ function updateColorBars() {
111111
const maxElement = maxAttr ? document.querySelector(`[${maxAttr}]`) : null;
112112

113113
if (!bar || !card) return;
114-
let percentage = parseFloat(bar.style.width);
115-
if (isNaN(percentage)) return;
114+
let card_value = parseFloat(bar.style.width);
115+
if (isNaN(card_value)) return;
116116

117117
if (maxElement) {
118118
const maxValue = parseFloat(maxElement.getAttribute(maxAttr));
119119
if (!isNaN(maxValue)) {
120120
limits = [maxValue * limits[0]/100, maxValue * limits[1]/100];
121121
}
122122
}
123-
124-
percentage = Math.min(percentage, 100); // Ensure percentage is not greater than 100
123+
125124
bar.classList.remove('low', 'medium', 'high');
126125
// Apply the appropriate class based on the limits
127-
if (percentage <= limits[0]) {
126+
if (card_value <= limits[0]) {
128127
bar.classList.add('low');
129-
} else if (percentage > limits[0] && percentage <= limits[1]) {
128+
} else if (card_value > limits[0] && card_value <= limits[1]) {
130129
bar.classList.add('medium');
131130
} else {
132131
bar.classList.add('high');

src/templates/card_comp/cpu/current_temp.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ <h5 class="card-title mb-3">CPU Temperature <i class="fas fa-microchip"></i></h5
88
<div class="temp-indicator mt-2">
99
<div class="temp-bar" style="width: {{ system_info['current_temp'] }}%;"></div>
1010
</div>
11+
<p class="card-text">Max Temperature: {{ system_info['high_temp'] }} &deg;C</p>
1112
</div>
1213
</div>
1314
</div>

src/templates/card_comp/cpu/frequency.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ <h5 class="card-title mb-3">CPU Frequency <i class="fas fa-microchip"></i></h5>
99
<div class="frequency-indicator mt-3">
1010
<div class="frequency-bar" style="width: {{ 100 * system_info['cpu_frequency'] / (system_info['cpu_max_frequency'] if system_info['cpu_max_frequency'] != 0 else 1) }}%;"></div>
1111
</div>
12+
<p class="card-text fs-6 mt-2">Max Frequency: {{ system_info['cpu_max_frequency'] }} MHz</p>
1213
</div>
1314
</div>
1415
</div>

src/templates/card_comp/disk/usage.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ <h5 class="card-title mb-3">Disk Usage <i class="fas fa-hdd"></i></h5>
99
<div class="usage-indicator mt-2">
1010
<div class="disk-bar" style="width: {{ system_info['disk_percent'] }}%;"></div>
1111
</div>
12+
<p class="card-text fs-6 mt-2">Total Disk: {{ system_info['disk_total'] }} Gb</p>
1213
</div>
1314
</div>
1415
</div>

src/templates/card_comp/memory/usage.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ <h5 class="card-title mb-3">Memory Usage <i class="fas fa-memory"></i></h5>
1010
<div class="usage-indicator mt-2">
1111
<div class="memory-usage-bar" style="width: {{ system_info['memory_percent'] }}%;"></div>
1212
</div>
13+
<p class="card-text fs-6 mt-2">Total Memory: {{ system_info['memory_available'] }} Mb</p>
1314
</div>
1415
</div>
1516
</div>

src/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ def _get_system_info():
437437
"""
438438
boot_time = get_cached_value('boot_time', lambda: datetime.datetime.fromtimestamp(psutil.boot_time()))
439439
uptime_dict = get_cached_value('uptime', lambda: format_uptime(datetime.datetime.now() - boot_time))
440+
disk_total = get_cached_value("disk_total", get_disk_total)
440441
memory_available = get_cached_value("memory_available", get_memory_available)
441442
# Gathering fresh system information
442443
battery_info = psutil.sensors_battery()
@@ -454,6 +455,7 @@ def _get_system_info():
454455
'memory_percent': round(memory_info.percent, 2),
455456
'memory_available': memory_available,
456457
'disk_percent': round(disk_info.percent, 2),
458+
'disk_total': disk_total,
457459
'network_sent': network_sent,
458460
'battery_percent': round(battery_info.percent, 1) if battery_info else 0,
459461
'network_received': network_received,

0 commit comments

Comments
 (0)