forked from renxulei/Redfish-Mockup-Creator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.html
207 lines (204 loc) · 7.67 KB
/
template.html
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
<!--
Copyright Notice:
Copyright 2019 Lenovo. All rights reserved.
License: Apache License. For full text see link: https://github.com/renxulei/Redfish-Mockup-Creator/blob/master/APACHE_LICENSE
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{title}}</title>
<link rel="stylesheet" href="http://fw.core.lenovo.com/static/css/bootstrap.min.css">
<link rel="stylesheet" href="http://fw.core.lenovo.com/static/css/bootstrap-sortable.css">
<style>
th.tiny-col {
width: 2rem;
}
</style>
</head>
<body>
<div class="container" ng-app="app" ng-controller="mainCtrl as $ctrl">
<h3 class="page-header">{{title}}</h3>
<div class="alert alert-info">
<p><a href="https://{{HostIP}}" target="_blank">HostIP:{{HostIP}}</a> AverageTime:{{AverageTime}} TotalTime:{{TotalTime}}</p>
</div>
<div id="chart" style="width: 100%; height: 480px"></div>
<div class="row">
<div class="col-md-12 col-xs-12">
<div class="table-responsive" ng-cloak>
<table class="table table-hover sortable">
<thead>
<tr>
<th class="tiny-col"></th>
<th>Resource/URI</th>
<th>Time(ms)</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in $ctrl.data.rows" ng-class="{'danger': item.min == 0}">
<td>[[ $index + 1]]</td>
<td>[[ item.url ]]</td>
<td>[[ item.time ]]</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</table>
<script src="http://fw.core.lenovo.com/static/js/jquery.min.js"></script>
<script src="http://fw.core.lenovo.com/static/js/angular.min.js"></script>
<script src="http://fw.core.lenovo.com/static/js/bootstrap.min.js"></script>
<script src="http://fw.core.lenovo.com/static/js/bootstrap-select.js"></script>
<script src="http://fw.core.lenovo.com/static/js/bootstrap-sortable.js"></script>
<script src="http://fw.core.lenovo.com/static/js/echarts.min.js"></script>
<script>
angular.module("app", [])
.config(['$interpolateProvider', function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
}])
.config(['$compileProvider', function($compileProvider){//配置这段代码即可
//注:有些版本的angularjs为$compileProvider.urlSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|javascript):/);,两种都试一下可以即可
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|javascript):/);
}])
.filter('arrayMax', function(){
return function arrayMax(array, n) {
var ret = array.reduce(function(a, b) {
return Math.max(a, b);
});
return parseInt(ret * ( n || 1));
}
})
.filter('arrayMin', function(){
return function arrayMin(array, n) {
var ret = array.reduce(function(a, b) {
return Math.min(a, b);
});
return parseInt(ret * ( n || 1));
}
})
.filter('arrayAverage', function(){
return function arrayAverage(array, n) {
var avg = array.reduce(function(a, b) {
return a + b;
}) / array.length;
return parseInt(avg * (n || 1));
}
})
.value("jsondata",{{jsondata}})
.controller('mainCtrl', function($scope, jsondata){
this.data = jsondata;
this.getRounds = function(arr){
var text = '';
arr.forEach(function(e){
text += parseInt(e * 1000) + ' ';
})
return text;
}
function initPerfSeries(charts_data) {
//
var ret = [];
charts_data.legend.forEach(function(val) {
one = {
name: val,
type: charts_data.types[val],
data: charts_data.series[val],
}
if (val == "max") {
one.barGap = "-30%";
one.zlevel = 1;
}
one.itemStyle = {
normal: {
color: charts_data.colors[val],
label: {
show: true,
position: 'top',
formatter: function(c) {
return c.data == 0 ? '' : c.data
}
}
}
}
ret.push(one)
})
return ret;
}
function do_set_redfish_perf(charts_data, canvasId) {
var panel = document.getElementById(canvasId);
if (panel == undefined) return;
var myChart = echarts.init(panel);
// var h = $(panel).height();
// $(panel).height(20 * charts_data.assignee.cols.length);
var option = {
title: {
text: 'Elasped Time',
textStyle: {
//文字颜色
color: 'black',
//字体风格,'normal','italic','oblique'
fontStyle: 'normal',
//字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
fontWeight: 'bold',
//字体系列
fontFamily: 'sans-serif',
//字体大小
fontSize: 20
}
},
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
legend: {
data: charts_data.legend,
},
grid: {
left: '3%',
right: '4%',
bottom: '30%',
containLabel: true
},
xAxis: {
type: 'category',
data: charts_data.xAxis,
axisLabel:{
interval: 0 ,
rotate:20,
fontSize: 10
}
},
yAxis: {
type: 'value',
minInterval: 1,
// max: 100,
axisLabel: {
formatter: function(val) {
return val + ' (ms)';
}
// formatter: '{value} %'
},
},
dataZoom : {
show : true,
realtime : true,
startValue:0, //数据窗口范围的起始数值
endValue:20,
// start : 0,
// orient: 'horizontal',
// end : 5
},
};
option['series'] = initPerfSeries(charts_data)
myChart.setOption(option);
}
do_set_redfish_perf(this.data, 'chart')
})
</script>
</body>
</html>