diff --git a/public/js/pages/Radius/Radius.js b/public/js/pages/Radius/Radius.js index 94ad6773a..45bc03abf 100644 --- a/public/js/pages/Radius/Radius.js +++ b/public/js/pages/Radius/Radius.js @@ -276,43 +276,49 @@ Vue.component('radius-ont-parser', { Vue.component('radius-online-state', { props: ['username'], template: ` -
- - -
- `, - data() { - return { - data: null, - }; +
+ + +
+ `, + data: () => ({ + data: null, + observer: null, + observed: false + }), + mounted() { + this.observer = new IntersectionObserver(entries => { + if (entries[0].isIntersecting && !this.observed) { + this.observed = true; + this.fetchOnlineState(); + } + }, { threshold: 0.1 }); + + this.observer.observe(this.$refs.container); }, - async created() { - await this.fetchOnlineState(); + beforeDestroy() { + this.observer?.disconnect(); }, methods: { async fetchOnlineState() { - const response = await fetch(window.TT_CONFIG['BASE_PATH'] + '/Radius/proxyUnsecureHTTPRequestToRadius?action2=fetchRadacct&username=' + this.username); + const response = await fetch(`${window.TT_CONFIG['BASE_PATH']}/Radius/proxyUnsecureHTTPRequestToRadius?action2=fetchRadacct&username=${this.username}`); if (response.ok) this.data = await response.json(); } } }) + + Vue.component('radius', { template: ` @@ -333,7 +339,8 @@ Vue.component('radius', { - + @@ -361,7 +368,7 @@ Vue.component('radius', {
{{ user.info }} @@ -472,6 +479,8 @@ Vue.component('radius', { showRadacctModal: false, checkOnlineState: 0, radacctData: null, + isLoading: false, + searchCount: 0, } }, async mounted() { @@ -483,6 +492,7 @@ Vue.component('radius', { this.showRadacctModal = false; }, async loadRadiusUsers() { + this.isLoading = true; let custnum = ''; if (this.$refs.billAddr.displayValue.length > 5) { custnum = this.$refs.billAddr.displayValue.match(/\[(\d+)]/)[1]; @@ -503,6 +513,8 @@ Vue.component('radius', { } else { console.error('Failed to load radius users'); } + this.isLoading = false; + this.searchCount = this.searchCount + 1; }, async fetchRadacctData(username) { const params = new URLSearchParams({