summaryrefslogtreecommitdiffstats
path: root/docker/storperf-reporting/src/templates/plot_multi_data.html
blob: 4205fd65655f154dd9c3710ff19a896d3d5445bc (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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>Chart | Storperf</title>
    <link rel="stylesheet" href="/reporting/css/bootstrap.min.css">
    <script src="/reporting/js/jquery-2.1.3.min.js"></script>
    <script src="/reporting/js/bootstrap.min.js"></script>
    <script src="/reporting/js/jquery.bootpag.min.js"></script>
    <script src="/reporting/js/plotly-latest.min.js"></script>
    <script src="/reporting/js/Chart.min.js"></script>
    <style>
/* The Modal (background) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    padding-top: 100px; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

/* Modal Content */
.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
}

/* The Close Button */
.close {
    color: #aaaaaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}
.main {
    border: 1px;
}
li {
    font-size: 14px;
}
ul {
    margin-left: 50px;
}
</style>
</head>

<body>
    <div class="container">
        {% include 'header.html' %}
        <div id="content"><strong>Loading...</strong>
        </div>
        <div id="myModal" class="modal">

  <!-- Modal content -->
  <div class="modal-content">
      <span class="close" id="close">&times;</span>
    <div id="modal-text"></div>
  </div>

</div>
        <center>
            <div id="page-selection"></div>
        </center>
    </div>
    <script>
        results = {{ results | tojson | safe }};
        function init(){
            page = [];
            report_data = results[0]["details"]["report_data"];
            ids = [];
            text = "<a href='/reporting/'><button type='button' class='btn btn-default btn-lg'>Go back</button></a><br><br>";
            for ( var i = 0; i < results.length ; i++ ){
                ids.push(results[i]["_id"]);
                text += "<div class='row well' id='row-" + ids[i] + "'>";
                text += "<h4> ID  : " + results[i]["_id"] + "</h4>";
                text += "<h4> Start Date  : " + results[i]["start_date"] + "</h4>";
                text += "<h4> Criteria  : " + results[i]["criteria"] + "</h4>";
                text += "<h4> Build Tag  : " + results[i]["build_tag"] + "</h4>";
                text += "<button type='button' class='btn btn-default btn-lg' id='para-"+ ids[i] +
                        "' onclick=add_info('" + ids[i] + "')> Click here to view details </button>"; 
                text += "</div>"; 
            }
            $("#content").html(text);
        }
        function add_info(ids){
            report_data = {};
            keys = [];
            var i = 0;
            for ( i = 0; i < results.length ; i++ ){
                if( results[i]["_id"] == ids ){
                    report_data = results[i]["details"]["report_data"];
                    break;
                }
            }
            for (var k in report_data){
                keys.push(k);
            }
            text = "";
            text += "<div class='row well' id='row-" + results[i]["_id"] + "'>";
            text += "<h4> ID  : " + results[i]["_id"] + "</h4>";
            text += "<h4> Start Date  : " + results[i]["start_date"] + "</h4>";
            text += "<h4> Criteria  : " + results[i]["criteria"] + "</h4>";
            text += "<h4> Build Tag  : " + results[i]["build_tag"] + "</h4>";
            text += "<button type='button' class='btn btn-default btn-lg' onclick=init()>Go Back</button>";
            text += "</div>";
            for (var i = 0; i < keys.length; i++ ){
                text += "<div class='row' id='row-"+ keys[i] +"'>";
                text += "<h4 onclick=add_test('" + keys[i] + "')>" + keys[i] + "</h4>";
                text += "</div>";
            }   
            $("#content").html(text);   
        }
        function add_test(key){
            if(document.getElementById("test-" + key) == null){
                tests = [];
                for(var test in report_data[key]) tests.push(test);
                text = "<div class='col-md-12' id = 'test-" + key + "'><ul class='list-group'>";
                for(var i = 0; i < tests.length; i++ ){
                    text +=  "<li class='list-group-item' onclick=add_data('"+ key +"','" + tests[i] + "') id='li-" +
                             key + "-" + tests[i] + "'>" + tests[i] + "</li>"
                }
                text += "<li class='list-group-item' onclick=delete_test('" + key + "')> close </li>";
                text += "</ul></div>";
                var div = document.getElementById('row-' + key);
                div.innerHTML += text;
            }
        }
        function delete_test(key){
            document.getElementById("test-" + key).remove();
        }
        function add_data(key,test){
            text = "<ul id='list-" + key + "-" + test + "'>";
            if(document.getElementById('list-' + key + '-' + test ) == null){
                for( item in report_data[key][test] ){
                    var state = report_data[key][test][item]["steady_state"];
                    text += "<li onclick=create_modal('" + key + "','" + test + "','" + item + "') id='" +
                            key + "-" + test + "-" + item + "'>" + item + " (steady state: " + state +")</li>";
                }
                text += "</ul>"
                var div = document.getElementById("li-" + key + "-" + test);
                div.innerHTML += text;
            }
        }
        function create_modal(key,test,item){
            var  modal = document.getElementById('myModal');
            var modal_div = document.getElementById('modal-text');
            modal_div.innerHTML += "<div id='graph'></div><br><div id='report'></div>";
            data = report_data[key][test][item];
            var x = [];
            var y = [];
            var name = "";
            var average = data["average"];
            if(test == "bw")
                name = "Bandwidth (KB/s)";
            else if(test == "iops")
                name = "IOPS";
            else
                name = "Latency (nanoseconds/ns)";
            var len = data["series"].length;
            for(var i = 0 ; i < len ; i++){
                x[i] = data["series"][i][0];
                y[i] = data["series"][i][1];
            }
            var trace1 = {
                x: x,
                y: y,
                name: name,
                type: 'scatter'
            };
            var layout = {
                xaxis: {
                    title: 'Round'
                },
                yaxis: {
                    title: name
                }
            };
            // Creating average plot in var trace2
            var average_y = [];
            for(var i = 0; i < len ;i++ ){
                average_y.push(average)
            }
            var trace2 = {
                x: x,
                y: average_y,
                name: 'Average',
                type: 'scatter'
            };
            // Creating average plot in var trace3
            var average_plus_y = [];
            for(var i = 0; i < len ;i++ ){
                average_plus_y.push(1.1*average)
            }
            var trace3 = {
                x: x,
                y: average_plus_y,
                name: '110%*Average',
                type: 'scatter'
            };
            // Creating average plot in var trace4
            var average_minus_y = [];
            for(var i = 0; i < len ;i++ ){
                average_minus_y.push(0.9*average)
            }
            var trace4 = {
                x: x,
                y: average_minus_y,
                name: '90%*Average',
                type: 'scatter'
            };
            // Creating slope plot in var trace5
            var slope_y = [];
            var slope_mid = parseInt(len/2);
            // Init slope_y with average
            for(var i = 0; i < len; i++){
                slope_y.push(average);
            }
            // Creating the slope plot
            var i = slope_mid - 1;
            var count = data["slope"];
            while(i >= 0){
                slope_y[i] -= count;
                count += data["slope"];
                i--;
            }
            var i = slope_mid + 1;
            var count = data["slope"];
            while(i < len){
                slope_y[i] += count;
                count += data["slope"];
                i++;
            }
            var trace5 = {
                x: x,
                y: slope_y,
                name: 'Slope',
                type: 'scatter'
            };
            var plot_data = [trace1,trace2,trace3,trace4,trace5];
            Plotly.newPlot('graph',plot_data,layout);
            modal.style.display = "block";
            table = "<table class='table table-bordered'>";
            table += "<thead><tr>Steady State Determination Data</tr></thead>";
            table += "<tbody>";
            table += "<tr><td>Steady State: "+ data["steady_state"] +"</td><td> Average " + name + ": " + average + "</td></tr>";
            table += "<tr><td> Allowed Maximum Data Excursion: " + 0.2*average +
                     "</td><td> Measured Maximum Data Excursion: " + data["range"] + "</td></tr>";
            table += "<tr><td> Allowed Maximum Slope Excursion: " + 0.1*average +
                     "</td><td> Measured Maximum Slope Excursion: " + data["slope"] + "</td></tr>";
            table += "</tbody></table>";
            document.getElementById("report").innerHTML = table;

        }
        init();
        document.getElementById("close").onclick = function(){
            document.getElementById('modal-text').innerHTML = "";
            document.getElementById("myModal").style.display = "none";
        }
    </script>
</body>

</html>