Skip to content

Commit

Permalink
feat: loading animation for latency testing
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Oct 9, 2023
1 parent 92ca452 commit b641f11
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions web/src/components/Channel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ function refreshChannelList() {
})
return;
}else{
channelList.value = res.data.data;
var copy = res.data.data;
for (let i = 0; i < copy.length; i++) {
copy[i].loading = false;
}
channelList.value = copy;
ElNotification({
message: 'Successfully refreshed channel list.',
type: 'success',
Expand Down Expand Up @@ -107,6 +111,13 @@ function deleteChannelConfirmed(channel_id) {
function testChannelLatancy(channel_id) {
console.log(channel_id);
for (let i = 0; i < channelList.value.length; i++) {
if (channelList.value[i].id == channel_id) {
channelList.value[i].loading = true;
break
}
}
axios.post('/api/channel/test/' + channel_id)
.then(res => {
console.log(res);
Expand All @@ -115,18 +126,20 @@ function testChannelLatancy(channel_id) {
for (let i = 0; i < channelList.value.length; i++) {
if (channelList.value[i].id == channel_id) {
channelList.value[i].loading = false;
channelList.value[i].latency = parseInt(res.data.data.latency*100)/100;
break
}
}
} else {
ElNotification({
message: 'Failed: ' + res.data.message,
message: 'Failed: ' + res.data.message +" Channel: "+channel_id,
type: 'error'
})
for (let i = 0; i < channelList.value.length; i++) {
if (channelList.value[i].id == channel_id) {
channelList.value[i].loading = false;
channelList.value[i].latency = -1;
break
}
Expand All @@ -141,6 +154,7 @@ function testChannelLatancy(channel_id) {
})
for (let i = 0; i < channelList.value.length; i++) {
if (channelList.value[i].id == channel_id) {
channelList.value[i].loading = false;
channelList.value[i].latency = -1
break
}
Expand Down Expand Up @@ -455,6 +469,7 @@ function applyChannelDetails() {
</text>
<text class="channel_latency">
<el-button class="channel_latency_box" @click="testChannelLatancy(channel.id)"
v-loading="channel.loading" element-loading-svg-view-box="-35, -35, 120, 120"
:type="channel.latency > 0 ? 'success' : 'default'" plain>{{ channel.latency >= 0 ? channel.latency +
's' :
'N/A' }}</el-button>
Expand Down

0 comments on commit b641f11

Please sign in to comment.