Authored by mlge

DOCKER配置功能开发

... ... @@ -390,4 +390,11 @@ public class HttpUriContants {
//redis缓存清理
public static final String REDIS_INFO_LIST_NO_SYNC= "/redisClear/queryNoSyncRedisList";
public static final String REDIS_INFO_CLEAR= "/redisClear/clear";
//Docker信息
public static final String DOCKER_INFO_LIST = "/dockerProject/getDockerInfoList";
public static final String ADDORUPDATE_DOCKER_INFO = "/dockerProject/addOrUpdateDockerInfo";
public static final String GET_DOCERK_INFO_BY_ID = "/dockerProject/getDockerInfoById";
public static final String DEL_DOCKER_INFO_BYID = "/dockerProject/delDockerInfoById";
}
\ No newline at end of file
... ...
package com.ui.model.req;
import lombok.Data;
import java.util.List;
/**
* Created by yoho on 2016/6/14.
*/
@Data
public class DockerInfoReq extends PageRequest {
private int id;
private String projectName;//项目名称
private String dockerProjectName;//docker项目名称
private String projectJobType;//项目job类型
}
... ...
... ... @@ -9,6 +9,7 @@ import com.ui.model.domain.DockerProjectModel;
import com.ui.model.req.BuildRequest;
import com.ui.model.req.DockerJenkinsReq;
import com.ui.model.req.User;
import com.ui.model.req.*;
import com.ui.project.ProjectEnvironment;
import com.ui.project.ProjectOnline;
import org.apache.commons.lang.StringUtils;
... ... @@ -121,4 +122,53 @@ public class DockerBuildCtrl {
public BaseResponse queryDockerServerStatus(DockerJenkinsReq dockerJenkinsReq) {
return httpRestClient.defaultPost("/dockerProject/queryDockerServerStatus",dockerJenkinsReq,BaseResponse.class);
}
@RequestMapping(value = "/toDockerInfoList")
public ModelAndView toDockerInfoList(DockerJenkinsReq dockerJenkinsReq) {
return new ModelAndView("project/docker_info");
}
/**
* docker信息列表
* @param req
* @return
* @throws Exception
*/
@RequestMapping("/getDockerInfoList")
@ResponseBody
public BaseResponse getHostInfos(DockerInfoReq req) throws Exception {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.DOCKER_INFO_LIST, req, BaseResponse.class);
return response;
}
@RequestMapping("/toEditDockerInfo")
public ModelAndView toEditDockerInfos(Map model) {
return new ModelAndView("project/editDockerInfo",model);
}
@RequestMapping("/saveDockerInfo")
@ResponseBody
public BaseResponse saveDockerInfo(@RequestBody DockerProjectModel req) throws Exception {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.ADDORUPDATE_DOCKER_INFO, req, BaseResponse.class);
return response;
}
@RequestMapping("/getDockerInfoById")
@ResponseBody
public BaseResponse getDockerInfoById(int id) throws Exception {
BaseResponse response = httpRestClient.defaultGet(HttpUriContants.GET_DOCERK_INFO_BY_ID + "?id=" + id, BaseResponse.class);
return response;
}
@RequestMapping("/delDockerInfoById")
@ResponseBody
public BaseResponse<Integer> delDockerInfoById(int id) throws Exception {
BaseResponse response = httpRestClient.defaultGet(HttpUriContants.DEL_DOCKER_INFO_BYID + "?id=" + id, BaseResponse.class);
return response;
}
}
... ...
<%@page language="java" contentType="text/html;charset=utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap-datetimepicker.css"/>
<link href="<%=basePath %>js/bootstrap-plugin/css/bootstrap.table.css" rel="stylesheet" media="screen"/>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/fullcalendar.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css"/>
<link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css"/>
<link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
<%--<link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
<link rel="stylesheet" href="<%=basePath %>js/select2/dist/css/select2.css"/>--%>
<link rel="stylesheet" href="<%=basePath %>css/select2-4.0.3.css"/>
<link rel="stylesheet" href="<%=basePath %>js/jstree/themes/proton/style.css"/>
<link rel="stylesheet" href="<%=basePath %>css/yoho.css"/>
<script src="<%=basePath %>js/excanvas.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-ui.custom.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>/js/bootstrap.min.js"></script>
<script src="<%=basePath %>/js/unicorn.js"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/moment-with-locales.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/global.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.pagination.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.alerts.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/layer/layer.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.select.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jstree/jstree.min.js"></script>
<script src="<%=basePath %>js/jquery.toaster.js"></script>
<script src="<%=basePath%>js/select2-4.0.3.min.js"></script>
<%--&lt;%&ndash;<script src="<%=basePath%>js/select2.min.js"></script>&ndash;%&gt;
<script src="<%=basePath %>js/select2/dist/js/select2.full.js"></script>--%>
<script>
var contextPath = '<%=basePath %>';
</script>
<title>YOHO!运维</title>
</head>
<body>
<!-- 头部 -->
<div id="head">
</div>
<!-- 右侧具体内容 -->
<div id="content">
<div id="breadcrumb">
<a href="#" title="Go to Home" class="tip-bottom"><i
class="icon-home"></i> Home</a> <a href="#" class="current">DOCKER配置</a>
</div>
<div class="container-fluid">
<div class="widget-box">
<div class="widget-title">
<h5>Docker信息查询</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-title" style="height: 106px;">
<div>
<div class="form-inline" role="form"
style=" margin-top: 12px;margin-left: 25px;float: left;">
<div class="input-group" style="float: left;">
<span class="input-group-addon">项目名称:</span>
<input type="text" id="projectName_search" name="projectName_search" class="form-control" placeholder="" style="width: 180px"/>
</div>
<div class="input-group" style="float: left;">
<span class="input-group-addon">Docker项目名称:</span>
<input type="text" id="dockerProjectName_search" name="dockerProjectName_search" class="form-control" placeholder="" style="width: 180px"/>
</div>
<div class="input-group" style="float: left;">
<span class="input-group-addon">项目job类型:</span>
<select id="projectJobType_search" class="form-control">
<option value="" selected="selected">所有类型</option>
<option value="Docker-Deploy-Node">Docker-Deploy-Node</option>
<option value="Docker-Deploy-Java">Docker-Deploy-Java</option>
</select>
</div>
<button id="searchDockerInfoBtn" class="btn btn-primary" style="margin-left: 18px;">搜索</button>
<button id="addDockerBtn" class="btn btn-success" style="margin-left: 18px;">新增</button>
</div>
</div>
</div>
</div>
<div id="dockerInfoTable">
</div>
</div>
</div>
</div>
</div>
</body>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script>
$("#li_config").addClass("active open");
$("#li_docker_project_info").addClass("active");
</script>
<script>
$(function () {
//加载表格
$("#dockerInfoTable").table({
columnAutoWidth : false,
url : "getDockerInfoList",
striped : true,
title : "Docker信息列表",
dataType : "json",
pagination : true,
pageSize : 50,
loadFilter : function(data) {
return defaultLoadFilter(data);
},
columns : [
{
title : " 序号 " ,
width : "3%",
formatter : function(value, rowData, rowIndex) {
return rowIndex + 1;
}
},{
title : "项目名称",
field : "projectName",
width : "12%"
}, {
title : "项目git所属组",
field : "projectGitGroup",
width : "10%"
}, {
title : "项目job类型",
field : "projectJobType",
width : "5%"
}, {
title : "docker项目名称",
field : "dockerProjectName",
width : "12%"
},{
title : "操作",
field : "op",
formatter : function(value, rowData, rowIndex) {
var div = $("<div>");
var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("修改").appendTo(div);
editBtn.click(function() {
editDockerInfo(rowData.id);
});
div.append("&nbsp;");
var delBtn = $("<button>").addClass("btn btn-xs btn-danger").html("删除").appendTo(div);
delBtn.click(function() {
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title : "删除",
backdrop : "static",
content : "你确定要删除吗?",
buttons : [{
text : "否",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}, {
text : "是",
className : "btn-success",
onclick : function() {
$(dialog).dialog("hide");
$.ajax({
url : "delDockerInfoById.do",
type : 'post',
async : false,
data : {
id : rowData.id
},
dataType : "json",
success : function(data) {
if (!data || data.code != 200) {
localAlert('删除失败',data.message);
}
$("#dockerInfoTable").table("load");
},
error: function (data) {
localAlert('系统异常',data.message);
}
});
}
}]
});
});
return div;
},
width : "8%"
}]
});
$("#addDockerBtn").click(function() {
editDockerInfo(0);
});
});
//点击查询按钮
$("#searchDockerInfoBtn").click(function () {
var projectName = $("#projectName_search").val();
var dockerProjectName = $("#dockerProjectName_search").val();
var projectJobType = $("#projectJobType_search").val();
$("#dockerInfoTable").table("load", {
'projectName': projectName,
'dockerProjectName':dockerProjectName,
'projectJobType':projectJobType
});
});
//打开新增或修改页面
function editDockerInfo(dockerInfoId) {
paramObj.dockerInfoId = dockerInfoId;
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
size : "modal-lg",
title : (dockerInfoId == 0 ? "新增" : "修改") + "Docker项目信息",
backdrop : "static",
href : "toEditDockerInfo",
buttons : [{
text : "关闭",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}, {
text : "提交",
className : "btn-success",
onclick : function() {
//check信息
var btn = $(this);
this.prop("disabled", "disabled");
var projectName=$("#dockerInfoForm #projectName").val();
var projectGitGroup=$("#dockerInfoForm #projectGitGroup").val();
var projectJobType=$("#dockerInfoForm #projectJobType").val();
var dockerProjectName=$("#dockerInfoForm #dockerProjectName").val();
var dockerGrayClusterId=$("#dockerInfoForm #dockerGrayClusterId").val();
var dockerGrayNameSpace=$("#dockerInfoForm #dockerGrayNameSpace").val();
var dockerGrayImageStore=$("#dockerInfoForm #dockerGrayImageStore").val();
var dockerOnlineClusterId=$("#dockerInfoForm #dockerOnlineClusterId").val();
var dockerOnlineNameSpace=$("#dockerInfoForm #dockerOnlineNameSpace").val();
var dockerOnlineImageStore=$("#dockerInfoForm #dockerOnlineImageStore").val();
var port=$("#dockerInfoForm #port").val();
if(projectName == null || projectName == ""){
$("#dockerInfoForm #messageAlert").alerts({
content : "请输入项目名称!",
type : "danger"
});
btn.removeAttr("disabled");
return;
}
if(projectGitGroup == null || projectGitGroup == ""){
$("#dockerInfoForm #messageAlert").alerts({
content : "请输入项目git所属组!",
type : "danger"
});
btn.removeAttr("disabled");
return;
}
if(dockerProjectName == null || dockerProjectName == ""){
$("#dockerInfoForm #messageAlert").alerts({
content : "请输入docker项目名称!",
type : "danger"
});
btn.removeAttr("disabled");
return;
}
if(dockerProjectName == null || dockerProjectName == ""){
$("#dockerInfoForm #messageAlert").alerts({
content : "请输入docker项目名称!",
type : "danger"
});
btn.removeAttr("disabled");
return;
}
if(dockerGrayClusterId == null || dockerGrayClusterId == ""){
$("#dockerInfoForm #messageAlert").alerts({
content : "请输入dockerGrayClusterId!",
type : "danger"
});
btn.removeAttr("disabled");
return;
}
if(dockerGrayNameSpace == null || dockerGrayNameSpace == ""){
$("#dockerInfoForm #messageAlert").alerts({
content : "请输入 dockerGrayNameSpace!",
type : "danger"
});
btn.removeAttr("disabled");
return;
}
if(dockerGrayImageStore == null || dockerGrayImageStore == ""){
$("#dockerInfoForm #messageAlert").alerts({
content : "请输入 dockerGrayImageStore!",
type : "danger"
});
btn.removeAttr("disabled");
return;
}
if(dockerOnlineClusterId == null || dockerOnlineClusterId == ""){
$("#dockerInfoForm #messageAlert").alerts({
content : "请输入 dockerOnlineClusterId!",
type : "danger"
});
btn.removeAttr("disabled");
return;
}
if(dockerOnlineNameSpace == null || dockerOnlineNameSpace == ""){
$("#dockerInfoForm #messageAlert").alerts({
content : "请输入 dockerOnlineNameSpace!",
type : "danger"
});
btn.removeAttr("disabled");
return;
}
if(dockerOnlineImageStore == null || dockerOnlineImageStore == ""){
$("#dockerInfoForm #messageAlert").alerts({
content : "请输入 dockerOnlineImageStore!",
type : "danger"
});
btn.removeAttr("disabled");
return;
}
if(port == null || port == ""){
$("#dockerInfoForm #messageAlert").alerts({
content : "请输入 port!",
type : "danger"
});
btn.removeAttr("disabled");
return;
}
var param ={
id: dockerInfoId,
projectName:projectName,
projectGitGroup:projectGitGroup,
projectJobType:projectJobType,
dockerProjectName:dockerProjectName,
dockerGrayClusterId:dockerGrayClusterId,
dockerGrayNameSpace:dockerGrayNameSpace,
dockerGrayImageStore:dockerGrayImageStore,
dockerOnlineClusterId:dockerOnlineClusterId,
dockerOnlineNameSpace:dockerOnlineNameSpace,
dockerOnlineImageStore:dockerOnlineImageStore,
port:port
}
$.ajax({
url: contextPath + 'dockerBuild/saveDockerInfo',
type: 'POST',
dataType: 'json',
contentType: "application/json",
data: JSON.stringify(param),
async:false,
success: function (data) {
if (!data || data.code != 200) {
$("#dockerInfoForm #messageAlert").alerts({
content: data.message,
type: "danger"
});
return;
} else {
$("#dockerInfoTable").table("load");
$(dialog).dialog("hide");
}
},
error: function (data) {
localAlert('系统异常', data.message);
}
});
/* $("#dockerInfoForm").form("submit", {
submitUrl : "saveDockerInfo.do",
submitData : {
id: dockerInfoId,
projectName:projectName,
projectGitGroup:projectGitGroup,
projectJobType:projectJobType,
dockerProjectName:dockerProjectName,
dockerGrayClusterId:dockerGrayClusterId,
dockerGrayNameSpace:dockerGrayNameSpace,
dockerGrayImageStore:dockerGrayImageStore,
dockerOnlineClusterId:dockerOnlineClusterId,
dockerOnlineNameSpace:dockerOnlineNameSpace,
dockerOnlineImageStore:dockerOnlineImageStore
},
onBeforeSubmit : function() {
if (!$(this).form("validate")) {
btn.removeAttr("disabled");
return false;
}
},
success : function(data) {
if (!data || data.code != 200) {
btn.removeAttr("disabled");
$("#dockerInfoForm #messageAlert").alerts({
content : data.message,
type : "danger"
});
return;
}
$("#dockerInfoTable").table("load");
$(dialog).dialog("hide");
}
});*/
}
}]
});
}
</script>
... ...
<%@page language="java" contentType="text/html;charset=utf-8" %>
<form class="form-horizontal" id="dockerInfoForm" name="dockerInfoForm">
<div class="form-group" >
<label class="col-sm-2 control-label" style="width:280px"> <span style="color:red">*</span>项目名称:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="projectName" name="projectName" size="40" />
</div>
</div>
<div class="form-group" >
<label class="col-sm-2 control-label" style="width:280px"> <span style="color:red">*</span>项目git所属组:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="projectGitGroup" name="projectGitGroup" size="40" />
</div>
</div>
<div class="form-group" >
<label class="col-sm-2 control-label" style="width:280px"> <span style="color:red">*</span>项目job类型:</label>
<div class="col-sm-8">
<select id="projectJobType" name="projectJobType" class="form-control" style = "width:450px;" >
<option value="Docker-Deploy-Node">Docker-Deploy-Node</option>
<option value="Docker-Deploy-Java">Docker-Deploy-Java</option>
</select>
</div>
</div>
<div class="form-group" >
<label class="col-sm-2 control-label" style="width:280px"> <span style="color:red">*</span>docker项目名称:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="dockerProjectName" name="dockerProjectName" size="40" />
</div>
</div>
<div class="form-group" >
<label class="col-sm-2 control-label" style="width:280px"> <span style="color:red">*</span>dockerGrayClusterId:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="dockerGrayClusterId" name="dockerGrayClusterId" size="40" />
</div>
</div>
<div class="form-group" >
<label class="col-sm-2 control-label" style="width:280px"> <span style="color:red">*</span>dockerGrayNameSpace:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="dockerGrayNameSpace" name="dockerGrayNameSpace" size="40" />
</div>
</div>
<div class="form-group" >
<label class="col-sm-2 control-label" style="width:280px"> <span style="color:red">*</span>dockerGrayImageStore:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="dockerGrayImageStore" name="dockerGrayImageStore" size="40" />
</div>
</div>
<div class="form-group" >
<label class="col-sm-2 control-label" style="width:280px"> <span style="color:red">*</span>dockerOnlineClusterId:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="dockerOnlineClusterId" name="dockerOnlineClusterId" size="40" />
</div>
</div>
<div class="form-group" >
<label class="col-sm-2 control-label" style="width:280px"> <span style="color:red">*</span>dockerOnlineNameSpace:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="dockerOnlineNameSpace" name="dockerOnlineNameSpace" size="40" />
</div>
</div>
<div class="form-group" >
<label class="col-sm-2 control-label"style="width:280px"> <span style="color:red">*</span>dockerOnlineImageStore:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="dockerOnlineImageStore" name="dockerOnlineImageStore" size="40" />
</div>
</div>
<div class="form-group" >
<label class="col-sm-2 control-label" style="width:280px"> <span style="color:red">*</span>port:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="port" name="port" size="40" />
</div>
</div>
<div class="form-group" >
<label class="col-sm-2 control-label"></label>
<div class="col-sm-8" id="messageAlert"></div>
</div>
</form>
<script>
$(function(){
$("#dockerInfoForm").form({
loadUrl : "getDockerInfoById.do",
loadParams : {
id : paramObj.dockerInfoId
},
loadFilter : function(data) {
return defaultLoadFilter(data);
},
onBeforeLoad : function(loadParams) {
if (loadParams.dockerInfoId == 0) {
return false;
}
},
onLoadSuccess : function(data) {
}
});
})
</script>
\ No newline at end of file
... ...
... ... @@ -79,6 +79,7 @@ innerHTML += "<li id='li_cache_info'><a id='li_cache_info_a' href=''><i class='i
/*innerHTML += "<li id='li_aws_ebs'><a id='li_aws_ebs_a' href=''><i class='icon icon-th'></i> <span>AWS_EBS镜像任务</span></a></li>";*/
// innerHTML += "<li id='li_ips_compare'><a id='li_ips_compare_a' href=''><i class='icon icon-th'></i> <span>在线服务Ip配置对比</span></a></li>";
innerHTML += "<li id='li_ips_compare_new'><a id='li_ips_compare_new_a' href=''><i class='icon icon-th'></i> <span>在线服务Ip配置对比</span></a></li>";
innerHTML += "<li id='li_docker_project_info'><a id='li_docker_project_info_a' href=''><i class='icon icon-th'></i> <span>DOCKER配置</span></a></li>";
innerHTML += "</ul></li>";
/*project*/
... ... @@ -214,6 +215,8 @@ document.getElementById("li_malicious_ips_record_a").setAttribute("href", path +
document.getElementById("li_malicious_ips_record_forbid_a").setAttribute("href", path + "/maliciousIp/toMaliciousIpRecordForbidList");
//document.getElementById("li_malicious_ips_bl_a").setAttribute("href", path + "/maliciousIp/toMaliciousIpsBL");
//document.getElementById("li_malicious_ips_cs_a").setAttribute("href", path + "/maliciousIp/toMaliciousIpsCS");
document.getElementById("li_docker_project_info_a").setAttribute("href", path + "/dockerBuild/toDockerInfoList");
//document.getElementById("li_limitswitch_a").setAttribute("href", path + "/limitSwitch/toLimitSwitch");
//document.getElementById("li_lbswitch_a").setAttribute("href", path + "/lbSwitch/toLbSwitch");
... ...