DeployManager.tml 11.5 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="4">发布管理</title>
偏锋书生's avatar
偏锋书生 已提交
7 8 9 10 11 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
</head>
<body>
   <r:query id="q"  qBlock="query" queryUrl="/setting/DeployManager:query"  uBlock="save"   saveUrl="/setting/DeployManager:save" deleteUrl="/setting/DeployManager:del" opFormatter="showopt" 
        columns="[[{field:'name',width:200,title:'发布名'},{field:'deploy',width:100,title:'发布类型'},{field:'env',width:100,title:'环境'},{field:'isInit2',width:70,title:'是否初始化'},{field:'version1',width:70,title:'版本'},{field:'namespace',width:150,title:'名称空间'},{field:'host',width:120,title:'主机'},{field:'op',width:320,title:'操作'}]]" 
        dialogStyle="width:800px;height:460px;" initAddHandle="initAdd" initSaveHandle="initUpdate" saveCheckHandle="saveCheck"  pagination="true"/>
   <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">1、k8s需要上传config文件 </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>
偏锋书生's avatar
偏锋书生 已提交
37
			            <r:comboboxenum id="deploy_save"  name="deploy" enumClass="net.wicp.tams.app.duckula.controller.config.constant.DeployType" required="true" changeHandle="selDeploy"></r:comboboxenum>
偏锋书生's avatar
偏锋书生 已提交
38 39 40 41 42 43 44 45 46 47 48 49 50
			          </td>
			      </tr>
			      <tr>			      
			         <td class="frame_table_list_2_righttext">环境</td>
			         <td>
			            <r:validatebox name="env" style="width:250px;" required="true"/>
			            
	                 </td>			        
			 	  	 <td class="frame_table_list_2_righttext">备注</td>
			 	     <td>
			 	        <r:validatebox name="remark" style="width:250px;" required="false"/>
			 	     </td>			 	     
			      </tr>
偏锋书生's avatar
偏锋书生 已提交
51 52
			      <tr>			      
			         <td class="frame_table_list_2_righttext">名称空间</td>
偏锋书生's avatar
偏锋书生 已提交
53
			         <td>
偏锋书生's avatar
偏锋书生 已提交
54
			            <r:validatebox id="namespace_save" name="namespace" style="width:250px;" required="false"/>
偏锋书生's avatar
偏锋书生 已提交
55 56 57 58 59 60 61 62 63 64
	                 </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>
偏锋书生's avatar
偏锋书生 已提交
65
			            <r:validatebox  id="host_save" name="host" style="width:250px;" required="false"/>
偏锋书生's avatar
偏锋书生 已提交
66 67 68
	                 </td>			        
			 	  	 <td class="frame_table_list_2_righttext">端口</td>
			 	     <td>
偏锋书生's avatar
偏锋书生 已提交
69
			 	        <r:numberbox id="port_save" name="port" style="width:250px;"  required="false"/>
偏锋书生's avatar
偏锋书生 已提交
70 71 72 73 74 75 76 77 78
			 	     </td>			 	     
			      </tr>
			      <tr>			      
			         <td class="frame_table_list_2_righttext">duckula密码</td>
			         <td>
			            <r:validatebox id="pwdDuckula_save" name="pwdDuckula" style="width:250px;" required="false" readonly="false"/>
	                 </td>			        
			 	  	 <td class="frame_table_list_2_righttext">是否初始化</td>
			 	     <td>
偏锋书生's avatar
偏锋书生 已提交
79
			 	        <r:comboboxenum  id="isInit_save" name="isInit" enumClass="net.wicp.tams.common.constant.dic.YesOrNo" required="false" readonly="true"></r:comboboxenum>
偏锋书生's avatar
偏锋书生 已提交
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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
			 	     </td>			 	     
			      </tr>
			      
	 </table>
   </t:block>

   <r:dialog id="uploadFile" width="440" height="300" title="上传k8s配置文件" toolbar="[{id:'uploadDo',text:'上传',iconCls:'icon-save'}]">
         <form id="cfm" method="post"  enctype="multipart/form-data" action="${contextPath}/setting/DeployManager:saveFile">
 	   		<table class="frame_table_list_2">
               <tr>
 	   		 		<td class="frame_table_list_2_righttext">配置文件</td>
 	   		 		<td><span><r:upload id="upFile" multi="false"></r:upload></span></td>
 	   		 	</tr>		
                <tr>
         			<td  colspan="2" align="left">   
	         			<font color="red">
					       <div align="left">选择用户目录 ~/.kube/config文件 </div>
					   </font>
				      <input type="hidden" id="uploadId" name="id"/></td>
         		</tr>
         		
 	   		 </table>
 	   	</form>
 	</r:dialog>
  
   
<script>	
    function showopt(value,row,index){
            var optCan=false;//row.taskNum=='0'?false:true;
            var isK8s=row.deploy=='k8s'?true:false;
            var initNot=row.isInit=='yes'?true:false;
       	    var update= '<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit"  data-options="disabled:'+optCan+'"  style="margin-right:10px" onclick="_doUpdate('+index+') ">'+msg.update+'</a>';
       	    var deletebut= '<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" data-options="disabled:'+optCan+'" style="margin-right:10px" onclick="_doDelete('+index+') ">'+msg.delete_+'</a>'; 
       	    var initbut='<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-role" data-options="disabled:false" style="margin-right:10px" onclick="initServer(\''+index+'\') ">初始化</a>';
       	    var upbut='<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" data-options="disabled:false" style="margin-right:10px" onclick="upServer(\''+index+'\') ">版本升级</a>';
       	    var uploadK8sConf='<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-redo" data-options="disabled:false" style="margin-right:10px" onclick="uploadK8sConf(\''+index+'\') ">上传k8s配置</a>';
       	    if(isK8s){
       	        return update+deletebut+uploadK8sConf;
       	    }else if(initNot){
       	       return update+deletebut+upbut;
       	    }else{
       	       return update+deletebut+initbut;
       	    }	
     }

偏锋书生's avatar
偏锋书生 已提交
125 126 127 128 129

  function selDeploy(val){	   
	   var initValue= $('#isInit_save').combogrid('getValue');
	   var row={'deploy':val,'isInit':initValue};
	   initUpdate(row);
偏锋书生's avatar
偏锋书生 已提交
130 131
	}

偏锋书生's avatar
偏锋书生 已提交
132 133 134
   function initAdd(row){
      //$('#os_save').combobox('setValue','Linux');
      $('#pwdDuckula_save').validatebox("readonly",false);
偏锋书生's avatar
偏锋书生 已提交
135
      $('#port_save').numberbox('setValue',22);
偏锋书生's avatar
偏锋书生 已提交
136
   }
偏锋书生's avatar
偏锋书生 已提交
137
   function initUpdate(row){  
偏锋书生's avatar
偏锋书生 已提交
138 139 140 141 142 143
      //如果是host或docker需要可以设置duckula密码
     var deploy=or(row.deploy=='host',row.deploy=='docker');
     if(and(deploy,!(row.isInit=='yes'))){
        $('#pwdDuckula_save').validatebox("readonly",false);
     }else{
        $('#pwdDuckula_save').validatebox("readonly",true);
偏锋书生's avatar
偏锋书生 已提交
144
        $('#pwdDuckula_save').val("");
偏锋书生's avatar
偏锋书生 已提交
145
     }
偏锋书生's avatar
偏锋书生 已提交
146 147 148 149 150 151
     if('host'==row.deploy){//只有host需要选择版本,其它的由任务版本决定
	      $('#versionId_save').combogrid('enable');	      
	 }else{
	      $('#versionId_save').combogrid('disable');
	      $('#versionId_save').combogrid('setValue','');
	  }
偏锋书生's avatar
偏锋书生 已提交
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
   }

   
   function initServer(index){
       var row=getRow(index);
       $.rjzjh.prompt('请输入此服务器的root密码?',function(pwd){
           pwd=pwd.replace(/^\s+|\s+$/g,"");
           if(gt(pwd.length,0)){
               row.pwd=pwd;
               $.messager.progress({
			    	title:window.msg.hintwaiting,
			    	msg:window.msg.hinthandling
	            }); 
               $.post($.rjzjh.packurl('/setting/DeployManager:initServer'),row,function(data){
                 $.messager.progress('close');
	             $.rjzjh.opt2(data,function(){
	                $.rjzjh.alert("初始化成功");
				    jQuery('#q_grid').datagrid('reload');
		         }); 
		       },'json');
           }
		});
   }
   
   function upServer(index){
       var row=getRow(index);
       $.rjzjh.prompt('你要更新哪个版本?',function(versionNew){
           versionNew=versionNew.replace(/^\s+|\s+$/g,"");
           if(gt(versionNew.length,0)){
               row.versionNew=versionNew;
               $.messager.progress({
			    	title:window.msg.hintwaiting,
			    	msg:window.msg.hinthandling
	            }); 
               $.post($.rjzjh.packurl('/setting/DeployManager:upServer'),row,function(data){
                 $.messager.progress('close');
	             $.rjzjh.opt2(data,function(){
	                $.rjzjh.alert("版本升级成功");
				    jQuery('#q_grid').datagrid('reload');
		         }); 
		       },'json');
           }
		});
   }
   function uploadK8sConf(index){
        var row=getRow(index);
         $('#uploadId').val(row.id);
         $.rjzjh.opendialog2("uploadFile");
   }   
   
   
   
   function saveCheck(){
      var pwdDuckula=$('#pwdDuckula_save').val();
      var deploySave=  $('#deploy_save').combobox('getValue'); 
      //host或docker必须要填写duckula用的密码
偏锋书生's avatar
偏锋书生 已提交
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
      if(or(deploySave=='host',deploySave=='docker')){
	      if(pwdDuckula==''){
	        $.rjzjh.alert('你需要填写duckula密码!');
	        return false;
	      }
	       var versionIdSave=  $('#versionId_save').combobox('getValue'); 
	      if(versionIdSave==''){
	         $.rjzjh.alert('你需要选择版本!');
	        return false;
	      }
	      var hostSave=$('#host_save').val();
	      if(hostSave==''){
	         $.rjzjh.alert('你需要填写主机!');
	        return false;
	      }
	      var portSave=$('#port_save').numberbox('getValue');
	       if(portSave==''){
	         $.rjzjh.alert('你需要填写端口!');
	        return false;
	      }
偏锋书生's avatar
偏锋书生 已提交
228
      }
偏锋书生's avatar
偏锋书生 已提交
229 230 231 232
      
      
      
      
偏锋书生's avatar
偏锋书生 已提交
233 234 235 236 237
     var namespace=$('#namespace_save').val();
     if(and(deploySave=='k8s',namespace=='')){
        $.rjzjh.alert('k8s需要配置名称空间!');
        return false;
      }
偏锋书生's avatar
偏锋书生 已提交
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 278 279 280 281
      return true;
   }

     
   function getRow(index){
     	 var rows = jQuery('#q_grid').datagrid('getRows');
     	 return rows[index];
   }
   


    function checkForm(){
	        	var retValue=true;
		        var uploadId=jQuery('#uploadId').val();
		        if(uploadId==''){
		           $.rjzjh.alert('需要id');
		           return false;
		        }
				jQuery("input[filetag='rjzjhuploadfield']").each(function(i,n){
				            if(n.value==''){
				              retValue=false;
				              $.rjzjh.alert('上传文件不能为空');
				              return;
				            }
				            //if(!n.value.endWith('.tar')){
				            //   retValue=false;
				           //    $.rjzjh.alert('需要选择tar包上传');
				            //  return;
				           // }
				 });
				return retValue;
	 }
	 
  $(function(){      
       jQuery('#uploadDo').click(function(){
			   	if(checkForm()){
			   	   document.getElementById('cfm').submit();
			   	}		   
		});
   });  
    
</script>
</body>
</html>