Răsfoiți Sursa

修改平台时删除心跳

maxiaoshan 3 ani în urmă
părinte
comite
19b1326727
2 a modificat fișierele cu 108 adăugiri și 103 ștergeri
  1. 5 0
      src/front/front.go
  2. 103 103
      src/web/templates/index.html

+ 5 - 0
src/front/front.go

@@ -7,6 +7,7 @@ import (
 	"log"
 	qu "qfw/util"
 	mgdb "qfw/util/mongodb"
+	mgu "qfw/util/mongodbutil"
 	"qfw/util/redis"
 	"regexp"
 	"sort"
@@ -863,6 +864,7 @@ func (f *Front) UpdateESP() {
 	val := f.GetString("val")
 	w := f.GetString("w")
 	id := f.GetString("id")
+	code := f.GetString("c")
 	query := map[string]interface{}{
 		"_id": qu.StringTOBsonId(id),
 	}
@@ -874,6 +876,9 @@ func (f *Front) UpdateESP() {
 		set["state"] = 0
 	} else if w == "platform" {
 		set["platform"] = val
+		if val != "golua平台" { //由lua平台切换到其他平台,删除爬虫spider_heart心跳
+			mgu.Update("spider_heart", "spider", "spider", map[string]interface{}{"code": code}, map[string]interface{}{"$set": map[string]interface{}{"del": true}}, false, true)
+		}
 	} else { //修改节点
 		event, _ := strconv.Atoi(val)
 		set["event"] = event

+ 103 - 103
src/web/templates/index.html

@@ -136,12 +136,12 @@
           				<th>网站名称</th>
           				<th>栏目名称</th>
           				<th>爬虫代码</th>
-                  <th>紧急度</th>
+                  		<th>紧急度</th>
           				<th>节点</th>
           				<th>作者</th>
           				<th>最后修改时间</th>
           				<th>状态</th>
-					        <th>平台</th>
+						<th>平台</th>
                   <th class="hidden-xs">操作</th>
                 </tr>
                 </thead>
@@ -160,103 +160,103 @@ $(function(){
           },
 		"columnDefs": [
 		    { "orderable": false, "targets": [0,10,11] },
-			  {"targets":[6], createdCell: function (cell, cellData, rowData, rowIndex, colIndex) {
-          {{if gt (session "auth") 2}}
-          var aInput;
-          $(cell).click(function () {
-            $(this).html(createComboxEvent(rowData._id,rowData.state,rowData.code));
-            var aInput = $(this).find(":input");
-            aInput.focus().val(cellData);
-          });
-          $(cell).on("click", ":input", function (e) {
-            e.stopPropagation();
-          });
-          $(cell).on("change", ":input", function () {
-            $(this).blur();
-          });
-          $(cell).on("blur", ":input", function () {
-            var text = $(this).find("option:selected").text();
-            ttable.cell(cell).data(text);
-            cellData = text;
-          });
-          {{end}}
-        }},
-        {"targets":[9], createdCell: function (cell, cellData, rowData, rowIndex, colIndex) {
-          {{if gt (session "auth") 2}}
-          var aInput;
-          $(cell).click(function () {
-            if(cellData!=4&&cellData!=7&&cellData!=8&&cellData!=9&&cellData!=10){
-              return
-            }
-            $(this).html(createComboxState(rowData._id));
-            var aInput = $(this).find(":input");
-            aInput.focus().val(cellData);
-          });
-          $(cell).on("click", ":input", function (e) {
-            e.stopPropagation();
-          });
-          $(cell).on("change", ":input", function () {
-            $(this).blur();
-          });
-          $(cell).on("blur", ":input", function () {
-            var text = $(this).find("option:selected").text();
-            if(text=="待完成"){
-              text = 0
-            }else if (text=="已作废"){
-              text = 4
-            }else if (text=="无发布"){
-              text = 7
-            }else if (text=="需登录"){
-              text = 8
-            }else if (text=="无法处理"){
-              text = 9
-            }else if (text=="已删除"){
-              text = 10
-            }else if (text=="已上线"){
-              text = 11
-            }
-            ttable.cell(cell).data(text);
-            cellData = text;
-          });
-          {{end}}
-        }},
-        {"targets":[10], createdCell: function (cell, cellData, rowData, rowIndex, colIndex) {
-          {{if gt (session "auth") 2}}
-          var aInput;
-          $(cell).click(function () {
-            $(this).html(createComboxPlatform(rowData._id));
-            var aInput = $(this).find(":input");
-            aInput.focus().val(cellData);
-          });
-          $(cell).on("click", ":input", function (e) {
-            e.stopPropagation();
-          });
-          $(cell).on("change", ":input", function () {
-            $(this).blur();
-          });
-          $(cell).on("blur", ":input", function () {
-            var text = $(this).find("option:selected").text();
-            if(text=="待完成"){
-              text = 0
-            }else if (text=="已作废"){
-              text = 4
-            }else if (text=="无发布"){
-              text = 7
-            }else if (text=="需登录"){
-              text = 8
-            }else if (text=="无法处理"){
-              text = 9
-            }else if (text=="已删除"){
-              text = 10
-            }else if (text=="已上线"){
-              text = 11
-            }
-            
-            ttable.cell(cell).data(text);
-            cellData = text;
-          });
-          {{end}}
-        }}
+			{"targets":[6], createdCell: function (cell, cellData, rowData, rowIndex, colIndex) {
+			  {{if gt (session "auth") 2}}
+			  var aInput;
+			  $(cell).click(function () {
+				$(this).html(createComboxEvent(rowData._id,rowData.state,rowData.code));
+				var aInput = $(this).find(":input");
+				aInput.focus().val(cellData);
+			  });
+			  $(cell).on("click", ":input", function (e) {
+				e.stopPropagation();
+			  });
+			  $(cell).on("change", ":input", function () {
+				$(this).blur();
+			  });
+			  $(cell).on("blur", ":input", function () {
+				var text = $(this).find("option:selected").text();
+				ttable.cell(cell).data(text);
+				cellData = text;
+			  });
+			  {{end}}
+			}},
+			{"targets":[9], createdCell: function (cell, cellData, rowData, rowIndex, colIndex) {
+			  {{if gt (session "auth") 2}}
+			  var aInput;
+			  $(cell).click(function () {
+				if(cellData!=4&&cellData!=7&&cellData!=8&&cellData!=9&&cellData!=10){
+				  return
+				}
+				$(this).html(createComboxState(rowData._id));
+				var aInput = $(this).find(":input");
+				aInput.focus().val(cellData);
+			  });
+			  $(cell).on("click", ":input", function (e) {
+				e.stopPropagation();
+			  });
+			  $(cell).on("change", ":input", function () {
+				$(this).blur();
+			  });
+			  $(cell).on("blur", ":input", function () {
+				var text = $(this).find("option:selected").text();
+				if(text=="待完成"){
+				  text = 0
+				}else if (text=="已作废"){
+				  text = 4
+				}else if (text=="无发布"){
+				  text = 7
+				}else if (text=="需登录"){
+				  text = 8
+				}else if (text=="无法处理"){
+				  text = 9
+				}else if (text=="已删除"){
+				  text = 10
+				}else if (text=="已上线"){
+				  text = 11
+				}
+				ttable.cell(cell).data(text);
+				cellData = text;
+			  });
+			  {{end}}
+			}},
+        	{"targets":[10], createdCell: function (cell, cellData, rowData, rowIndex, colIndex) {
+			  {{if gt (session "auth") 2}}
+			  var aInput;
+			  $(cell).click(function () {
+				$(this).html(createComboxPlatform(rowData.code,rowData._id));
+				var aInput = $(this).find(":input");
+				aInput.focus().val(cellData);
+			  });
+			  $(cell).on("click", ":input", function (e) {
+				e.stopPropagation();
+			  });
+			  $(cell).on("change", ":input", function () {
+				$(this).blur();
+			  });
+			  $(cell).on("blur", ":input", function () {
+				var text = $(this).find("option:selected").text();
+				if(text=="待完成"){
+				  text = 0
+				}else if (text=="已作废"){
+				  text = 4
+				}else if (text=="无发布"){
+				  text = 7
+				}else if (text=="需登录"){
+				  text = 8
+				}else if (text=="无法处理"){
+				  text = 9
+				}else if (text=="已删除"){
+				  text = 10
+				}else if (text=="已上线"){
+				  text = 11
+				}
+
+				ttable.cell(cell).data(text);
+				cellData = text;
+			  });
+			  {{end}}
+			}}
 		],
 		"order": [[1,"desc"]],
 		"processing":true,
@@ -733,8 +733,8 @@ $(function(){
             "<option disabled value='10'>已上线</option>"+
           +"</select>"
   };
-  function createComboxPlatform(id){
-    return "<select onchange='changeEventOrStateOrPlatform(this.value,\"platform\",\"\",\"\",\""+id+"\")' class='form-control input-sm'>"+
+  function createComboxPlatform(code,id){
+    return "<select onchange='changeEventOrStateOrPlatform(this.value,\"platform\",\"\",\""+code+"\",\""+id+"\")' class='form-control input-sm'>"+
     			  "<option value='golua平台'>golua平台</option>"+
     			  "<option value='python'>python</option>"+
     				"<option value='通用爬虫'>通用爬虫</option>"+
@@ -749,8 +749,8 @@ $(function(){
 				"val":val,
 				"w":w,
 				"id":id,
-        "s":s,
-        "c":c
+				"s":s,
+				"c":c
 			},
       success:function(r){
 				if(r=="n"){