/* ===== RadiusFreeUsers.js (Vue 3 + TT-Core) ===== */
const RadiusFreeUsers = {
name: 'RadiusFreeUsers',
template: `
Freie NAT Benutzer {{ filteredNat.length }}
| Username |
Info |
|
{{ item.Username }}
|
{{ item.Info }} |
{{ filteredNat.length }} Treffer gefunden
Freie STF Benutzer {{ filteredStf.length }}
| Username |
Info |
|
{{ item.Username }}
|
{{ item.Info }} |
{{ filteredStf.length }} Treffer gefunden
`,
data: () => ({
nat: [],
stf: [],
loadingNat: false,
loadingStf: false,
_initialized: false
}),
computed: {
filteredNat() {
return this.nat.filter(this.isTrulyFree);
},
filteredStf() {
return this.stf.filter(this.isTrulyFree);
}
},
methods: {
initIfNeeded() {
if (this._initialized) return;
this._initialized = true;
this.reloadNat();
this.reloadStf();
},
isTrulyFree(user) {
return !/frei[a-z]/.test((user.Info || '').toLowerCase());
},
normalizeUsers(arr) {
if (!Array.isArray(arr)) return [];
return arr.map(u => ({
Username: (u.Username || u.username || '').trim(),
Info: (u.Info || u.info || '').toString().replace(/\s+$/, '')
})).filter(u => u.Username);
},
async reloadNat() {
this.nat = [];
this.loadingNat = true;
try {
const { data } = await axios.get(`${window.TT_CONFIG.BASE_PATH}/Radius/proxyUnsecureHTTPRequestToRadius`, {
params: { action2: 'free_user', filter: 'nat' }
});
this.nat = this.normalizeUsers(data?.users || []);
} catch (error) {
this.nat = [];
}
this.loadingNat = false;
},
async reloadStf() {
this.stf = [];
this.loadingStf = true;
try {
const { data } = await axios.get(`${window.TT_CONFIG.BASE_PATH}/Radius/proxyUnsecureHTTPRequestToRadius`, {
params: { action2: 'free_user', filter: 'stf' }
});
this.stf = this.normalizeUsers(data?.users || []);
} catch (error) {
this.stf = [];
}
this.loadingStf = false;
}
}
};
// Register component with Vue 3 app
if (window.VueApp) {
window.VueApp.component('radius-free-users', RadiusFreeUsers);
}