Ver código fonte

实例删除

fengweiqiang 6 anos atrás
pai
commit
af638ee11c

+ 7 - 0
src/jy/admin/distribution/distribution.go

@@ -61,6 +61,13 @@ func init() {
 		cluster.DeleteInstance(InstanceId)
 		c.JSON(200, gin.H{"rep": true})
 	})
+	//释放ecs实例
+	Admin.POST("/distribution/deleteInstancedb", func(c *gin.Context) {
+		InstanceId, _ := c.GetPostForm("InstanceId")
+		log.Println(InstanceId)
+		b := db.Mgo.Del("ecs",`{"InstanceId":"`+InstanceId+`"}`)
+		c.JSON(200, gin.H{"rep": b})
+	})
 
 	//部署
 	Admin.POST("/distribution/deploy", func(c *gin.Context) {

+ 36 - 16
src/web/templates/admin/distribution.html

@@ -49,7 +49,7 @@
 	</div>
   </section>
 </div>
-	
+
 <!-- footer -->
 {{template "mask"}}
 {{template "dialog"}}
@@ -109,8 +109,12 @@ $(function () {
                 }
             }},
 			{"data":"InstanceId",render:function(val,a,row,pos){
-				return '<a class="btn btn-sm btn-warning" onclick="del(\''+row.InstanceId+'\')">释放</a>';
-			}}
+				return  '<div class="btn-group">'+
+                    '<a class="btn btn-sm btn-warning" onclick="del(\''+row.InstanceId+'\')">释放</a>'+
+                    '<a class="btn btn-sm btn-danger" href="#" onclick="delInstanceId(\''+row.InstanceId+'\')">删&nbsp;&nbsp;除</a>'
+                    '</div>';
+			},
+			}
        	]
 	});
 	ttable.on('init.dt', function () {
@@ -136,14 +140,14 @@ $(function () {
     					{label:"表名",s_label:"s_table",placeholder:"信息表名",must:true},
                         {label:"开始日期",s_label:"s_date",placeholder:"2018-01-01",must:true},
                         {label:"截止日期",s_label:"e_date",placeholder:"2019-01-01",must:true},
-    				]   
+    				]
                 }else if (n=="releasetime"){
                     _tit="释放设置"
                     tag=[
     					{label:"实例ID",s_label:"instanceid",placeholder:"实例ID",must:true},
                         {label:"顺延时间",s_label:"hours",placeholder:"当前时间起(单位/h)",must:true},
-    				] 
-                } 
+    				]
+                }
 				htmlObj={
 					title:_tit,
 					tag:tag,
@@ -159,12 +163,12 @@ $(function () {
 										bcon=false
 										return false
 									}
-								}) 
-								if (bcon){	
-                                    showConfirm("确认执行?", function() {							
+								})
+								if (bcon){
+                                    showConfirm("确认执行?", function() {
     									$.post("/admin/distribution/runInstances",obj,function(data){
     										if(data&&data.rep){
-    											window.location.href="/admin/distribution"			
+    											window.location.href="/admin/distribution"
     										}else{
     											showTip(data.msg,1000)
     										}
@@ -190,7 +194,7 @@ function del(_id){
 			type:"post",
 			data:{"InstanceId":_id},
 			success:function(r){
-				if(r.rep){				
+				if(r.rep){
 					ttable.ajax.reload();
 				}else{
 					showTip("释放失败", 1000, function() {});
@@ -199,6 +203,22 @@ function del(_id){
 		})
 	});
 }
+function delInstanceId(_id){
+    showConfirm("确定删除实例(数据库的)?", function() {
+        $.ajax({
+            url:"/admin/distribution/deleteInstancedb",
+            type:"post",
+            data:{"InstanceId":_id},
+            success:function(r){
+                if(r.rep){
+                    ttable.ajax.reload();
+                }else{
+                    showTip("确定删除实例", 1000, function() {});
+                }
+            }
+        })
+    });
+}
 function upInstanceIds(){
     showConfirm("更新实例?", function() {
     	com.maskShow("正在更新实例...");
@@ -206,7 +226,7 @@ function upInstanceIds(){
     		url:"/admin/distribution/upstatus",
     		type:"post",
     		success:function(r){
-    			if(r.rep){			
+    			if(r.rep){
     				ttable.ajax.reload();
                     com.maskHide();
     			}
@@ -222,14 +242,14 @@ function deploy(){
     		url:"/admin/distribution/deploy",
     		type:"post",
     		success:function(r){
-    			if(r.rep){				
+    			if(r.rep){
     				ttable.ajax.reload();
                     com.maskHide();
     			}else{
     				showTip("部署失败", 1000, function() {});
     			}
     		}
-    	}) 
+    	})
     })
 }
 
@@ -240,7 +260,7 @@ function rangetask(){
     		url:"/admin/distribution/rangetask",
     		type:"post",
     		success:function(r){
-    			if(r.rep){				
+    			if(r.rep){
     				ttable.ajax.reload();
                     com.maskHide();
     			}else{
@@ -248,6 +268,6 @@ function rangetask(){
     			}
     		}
     	})
-    }) 
+    })
 }
 </script>