-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
151 lines (130 loc) · 5.04 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!DOCTYPE html>
<html>
<head>
<title>PiAccess WebInterface</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<div class="flexbox">
<h2>Welcome</h2><br><br>
<a>
Das hier ist das PiAccess Webinterface
Hier kannst du einstellungen machen die du willst
</a>
</div>
<div class="flexbox">
<h2>Verbundene Geräte:</h2><br><br><br>
<span id="connecteddevices"></span>
</div>
<div class="flexbox">
<h2>Statistics</h2><h2 style="font-size:14px;">Datennutzung</h2><span>Heruntergeladen: </span> <span id="totalRX">Laden...</span><br>
<span>Hochgeladen::</span> <span id="totalTX">Laden...</span><br><span>Aktuell: </span> <span id="bandwidth">Laden...</span><br><br>
</div>
<div class="flexbox">
<h2>Einstellungen</h2><br>
<form action="networkManager.php" method="GET">
<label for="input-box">Network Name:</label>
<input name="netname" type="text" id="input-box network-name" placeholder="Neuer Netzwerk Name">
<label for="input-box">Network Password:</label>
<input name="netpswd" type="password" id="input-box network-password"" placeholder="Neues Netzwerk passwort:">
<button type="submit" class="button-green">Speichern und das Netzwerk neu starten.</button>
<span>Achtung: Nach dem Speichern müssen sie sich neu verbinden mit dem WLAN</span>
</form>
</div>
<div class="flexbox">
<h2>System Statistiken</h2><br><br>
<span>Prozessor: </span> <span id="processor">Laden...</span><br>
<span>Arbeitsspeicher:</span> <span id="memory">Laden...</span><br>
<span>Temparatur:</span> <span id="temp">Laden...</span>
</div>
<div class="flexbox">
<h2>System</h2><br><br><br>
<button onclick='window.location.href = "shutdown.php";' class="button-red">Herunterfahren</button>
</div>
</div>
<script>
function updateNetworkUsage() {
// Get the span element by its ID
const totalRX = document.getElementById("totalRX");
const totalTX = document.getElementById("totalTX");
const bandwidth = document.getElementById("bandwidth");
const connectedDevices = document.getElementById("connecteddevices");
// Make an HTTP request to the API
fetch("getNetworkUsage.php?type=download")
.then(response => response.text())
.then(data => {
// Update the text of the span element with the response data
totalRX.textContent = data;
})
.catch(error => {
console.error("Error fetching network usage data:", error);
});
fetch("getNetworkUsage.php?type=upload")
.then(response => response.text())
.then(data => {
// Update the text of the span element with the response data
totalTX.textContent = data;
})
.catch(error => {
console.error("Error fetching network usage data:", error);
});
fetch("getTroughput.php")
.then(response => response.text())
.then(data => {
// Update the text of the span element with the response data
bandwidth.textContent = data;
})
.catch(error => {
console.error("Error fetching network usage data:", error);
});
fetch("states/connectedDevices.state")
.then(response => response.text())
.then(data => {
// Update the text of the span element with the response data
connectedDevices.textContent = data;
})
.catch(error => {
console.error("Error fetching network usage data:", error);
});
}
function updateSystem() {
// Get the span element by its ID
const processor = document.getElementById("processor");
const memory = document.getElementById("memory");
const temp = document.getElementById("temp");
// Make an HTTP request to the API
fetch("getCpuUsage.php")
.then(response => response.text())
.then(data => {
// Update the text of the span element with the response data
processor.textContent = data + "%";
})
.catch(error => {
console.error("Error fetching cpu data:", error);
});
fetch("getMemoryUsage.php")
.then(response => response.text())
.then(data => {
// Update the text of the span element with the response data
memory.textContent = data + " / 4000M";
})
.catch(error => {
console.error("Error fetching memory data:", error);
});
fetch("getCpuTemp.php")
.then(response => response.text())
.then(data => {
// Update the text of the span element with the response data
temp.textContent = data;
})
.catch(error => {
console.error("Error fetching memory data:", error);
});
}
// Update state every 5 seconds
setInterval(updateNetworkUsage, 2000);
setInterval(updateSystem, 2000);
</script>
</body>
</html>