TaskManager.tml 31.7 KB
Newer Older
偏锋书生's avatar
偏锋书生 已提交
1 2 3 4 5
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"
      xmlns:r="tapestry-library:rjzjh"
      xmlns:s="tapestry-library:tams"
      xmlns:p="tapestry:parameter"> 
<head>
偏锋书生's avatar
偏锋书生 已提交
6
   <title isMenu="true" module="3">binlog监听任务管理</title>
偏锋书生's avatar
偏锋书生 已提交
7 8 9 10
</head>
<body>
   <r:query id="q"  qBlock="query" queryUrl="/runing/TaskManager:query"  uBlock="save"   saveUrl="/runing/TaskManager:save" deleteUrl="/runing/TaskManager:del" opFormatter="showopt" 
        columns="[[{field:'name',width:200,title:'监听任务名'},{field:'version1',width:80,title:'版本'},{field:'deployId1',width:150,title:'布署环境'},{field:'middlewareId1',width:150,title:'目的中间件'},{field:'instanceId1',width:350,title:'监听实例'},{field:'checkpoint1',width:140,title:'检查点'},{field:'taskStatus',width:100,title:'运行状态'},{field:'pos',width:120,title:'运行位点'},{field:'op',width:280,title:'操作'}]]" 
偏锋书生's avatar
偏锋书生 已提交
11
        dialogStyle="width:900px;height:560px;" initAddHandle="initAdd" initSaveHandle="initUpdate"  queryButs="[{'id':'viewLogBut','iconCls':'icon-attach','text':'查看日志'},{'id':'viewConfigBut','iconCls':'icon-attach','text':'查看配置'},{'id':'editPosBut','text':'位点配置'},{'id':'taskdownBut','iconCls':'icon-attach','text':'任务离线下载'}]"  saveCheckHandle="saveCheck" pagination="true"/>
偏锋书生's avatar
偏锋书生 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
   <t:block id="query">
       <table class="frame_table_list_4">
		 <tr>
			    <td class="frame_table_list_4_righttext">任务名</td>
				<td>
				   <r:validatebox name="name"/>
				</td>
				<td class="frame_table_list_4_righttext" colspan="6">
				  <font color="red">
				   <div align="left"> </div>
				   </font>
				</td>
		 </tr>
	  </table>
   </t:block>
   <t:block id="save">
        <table class="frame_table_list_2">
			      <tr>
			 	  	 <td class="frame_table_list_2_righttext">监听任务名</td>
			 	     <td>
			 	       <input type="hidden" name="id"/>
			 	       <r:validatebox name="name" style="width:250px;" required="true"/>
			 	     </td>
			 	     <td class="frame_table_list_2_righttext">版本</td>
			 	     <td>
			 	        <r:combogrid id="versionId_save" name="versionId"  columns="[[{field:'mainVersion',width:70,title:'主程序版本'},{field:'dataVersion',width:70,title:'数据版本'},{field:'updateTimeStr',width:150,title:'升级时间'},{field:'author',width:70,title:'作者'}]]" idfield="id" panelWidth="400" panelHeight="300" textfield="mainVersion" width="180" pagination="false" url="/setting/VersionManager:query?needpage=false"></r:combogrid>
	                 </td>	
			      </tr>
			      <tr>	
			         <td class="frame_table_list_2_righttext">监听实例</td>
			         <td>
			            <r:combogrid id="instanceId_save" name="instanceId" required="true"  changeHandle="selectInstance"   columns="[[{field:'name',width:200,title:'实例名'},{field:'host',width:350,title:'主机'},{field:'port',width:70,title:'端口'},{field:'username',width:100,title:'用户名'}]]" idfield="id" panelWidth="750" panelHeight="700" textfield="name" width="180" pagination="false" url="/setting/InstanceManager:query?needpage=false"></r:combogrid>
			         </td>
			 	      <td class="frame_table_list_2_righttext">布署环境</td>
			         <td>
偏锋书生's avatar
偏锋书生 已提交
47
			            <r:combogrid id="deployId_save" name="deployId" required="true"  changeHandle="selectDeploy"  columns="[[{field:'name',width:200,title:'发布名'},{field:'deploy',width:100,title:'发布类型'},{field:'env',width:100,title:'环境'},{field:'namespace',width:150,title:'名称空间'},{field:'host',width:120,title:'主机'}]]" idfield="id" panelWidth="700" panelHeight="300" textfield="name" width="180" pagination="false" url="/setting/DeployManager:query?needpage=false"></r:combogrid>
偏锋书生's avatar
偏锋书生 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
			        </td>		 	  	 		 	     
			      </tr>
			      <tr>	
			 	     <td class="frame_table_list_2_righttext">目的中间件</td>
			         <td>
			           <r:combogrid id="middlewareId_save" name="middlewareId" required="true"  changeHandle="selectMiddleware" columns="[[{field:'name',width:100,title:'实例名'},{field:'middlewareType',width:70,title:'类型'},{field:'version',width:70,title:'版本'},{field:'host',width:250,title:'主机'},{field:'port',width:70,title:'端口'},{field:'username',width:70,title:'用户名'},{field:'remark',width:150,title:'备注'}]]" idfield="id" panelWidth="900" panelHeight="300" textfield="name" width="180" pagination="false" url="/setting/MiddlewareManager:query?needpage=false"></r:combogrid>
			         </td> 		      
			         <td class="frame_table_list_2_righttext">检查点</td>
			         <td>
			             <r:combogrid id="checkpointId_save" name="checkpointId" required="true"  columns="[[{field:'name',width:200,title:'检查点名'},{field:'checkpointType',width:70,title:'检查点类型'},{field:'host',width:200,title:'主机'},{field:'port',width:60,title:'端口'},{field:'username',width:100,title:'用户名'}]]" idfield="id" panelWidth="700" panelHeight="300" textfield="name" width="180" pagination="false" url="/setting/CheckpointManager:query?needpage=false"></r:combogrid>
			         </td>			 	  	 		 	     
			      </tr>
			      <tr>	
			          <td class="frame_table_list_2_righttext">ha类型</td>
			 	     <td>
			 	        <r:comboboxenum id="haType_save"  name="haType" enumClass="net.wicp.tams.app.duckula.controller.config.constant.HaType" required="true" panelHeight="120" panelWidth="160" width="180"></r:comboboxenum>
			 	     </td>			      
			         <td class="frame_table_list_2_righttext">启动的gtid</td>
			         <td>
			            <r:validatebox name="gtids" style="width:375px;" required="false"/>
	                 </td>			        			 	  	 		 	     
			     </tr>
			     <tr>
			         <td class="frame_table_list_2_righttext">附加配置</td>
			         <td colspan="3">
			            <r:validatebox   name="attrConfig" style="width:755px;" required="false"/>
	                 </td>
			    </tr>
			     <tr name="showmodel">
			        <td colspan="4">
				        <table id="dg" title="规则编辑" style="width:98%;height:180px"
					            toolbar="#toolbar" pagination="false" idField="id"
					            rownumbers="false" fitColumns="true" singleSelect="true">
					        <thead>
					            <tr>
					                <th field="dbPattern" width="15%"  editor="{type:'validatebox',destroy:'updateRuleInput',options:{required:true}}">库名模式</th>
					                <th field="tbPattern" width="30%" editor="{type:'validatebox',options:{required:true}}">表名模式</th>
					                <th field="drds" width="13%" editor="{type:'combobox',options:{required:false,valueField:'value',textField:'label',panelHeight:80,data:[{label:'分库也分表',value:'dbtb'},{label:'只分库',value:'db'},{label:'不分库分表',value:'no'}]}}">drds分表模式</th>
					                
					                <th field="topic" width="20%" editor="{type:'validatebox',options:{required:false}}">消息主题</th>
					                <th field="key" width="15%" editor="{type:'validatebox',options:{required:false}}">主键</th>
					                <th field="relakey" width="12%" editor="{type:'validatebox',options:{required:false}}">关联字段</th>
					                <th field="index" width="12%" editor="{type:'validatebox',options:{required:false}}">es索引</th>
					                <th field="splitkey" width="12%" editor="{type:'validatebox',options:{required:false}}">分隔字段</th>
					                
					                <th field="redisurl" width="12%" editor="{type:'validatebox',options:{required:false}}">缓存地址</th>
					                 <th field="appid" width="12%" editor="{type:'validatebox',options:{required:false}}">appid</th>
					                <th field="type" width="12%" editor="{type:'validatebox',options:{required:false}}">索引类型</th>
					                <th field="middleware" width="12%" editor="{type:'validatebox',options:{required:false}}">中间件实例</th>
					                <th field="dbinstanceid" width="12%" editor="{type:'validatebox',options:{required:false}}">数据库</th>
					                <th field="dbtb" width="12%" editor="{type:'validatebox',options:{required:false}}">库名表名</th>
					                <th field="partitions" width="12%" editor="{type:'validatebox',options:{required:false}}">分区数</th>
					                <th field="copynum" width="12%" editor="{type:'validatebox',options:{required:false}}">复制份数</th>					                
					                <th field="ks" width="12%" editor="{type:'validatebox',options:{required:false}}">名称空间</th>
					                <th field="table" width="12%" editor="{type:'validatebox',options:{required:false}}">表名</th>	
					                
					                <th field="colName" width="12%" editor="{type:'validatebox',options:{required:false}}">附加列</th>
					                <th field="addProp" width="12%" editor="{type:'validatebox',options:{required:false}}">静态属性</th>
偏锋书生's avatar
偏锋书生 已提交
106
					                <th field="filter" width="30%" editor="{type:'validatebox',options:{required:false}}">过滤器配置</th>					                				                			               
偏锋书生's avatar
偏锋书生 已提交
107 108 109 110 111 112 113 114 115
					                <th field="other" width="12%" editor="{type:'validatebox',options:{required:false}}">其它配置</th>
					            </tr>
					        </thead>
					    </table>
					     <div id="toolbar">
					        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="javascript:$('#dg').edatagrid('addRow')">新增规则</a>
					        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="javascript:$('#dg').edatagrid('destroyRow')">删除</a>
					        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="javascript:$('#dg').edatagrid('cancelRow')">取消</a>
					        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="javascript:$('#dg').edatagrid('saveRow')">保存</a>	
偏锋书生's avatar
偏锋书生 已提交
116
					        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-filter" plain="true" onclick="javascript:openFilter()">过滤器</a>
偏锋书生's avatar
偏锋书生 已提交
117
					        <font color="red" style="font-weight:bold;"> &emsp;&msp;&emsp;&emsp;&emsp;     请选择接收者,编辑完成后请“保存”,配置以输入框内容为准,界面只是辅助输入	</font>			        
偏锋书生's avatar
偏锋书生 已提交
118
					        <r:validatebox id="ruleEdit"  name="rule" style="width:100%;" required="true"/>
偏锋书生's avatar
偏锋书生 已提交
119 120 121 122 123 124 125 126 127
					    </div>
			        </td>
			     </tr>	
			     			      
	 </table>
   </t:block>
   
   <r:window id="configWindow" title="配置文件对比" width="1200" height="600"  resizable="false" maximizable="false" minimizable="false" collapsible="false">
       <div  id="configview" class="easyui-layout" data-options="fit:true">
偏锋书生's avatar
偏锋书生 已提交
128
			<div  data-options="region:'east',split:true" style="padding:10px;width:600px">
偏锋书生's avatar
偏锋书生 已提交
129 130
			      dddd
			</div>
偏锋书生's avatar
偏锋书生 已提交
131
			<div data-options="region:'center'" style="padding:10px;width:600px">
偏锋书生's avatar
偏锋书生 已提交
132 133 134 135 136 137 138 139 140 141
				jQuery EasyUI framework help you build your web page easily.
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 5px;">
			    <a class="easyui-linkbutton" data-options="iconCls:'icon-lightbulb',plain:true" href="javascript:void(0)"  style="width:400px"><font color="red">当前配置</font></a>
			    <a class="easyui-linkbutton" data-options="iconCls:'icon-lightbulb',plain:true" href="javascript:void(0)"  style="width:400px"><font color="red">已发布配置</font></a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:addConfig()" style="width:200px">重新布署配置</a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:$('#configWindow').window('close')" style="width:80px">关闭</a>
			</div>
		</div>
   </r:window>
偏锋书生's avatar
偏锋书生 已提交
142 143 144 145 146 147 148 149 150
   
   <r:dialog id="inputFilter" title="请填写过滤规则" width="1150" height="520"  closable="flase" >
        <table id="dgFilter"  style="height:90%;width:98%"
					            toolbar="#toolbar-dgFilter" pagination="false" idField="id"
					            rownumbers="false" fitColumns="true" singleSelect="true">
					        <thead>
					            <tr>
					                <th field="field" width="14%" editor="{type:'validatebox',options:{required:false}}">字段名</th>
					                <th field="index" width="3%" editor="{type:'numberbox',options:{min:0,max:9,required:false}}">index</th>
偏锋书生's avatar
偏锋书生 已提交
151
					                <th field="rule" width="14%" editor="{type:'combobox',options:{valueField:'label',textField: 'value',onSelect:selectFilterRule,groupField:'group',panelWidth:120,data: [{label: 'regular',value: '正则表达式',group:'行过滤'},{label: 'sql',value: 'sql过滤',group:'行过滤'},{label: 'colname',value: '列名',group:'列过滤'},{label: 'opttype',value: '操作类型',group:'其它'}],required:true}}">规则</th>
偏锋书生's avatar
偏锋书生 已提交
152 153 154 155 156 157 158 159 160
					                <th field="ruleValue" width="69%" editor="{type:'validatebox',options:{required:false}}">规则值</th>
					            </tr>
					        </thead>
		  </table>
		  <div id="toolbar-dgFilter">
					        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="javascript:$('#dgFilter').edatagrid('addRow')">新增规则</a>
					        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="javascript:$('#dgFilter').edatagrid('destroyRow')">删除</a>
					        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="javascript:$('#dgFilter').edatagrid('cancelRow')">取消</a>
					        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="javascript:$('#dgFilter').edatagrid('saveRow')">保存</a>	
偏锋书生's avatar
偏锋书生 已提交
161
					        <font color="red" style="font-weight:bold;"> &emsp;&msp;&emsp;&emsp;&emsp;     index可以不做填定,备用。只有规则为“正则表达式”需要填字段名,规则其它注意项:<br/>操作类型:默认insert,update,delete代表增改删&emsp;&emsp;   sql过滤:parenttable指父表名,@{joinColName}指binlog的字段名,duckula会把对应的字段值替换它,filterColname指需要过滤的父表的某个字段名	</font>	
偏锋书生's avatar
偏锋书生 已提交
162 163 164
					        <input id="filterContext"  name="filterContext" class="easyui-textbox" data-options="multiline:true"  style="height:200;width:100%"/>
		 </div>                
   </r:dialog>
偏锋书生's avatar
偏锋书生 已提交
165 166
 
 
偏锋书生's avatar
偏锋书生 已提交
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
    <div id="opsMenu" style="width:100px;">
		<div id="opsSelBut" class="easyui-linkbutton"  iconCls="icon-undo">选择位点</div>
		<div id="opsDelBut" class="easyui-linkbutton"  iconCls="icon-remove">删除位点</div>
	</div>
	
   <r:dialog id="queryPos" title="请选择位点" width="640" height="420"  closable="true"   toolbar="[{'id':'savePosBut','text':'保存','plain':false}]">
       <table id="pos_grid" class="easyui-datagrid" title="位点信息" style="width:600px;height:350px" data-options="url:'/zh/runing/TaskManager:QueryPos',fitColumns:true,singleSelect:true">
		  <thead>
			<tr>
				<th data-options="field:'timeStr',width:120">时间</th>
				<th data-options="field:'fileName',width:110">文件名</th>
				<th data-options="field:'pos',width:70,align:'right'">位置</th>
				<th data-options="field:'serverIp',width:250,align:'right'">数据库实例</th>
				<th data-options="field:'clintId',width:45">clientId</th>
			</tr>
		</thead>
	  </table>
偏锋书生's avatar
偏锋书生 已提交
184
   </r:dialog>   
偏锋书生's avatar
偏锋书生 已提交
185 186 187 188
<script>	
    function showopt(value,row,index){
            var reg = RegExp(/未布署/);
            var opt=!reg.test(row.taskStatus);
189
       	    var update= '<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit"  data-options="disabled:false"  style="margin-right:10px" onclick="_doUpdate('+index+') ">'+msg.update+'</a>';
偏锋书生's avatar
偏锋书生 已提交
190 191 192 193 194 195 196 197 198 199 200 201 202 203
       	    var deletebut= '<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" data-options="disabled:'+opt+'" style="margin-right:10px" onclick="_doDelete('+index+') ">'+msg.delete_+'</a>';
       	    var deploybut= '<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-reload" data-options="disabled:'+opt+'" style="margin-right:10px" onclick="doStart('+index+') ">启动</a>'; 
       	    var stopbut= '<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-reload" data-options="disabled:'+!opt+'" style="margin-right:10px" onclick="doStop('+index+') ">停止</a>';  
       	    //var viewLogbut= '<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-reload" data-options="disabled:'+!opt+'" style="margin-right:10px" onclick="viewLog('+index+') ">查看日志</a>';
       	    return update+deletebut+deploybut+stopbut;
     }
     
   function initAdd(){
      //$('#os_save').combobox('setValue','Linux');
      $('#dg').edatagrid("loadData", []);
      $('#dg').edatagrid("hideColumn", "drds");
      for (var item of allcolumn) {
           $('#dg').edatagrid("hideColumn", item);
	  }
偏锋书生's avatar
偏锋书生 已提交
204 205
	  $('#dg').edatagrid("loadData", []);
	  $('#dgFilter').edatagrid("loadData", []);
偏锋书生's avatar
偏锋书生 已提交
206 207 208 209 210 211 212 213 214 215 216 217 218 219
   }
   function initUpdate(row){
      //$('#ip2').textbox('readonly',true);
      //$('#version_save').textbox('readonly',true);
      syncRule();
      selectMiddleware();
     //host和docker不能设置版本
     //var deploy=or((row.deployId1.search("【host】") != -1),(row.deployId1.search("【docker】") != -1));
     var deploy=row.deployId1.search("【host】") != -1;
     //alert(deploy);
     if(deploy){
        $('#versionId_save').combogrid("readonly",true);
     }else{
        $('#versionId_save').combogrid("readonly",false);
220 221 222 223
     }
     //把权限退到“保存”按钮,这样就可以查看任务了
     var reg = RegExp(/未布署/);
     var opt=!reg.test(row.taskStatus);
偏锋书生's avatar
偏锋书生 已提交
224
     $('#q_saveDoBut').unbind('click'); 
225
     if(opt){
偏锋书生's avatar
偏锋书生 已提交
226
         $('#q_saveDoBut').linkbutton('disable'); 
227
     }else{
偏锋书生's avatar
偏锋书生 已提交
228
         $('#q_saveDoBut').bind('click', _doSaveRecode);
229
     }     
偏锋书生's avatar
偏锋书生 已提交
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
   }
 
   var sleep = function(time) {
      var startTime = new Date().getTime() + parseInt(time, 10);
       while(lt(new Date().getTime(), startTime)) {}
   }

   function saveCheck(){
      //updateRuleInput();
      $('#dg').edatagrid('saveRow');
      //sleep(3000);
       var deployComValue= $.rjzjh.getcombogrid('deployId_save','deploy');
       var versionIdValue=$.rjzjh.getcombogrid('versionId_save','id');
       //var deploy=deployComValue.search("【host】") != -1;
       if(and((deployComValue!='host') ,(versionIdValue==''))){
          $.rjzjh.alert('需要选择版本');
          return false;
       }
      return true;
   }

   
    function viewLog(index){
      // var row=getRow(index);       
       var row = jQuery('#q_grid').datagrid('getSelected');
       var deploy= $.rjzjh.getcombogrid('deployId_save','deploy');
       var url = $.rjzjh.packurl('/tools/ViewPodLog?params=task:'+row.id+':'+row.deployId);
       var iWidth=1200;                          //弹出窗口的宽度;
       var iHeight=1000;                         //弹出窗口的高度;
           //获得窗口的垂直位置
       var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
           //获得窗口的水平位置
       var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
        var  myWindow=  window.open(url, '查看日志', 'height=' + iHeight + ',,innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no');
   myWindow.focus();
       
      ///tools/ViewPodLog
      // var row=getRow(index);
      // $.post($.rjzjh.packurl('/runing/DumpManager:viewLog'),row,function(data){
	  //     alert(data);
	 //  },'json');
   }
   
  function viewConfig(){
      var row = jQuery('#q_grid').datagrid('getSelected');
      $('#configview').layout('panel','east').panel('refresh',$.rjzjh.packurl('/tools/ViewPodLog:OldConfig/task/'+row.id+'/'+row.deployId));
      $('#configview').layout('panel','center').panel('refresh',$.rjzjh.packurl('/tools/ViewPodLog:NewConfig/task/'+row.id+'/'+row.deployId));
      $('#configWindow').window('open');
偏锋书生's avatar
偏锋书生 已提交
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
   }   
   function opsSel(){
        var row = jQuery('#q_grid').datagrid('getSelected');
        $('#pos_grid').datagrid('load', row);
        $.rjzjh.opendialog2("queryPos");
        //$.post($.rjzjh.packurl('/runing/TaskManager:QueryPos'),row,function(data){
       //      $('#pos_grid').datagrid('loadData',data);
	   //      $.rjzjh.opendialog2("queryPos");  
	   // },'json');	
   }
   function  savePos(){
      var row = jQuery('#pos_grid').datagrid('getSelected');
      if(!row){
          $.rjzjh.alert('需要选择位点信息');
          return;
      }
      $.rjzjh.confirm('你确定要保存位点,从指定的位点启动吗?',function(){
           $.messager.progress({
		    	title:window.msg.hintwaiting,
		    	msg:window.msg.hinthandling
            }); 
           row.id=jQuery('#q_grid').datagrid('getSelected').id;
	       $.post($.rjzjh.packurl('/runing/TaskManager:UpdatePos'),row,function(data){
	          $.messager.progress('close');
	          $('#queryPos').dialog('close');
		       //关闭queryPos $.rjzjh.opendialog2("queryPos");  
		   },'json');
       });   
偏锋书生's avatar
偏锋书生 已提交
306
   }
偏锋书生's avatar
偏锋书生 已提交
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
   function opsDel(){
      var row = jQuery('#q_grid').datagrid('getSelected');
      $.rjzjh.confirm('你确定要删除位点,从当前位点启动吗?',function(){
           $.messager.progress({
		    	title:window.msg.hintwaiting,
		    	msg:window.msg.hinthandling
            });    
           $.post($.rjzjh.packurl('/runing/TaskManager:DelPos'),row,function(data){
             $.messager.progress('close');
             $.rjzjh.opt2(data,function(){
			    jQuery('#q_grid').datagrid('reload');
	         }); 
	       },'json');
       });
   }
偏锋书生's avatar
偏锋书生 已提交
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
   function taskdown(){
      var row = jQuery('#q_grid').datagrid('getSelected');
      if(!row){
          $.rjzjh.alert('需要选择任务');
          return;
      }
      $.rjzjh.confirm('你确定要下载适用于署地化部署的helm3 chart包进行独立安装监听任务吗?',function(){
           $.messager.progress({
		    	title:window.msg.hintwaiting,
		    	msg:window.msg.hinthandling
            });
            
           var urlpar= $.rjzjh.packurl('/tools/DownLoadHelm3Charts/task/'+row.id);
            //借用q_updateform,就不用新建form了
           jQuery('#q_updateform').form('submit',{
偏锋书生's avatar
偏锋书生 已提交
337
				url : urlpar,
偏锋书生's avatar
偏锋书生 已提交
338 339 340 341 342 343 344 345 346 347 348 349
				onSubmit: function(){
			    },
			    success: function(data){
			       //下载时不会触发,跳走了
			    }
		   });
           jQuery.messager.progress('close');  
           //$.post($.rjzjh.packurl('/tools/DownLoadHelm3Charts/task/'+row.id),row,function(data){
          //   $.messager.progress('close');
	      // },'json');
      });
   }
偏锋书生's avatar
偏锋书生 已提交
350 351
   
   
偏锋书生's avatar
偏锋书生 已提交
352 353 354 355 356 357 358
   function addConfig(){
        var row = jQuery('#q_grid').datagrid('getSelected');
        $.rjzjh.confirm('你确定要重新布署配置文件吗?',function(){
           $.messager.progress({
		    	title:window.msg.hintwaiting,
		    	msg:window.msg.hinthandling
            });    
偏锋书生's avatar
偏锋书生 已提交
359
           $.post($.rjzjh.packurl('/runing/TaskManager:AddConfig'),row,function(data){
偏锋书生's avatar
偏锋书生 已提交
360 361
             $.messager.progress('close');
             $.rjzjh.opt2(data,function(){
偏锋书生's avatar
偏锋书生 已提交
362
			     $.rjzjh.alert('布署成功');
偏锋书生's avatar
偏锋书生 已提交
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
	         }); 
	       },'json');
       });
   }
   
   
   
   
   function doStart(index){
	   var row=getRow(index);
       $.rjzjh.confirm('你确定要启动此任务吗?',function(){
           $.messager.progress({
		    	title:window.msg.hintwaiting,
		    	msg:window.msg.hinthandling
            });    
           $.post($.rjzjh.packurl('/runing/TaskManager:StartTask'),row,function(data){
             $.messager.progress('close');
             $.rjzjh.opt2(data,function(){
			    jQuery('#q_grid').datagrid('reload');
	         }); 
	       },'json');
       });
   }
   
   function doStop(index){
       var row=getRow(index);
       $.rjzjh.confirm('停止任务需要一段时间,你确定要停止此任务吗?',function(){
           $.messager.progress({
		    	title:window.msg.hintwaiting,
		    	msg:window.msg.hinthandling
            });    
           $.post($.rjzjh.packurl('/runing/TaskManager:StopTask'),row,function(data){
             $.messager.progress('close');
             $.rjzjh.opt2(data,function(){
			    jQuery('#q_grid').datagrid('reload');
	         }); 
	       },'json');
       });
   }
   
     
   function getRow(index){
     	 var rows = jQuery('#q_grid').datagrid('getRows');
     	 return rows[index];
   }
   
   
   
    var allcolumn=["topic","key","relakey","appid","redisurl","splitkey","index","type","middleware","dbinstanceid","dbtb","partitions","copynum","ks","table","colName","addProp","other"];
    function showRuleColumn(showcolumns){           
        for (var item of allcolumn) {
           $('#dg').edatagrid("hideColumn", item);
		   //$('#dg').edatagrid("showColumn", item);
		}
		
		for (var item of showcolumns) {
		   $('#dg').edatagrid("showColumn", item);
		}
	 }
   
偏锋书生's avatar
偏锋书生 已提交
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
   //选择opttype时,设置好初始值,新增/修改/删除
    function selectFilterRule(value){
      var row = jQuery('#dgFilter').datagrid('getSelected');
      var index=jQuery('#dgFilter').datagrid('getRowIndex',row);
      var ed = $('#dgFilter').datagrid('getEditor', {index:index,field:'ruleValue'});
      var edvalue= $(ed.target).val();
      if(value.label=='opttype'){
          $(ed.target).val('insert,update,delete');
      } 
      if(value.label=='sql'){
         if(edvalue==''){
             $(ed.target).val('select 1 from db.parenttable where id=@{joinColName} and filterColname= limit 0,1');
         }
      }
    }
    
偏锋书生's avatar
偏锋书生 已提交
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
   
   function syncRule(){
	   var rules= $('#ruleEdit').val();
       $.post($.rjzjh.packurl('/runing/TaskManager:ruleData'),{'ruleData':rules},function(data){
	         //alert(data);//更新edatagrid
	     $('#dg').edatagrid("loadData", data);
	   },'json');
	}
	
	function  updateRuleInput(index,data,changes){
      	var middlewareIdSel=  $('#middlewareId_save').combobox('getValue');     	
				   //数据检查
      	var dgdata= $('#dg').edatagrid('getData');
                   //提交后端进行格式化
				   //onSave有时会不起作用,故用onBeforeSave
      	var datastr=JSON.stringify(dgdata);	
      	$.post($.rjzjh.packurl('/runing/TaskManager:dataConvert'),{'saveData':datastr},function(data){
	      	$.rjzjh.opt2(data,function(){
	      	if("操作成功"==data.msg){
		      	jQuery('#ruleEdit').val("");
		     }else{
				jQuery('#ruleEdit').val(data.msg);					      
			 }
			 syncRule();//用于切换drds时同步做更新模式
			});
		},'json');		   
	}
	
	
	function selectMiddleware(val){
	    var middlewareType= $.rjzjh.getcombogrid('middlewareId_save','middlewareType');	  
	    // 选择规则
        if('kafka'==middlewareType){
           showRuleColumn(["topic","splitkey"]);
        }else if('mysql'==middlewareType){
           showRuleColumn(["dbtb"]);
        }else if('es' == middlewareType){
            showRuleColumn(["index"]);
        }else if('redis'==middlewareType){
            showRuleColumn(["key","splitkey","appid","redisurl"]);
        }else if('cassandra'==middlewareType){
            showRuleColumn(["ks","table"]);
        }else if('logger'==middlewareType){
           showRuleColumn([]);
        }
	}
	function selectInstance(val){
	    var isDrds= $.rjzjh.getcombogrid('instanceId_save','isDrds');
	    if('yes'==isDrds){
           $('#dg').edatagrid("showColumn", "drds");
        }else{
           $('#dg').edatagrid("hideColumn", "drds");
        }
	}
	
偏锋书生's avatar
偏锋书生 已提交
494 495 496 497 498 499 500 501 502
	function selectDeploy(val){
	    var deployComValue= $.rjzjh.getcombogrid('deployId_save','deploy');
	    if(deployComValue=='host'){
	        $('#versionId_save').combogrid("readonly",true);
	     }else{
	        $('#versionId_save').combogrid("readonly",false);
	     } 
	}
	
偏锋书生's avatar
偏锋书生 已提交
503
	//打开过滤规则配置窗口
偏锋书生's avatar
偏锋书生 已提交
504 505 506 507 508
	function openFilter(){
	   var row=$('#dg').datagrid('getSelected');
	   if(!row){
	     alert('请选择规则!');
	   }else{
偏锋书生's avatar
偏锋书生 已提交
509 510 511
	     $('#filterContext').textbox('setText',row.filter);
	     syncFilterRule();
	     $.rjzjh.opendialog2("inputFilter");
偏锋书生's avatar
偏锋书生 已提交
512 513
	   }
	}
偏锋书生's avatar
偏锋书生 已提交
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
	
	//更新过滤器输入框
	function updateFilterRule(){
	    var filterSaveDatastr= $('#dgFilter').edatagrid('getData');
	    var datastr=JSON.stringify(filterSaveDatastr);
	    var row=$('#dg').datagrid('getSelected');
	    var rules= $('#ruleEdit').val();//规则
		$.post($.rjzjh.packurl('/runing/TaskManager:filterDataConvert'),{'filterSaveData':datastr,'db':row.dbPattern,'tb':row.tbPattern,'rule':rules},function(data){
			$.rjzjh.opt2(data,function(){			    
				if("操作成功"==data.msg){
				    $('#filterContext').textbox('setText',"");
				}else{
					$('#filterContext').textbox('setText',data.filter);
					$('#ruleEdit').val(data.rule);
					syncRule();
				}
			});
		},'json');	
	 }
偏锋书生's avatar
偏锋书生 已提交
533 534

	
偏锋书生's avatar
偏锋书生 已提交
535 536 537 538 539 540 541 542
   function syncFilterRule(){
	      var filterContext= $('#filterContext').textbox('getText');
          $.post($.rjzjh.packurl('/runing/TaskManager:filterRuleData'),{'filterContext':filterContext},function(data){
	         //alert(data);//更新edatagrid
	         $('#dgFilter').edatagrid("loadData", data);
	      },'json');
	}
	
偏锋书生's avatar
偏锋书生 已提交
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
   
  $(function(){
      $('#ruleEdit').blur(function(){
          syncRule();
      });
       $('#dg').edatagrid({
			    data: [
					{db:'value11', tb:'value12'},
					{db:'value21', tb:'value22'}
				],
				destroyMsg: {
					norecord:{	// when no record is selected
						title:'警告',
						msg:'没有选择记录.'
					},
					confirm:{	// when select a row
						title:'确认',
						msg:'您确定要删除此监听规则吗?'
					}
				},
				autoSave: false,
				onDestroy: updateRuleInput,
				onAfterEdit: updateRuleInput
      });
      
      
      $('#viewLogBut').linkbutton('disable');
      $('#viewConfigBut').linkbutton('disable');
偏锋书生's avatar
偏锋书生 已提交
571 572 573 574 575
      $('#editPosBut').menubutton({
		    iconCls: 'icon-edit',
		    menu: '#opsMenu'
	  });
      $('#editPosBut').menubutton('disable');
偏锋书生's avatar
偏锋书生 已提交
576 577 578 579 580
       $('#q_grid').datagrid({
          onSelect: function(rowIndex, row){
            var reg = RegExp(/未布署/);
            var opt=!reg.test(row.taskStatus);
            if(opt){
偏锋书生's avatar
偏锋书生 已提交
581
               $('#viewLogBut').unbind('click');
偏锋书生's avatar
偏锋书生 已提交
582
               $('#viewLogBut').linkbutton('enable').bind('click', viewLog);
偏锋书生's avatar
偏锋书生 已提交
583
               $('#editPosBut').menubutton('disable');
偏锋书生's avatar
偏锋书生 已提交
584 585
            }else{
               $('#viewLogBut').linkbutton('disable').unbind('click',viewLog,false);
偏锋书生's avatar
偏锋书生 已提交
586
               $('#editPosBut').menubutton('enable');
偏锋书生's avatar
偏锋书生 已提交
587
            }
偏锋书生's avatar
偏锋书生 已提交
588
            $('#viewConfigBut').unbind('click');
偏锋书生's avatar
偏锋书生 已提交
589 590 591
            $('#viewConfigBut').linkbutton('enable').bind('click', viewConfig);
          }
       });
偏锋书生's avatar
偏锋书生 已提交
592 593 594 595 596 597
     
     
	  
	 $('#opsSelBut').bind('click', opsSel);
	 $('#opsDelBut').bind('click', opsDel);
	 $('#savePosBut').bind('click', savePos);
偏锋书生's avatar
偏锋书生 已提交
598 599
	 $('#taskdownBut').bind('click', taskdown);
	 
偏锋书生's avatar
偏锋书生 已提交
600 601 602 603
	 
	 
	  
     
偏锋书生's avatar
偏锋书生 已提交
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623
      $('#dgFilter').edatagrid({
			    data: [
				],
				destroyMsg: {
					norecord:{	// when no record is selected
						title:'警告',
						msg:'没有选择记录.'
					},
					confirm:{	// when select a row
						title:'确认',
						msg:'您确定要删除此过滤规则吗?'
					}
				},
				autoSave: false,
				onDestroy: updateFilterRule,
				onAfterEdit: updateFilterRule,
      });
    $('#filterContext').textbox('textbox').blur(function(){
          syncFilterRule();
    });
偏锋书生's avatar
偏锋书生 已提交
624 625 626
    
    jQuery('#q_grid').datagrid('onRowContextMenu',function(){alert(3);});
    
偏锋书生's avatar
偏锋书生 已提交
627 628 629 630 631 632
  });
   
    
</script>
</body>
</html>