const RadiusRouterManager = { name: 'RadiusRouterManager', props: { show: Boolean, userItem: Object }, template: `
Gesendet{{ pingResult.packetsTransmitted }}
Empfangen{{ pingResult.packetsReceived }}
Verlust{{ pingResult.packetLoss }}%
Min / Avg / Max{{ pingResult.min }} / {{ pingResult.avg }} / {{ pingResult.max }} ms
Kein Ergebnis.
# Bandbreite Übertragen Pakete
{{ idx + 1 }} {{ row.bpsFormatted }} {{ row.bytesFormatted }} {{ row.packets }}
Aktualisiere...
Abgeschlossen
Konfiguration erfolgreich abgeschlossen.
Username
{{ remoteAccessResult.username }}
Password
{{ remoteAccessResult.password }}
Ein Fehler ist aufgetreten.
(Cache)
Keine Daten verfügbar.
Datum Uhrzeit Gruppe Nachricht
{{ event.date }} {{ event.time }} {{ event.group }} {{ event.msg }}
Keine Ereignisse verfügbar.
WLAN Cache
SSID
{{ wlanKeyData.ssid || '-' }}
SSID 5GHz
{{ wlanKeyData.ssid_secondary }}
Passwort
{{ wlanKeyData.psk || '-' }}
Sicherheit {{ wlanKeyData.wpa_type?.toUpperCase() || 'WPA2' }}
LAN
Router-IP
{{ wlanKeyData.lan?.ip || '-' }}
Subnetz {{ wlanKeyData.lan?.subnet || '-' }}
DHCP
Bereich {{ wlanKeyData.lan.dhcp_start }} - {{ wlanKeyData.lan.dhcp_end }} -
DNS {{ wlanKeyData.lan?.dns_servers || '-' }}
Gerät
Modell {{ wlanKeyData.device_name }}
WLAN-Geräte {{ wlanKeyData.known_devices_count }}
Keine Daten verfügbar.
`, data: () => ({ routerLoading: false, routerActionLoading: false, routerDevice: null, // Sub-Modal States showPingModal: false, pingResult: null, showSpeedtestModal: false, speedtestLoading: false, speedtestResult: null, speedtestHistory: [], speedtestHasStarted: false, showRemoteAccessModal: false, remoteAccessLoading: false, remoteAccessResult: null, remoteAccessStep: '', showNetworkStructureModal: false, networkStructureLoading: false, networkStructureCached: false, rootDevice: null, showEventLogModal: false, eventLogLoading: false, eventLogData: null, refreshLoading: false, showWlanKeyModal: false, wlanKeyLoading: false, wlanKeyData: null, wlanKeyDataCached: false }), watch: { show: { handler(val) { if (val && this.userItem) { this.loadRouterData(); } }, immediate: true }, userItem(val) { if (val && this.show) { this.loadRouterData(); } } }, methods: { async loadRouterData() { this.routerLoading = true; this.routerDevice = null; this.pingResult = null; this.speedtestResult = null; this.speedtestLoading = false; try { const { data: deviceData } = await axios.get(`${window.TT_CONFIG.BASE_PATH}/Radius/genieacsGetDeviceByMac`, { params: { mac: this.userItem.username } }); if (deviceData?.success) { this.routerDevice = deviceData; } } catch (error) { console.error('Error fetching router:', error); window.notify('error', 'Fehler beim Laden des Routers'); } this.routerLoading = false; }, async refreshDevice() { if (!this.routerDevice?.deviceId) return; this.refreshLoading = true; try { const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}/Radius/genieacsRefreshDevice`, { deviceId: this.routerDevice.deviceId }); if (data?.success) { this.routerDevice.deviceInfo = data.deviceInfo; this.routerDevice.externalIp = data.externalIp; this.routerDevice.managementIp = data.managementIp; window.notify('success', 'Daten aktualisiert'); } } catch (error) { console.error('Error refreshing device:', error); window.notify('error', 'Fehler beim Aktualisieren'); } this.refreshLoading = false; }, async rebootRouter() { if (!this.routerDevice || !this.routerDevice.deviceId) return; if (!confirm('Möchten Sie den Router wirklich neu starten?')) return; this.routerActionLoading = true; try { const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}/Radius/genieacsRebootDevice`, { deviceId: this.routerDevice.deviceId }); if (data.success) { window.notify('success', 'Router-Neustart gestartet'); } else { window.notify('error', data.message || 'Fehler beim Neustart'); } } catch (error) { console.error('Error rebooting router:', error); window.notify('error', 'Fehler beim Neustarten des Routers'); } this.routerActionLoading = false; }, async pingRouter() { if (!this.routerDevice) return; const pingIp = this.routerDevice.managementIp || this.routerDevice.ip; if (!pingIp) return; this.showPingModal = true; this.routerActionLoading = true; this.pingResult = null; try { const { data } = await axios.get(`${window.TT_CONFIG.BASE_PATH}/Radius/genieacsPing`, { params: { ip: pingIp } }); if (data.success && data.result) { this.pingResult = data.result; window.notify('success', 'Ping erfolgreich'); } else { window.notify('error', 'Ping fehlgeschlagen'); } } catch (error) { console.error('Error pinging router:', error); window.notify('error', 'Fehler beim Pingen des Routers'); } this.routerActionLoading = false; }, async runSpeedtest() { if (!this.routerDevice || !this.routerDevice.deviceId) return; this.showSpeedtestModal = true; this.speedtestLoading = true; this.speedtestResult = null; this.speedtestHistory = []; this.speedtestHasStarted = false; try { const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}/Radius/genieacsRunSpeedtest`, { deviceId: this.routerDevice.deviceId }); if (data.success) { this.pollSpeedtestResult(); } else { throw new Error(data.message || "Speedtest konnte nicht gestartet werden"); } } catch (e) { window.notify('error', e.response?.data?.message || e.message || 'Fehler beim Starten des Speedtests'); this.speedtestLoading = false; } }, async pollSpeedtestResult() { let attempts = 0; const maxAttempts = 240; const poll = async () => { if (!this.showSpeedtestModal) return; if (attempts >= maxAttempts) { this.speedtestLoading = false; window.notify('error', 'Speedtest Zeitüberschreitung'); return; } attempts++; try { const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}/Radius/genieacsGetSpeedtestResult`, { deviceId: this.routerDevice.deviceId }); if (data.success && data.result) { this.speedtestHistory.push(data.result); this.$nextTick(() => { if (this.$refs.speedtestBottom) { this.$refs.speedtestBottom.scrollIntoView({ behavior: 'smooth' }); } }); if (data.result.bps > 0) this.speedtestHasStarted = true; if (this.speedtestHasStarted && data.result.bps === 0) { this.speedtestLoading = false; window.notify('success', 'Speedtest abgeschlossen'); return; } } } catch (e) { console.error(e); } if (this.speedtestLoading) setTimeout(poll, 1000); }; poll(); }, async runRemoteAccess(forceRecreate = false) { if (!this.routerDevice || !this.routerDevice.deviceId) return; this.showRemoteAccessModal = true; this.remoteAccessLoading = true; this.remoteAccessStep = forceRecreate ? 'Erstelle neue Zugangsdaten...' : 'Konfiguriere Zugriff...'; this.remoteAccessResult = null; try { const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}/Radius/genieacsRemoteAccess`, { deviceId: this.routerDevice.deviceId, forceRecreate: forceRecreate }); if (data.success) { this.remoteAccessResult = data; if (forceRecreate) { window.notify('success', 'Neue Zugangsdaten erstellt'); } } else { throw new Error(data.message || "Unbekannter Fehler"); } } catch (error) { window.notify('error', error.response?.data?.message || error.message || 'Fehler bei Remote Access'); } finally { this.remoteAccessLoading = false; } }, async openNetworkStructure(forceRefresh = false) { if (!this.routerDevice || !this.routerDevice.deviceId) return; this.showNetworkStructureModal = true; this.networkStructureLoading = true; this.rootDevice = null; this.networkStructureCached = false; try { const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}/Radius/genieacsNetworkStructure`, { deviceId: this.routerDevice.deviceId, forceRefresh: forceRefresh }); if (data.root) { this.rootDevice = data.root; this.networkStructureCached = data.cached === true; } } catch (error) { console.error(error); window.notify('error', 'Fehler beim Laden der Netzwerkstruktur'); } finally { this.networkStructureLoading = false; } }, async openEventLog() { if (!this.routerDevice || !this.routerDevice.deviceId) return; this.showEventLogModal = true; this.eventLogLoading = true; this.eventLogData = null; try { const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}/Radius/genieacsEventLog`, { deviceId: this.routerDevice.deviceId }); if (data.success && data.events) { this.eventLogData = data.events; } else { throw new Error(data.message || "Keine Ereignisse gefunden"); } } catch (error) { console.error(error); window.notify('error', error.response?.data?.message || 'Fehler beim Laden des Ereignisprotokolls'); } finally { this.eventLogLoading = false; } }, async openWlanKeyModal(forceRefresh = false) { if (!this.routerDevice || !this.routerDevice.deviceId) return; this.showWlanKeyModal = true; this.wlanKeyLoading = true; this.wlanKeyData = null; this.wlanKeyDataCached = false; try { const { data } = await axios.post(`${window.TT_CONFIG.BASE_PATH}/Radius/genieacsFritzboxWlanKey`, { deviceId: this.routerDevice.deviceId, forceRefresh: forceRefresh }); if (data.success && data.wlan) { this.wlanKeyData = data.wlan; this.wlanKeyDataCached = data.cached === true; } else { throw new Error(data.message || "Keine WLAN-Daten gefunden"); } } catch (error) { console.error(error); window.notify('error', error.response?.data?.message || 'Fehler beim Laden der WLAN-Daten'); } finally { this.wlanKeyLoading = false; } }, copyAllNetworkConfig() { if (!this.wlanKeyData) return; const d = this.wlanKeyData; const lines = [ '=== WLAN ===', `SSID: ${d.ssid || '-'}`, d.ssid_secondary && d.ssid_secondary !== d.ssid ? `SSID 5GHz: ${d.ssid_secondary}` : null, `Passwort: ${d.psk || '-'}`, `Sicherheit: ${d.wpa_type?.toUpperCase() || 'WPA2'}`, d.ap_enabled !== undefined ? `WLAN aktiv: ${d.ap_enabled ? 'Ja' : 'Nein'}` : null, '', '=== LAN ===', `Router-IP: ${d.lan?.ip || '-'}`, `Subnetz: ${d.lan?.subnet || '-'}`, '', '=== DHCP ===', `Bereich: ${d.lan?.dhcp_start && d.lan?.dhcp_end ? `${d.lan.dhcp_start} - ${d.lan.dhcp_end}` : '-'}`, `DNS: ${d.lan?.dns_servers || '-'}`, '', '=== Gerät ===', d.device_name ? `Modell: ${d.device_name}` : null, d.known_devices_count !== undefined ? `WLAN-Geräte: ${d.known_devices_count}` : null, ].filter(Boolean).join('\n'); navigator.clipboard.writeText(lines).then(() => { window.notify('success', 'Netzwerk-Konfiguration kopiert'); }).catch(() => { window.notify('error', 'Kopieren fehlgeschlagen'); }); } } }; if (window.VueApp) { window.VueApp.component('radius-router-manager', RadiusRouterManager); }