aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/common/nsb_report.html.j2
blob: f1b4ae1c2199165807f7ad4ecbd09c50fd9782e9 (plain)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<html>

<!--
 Copyright (c) 2017 Rajesh Kudaka <4k.rajesh@gmail.com>
 Copyright (c) 2018 Intel Corporation.

 All rights reserved. This program and the accompanying materials
 are made available under the terms of the Apache License, Version 2.0
 which accompanies this distribution, and is available at
 http://www.apache.org/licenses/LICENSE-2.0
-->

    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.5/themes/default/style.min.css">
        <link rel="stylesheet" href="{{template_dir}}/nsb_report.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
        <script src="https://code.highcharts.com/highcharts.js"></script>
    </head>

    <body>
        <div class="container" style="width:80%">
            <div class="row">
                <header class="jumbotron">
                    <h1>Yardstick User Interface</h1>
                    <h4>Report of {{task_id}} Generated</h4>
                </header>
            </div>
            <div class="row" style="height:500px">
                <div class="col-md-2 control-pane">
                    <div id="data_selector"></div>
                </div>
                <div class="col-md-10 data-pane">
                    <div id="graph"></div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12 table-responsive">
                    <table class="table table-hover"></table>
                </div>
            </div>
        </div>

        <script>
            var arr, tab, tr, td, tbody, keys, key, curr_data;
            arr = {{table|safe}};

            tab = document.getElementsByTagName('table')[0];
            tbody = document.createElement('tbody');
            keys = Object.keys(arr);
            // for each metric
            for (var i = 0; i < keys.length; i++) {
                tr = document.createElement('tr');
                td = document.createElement('td');
                key = keys[i];
                td.append(key);
                tr.append(td);
                curr_data = arr[key];
                // add each piece of data as its own column
                for (var j = 0; j < curr_data.length; j++) {
                    td = document.createElement('td');
                    td.append(curr_data[j]);
                    tr.append(td);
                }
                tbody.append(tr);
            }
            tab.appendChild(tbody);

            $(function() {
                $('#data_selector').jstree({
                    plugins: ['checkbox'],
                    checkbox: {
                        three_state: false,
                        whole_node: true,
                        tie_selection: false,
                    },
                    core: {
                        themes: {
                            icons: false,
                            stripes: true,
                        },
                        data: {{jstree_nodes|safe}},
                    },
                });

                $('#data_selector').on('check_node.jstree uncheck_node.jstree', function(e, data) {
                    var selected_leaves = [];
                    for (var i = 0; i < data.selected.length; i++) {
                        var node = data.instance.get_node(data.selected[i]);
                        if (node.children.length == 0) {
                            var point = {name: node.id, data: arr[node.id]};
                            selected_leaves.push(point);
                        }
                    }

                    $('#graph').highcharts({
                        title: {
                            text: 'Yardstick Graphs',
                            x: -20, //center
                        },
                        chart: {
                            marginLeft: 400,
                            zoomType: 'x',
                            type: 'spline',
                        },
                        xAxis: {
                            crosshair: {
                                width: 1,
                                color: 'black',
                            },
                            title: {
                                text: 'Timestamp',
                            },
                            categories: {{Timestamps|safe}},
                        },
                        yAxis: {
                            crosshair: {
                                width: 1,
                                color: 'black',
                            },
                            plotLines: [{
                                value: 0,
                                width: 1,
                                color: '#808080',
                            }],
                        },
                        plotOptions: {
                            series: {
                                showCheckbox: false,
                                visible: false,
                            },
                        },
                        tooltip: {
                            valueSuffix: '',
                        },
                        legend: {
                            enabled: true,
                        },
                        series: selected_leaves,
                    });

                    var chart = $('#graph').highcharts();
                    for (var i = 0; i < chart.series.length; i++) {
                        var series = chart.series[i];
                        if (series.visible) {
                            series.hide();
                        } else {
                            series.show();
                        }
                    }
                });
            });
        </script>
    </body>
</html>