/* ===== RadiusUnused.js (Vue 3 + TT-Core) ===== */
const RadiusUnusedUsers = {
name: 'RadiusUnusedUsers',
template: `
Die Abfrage läuft...
Dies kann einen Moment dauern, da große Datenmengen analysiert werden.
| Kundennummer |
Username |
Letzter Login |
Info |
Sessions |
Dauer |
Traffic |
|
|
|
|
|
|
|
{{ item.customerNumber }}
|
{{ item.username }}
|
{{ item.lastLogin }} |
{{ item.info }} |
{{ item.totalSessions }} |
{{ window.TT_CORE.formatDuration(item.totalDurationSeconds) }} |
{{ window.TT_CORE.formatBytes(item.totalTrafficBytes) }} |
{{ filteredUsers.length }} Treffer gefunden
`,
data: () => ({
users: [],
isLoading: false,
_initialized: false,
hasSearched: false,
window: window,
visibleCount: 50,
observer: null,
activeFilter: 'all',
filters: [
{id: 'all', name:'Alle', icon:'fa-duotone fa-globe'},
{id:'nat', name:'NAT*', icon:'fa-duotone fa-users'},
{id:'st', name:'ST*', icon:'fa-duotone fa-server'},
{id:'stf', name:'STF*', icon:'fa-duotone fa-id-card-clip'}
]
}),
computed: {
filteredUsers() {
return this.activeFilter === 'all'
? this.users
: this.users.filter(u => u.username && u.username.startsWith(this.activeFilter));
},
visibleFilteredUsers() {
return this.filteredUsers.slice(0, this.visibleCount);
}
},
mounted() {
this.observer = new IntersectionObserver(([e]) => {
if (e && e.isIntersecting) this.loadMore();
}, { root: this.$refs.tableWrap, threshold: 0.1 });
if (this.$refs.sentinel) this.observer.observe(this.$refs.sentinel);
},
beforeUnmount() {
if (this.observer) this.observer.disconnect();
},
updated() {
if (this.observer && this.$refs.sentinel) {
this.observer.disconnect();
this.observer.observe(this.$refs.sentinel);
}
},
methods: {
initIfNeeded() {
if (this._initialized) return;
this._initialized = true;
},
setFilter(filter) {
this.activeFilter = filter;
this.visibleCount = 50;
},
async fetchUnusedUsers() {
this.isLoading = true;
this.hasSearched = true;
this.visibleCount = 50;
this.users = [];
try {
const { data } = await axios.get(`${window.TT_CONFIG.BASE_PATH}/Radius/proxyUnsecureHTTPRequestToRadius`, {
params: { action2: 'reportUnused' }
});
this.users = data || [];
} catch (error) {
console.error("Failed to fetch unused users:", error);
this.users = [];
}
this.isLoading = false;
},
loadMore() {
if (this.visibleCount < this.filteredUsers.length) this.visibleCount += 50;
}
}
};
// Register component with Vue 3 app
if (window.VueApp) {
window.VueApp.component('radius-unused-users', RadiusUnusedUsers);
}