Authored by FengRuwei

API自定义url

@@ -35,4 +35,10 @@ div.api_info_container{ @@ -35,4 +35,10 @@ div.api_info_container{
35 35
36 .item_java_api_title{ 36 .item_java_api_title{
37 font-size:24px; 37 font-size:24px;
38 -}  
  38 +}
  39 +
  40 +/*.api_info_item{*/
  41 + /*width: 450px;*/
  42 + /*margin-left: 5px;*/
  43 + /*margin-right: 5px;*/
  44 +/*}*/
@@ -123,13 +123,13 @@ @@ -123,13 +123,13 @@
123 var initDashBoard = function (data) { 123 var initDashBoard = function (data) {
124 var div_dash = $(".api_info_container"); 124 var div_dash = $(".api_info_container");
125 $.each(data, function (idx, val) { 125 $.each(data, function (idx, val) {
126 - var api_info_item = $('<div class="api_info_item col-xs-3 ">'); 126 + var api_info_item = $('<div class="api_info_item col-xs-4 ">');
127 var api_info_item_panel = $(' <div class="panel panel-default">'); 127 var api_info_item_panel = $(' <div class="panel panel-default">');
128 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>'); 128 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>');
129 var api_info_item_panel_body = $('<div class="panel-body">'); 129 var api_info_item_panel_body = $('<div class="panel-body">');
130 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>'); 130 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>');
131 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>'); 131 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>');
132 -// 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>'); 132 + 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>');
133 // api_info_item_panel_body.append('<h5 >更新时间:<span id="span_time_'+val.typeId+'"></span></h5>'); 133 // api_info_item_panel_body.append('<h5 >更新时间:<span id="span_time_'+val.typeId+'"></span></h5>');
134 api_info_item_panel.append(api_info_item_panel_title) 134 api_info_item_panel.append(api_info_item_panel_title)
135 .append(api_info_item_panel_body); 135 .append(api_info_item_panel_body);
@@ -177,10 +177,10 @@ @@ -177,10 +177,10 @@
177 return; 177 return;
178 } 178 }
179 console.info(data.data); 179 console.info(data.data);
180 - 180 + $("button[id^='btn_0']").hide();
181 $.each(data.data, function (idx, val) { 181 $.each(data.data, function (idx, val) {
182 console.log($("#btn_" + val.cloudType + "_" + val.serviceType)); 182 console.log($("#btn_" + val.cloudType + "_" + val.serviceType));
183 - if(val.cloudType!=1&&val.cloudType!=2)//目前只有腾讯aws 183 + if(val.cloudType!=1&&val.cloudType!=2&&val.cloudType!=0)//目前只有腾讯aws、自定义url=0
184 return; 184 return;
185 var btn = $("#btn_" + val.cloudType + "_" + val.serviceType); 185 var btn = $("#btn_" + val.cloudType + "_" + val.serviceType);
186 if (val.updateTime != undefined && val.updateTime != "") { 186 if (val.updateTime != undefined && val.updateTime != "") {
@@ -189,6 +189,7 @@ @@ -189,6 +189,7 @@
189 $("#span_time_" + val.serviceType).html(timestr); 189 $("#span_time_" + val.serviceType).html(timestr);
190 } 190 }
191 console.log(val); 191 console.log(val);
  192 + btn.show();
192 if (val.errNum > 0) { 193 if (val.errNum > 0) {
193 $(btn.children("span")[0]).html(val.errNum); 194 $(btn.children("span")[0]).html(val.errNum);
194 btn.removeClass("btn-success"); 195 btn.removeClass("btn-success");
@@ -218,8 +218,23 @@ @@ -218,8 +218,23 @@
218 } 218 }
219 }); 219 });
220 }); 220 });
221 - var createJavaAppDiv = function (apps, serviceId, toggle) { 221 + var createJavaAppDiv = function (apps, serviceId, toggle,apiUrlCustom) {
222 var rel = $("<div>"); 222 var rel = $("<div>");
  223 + if(apiUrlCustom==1){
  224 + var span;
  225 + if (toggle == 1) {
  226 + span = $("<button class='btn btn-default btn-xs tag_javaapp has-popover' >").attr("id", "span_" + serviceId + "_0" ).html("node");
  227 + span.attr("data-toggle", "popover");
  228 + span.attr("data-placement", "bottom");
  229 + span.attr("data-html", "true");
  230 +// span.attr("title", "message");
  231 + span.attr("data-content", "unkown");
  232 + } else {
  233 + span = $("<button class='btn btn-inverse btn-xs tag_javaapp' >").attr("id", "span_no_" + serviceId + "_0").html("node");
  234 + }
  235 + rel.append(span);
  236 + return rel;
  237 + }
223 $.each(apps, function (idx, val) { 238 $.each(apps, function (idx, val) {
224 var span; 239 var span;
225 if (toggle == 1) { 240 if (toggle == 1) {
@@ -243,7 +258,7 @@ @@ -243,7 +258,7 @@
243 258
244 var setStatus = function (statusObj) { 259 var setStatus = function (statusObj) {
245 var id = "span_" + statusObj.serviceId + "_" + statusObj.mObjectId; 260 var id = "span_" + statusObj.serviceId + "_" + statusObj.mObjectId;
246 -// console.log(statusObj); 261 + console.log(statusObj);
247 var content = "start: " + statusObj.startTime + " "; 262 var content = "start: " + statusObj.startTime + " ";
248 content += "end: " + statusObj.endTime + " "; 263 content += "end: " + statusObj.endTime + " ";
249 content += "cost: " + statusObj.costTime + "ms<br>"; 264 content += "cost: " + statusObj.costTime + "ms<br>";
@@ -283,15 +298,22 @@ @@ -283,15 +298,22 @@
283 $.each(table_data.rows, function (idx, val) { 298 $.each(table_data.rows, function (idx, val) {
284 if (val.apiToggle == 0) //关闭了 299 if (val.apiToggle == 0) //关闭了
285 return; 300 return;
286 - var apps = java_app["" + val.serviceType];  
287 var serviceId = val.serviceId; 301 var serviceId = val.serviceId;
288 var reqList = []; 302 var reqList = [];
289 - $.each(apps, function (idx, val) { 303 + if(val.apiUrlCustom==1){ //custom url get status
290 reqList.push({ 304 reqList.push({
291 serviceId: serviceId, 305 serviceId: serviceId,
292 - mObjectId: val.moId 306 + mObjectId: 0
293 }); 307 });
294 - }); 308 + }else {
  309 + var apps = java_app["" + val.serviceType];
  310 + $.each(apps, function (idx, val) {
  311 + reqList.push({
  312 + serviceId: serviceId,
  313 + mObjectId: val.moId
  314 + });
  315 + });
  316 + }
295 //每行就去获取,缩短整个表请求时间 317 //每行就去获取,缩短整个表请求时间
296 $.ajax({ 318 $.ajax({
297 url: contextPath + "/javaApi/status?list=" + JSON.stringify(reqList), 319 url: contextPath + "/javaApi/status?list=" + JSON.stringify(reqList),
@@ -324,7 +346,7 @@ @@ -324,7 +346,7 @@
324 $.each(table_data.rows, function (idx, val) { 346 $.each(table_data.rows, function (idx, val) {
325 var apps = java_app["" + val.serviceType]; 347 var apps = java_app["" + val.serviceType];
326 //创建服务状态 348 //创建服务状态
327 - var appDiv = createJavaAppDiv(apps, val.serviceId, val.apiToggle); 349 + var appDiv = createJavaAppDiv(apps, val.serviceId, val.apiToggle,val.apiUrlCustom);
328 $("#status_" + val.serviceId).html(""); 350 $("#status_" + val.serviceId).html("");
329 $("#status_" + val.serviceId).append(appDiv); 351 $("#status_" + val.serviceId).append(appDiv);
330 352