1- {% extends 'base.html' %}{% block title %}Server Dashboard{% endblock %}{% block content %}< div class ="container mt-4 ">
2- < div class ="row "> {% include 'dasbhboard_comp/other/username.html' %}{% include
1+
2+ {% extends 'base.html' %}{% block title %}Server Dashboard{% endblock %}{% block content %}
3+ {% block extra_head %}
4+ < link rel ="stylesheet " href ="{{ url_for('static', filename='css/dashbaord.css') }} ">
5+ {% endblock %}
6+ < div class ="selector-container ">
7+ < div class ="row ">
8+ < label for ="refresh-interval "> Select Refresh Interval (seconds):</ label >
9+ < select id ="refresh-interval ">
10+ < option value ="5 " {% if feature_toggles_settings.refresh_interval == 5 %}selected{% endif %} > 5 seconds</ option >
11+ < option value ="10 " {% if feature_toggles_settings.refresh_interval == 10 %}selected{% endif %} > 10 seconds</ option >
12+ < option value ="15 " {% if feature_toggles_settings.refresh_interval == 15 %}selected{% endif %} > 15 seconds</ option >
13+ < option value ="30 " {% if feature_toggles_settings.refresh_interval == 30 %}selected{% endif %} > 30 seconds</ option >
14+ < option value ="60 " {% if feature_toggles_settings.refresh_interval == 60 %}selected{% endif %} > 60 seconds</ option >
15+ </ select >
16+ </ div >
17+ </ div >
18+ < div class ="row ">
19+ <!-- Container for positioning the select input on the right -->
20+ {% include 'dasbhboard_comp/other/username.html' %}{% include
321 'dasbhboard_comp/other/boot_time.html' %}{% include 'dasbhboard_comp/battery/percentage.html' %}{% include
422 'dasbhboard_comp/cpu/core.html' %}{% include 'dasbhboard_comp/cpu/usages.html' %}{% include
523 'dasbhboard_comp/cpu/current_temp.html' %}{% include 'dasbhboard_comp/memory/dashboard_memory.html' %}{% include
624 'dasbhboard_comp/memory/usage.html' %}{% include 'dasbhboard_comp/disk/usage.html' %}{% include
725 'dasbhboard_comp/other/uptime.html' %}{% include 'dasbhboard_comp/network/stats.html' %}{% include
826 'dasbhboard_comp/other/speedtest.html' %} </ div >
9- </ div > {% endblock %}
27+ </ div>
28+ < script >
29+ let refreshInterval = { { feature_toggles_settings. refresh_interval * 1000 } } ;
30+ let refreshTimeout ;
31+
32+ function startRefresh ( ) {
33+ refreshTimeout = setTimeout ( function ( ) {
34+ location . reload ( ) ;
35+ } , refreshInterval ) ;
36+ }
37+
38+ // Start the refresh process
39+ startRefresh ( ) ;
40+
41+ // Event listener for select input change
42+ document . getElementById ( 'refresh-interval' ) . addEventListener ( 'change' , function ( ) {
43+ // Clear the existing timeout
44+ clearTimeout ( refreshTimeout ) ;
45+
46+ // Update the interval based on the selected value
47+ refreshInterval = parseInt ( this . value ) * 1000 ;
48+
49+ // Restart the refresh process with the new interval
50+ startRefresh ( ) ;
51+
52+ // Send the updated refresh interval to the server
53+ fetch ( '/update-refresh-interval' , {
54+ method : 'POST' ,
55+ headers : {
56+ 'Content-Type' : 'application/json'
57+ } ,
58+ body : JSON . stringify ( { refresh_interval : parseInt ( this . value ) } )
59+ } )
60+ . then ( response => response . json ( ) )
61+ . then ( data => {
62+ if ( data . success ) {
63+ console . log ( 'Refresh interval updated successfully:' , data . refresh_interval ) ;
64+ } else {
65+ console . error ( 'Failed to update refresh interval:' , data . error ) ;
66+ }
67+ } )
68+ . catch ( error => console . error ( 'Error:' , error ) ) ;
69+ } ) ;
70+ </ script > {% endblock %}
0 commit comments