美化三网延迟界面 (#335)
* Update network.html 修复以下问题: - 延迟默认最高300ms,超过后默认抹平 - 曲线上有很多ping值为0的无效散点,导致毛刺很多,干扰效果 - 图标的y轴比例失调,上方大片留白,大大降低了有效显示区域 - 默认只显示最近不到半小时左右的延迟表现,想看全天需要拖动,影响效果 - 曲线不显示极大极小值,不够直观 * Update config.go 修复了以下问题: - 延迟默认最高300ms,超过后默认抹平 - 曲线上有很多ping值为0的无效散点,导致毛刺很多,干扰效果 - 图标的y轴比例失调,上方大片留白,大大降低了有效显示区域 - 默认只显示最近不到半小时左右的延迟表现,想看全天需要拖动,影响效果 - 曲线不显示极大极小值,不够直观 * Update network.html 美化了三网延迟界面: 1. 将Marker缩小降低曲线遮挡 2. 设置为曲线对应的颜色使其更加直观 3. 设置Marker透明度降低对画面的影响 4. 将延迟极小值的Marker倒置显示以快速区别极大值 5. 将超过MaxTCPPingValue的点删除 6. 显示丢包分布(细线),以及服务器断流区间(粗线) * Update network.html * Update network.html * Update network.html * Update network.html
This commit is contained in:
		
							parent
							
								
									7d85c4c4a5
								
							
						
					
					
						commit
						3a733c85ad
					
				
							
								
								
									
										355
									
								
								resource/template/theme-daynight/network.html
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										355
									
								
								resource/template/theme-daynight/network.html
									
									
									
									
										vendored
									
									
								
							@ -107,149 +107,250 @@
 | 
			
		||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/limonte-sweetalert2/11.4.4/sweetalert2.all.min.js"></script>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
        const monitorInfo =  JSON.parse('{{.MonitorInfos}}');
 | 
			
		||||
        const initData = JSON.parse('{{.Servers}}').servers;
 | 
			
		||||
        let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}};
 | 
			
		||||
	    if (MaxTCPPingValue == null) {
 | 
			
		||||
	        MaxTCPPingValue = 1000;
 | 
			
		||||
	    }
 | 
			
		||||
        // 基于准备好的dom,初始化echarts实例
 | 
			
		||||
        var myChart = echarts.init(document.getElementById('monitor-info-container'));
 | 
			
		||||
        // 使用刚指定的配置项和数据显示图表。
 | 
			
		||||
        var statusCards = new Vue({
 | 
			
		||||
            el: '#network',
 | 
			
		||||
            delimiters: ['@#', '#@'],
 | 
			
		||||
            data: {
 | 
			
		||||
                servers: initData,
 | 
			
		||||
                cache: [],
 | 
			
		||||
                option: {
 | 
			
		||||
                    tooltip: {
 | 
			
		||||
                        trigger: 'axis',
 | 
			
		||||
                        position: function (pt) {
 | 
			
		||||
                            return [pt[0], '10%'];
 | 
			
		||||
                        },
 | 
			
		||||
                        formatter: function(params){
 | 
			
		||||
                            let result = params[0].axisValueLabel + "<br />";
 | 
			
		||||
                            params.forEach(function(item){
 | 
			
		||||
                                result += item.marker + item.seriesName + ": " + item.value[1].toFixed(2) + " ms<br />";
 | 
			
		||||
                             })
 | 
			
		||||
                            return result;
 | 
			
		||||
                        },
 | 
			
		||||
                        confine: true,
 | 
			
		||||
                        transitionDuration: 0
 | 
			
		||||
    const monitorInfo =  JSON.parse('{{.MonitorInfos}}');
 | 
			
		||||
    const initData = JSON.parse('{{.Servers}}').servers;
 | 
			
		||||
    let MaxTCPPingValue = {{.Conf.MaxTCPPingValue}};
 | 
			
		||||
    if (MaxTCPPingValue == null) {
 | 
			
		||||
        MaxTCPPingValue = 1000;
 | 
			
		||||
    }
 | 
			
		||||
    new Vue({
 | 
			
		||||
        el: '#app',
 | 
			
		||||
        delimiters: ['@#', '#@'],
 | 
			
		||||
        data: {
 | 
			
		||||
            page: 'network',
 | 
			
		||||
            defaultTemplate: {{.Conf.Site.Theme}},
 | 
			
		||||
            templates: {{.Themes}},
 | 
			
		||||
            servers: initData,
 | 
			
		||||
            option: {
 | 
			
		||||
                tooltip: {
 | 
			
		||||
                    trigger: 'axis',
 | 
			
		||||
                    position: function (pt) {
 | 
			
		||||
                        return [pt[0], '10%'];
 | 
			
		||||
                    },
 | 
			
		||||
                    title: {
 | 
			
		||||
                        left: 'center',
 | 
			
		||||
                        text: "",
 | 
			
		||||
                        textStyle: {}
 | 
			
		||||
                    formatter: function(params){
 | 
			
		||||
                        let result = params[0].axisValueLabel + "<br />";
 | 
			
		||||
                        params.forEach(function(item){
 | 
			
		||||
                            result += item.marker + item.seriesName + ": " + item.value[1].toFixed(2) + " ms<br />";
 | 
			
		||||
                         })
 | 
			
		||||
                        return result;
 | 
			
		||||
                    },
 | 
			
		||||
                    legend: {
 | 
			
		||||
                        top: '5%',
 | 
			
		||||
                        data: [],
 | 
			
		||||
                        textStyle: {
 | 
			
		||||
                            fontSize: 14
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    toolbox: {
 | 
			
		||||
                        feature: {
 | 
			
		||||
                            dataZoom: {
 | 
			
		||||
                                yAxisIndex: 'none'
 | 
			
		||||
                            },
 | 
			
		||||
                            restore: {},
 | 
			
		||||
                            saveAsImage: {}
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    dataZoom: [
 | 
			
		||||
                        {
 | 
			
		||||
                            start: 94,
 | 
			
		||||
                            end: 100
 | 
			
		||||
                        }
 | 
			
		||||
                    ],
 | 
			
		||||
                    xAxis: {
 | 
			
		||||
                        type: 'time',
 | 
			
		||||
                        boundaryGap: false
 | 
			
		||||
                    },
 | 
			
		||||
                    yAxis: {
 | 
			
		||||
                        type: 'value',
 | 
			
		||||
                        boundaryGap: [0, '100%']
 | 
			
		||||
                    },
 | 
			
		||||
                    series: [],
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            mounted() {
 | 
			
		||||
                this.DarkMode();
 | 
			
		||||
                this.parseMonitorInfo(monitorInfo);
 | 
			
		||||
		window.addEventListener('resize', this.resizeHandle);
 | 
			
		||||
            },
 | 
			
		||||
	    destroyed () {
 | 
			
		||||
                window.removeEventListener('resize', this.resizeHandle)
 | 
			
		||||
            },
 | 
			
		||||
            methods: {
 | 
			
		||||
                DarkMode() {
 | 
			
		||||
                    const hour = new Date(Date.now()).getHours()
 | 
			
		||||
                    if (hour > 17 || hour < 4) {
 | 
			
		||||
                        document.querySelector("input[name=theme]").checked = true;
 | 
			
		||||
                        document.getElementsByTagName("BODY")[0].setAttribute('data-theme', 'dark');
 | 
			
		||||
                        document.getElementById("monitor-info-container").style.backgroundColor = "#1E1E1E";
 | 
			
		||||
                    confine: true,
 | 
			
		||||
                    transitionDuration: 0
 | 
			
		||||
                },
 | 
			
		||||
                title: {
 | 
			
		||||
                    left: 'center',
 | 
			
		||||
                    text: "",
 | 
			
		||||
                    textStyle: {}
 | 
			
		||||
                },
 | 
			
		||||
                legend: {
 | 
			
		||||
                    top: '5%',
 | 
			
		||||
                    data: [],
 | 
			
		||||
                    textStyle: {
 | 
			
		||||
                        fontSize: 14
 | 
			
		||||
                    }
 | 
			
		||||
                },
 | 
			
		||||
                redirectNetwork(id) {
 | 
			
		||||
                grid: {
 | 
			
		||||
                    left: '8%',
 | 
			
		||||
                    right: '8%',
 | 
			
		||||
                },
 | 
			
		||||
                backgroundColor: 'rgba(255, 255, 255, 0.8)',
 | 
			
		||||
                toolbox: {
 | 
			
		||||
                    feature: {
 | 
			
		||||
                        dataZoom: {
 | 
			
		||||
                            yAxisIndex: 'none'
 | 
			
		||||
                        },
 | 
			
		||||
                        restore: {},
 | 
			
		||||
                        saveAsImage: {}
 | 
			
		||||
                    }
 | 
			
		||||
                },
 | 
			
		||||
                dataZoom: [
 | 
			
		||||
                    {
 | 
			
		||||
                        start: 0,
 | 
			
		||||
                        end: 100
 | 
			
		||||
                    }
 | 
			
		||||
                ],
 | 
			
		||||
                xAxis: {
 | 
			
		||||
                    type: 'time',
 | 
			
		||||
                    boundaryGap: false
 | 
			
		||||
                },
 | 
			
		||||
                yAxis: {
 | 
			
		||||
                    type: 'value',
 | 
			
		||||
                    boundaryGap: false
 | 
			
		||||
                },
 | 
			
		||||
                series: [],
 | 
			
		||||
            },
 | 
			
		||||
            chartOnOff: true,
 | 
			
		||||
        },
 | 
			
		||||
        mixins: [mixinsVue],
 | 
			
		||||
        mounted() {
 | 
			
		||||
            this.renderChart();
 | 
			
		||||
            this.parseMonitorInfo(monitorInfo);
 | 
			
		||||
            window.addEventListener('resize', this.resizeHandle);
 | 
			
		||||
        },
 | 
			
		||||
        destroyed () {
 | 
			
		||||
            window.removeEventListener('resize', this.resizeHandle)
 | 
			
		||||
        },
 | 
			
		||||
        methods: {
 | 
			
		||||
            getFontLogoClass(str) {
 | 
			
		||||
                if (["almalinux",
 | 
			
		||||
                        "alpine",
 | 
			
		||||
                        "aosc",
 | 
			
		||||
                        "apple",
 | 
			
		||||
                        "archlinux",
 | 
			
		||||
                        "archlabs",
 | 
			
		||||
                        "artix",
 | 
			
		||||
                        "budgie",
 | 
			
		||||
                        "centos",
 | 
			
		||||
                        "coreos",
 | 
			
		||||
                        "debian",
 | 
			
		||||
                        "deepin",
 | 
			
		||||
                        "devuan",
 | 
			
		||||
                        "docker",
 | 
			
		||||
                        "elementary",
 | 
			
		||||
                        "fedora",
 | 
			
		||||
                        "ferris",
 | 
			
		||||
                        "flathub",
 | 
			
		||||
                        "freebsd",
 | 
			
		||||
                        "gentoo",
 | 
			
		||||
                        "gnu-guix",
 | 
			
		||||
                        "illumos",
 | 
			
		||||
                        "kali-linux",
 | 
			
		||||
                        "linuxmint",
 | 
			
		||||
                        "mageia",
 | 
			
		||||
                        "mandriva",
 | 
			
		||||
                        "manjaro",
 | 
			
		||||
                        "nixos",
 | 
			
		||||
                        "openbsd",
 | 
			
		||||
                        "opensuse",
 | 
			
		||||
                        "pop-os",
 | 
			
		||||
                        "raspberry-pi",
 | 
			
		||||
                        "redhat",
 | 
			
		||||
                        "rocky-linux",
 | 
			
		||||
                        "sabayon",
 | 
			
		||||
                        "slackware",
 | 
			
		||||
                        "snappy",
 | 
			
		||||
                        "solus",
 | 
			
		||||
                        "tux",
 | 
			
		||||
                        "ubuntu",
 | 
			
		||||
                        "void",
 | 
			
		||||
                        "zorin"].indexOf(str)
 | 
			
		||||
                    > -1) {
 | 
			
		||||
                    return str;
 | 
			
		||||
                }
 | 
			
		||||
                if (['openwrt', 'linux', "immortalwrt"].indexOf(str) > -1) {
 | 
			
		||||
                    return 'tux';
 | 
			
		||||
                }
 | 
			
		||||
                if (str == 'amazon') {
 | 
			
		||||
                    return 'redhat';
 | 
			
		||||
                }
 | 
			
		||||
                if (str == 'arch') {
 | 
			
		||||
                    return 'archlinux';
 | 
			
		||||
                }
 | 
			
		||||
                return '';
 | 
			
		||||
            },
 | 
			
		||||
            redirectNetwork(id) {
 | 
			
		||||
                    this.getMonitorHistory(id)
 | 
			
		||||
                    .then(function(monitorInfo) {
 | 
			
		||||
                          var vm = network.__vue__;
 | 
			
		||||
                          var vm = app.__vue__;
 | 
			
		||||
                          vm.parseMonitorInfo(monitorInfo);
 | 
			
		||||
                    })
 | 
			
		||||
                    .catch(function(error){
 | 
			
		||||
                        window.location.href = "/404";
 | 
			
		||||
                    })
 | 
			
		||||
                },
 | 
			
		||||
                getMonitorHistory(id) {
 | 
			
		||||
                      return $.ajax({
 | 
			
		||||
                        url: "/api/v1/monitor/"+id,
 | 
			
		||||
                        method: "GET"
 | 
			
		||||
                      });
 | 
			
		||||
                },
 | 
			
		||||
                parseMonitorInfo(monitorInfo) {
 | 
			
		||||
                    let tSeries = [];
 | 
			
		||||
                    let tLegendData = [];
 | 
			
		||||
                    for (let i = 0; i < monitorInfo.result.length; i++) {
 | 
			
		||||
                        let loss = 0;
 | 
			
		||||
                        let data = [];
 | 
			
		||||
                        for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
 | 
			
		||||
                            avgDelay = monitorInfo.result[i].avg_delay[j];
 | 
			
		||||
                            if (avgDelay > 0.9 * MaxTCPPingValue) {
 | 
			
		||||
                                loss += 1
 | 
			
		||||
                            }
 | 
			
		||||
            getMonitorHistory(id) {
 | 
			
		||||
                  return $.ajax({
 | 
			
		||||
                    url: "/api/v1/monitor/"+id,
 | 
			
		||||
                    method: "GET"
 | 
			
		||||
                  });
 | 
			
		||||
            },
 | 
			
		||||
            parseMonitorInfo(monitorInfo) {
 | 
			
		||||
                let tSeries = [];
 | 
			
		||||
                let tLegendData = [];
 | 
			
		||||
                var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
 | 
			
		||||
                let maxPing = 0;
 | 
			
		||||
                for (let i = 0; i < monitorInfo.result.length; i++) {
 | 
			
		||||
                	 for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
 | 
			
		||||
                	 	avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
 | 
			
		||||
                        if ( avgDelay < MaxTCPPingValue && avgDelay > maxPing) {
 | 
			
		||||
                            maxPing = avgDelay;
 | 
			
		||||
                        }
 | 
			
		||||
                	 }
 | 
			
		||||
                }
 | 
			
		||||
                for (let i = 0; i < monitorInfo.result.length; i++) {
 | 
			
		||||
                    var lcolor = lcolors[i % lcolors.length];
 | 
			
		||||
                    var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
 | 
			
		||||
                    var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)';
 | 
			
		||||
                    let loss = 0;
 | 
			
		||||
                    let data = [];
 | 
			
		||||
                    let datal = [];
 | 
			
		||||
                    for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
 | 
			
		||||
                        avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
 | 
			
		||||
                        if (avgDelay > 0 && avgDelay < MaxTCPPingValue) {
 | 
			
		||||
                            data.push([monitorInfo.result[i].created_at[j], avgDelay]);
 | 
			
		||||
                        }
 | 
			
		||||
                        lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
 | 
			
		||||
			            legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%";
 | 
			
		||||
                        tLegendData.push(legendName);
 | 
			
		||||
                        tSeries.push({
 | 
			
		||||
                                name: legendName,
 | 
			
		||||
                                type: 'line',
 | 
			
		||||
                                smooth: true,
 | 
			
		||||
                                symbol: 'none',
 | 
			
		||||
                                data: data
 | 
			
		||||
                        });
 | 
			
		||||
                        else {
 | 
			
		||||
                            loss += 1;
 | 
			
		||||
                            datal.push([monitorInfo.result[i].created_at[j], maxPing]);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    this.option.title.text = monitorInfo.result[0].server_name;
 | 
			
		||||
                    this.option.series = tSeries;
 | 
			
		||||
                    this.option.legend.data = tLegendData;
 | 
			
		||||
                    const hour = new Date(Date.now()).getHours()
 | 
			
		||||
                    if (hour > 17 || hour < 4) {
 | 
			
		||||
                        this.option.legend.textStyle.color = "#F1F1F2";
 | 
			
		||||
                        this.option.title.textStyle.color = "#ccc";
 | 
			
		||||
                    lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
 | 
			
		||||
                    if (lossRate > 99) {
 | 
			
		||||
                        datal = [];
 | 
			
		||||
                    }
 | 
			
		||||
                    myChart.clear();
 | 
			
		||||
                    myChart.setOption(this.option);
 | 
			
		||||
                },
 | 
			
		||||
	        resizeHandle () {
 | 
			
		||||
                    this.myChart.resize();
 | 
			
		||||
                },
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    </script>
 | 
			
		||||
                    legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%";
 | 
			
		||||
                    tLegendData.push(legendName);
 | 
			
		||||
                    tSeries.push({
 | 
			
		||||
                            name: legendName,
 | 
			
		||||
                            type: 'line',
 | 
			
		||||
                            smooth: true,
 | 
			
		||||
                            symbol: 'none',
 | 
			
		||||
                            data: data,
 | 
			
		||||
                            markPoint: {
 | 
			
		||||
                                data: [
 | 
			
		||||
                                    { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } },
 | 
			
		||||
                                    { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 }
 | 
			
		||||
                                ]
 | 
			
		||||
                            }
 | 
			
		||||
                    });
 | 
			
		||||
                    tSeries.push({
 | 
			
		||||
                            name: legendName,
 | 
			
		||||
                            type: 'bar',
 | 
			
		||||
                            smooth: true,
 | 
			
		||||
                            symbol: 'none',
 | 
			
		||||
                            data: datal,
 | 
			
		||||
                            itemStyle: { color: rgbaColorBar }
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
                this.option.title.text = monitorInfo.result[0].server_name;
 | 
			
		||||
                this.option.series = tSeries;
 | 
			
		||||
                this.option.legend.data = tLegendData;
 | 
			
		||||
                this.myChart.clear();
 | 
			
		||||
                this.myChart.setOption(this.option);
 | 
			
		||||
            },
 | 
			
		||||
                this.option.title.text = monitorInfo.result[0].server_name;
 | 
			
		||||
                this.option.series = tSeries;
 | 
			
		||||
                this.option.legend.data = tLegendData;
 | 
			
		||||
                this.myChart.clear();
 | 
			
		||||
                this.myChart.setOption(this.option);
 | 
			
		||||
            },
 | 
			
		||||
            isWindowsPlatform(str) {
 | 
			
		||||
                return str.includes('Windows')
 | 
			
		||||
            },
 | 
			
		||||
            renderChart() {
 | 
			
		||||
              this.myChart = echarts.init(this.$refs.chartDom);
 | 
			
		||||
              this.myChart.setOption(this.option);
 | 
			
		||||
            },
 | 
			
		||||
            resizeHandle () {
 | 
			
		||||
              this.myChart.resize();
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
        beforeDestroy() {
 | 
			
		||||
            this.myChart.dispose();
 | 
			
		||||
            this.myChart = null;
 | 
			
		||||
        },
 | 
			
		||||
    });
 | 
			
		||||
</script>
 | 
			
		||||
</body>
 | 
			
		||||
<style>
 | 
			
		||||
#network {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										44
									
								
								resource/template/theme-default/network.html
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										44
									
								
								resource/template/theme-default/network.html
									
									
									
									
										vendored
									
									
								
							@ -185,19 +185,37 @@
 | 
			
		||||
            parseMonitorInfo(monitorInfo) {
 | 
			
		||||
                let tSeries = [];
 | 
			
		||||
                let tLegendData = [];
 | 
			
		||||
                var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
 | 
			
		||||
                let maxPing = 0;
 | 
			
		||||
                for (let i = 0; i < monitorInfo.result.length; i++) {
 | 
			
		||||
                	 for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
 | 
			
		||||
                	 	avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
 | 
			
		||||
                        if ( avgDelay < MaxTCPPingValue && avgDelay > maxPing) {
 | 
			
		||||
                            maxPing = avgDelay;
 | 
			
		||||
                        }
 | 
			
		||||
                	 }
 | 
			
		||||
                }
 | 
			
		||||
                for (let i = 0; i < monitorInfo.result.length; i++) {
 | 
			
		||||
                    var lcolor = lcolors[i % lcolors.length];
 | 
			
		||||
                    var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
 | 
			
		||||
                    var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)';
 | 
			
		||||
                    let loss = 0;
 | 
			
		||||
                    let data = [];
 | 
			
		||||
                    let datal = [];
 | 
			
		||||
                    for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
 | 
			
		||||
                        avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
 | 
			
		||||
                        if (avgDelay > 0.9 * MaxTCPPingValue) {
 | 
			
		||||
                            loss += 1
 | 
			
		||||
                        }
 | 
			
		||||
                        if (avgDelay > 0) {
 | 
			
		||||
                        if (avgDelay > 0 && avgDelay < MaxTCPPingValue) {
 | 
			
		||||
                            data.push([monitorInfo.result[i].created_at[j], avgDelay]);
 | 
			
		||||
                        }
 | 
			
		||||
                        else {
 | 
			
		||||
                            loss += 1;
 | 
			
		||||
                            datal.push([monitorInfo.result[i].created_at[j], maxPing]);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
 | 
			
		||||
                    if (lossRate > 99) {
 | 
			
		||||
                        datal = [];
 | 
			
		||||
                    }
 | 
			
		||||
                    legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%";
 | 
			
		||||
                    tLegendData.push(legendName);
 | 
			
		||||
                    tSeries.push({
 | 
			
		||||
@ -208,17 +226,31 @@
 | 
			
		||||
                            data: data,
 | 
			
		||||
                            markPoint: {
 | 
			
		||||
                                data: [
 | 
			
		||||
                                    { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: '#f00' } },
 | 
			
		||||
                                    { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: '#0f0' } }
 | 
			
		||||
                                    { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } },
 | 
			
		||||
                                    { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 }
 | 
			
		||||
                                ]
 | 
			
		||||
                            }
 | 
			
		||||
                    });
 | 
			
		||||
                    tSeries.push({
 | 
			
		||||
                            name: legendName,
 | 
			
		||||
                            type: 'bar',
 | 
			
		||||
                            smooth: true,
 | 
			
		||||
                            symbol: 'none',
 | 
			
		||||
                            data: datal,
 | 
			
		||||
                            itemStyle: { color: rgbaColorBar }
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
                this.option.title.text = monitorInfo.result[0].server_name;
 | 
			
		||||
                this.option.series = tSeries;
 | 
			
		||||
                this.option.legend.data = tLegendData;
 | 
			
		||||
                this.myChart.clear();
 | 
			
		||||
                this.myChart.setOption(this.option);
 | 
			
		||||
            },
 | 
			
		||||
                this.option.title.text = monitorInfo.result[0].server_name;
 | 
			
		||||
                this.option.series = tSeries;
 | 
			
		||||
                this.option.legend.data = tLegendData;
 | 
			
		||||
                this.myChart.clear();
 | 
			
		||||
                this.myChart.setOption(this.option);
 | 
			
		||||
            },
 | 
			
		||||
            isWindowsPlatform(str) {
 | 
			
		||||
                return str.includes('Windows')
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										40
									
								
								resource/template/theme-mdui/network.html
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										40
									
								
								resource/template/theme-mdui/network.html
									
									
									
									
										vendored
									
									
								
							@ -208,19 +208,37 @@
 | 
			
		||||
            parseMonitorInfo(monitorInfo) {
 | 
			
		||||
                let tSeries = [];
 | 
			
		||||
                let tLegendData = [];
 | 
			
		||||
                var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
 | 
			
		||||
                let maxPing = 0;
 | 
			
		||||
                for (let i = 0; i < monitorInfo.result.length; i++) {
 | 
			
		||||
                	 for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
 | 
			
		||||
                	 	avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
 | 
			
		||||
                        if ( avgDelay < MaxTCPPingValue && avgDelay > maxPing) {
 | 
			
		||||
                            maxPing = avgDelay;
 | 
			
		||||
                        }
 | 
			
		||||
                	 }
 | 
			
		||||
                }
 | 
			
		||||
                for (let i = 0; i < monitorInfo.result.length; i++) {
 | 
			
		||||
                    var lcolor = lcolors[i % lcolors.length];
 | 
			
		||||
                    var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
 | 
			
		||||
                    var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)';
 | 
			
		||||
                    let loss = 0;
 | 
			
		||||
                    let data = [];
 | 
			
		||||
                    let datal = [];
 | 
			
		||||
                    for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
 | 
			
		||||
                        avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
 | 
			
		||||
                        if (avgDelay > 0.9 * MaxTCPPingValue) {
 | 
			
		||||
                            loss += 1
 | 
			
		||||
                        }
 | 
			
		||||
                        if (avgDelay > 0) {
 | 
			
		||||
                        if (avgDelay > 0 && avgDelay < MaxTCPPingValue) {
 | 
			
		||||
                            data.push([monitorInfo.result[i].created_at[j], avgDelay]);
 | 
			
		||||
                        }
 | 
			
		||||
                        else {
 | 
			
		||||
                            loss += 1;
 | 
			
		||||
                            datal.push([monitorInfo.result[i].created_at[j], maxPing]);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
 | 
			
		||||
                    if (lossRate > 99) {
 | 
			
		||||
                        datal = [];
 | 
			
		||||
                    }
 | 
			
		||||
                    legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%";
 | 
			
		||||
                    tLegendData.push(legendName);
 | 
			
		||||
                    tSeries.push({
 | 
			
		||||
@ -230,12 +248,20 @@
 | 
			
		||||
                            symbol: 'none',
 | 
			
		||||
                            data: data,
 | 
			
		||||
                            markPoint: {
 | 
			
		||||
                            data: [
 | 
			
		||||
                                    { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: '#f00' } },
 | 
			
		||||
                                    { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: '#0f0' } }
 | 
			
		||||
                                data: [
 | 
			
		||||
                                    { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } },
 | 
			
		||||
                                    { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 }
 | 
			
		||||
                                ]
 | 
			
		||||
                            }
 | 
			
		||||
                    });
 | 
			
		||||
                    tSeries.push({
 | 
			
		||||
                            name: legendName,
 | 
			
		||||
                            type: 'bar',
 | 
			
		||||
                            smooth: true,
 | 
			
		||||
                            symbol: 'none',
 | 
			
		||||
                            data: datal,
 | 
			
		||||
                            itemStyle: { color: rgbaColorBar }
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
                this.option.title.text = monitorInfo.result[0].server_name;
 | 
			
		||||
                this.option.series = tSeries;
 | 
			
		||||
 | 
			
		||||
@ -171,19 +171,37 @@
 | 
			
		||||
            parseMonitorInfo(monitorInfo) {
 | 
			
		||||
                let tSeries = [];
 | 
			
		||||
                let tLegendData = [];
 | 
			
		||||
                var lcolors = ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'];
 | 
			
		||||
                let maxPing = 0;
 | 
			
		||||
                for (let i = 0; i < monitorInfo.result.length; i++) {
 | 
			
		||||
                	 for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
 | 
			
		||||
                	 	avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
 | 
			
		||||
                        if ( avgDelay < MaxTCPPingValue && avgDelay > maxPing) {
 | 
			
		||||
                            maxPing = avgDelay;
 | 
			
		||||
                        }
 | 
			
		||||
                	 }
 | 
			
		||||
                }
 | 
			
		||||
                for (let i = 0; i < monitorInfo.result.length; i++) {
 | 
			
		||||
                    var lcolor = lcolors[i % lcolors.length];
 | 
			
		||||
                    var rgbaColorMarker = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.5)';
 | 
			
		||||
                    var rgbaColorBar = 'rgba(' + parseInt(lcolor.slice(1, 3), 16) + ',' + parseInt(lcolor.slice(3, 5), 16) + ',' + parseInt(lcolor.slice(5, 7), 16) + ',0.35)';
 | 
			
		||||
                    let loss = 0;
 | 
			
		||||
                    let data = [];
 | 
			
		||||
                    let datal = [];
 | 
			
		||||
                    for (let j = 0; j < monitorInfo.result[i].created_at.length; j++) {
 | 
			
		||||
                        avgDelay = Math.round(monitorInfo.result[i].avg_delay[j]);
 | 
			
		||||
                        if (avgDelay > 0.9 * MaxTCPPingValue) {
 | 
			
		||||
                            loss += 1
 | 
			
		||||
                        }
 | 
			
		||||
                        if (avgDelay > 0) {
 | 
			
		||||
                        if (avgDelay > 0 && avgDelay < MaxTCPPingValue) {
 | 
			
		||||
                            data.push([monitorInfo.result[i].created_at[j], avgDelay]);
 | 
			
		||||
                        }
 | 
			
		||||
                        else {
 | 
			
		||||
                            loss += 1;
 | 
			
		||||
                            datal.push([monitorInfo.result[i].created_at[j], maxPing]);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    lossRate = ((loss / monitorInfo.result[i].created_at.length) * 100).toFixed(1);
 | 
			
		||||
                    if (lossRate > 99) {
 | 
			
		||||
                        datal = [];
 | 
			
		||||
                    }
 | 
			
		||||
                    legendName = monitorInfo.result[i].monitor_name +" "+ lossRate + "%";
 | 
			
		||||
                    tLegendData.push(legendName);
 | 
			
		||||
                    tSeries.push({
 | 
			
		||||
@ -194,11 +212,19 @@
 | 
			
		||||
                            data: data,
 | 
			
		||||
                            markPoint: {
 | 
			
		||||
                                data: [
 | 
			
		||||
                                    { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: '#f00' } },
 | 
			
		||||
                                    { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: '#0f0' } }
 | 
			
		||||
                                    { type: 'max', symbol: 'pin', name: 'Max', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8 } },
 | 
			
		||||
                                    { type: 'min', symbol: 'pin', name: 'Min', itemStyle: { color: rgbaColorMarker }, symbolSize: 30, label: { fontSize: 8, offset: [0, 7.5] }, symbolRotate: 180 }
 | 
			
		||||
                                ]
 | 
			
		||||
                            }
 | 
			
		||||
                    });
 | 
			
		||||
                    tSeries.push({
 | 
			
		||||
                            name: legendName,
 | 
			
		||||
                            type: 'bar',
 | 
			
		||||
                            smooth: true,
 | 
			
		||||
                            symbol: 'none',
 | 
			
		||||
                            data: datal,
 | 
			
		||||
                            itemStyle: { color: rgbaColorBar }
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
                this.option.title.text = monitorInfo.result[0].server_name;
 | 
			
		||||
                this.option.series = tSeries;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user