forked from InternetHealthReport/ihr-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathROV.vue
124 lines (114 loc) · 3.9 KB
/
ROV.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<script setup>
import { ref, computed, watch, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { DEFAULT_DISCO_AVG_LEVEL } from '@/plugins/disco'
import { AS_FAMILY } from '@/plugins/IhrApi'
import { isoCountries } from '@/plugins/countryName'
import report from '@/plugins/report'
import DateTimePicker from '@/components/DateTimePicker.vue'
import PrefixHegemonyChart from '@/components/charts/PrefixHegemonyChart.vue'
import Feedback from '@/components/Feedback.vue'
const LOADING_STATUS = {
ERROR: -3,
EXPIRED: -2,
NOT_FOUND: -1,
LOADING: 0,
LOADED: 1,
}
const CHART_REFS = ['countryHegemonyChart', 'prefixHegemonyChart', 'networkDelayChart', 'delayAndForwardingChart', 'ihrChartDisco']
const route = useRoute()
const router = useRouter()
const asNumber = ref(2497)
const addressFamily = ref(route.query.af == undefined ? 4 : route.query.af)
const loadingStatus = ref(LOADING_STATUS.LOADING)
const countryCode = ref(route.params.cc)
const countryName = ref(null)
const charRefs = ref(CHART_REFS)
const minAvgLevel = ref(DEFAULT_DISCO_AVG_LEVEL)
const show = ref({
disco: true,
disco_disable: false,
hegemony: true,
hegemony_disable: false,
net_delay: true,
net_delay_disable: false,
})
const majorEyeballs = ref([])
const majorEyeballsThreshold = ref(10)
const timeRange = route.query.last ? route.query.last : 3
let { interval, minDate, maxDate, fetch, utcString, reportDateFmt, setReportDate, startTime, endTime } = report(timeRange)
if (route.query.date && route.query.date != utcString(maxDate.value).split('T')[0]) {
setReportDate(new Date(route.query.date))
}
const family = computed(() => {
return addressFamily == 6 ? AS_FAMILY.v6 : AS_FAMILY.v4
})
const addressFamilyText = computed(() => {
return addressFamily ? 'IPv4' : 'IPv6'
})
const showGraphs = computed(() => {
return loadingStatus == LOADING_STATUS.LOADED
})
const headerString = computed(() => {
if (loadingStatus == LOADING_STATUS.LOADING) {
return t('Networks.headerString.loading')
} else if (loadingStatus == LOADING_STATUS.NOT_FOUND) {
return t('Networks.headerString.notFound')
} else if (loadingStatus == LOADING_STATUS.EXPIRED) {
return t('Networks.headerString.expired')
} else if (loadingStatus == LOADING_STATUS.LOADED) {
return isoCountries[countryCode]
} else {
return t('genericErrors.ups')
}
})
const subHeader = computed(() => {
if (loadingStatus == LOADING_STATUS.LOADING) {
return t('Networks.subHeader.loading')
} else if (loadingStatus == LOADING_STATUS.NOT_FOUND) {
return t('Networks.subHeader.notFound')
} else if (loadingStatus == LOADING_STATUS.EXPIRED) {
return t('Networks.subHeader.expired')
} else if (loadingStatus == LOADING_STATUS.LOADED) {
return countryCode
} else {
return t('genericErrors.badHappened')
}
})
const pushRoute = () => {
router.push({
replace: true,
query: Object.assign({}, route.query, {
af: family.value,
last: interval.value.dayDiff(),
date: utcString(interval.value.end).split('T')[0],
rov_tb: 'routes'
})
})
loadingStatus.value = LOADING_STATUS.LOADED
fetch.value = true
}
watch(addressFamily, () => {
pushRoute()
})
watch(interval, () => {
pushRoute()
})
onMounted(() => {
pushRoute()
})
</script>
<template>
<div id="IHR_as-and-ixp-container" ref="ihrAsAndIxpContainer" class="IHR_char-container">
<div>
<h1 class="text-center"><q-icon name="fas fa-route" /> Route Origin Validation</h1>
<h3 class="text-center">
{{ interval.dayDiff() }}-day report ending on {{ reportDateFmt }}
<DateTimePicker :min="minDate" :max="maxDate" :value="maxDate" @input="setReportDate" hideTime class="IHR_subtitle_calendar" />
</h3>
</div>
<PrefixHegemonyChart :start-time="startTime" :end-time="endTime" :fetch="fetch" />
<!-- <button @click="generateReport()" class="np-btn">Generate Report</button> -->
</div>
<Feedback />
</template>