Authored by qinchao

mha 通过db加载

... ... @@ -157,29 +157,47 @@
function drawHtml2(cfg) {
var model = cfg.model;
var container = Util.createDOM('<div class="node-container"></div>');
var title = Util.createDOM('<div class="widget-title" style="height: 36px;"></div>');
var colorBadge="#4169E1";
if(model.badge=="crash"){
colorBadge="#F90426";
}/*else if(model.badge=="standby"){
colorBadge="#5bc0de";
}else if(model.badge=="slave"){
colorBadge="#5bc0fe";
}*/
title.appendChild(Util.createDOM('<h5>'+model.label+'</h5>'));
var a = Util.createDOM('<a href="#" onclick="alert(1)" style="float:right;margin-right: 10px;"><H5 style="padding-right:0px;padding-left:0px;"><span class="glyphicon glyphicon-info-sign"></span></H5></a>');
title.appendChild(a);
var content = Util.createDOM(
'<div class="widget-content" style="height: 70px;">'
+'<span class="badge" style="margin-right:5px;background-color:'+colorBadge+';font-weight:normal;">'+model.badge+'</span>'
//+'<br/>'
+model.hostname+' '+model.port
+'</div>');
container.appendChild(title);
container.appendChild(content);
if(model.id >0){
/* var title = Util.createDOM('<div class="widget-title" style="background-image:none!important;background-color:#ddd;height: 36px;"></div>');
title.appendChild(Util.createDOM('<h5>'+model.label+'</h5>'));
var a = Util.createDOM('<a href="#" onclick="alert(1)" style="float:right;margin-right: 10px;"><H5 style="padding-right:0px;padding-left:0px;"><span class="glyphicon glyphicon-info-sign"></span></H5></a>');
title.appendChild(a);
if(model.seqNO==0){
//container.appendChild(title);
}*/
var colorBadge="#4169E1";
if(model.badge=="crash"){
colorBadge="#F90426";
}
var content = Util.createDOM(
'<div class="widget-content" style="height: 100%;padding-top: 5px;"></div>');
var badgeAndHost = Util.createDOM(
'<div>'
+'<span class="badge" style="margin-right:5px;background-color:'+colorBadge+';font-weight:normal;">'+model.badge+'</span>'
//+'<br/>'
+model.hostname+' '+model.port
+'</div>');
if(model.seqNO==0){
content.appendChild(Util.createDOM('<div style="margin:0px;">'+model.label+'</div>'));
}
content.appendChild(badgeAndHost);
container.appendChild(content);
}else{
var index = Util.createDOM(
'<div style="height: 100%;padding:40px 0;">'
+'<strong>'+model.seqNO+'</strong>'
+'</div>');
container.appendChild(index);
}
return container;
}
... ... @@ -206,23 +224,16 @@
behaviourFilter: ['wheelZoom', 'dragNode','dragBlank', 'dragCanvas'],
id: "mhaTopoDiv" , // 此处替换容器id
fitView: 'autoSize' // 自动缩放 autoSize autoZoom
/* ,layoutCfg: {
// direction: 'LR', // 方向(LR/RL/H/TB/BT/V)
getHGap: function(/!* d *!/) { // 横向间距
return 100;
},
getVGap: function(/!* d *!/) { // 竖向间距
return 10;
}
}*/
});
tree.source(nodes, edges);
tree.node().style({
stroke: null, // 去除默认边框
fillOpacity: 1
})/*.color( function(obj){
return '#aaa';
})*/.label('serverName').shape('customNode');
}).color( function(obj){
if(obj.badge=="crash"){
return '#ddd';
}
}).label('srvName')/*.shape('customNode')*/;
tree.edge().style({
//stroke: 'black',
lineWidth: 2,
... ...