/* ===== RadiusUsers.js =====
* Labels entfernt; Platzhalter vereinheitlicht; Online-Status Info; Copy-Tooltips vereinheitlicht;
* Modal zeigt Skeleton mit Überschriften.
*/
Vue.component('radius-users', {
template: `
Beginnen Sie Ihre Suche, indem Sie Filter eingeben.
Keine Ergebnisse für Ihre Suche gefunden.
Suche läuft...
{{ radiusUsers.length }} Treffer gefunden
Status
{{ radacctData.online ? 'Online' : 'Offline' }}
IP
{{ radacctData.ip || '—' }}
Kundennummer
{{ radacctData.customerNumber || '—' }}
Kundenname
{{ radacctData.customerName || '—' }}
Info
{{ radacctData.info || '—' }}
WLAN Password
{{ radacctData.wlanPassword || '—' }}
Bandbreite
{{ radacctData.actualBandwidth || '—' }}
`,
data() {
return {
window: window,
billAddrDisplay: '', billAddrCustnum: '', username: '', ip: '', info: '',
radiusUsers: [],
checkOnlineState: false,
isLoading: false,
showRadacctModal: false,
radacctData: null,
searchCount: 0,
hasSearched: false,
visibleCount: 50,
observer: null,
};
},
computed: {
hasFilters() {
return this.billAddrDisplay || this.username || this.ip || this.info;
},
visibleUsers() {
return this.radiusUsers.slice(0, this.visibleCount);
}
},
mounted() {
this.observer = new IntersectionObserver(([entry]) => {
if (entry && entry.isIntersecting) {
this.loadMore();
}
}, { root: this.$refs.tableWrap, threshold: 0.1 });
if (this.$refs.sentinel) {
this.observer.observe(this.$refs.sentinel);
}
},
beforeDestroy() {
if (this.observer) {
this.observer.disconnect();
}
},
updated() {
// Re-observe if the table view is re-rendered
if (this.observer && this.$refs.sentinel) {
this.observer.disconnect();
this.observer.observe(this.$refs.sentinel);
}
},
methods: {
onAddrSelect({ custnum, display }) { this.billAddrCustnum = custnum || ''; this.billAddrDisplay = display || ''; },
async loadRadiusUsers() {
this.isLoading = true;
this.radiusUsers = [];
this.hasSearched = true;
this.visibleCount = 50; // Reset visible count on new search
try {
const params = new URLSearchParams({
username: this.username || '',
info: this.info || '',
custnum: this.billAddrCustnum || '',
ip: this.ip || ''
});
const res = await fetch(`${window.TT_CONFIG['BASE_PATH']}/Radius/proxyUnsecureHTTPRequestToRadius?${params.toString()}`);
if (res.ok) {
const users = await res.json();
if (Array.isArray(users) && users.length < 6) this.checkOnlineState = true;
this.radiusUsers = Array.isArray(users) ? users : [];
}
} catch (e) { console.error(e); }
this.isLoading = false;
this.searchCount++;
},
async fetchRadacctData(username) {
this.showRadacctModal = true; this.radacctData = null;
try {
const params = new URLSearchParams({ action2: 'fetchRadacct', username });
const res = await fetch(`${window.TT_CONFIG['BASE_PATH']}/Radius/proxyUnsecureHTTPRequestToRadius?${params.toString()}`);
if (res.ok) this.radacctData = await res.json();
} catch (e) { console.error(e); this.radacctData = {}; }
},
async copy(text, type) {
await window.RadiusUtils.copyToClipboard(text);
if (window.notify) {
window.notify('success', `${type} kopiert!`);
}
},
clearFilters() {
this.billAddrDisplay = '';
this.billAddrCustnum = '';
this.username = '';
this.ip = '';
this.info = '';
this.radiusUsers = [];
this.hasSearched = false;
},
loadMore() {
if (this.visibleCount < this.radiusUsers.length) {
this.visibleCount += 50;
}
}
}
});