Authored by FengRuwei

API自定义url

... ... @@ -35,4 +35,10 @@ div.api_info_container{
.item_java_api_title{
font-size:24px;
}
\ No newline at end of file
}
/*.api_info_item{*/
/*width: 450px;*/
/*margin-left: 5px;*/
/*margin-right: 5px;*/
/*}*/
\ No newline at end of file
... ...
... ... @@ -123,13 +123,13 @@
var initDashBoard = function (data) {
var div_dash = $(".api_info_container");
$.each(data, function (idx, val) {
var api_info_item = $('<div class="api_info_item col-xs-3 ">');
var api_info_item = $('<div class="api_info_item col-xs-4 ">');
var api_info_item_panel = $(' <div class="panel panel-default">');
var api_info_item_panel_title = $('<div class="item_java_api_title panel-heading">' + val.typeName + '<span style="font-size: medium;float: right;padding-top: 15px"><span id="span_time_' + val.typeId + '"></span></span></div>');
var api_info_item_panel_body = $('<div class="panel-body">');
api_info_item_panel_body.append('<button class="btn_java_api btn btn-lg btn-default" id="btn_1_' + val.typeId + '">AWS &nbsp;<span class="badge"></span></button>');
api_info_item_panel_body.append('<button class="btn_java_api btn btn-lg btn-default" id="btn_2_' + val.typeId + '">QCloud &nbsp;<span class="badge"></span></button>');
// api_info_item_panel_body.append('<button class="btn_java_api btn btn-lg btn-default" id="btn_3_' + val.typeId + '">其他 &nbsp;<span class="badge"></span></button>');
api_info_item_panel_body.append('<button class="btn_java_api btn btn-lg btn-default" id="btn_0_' + val.typeId + '">Custom &nbsp;<span class="badge"></span></button>');
// api_info_item_panel_body.append('<h5 >更新时间:<span id="span_time_'+val.typeId+'"></span></h5>');
api_info_item_panel.append(api_info_item_panel_title)
.append(api_info_item_panel_body);
... ... @@ -177,10 +177,10 @@
return;
}
console.info(data.data);
$("button[id^='btn_0']").hide();
$.each(data.data, function (idx, val) {
console.log($("#btn_" + val.cloudType + "_" + val.serviceType));
if(val.cloudType!=1&&val.cloudType!=2)//目前只有腾讯aws
if(val.cloudType!=1&&val.cloudType!=2&&val.cloudType!=0)//目前只有腾讯aws、自定义url=0
return;
var btn = $("#btn_" + val.cloudType + "_" + val.serviceType);
if (val.updateTime != undefined && val.updateTime != "") {
... ... @@ -189,6 +189,7 @@
$("#span_time_" + val.serviceType).html(timestr);
}
console.log(val);
btn.show();
if (val.errNum > 0) {
$(btn.children("span")[0]).html(val.errNum);
btn.removeClass("btn-success");
... ...
... ... @@ -218,8 +218,23 @@
}
});
});
var createJavaAppDiv = function (apps, serviceId, toggle) {
var createJavaAppDiv = function (apps, serviceId, toggle,apiUrlCustom) {
var rel = $("<div>");
if(apiUrlCustom==1){
var span;
if (toggle == 1) {
span = $("<button class='btn btn-default btn-xs tag_javaapp has-popover' >").attr("id", "span_" + serviceId + "_0" ).html("node");
span.attr("data-toggle", "popover");
span.attr("data-placement", "bottom");
span.attr("data-html", "true");
// span.attr("title", "message");
span.attr("data-content", "unkown");
} else {
span = $("<button class='btn btn-inverse btn-xs tag_javaapp' >").attr("id", "span_no_" + serviceId + "_0").html("node");
}
rel.append(span);
return rel;
}
$.each(apps, function (idx, val) {
var span;
if (toggle == 1) {
... ... @@ -243,7 +258,7 @@
var setStatus = function (statusObj) {
var id = "span_" + statusObj.serviceId + "_" + statusObj.mObjectId;
// console.log(statusObj);
console.log(statusObj);
var content = "start: " + statusObj.startTime + " ";
content += "end: " + statusObj.endTime + " ";
content += "cost: " + statusObj.costTime + "ms<br>";
... ... @@ -283,15 +298,22 @@
$.each(table_data.rows, function (idx, val) {
if (val.apiToggle == 0) //关闭了
return;
var apps = java_app["" + val.serviceType];
var serviceId = val.serviceId;
var reqList = [];
$.each(apps, function (idx, val) {
if(val.apiUrlCustom==1){ //custom url get status
reqList.push({
serviceId: serviceId,
mObjectId: val.moId
mObjectId: 0
});
});
}else {
var apps = java_app["" + val.serviceType];
$.each(apps, function (idx, val) {
reqList.push({
serviceId: serviceId,
mObjectId: val.moId
});
});
}
//每行就去获取,缩短整个表请求时间
$.ajax({
url: contextPath + "/javaApi/status?list=" + JSON.stringify(reqList),
... ... @@ -324,7 +346,7 @@
$.each(table_data.rows, function (idx, val) {
var apps = java_app["" + val.serviceType];
//创建服务状态
var appDiv = createJavaAppDiv(apps, val.serviceId, val.apiToggle);
var appDiv = createJavaAppDiv(apps, val.serviceId, val.apiToggle,val.apiUrlCustom);
$("#status_" + val.serviceId).html("");
$("#status_" + val.serviceId).append(appDiv);
... ...