Browse Source

上传文件至 'env/static/js'

master
nfa 4 years ago
parent
commit
ed32b15e9e
  1. 123
      env/static/js/comprechart.js
  2. 17
      env/static/js/echarts.min.js
  3. 63
      env/static/js/envchart.js
  4. 4
      env/static/js/jquery-2.1.1.min.js
  5. 72
      env/static/js/recmd.js

123
env/static/js/comprechart.js

@ -0,0 +1,123 @@
function comprechart(spotslist, datalist) {
var app = {};
var chartDom = document.getElementById('mainchart');
var myChart = echarts.init(chartDom);
var option;
var posList = [
'left', 'right', 'top', 'bottom',
'inside',
'insideTop', 'insideLeft', 'insideRight', 'insideBottom',
'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight'
];
app.configParameters = {
rotate: {
min: -90,
max: 90
},
align: {
options: {
left: 'left',
center: 'center',
right: 'right'
}
},
verticalAlign: {
options: {
top: 'top',
middle: 'middle',
bottom: 'bottom'
}
},
position: {
options: posList.reduce(function (map, pos) {
map[pos] = pos;
return map;
}, {})
},
distance: {
min: 0,
max: 100
}
};
app.config = {
rotate: 90,
align: 'left',
verticalAlign: 'middle',
position: 'insideBottom',
distance: 15,
onChange: function () {
}
};
var labelOption = {
show: true,
position: app.config.position,
distance: app.config.distance,
align: app.config.align,
verticalAlign: app.config.verticalAlign,
rotate: app.config.rotate,
formatter: '{c} {name|{a}}',
fontSize: 16,
rich: {
name: {}
}
};
var datas = [];
for (i = 0; i < datalist.length; i++) {
datas.push({
'name': datalist[i]['spot'],
'type': 'bar',
'barGap': 0,
'label': labelOption,
'emphasis': {'focus': 'series'},
'data': datalist[i]['data']
});
}
option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
data: spotslist
},
color: [
"#5470c6", "#91cc75", "#fac858", "#ee6666", "#73c0de", "#fc8452", "#9a60b4"
],
toolbox: {
show: true,
orient: 'vertical',
left: 'right',
top: 'center',
feature: {
mark: {show: true},
dataView: {show: true, readOnly: false},
magicType: {show: true, type: ['line', 'bar', 'stack', 'tiled']},
restore: {show: true},
saveAsImage: {show: true}
}
},
xAxis: [
{
type: 'category',
axisTick: {show: false},
data: ['正常', '高温', '高湿', '断电', '漏水', '火情']
}
],
yAxis: [
{
type: 'value'
}
],
series: datas
};
option && myChart.setOption(option);
}

17
env/static/js/echarts.min.js

File diff suppressed because one or more lines are too long

63
env/static/js/envchart.js

@ -0,0 +1,63 @@
function envchart(title, tpcol, datalist) {
var chartDom = document.getElementById('mainchart');
var myChart = echarts.init(chartDom);
var option;
var data = [];
for(i=0;i<datalist.length;i++){
data.push([datalist[i]['rectime'], datalist[i][tpcol]]);
}
option = {
tooltip: {
trigger: 'axis',
position: function (pt) {
return [pt[0], '10%'];
}
},
title: {
left: 'center',
text: title+'统计表',
},
toolbox: {
feature: {
dataZoom: {
yAxisIndex: 'none'
},
restore: {},
saveAsImage: {}
}
},
xAxis: {
type: 'time',
boundaryGap: false
},
yAxis: {
type: 'value',
boundaryGap: [0, '100%']
},
dataZoom: [{
type: 'inside',
show:true,
xAxisIndex:[0],//表示x轴折叠
start: 0,
end: 30
}, {
type:"inside",
show:false,
start: 0,
end: 50
}],
series: [
{
name: title,
type: 'line',
smooth: false,
symbol: 'none',
areaStyle: {},
data: data
}
]
};
option && myChart.setOption(option);
}

4
env/static/js/jquery-2.1.1.min.js

File diff suppressed because one or more lines are too long

72
env/static/js/recmd.js

@ -0,0 +1,72 @@
$(function(){
var clock = '';
clock = setInterval(flushcmd, 5000);
});
function flushcmd(){
//alert('clock exec');
$.get("http://172.18.17.136:8000/env/cmdqueue/", function(result){
$("#cmdul").empty();
var clist = jQuery.parseJSON(result);
for(i in clist.cmdlist){
$("#cmdul").append("<li class=\"lst\">"+clist.cmdlist[i].replace(/\$/g,',')+"</li>");
}
});
}
function change_spot(value) {
$("#spotval").val(value);
$('#spotbtn').html($("#sptlist"+value).html());
$("#sptname").val($("#sptlist"+value).html());
}
function change_cmd(value) {
$("#cmdval").val(value);
$('#cmdbtn').html($("#cmdlist"+value).html());
$("#cmdname").val($("#cmdlist"+value).html());
$("#cmdval").change();
}
function isInteger(obj){
if(isFinite(obj) && obj%1===0){
return true;
}
else{
return false;
}
}
function check_form() {
if(!$("#spotval").val()||!$("#cmdval").val()){
alert('请选择设备和命令!');
return false;
}
if($("#cmdval").val()!='REBOOT'){
var reg = new RegExp("^[0-9]+\.?[0-9]*$");
if(!reg.test($("#paramval").val())){
alert('请输入正确的数值!');
return false;
}
}
if($("#cmdval").val()=='TIMESPAN'&&!isInteger($("#paramval").val())){
alert('时间间隔应为整数!');
return false;
}
else if($("#cmdval").val()=='A_FIRE'&&(parseInt($("#paramval").val())<8000||parseInt($("#paramval").val())>50000)){
alert('烟雾报警参数取值:[8000,50000]!');
return false;
}
else if($("#cmdval").val()=='A_TEMP'&&($("#paramval").val()<5||$("#paramval").val()>50)){
alert('温度报警参数取值:[5.0, 50.0]!');
return false;
}
else if($("#cmdval").val()=='A_HUM'&&($("#paramval").val()<30||$("#paramval").val()>95)){
alert('湿度报警参数取值:[30.0, 95.0]!');
return false;
}
return true;
}
function get_device(){
if($("#spotval").val()){
// alert($("#cmdval").val());
$.get("http://172.18.17.136:8000/env/deviceinfo/?spot="+$("#spotval").val(), function(result){
// alert(jQuery.parseJSON(result));
$("#paramval").val(jQuery.parseJSON(result)[$("#cmdval").val()]);
});
}
}
Loading…
Cancel
Save