openvpn页面调整;后台默认时间设置

This commit is contained in:
zhanghongqing
2018-06-13 13:51:21 +08:00
parent b3ac02c277
commit 84b36b08e3
4 changed files with 158 additions and 106 deletions

View File

@@ -35,6 +35,18 @@ public class BaseLogEntity<T> extends BaseEntity<T> {
protected String searchFoundEndTime;//结束时间,格式同上 protected String searchFoundEndTime;//结束时间,格式同上
public String getFoundTime() {
return foundTime;
}
public void setFoundTime(String foundTime) {
this.foundTime = foundTime;
}
public String getRecvTime() {
return recvTime;
}
public void setRecvTime(String recvTime) {
this.recvTime = recvTime;
}
public String getSearchFoundStartTime() { public String getSearchFoundStartTime() {
return searchFoundStartTime; return searchFoundStartTime;
} }
@@ -59,20 +71,6 @@ public class BaseLogEntity<T> extends BaseEntity<T> {
public void setCfgId(Integer cfgId) { public void setCfgId(Integer cfgId) {
this.cfgId = cfgId; this.cfgId = cfgId;
} }
public String getFoundTime() {
Date date = new Date(Long.parseLong(this.foundTime));
return DateUtils.formatDateTime(date);
}
public void setFoundTime(String foundTime) {
this.foundTime = foundTime;
}
public String getRecvTime() {
Date date = new Date(Long.parseLong(this.recvTime));
return DateUtils.formatDateTime(date);
}
public void setRecvTime(String recvTime) {
this.recvTime = recvTime;
}
public String getProtocol() { public String getProtocol() {
return protocol; return protocol;
} }
@@ -157,6 +155,16 @@ public class BaseLogEntity<T> extends BaseEntity<T> {
public void setUserRegion(String userRegion) { public void setUserRegion(String userRegion) {
this.userRegion = userRegion; this.userRegion = userRegion;
} }
@Override
public String toString() {
return "BaseLogEntity [cfgId=" + cfgId + ", foundTime=" + foundTime + ", recvTime=" + recvTime + ", protocol="
+ protocol + ", addrType=" + addrType + ", serverIp=" + serverIp + ", clientIp=" + clientIp
+ ", serverPort=" + serverPort + ", clientPort=" + clientPort + ", serviceType=" + serviceType
+ ", entranceId=" + entranceId + ", deviceId=" + deviceId + ", direction=" + direction + ", streamType="
+ streamType + ", cljIp=" + cljIp + ", nestAddrList=" + nestAddrList + ", userRegion=" + userRegion
+ ", seltype=" + seltype + ", searchFoundStartTime=" + searchFoundStartTime + ", searchFoundEndTime="
+ searchFoundEndTime + "]";
}

View File

@@ -2,6 +2,7 @@ package com.nis.web.controller.log.ntc;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -22,6 +23,9 @@ import com.google.gson.reflect.TypeToken;
import com.nis.domain.Page; import com.nis.domain.Page;
import com.nis.domain.log.NtcOpenVpnLog; import com.nis.domain.log.NtcOpenVpnLog;
import com.nis.domain.maat.LogRecvData; import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.StringUtils;
import com.nis.util.httpclient.HttpClientUtil; import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController; import com.nis.web.controller.BaseController;
@@ -29,19 +33,66 @@ import com.nis.web.controller.BaseController;
@RequestMapping(value = "${adminPath}/log/ntc/ntcOpenvpnLogs") @RequestMapping(value = "${adminPath}/log/ntc/ntcOpenvpnLogs")
public class OpenVpnController extends BaseController{ public class OpenVpnController extends BaseController{
/**
* @param model
* @param entry
* @param request
* @param response
* @return
* @throws ClientProtocolException
* @throws IOException
*/
@RequestMapping(value={"list",""}) @RequestMapping(value={"list",""})
public String list(Model model,@ModelAttribute("log")NtcOpenVpnLog testEntry,HttpServletRequest request, HttpServletResponse response) throws ClientProtocolException, IOException { public String list(Model model,@ModelAttribute("log")NtcOpenVpnLog entry,HttpServletRequest request, HttpServletResponse response) throws ClientProtocolException, IOException {
try {
Page<NtcOpenVpnLog> page = new Page<NtcOpenVpnLog>(request, response); Page<NtcOpenVpnLog> page = new Page<NtcOpenVpnLog>(request, response);
int pageSize = page.getPageSize();
int pageNo = page.getPageNo();
Map<String, Object> params=new HashMap<>(); Map<String, Object> params=new HashMap<>();
// String jsonString = HttpClientUtil.getMsg("http://localhost:8080/gwall/view/logs/test",params); params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
if (StringUtils.isNotBlank(entry.getSearchFoundStartTime())&&StringUtils.isNotBlank(entry.getSearchFoundEndTime())) {
params.put("searchFoundStartTime", entry.getSearchFoundStartTime());
params.put("searchFoundEndTime", entry.getSearchFoundEndTime());
}else{
//设置默认查询当前时间及前五分钟
String startTime = DateUtils.getDateTime();
Date dateEnd = new Date(new Date().getTime()-Constants.LOG_TIME_RANGE);
String endTime = DateUtils.formatDateTime(dateEnd);
params.put("searchFoundStartTime", startTime);
params.put("searchFoundEndTime",endTime );
entry.setSearchFoundStartTime(startTime);
entry.setSearchFoundEndTime(endTime);
}
if (StringUtils.isNotBlank(entry.getProtocol())) {
params.put("searchProtocol", entry.getProtocol());
}
if (entry.getServiceType()!=null) {
params.put("searchServiceType", entry.getServiceType());
}
if (StringUtils.isNotBlank(entry.getServerIp())) {
params.put("searchServerIp", entry.getServerIp());
}
if (StringUtils.isNotBlank(entry.getClientIp())) {
params.put("searchClientIp", entry.getClientIp());
}
if (StringUtils.isNotBlank(entry.getCljIp())) {
params.put("searchCljIp", entry.getCljIp());
}
if (entry.getDirection()!=null) {
params.put("searchDirection", entry.getDirection());
}
if (entry.getEntranceId()!=null) {
params.put("searchEntranceId", entry.getEntranceId());
}
String url = "";
url = Constants.LOG_BASE_URL+Constants.NTC_OPENVPN_LOG;
String jsonString = HttpClientUtil.getMsg(url,params);
String readAsString = FileUtil.readAsString(new File("D:/FeigeDownload/logTest.txt"));
Gson gson = new GsonBuilder().create(); Gson gson = new GsonBuilder().create();
//gson泛型支持 //gson泛型支持
LogRecvData<NtcOpenVpnLog> fromJson = gson.fromJson(readAsString, new TypeToken<LogRecvData<NtcOpenVpnLog>>(){}.getType()); LogRecvData<NtcOpenVpnLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcOpenVpnLog>>(){}.getType());
Page<NtcOpenVpnLog> data = fromJson.getData(); Page<NtcOpenVpnLog> data = fromJson.getData();
List<NtcOpenVpnLog> list = data.getList(); List<NtcOpenVpnLog> list = data.getList();
@@ -49,23 +100,11 @@ public class OpenVpnController extends BaseController{
page.setCount(data.getCount()); page.setCount(data.getCount());
model.addAttribute("page", page); model.addAttribute("page", page);
logger.info("查询OpenVpn日志成功"); logger.info("查询OpenVpn日志成功");
return "/log/ntc/openVpnList"; } catch (Exception e) {
} logger.info("查询OpenVpn日志失败");
public static void main(String[] args) {
String readAsString;
try {
readAsString = FileUtil.readAsString(new File("D:/FeigeDownload/logTest.txt"));
Gson gson = new GsonBuilder().create();
//gson泛型支持
LogRecvData<NtcOpenVpnLog> fromJson = gson.fromJson(readAsString, new TypeToken<LogRecvData<NtcOpenVpnLog>>(){}.getType());
Page<NtcOpenVpnLog> page = fromJson.getData();
NtcOpenVpnLog object = page.getList().get(0);
System.err.println(object.getCfgId());
} catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return "/log/ntc/openVpnList";
} }
} }

View File

@@ -5,21 +5,6 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
//搜索框提示语初始化
if("${log.clientIp}"){
$("#intype").val("${log.clientIp}");
}else if("${log.serverIp}"){
$("#intype").val("${log.serverIp}");
}else if("${log.cljIp}"){
$("#intype").val("${log.cljIp}");
}else if("${log.entranceId}"){
$("#intype").val("${log.entranceId}");
} else{
$("#intype").attr("placeholder","<spring:message code='input'/>"+$("#seltype").find("option:selected").text());
}
$("#seltype").change(function(){
$("#intype").attr("placeholder","<spring:message code='input'/>"+$(this).find("option:selected").text());
});
//筛选功能 //筛选功能
filterActionInit(); filterActionInit();
//reset //reset
@@ -30,7 +15,9 @@ $(document).ready(function(){
$(this).find("option:first").attr("selected",true); $(this).find("option:first").attr("selected",true);
}); });
$(".Wdate").attr("value",''); $(".Wdate").attr("value",'');
$("#intype").attr("placeholder","<spring:message code='input'/>"+$("#seltype").find("option:selected").text()); $(':input','#searchForm')
.not(':button,:submit,:reset,:hidden')
.attr("value",'');
$("#searchForm")[0].reset(); $("#searchForm")[0].reset();
}); });
@@ -46,7 +33,6 @@ $(document).ready(function(){
} }
</script> </script>
</head> </head>
<body> <body>
<div class="page-content"> <div class="page-content">
@@ -75,14 +61,10 @@ $(document).ready(function(){
<div class="pull-left"> <div class="pull-left">
<div class="input-group"> <div class="input-group">
<div class="input-group-btn"> <div class="input-group-btn">
<c:set var="select"><spring:message code='select'/></c:set> <span class="selectpicker form-control" ><spring:message code="entrance_id"/></span>
<form:select path="protocol" class="selectpicker select2 input-small" data-live-search="true" data-live-search-placeholder="search"> </div>
<form:option value=""><spring:message code="protocol_type"/></form:option> <input id="entranceId" name="entranceId" class="form-control input-small" type="text" value="${log.entranceId}"/>
<c:forEach items="${fns:getDictList('LOG_PROTOCOL')}" var="dict"> </div>
<form:option value="${dict.itemCode}" ><spring:message code="${dict.itemValue}"/></form:option>
</c:forEach>
</form:select>
</div></div>
</div> </div>
<div class="pull-left"> <div class="pull-left">
<div class="input-group"> <div class="input-group">
@@ -100,14 +82,21 @@ $(document).ready(function(){
<div class="pull-left"> <div class="pull-left">
<div class="input-group"> <div class="input-group">
<div class="input-group-btn"> <div class="input-group-btn">
<form:select path="seltype" class="selectpicker select2 input-small" > <c:set var="select"><spring:message code='select'/></c:set>
<form:option value="clientIp"><spring:message code="clientip"></spring:message></form:option> <form:select path="protocol" class="selectpicker select2 input-small" data-live-search="true" data-live-search-placeholder="search">
<form:option value="serverIp"><spring:message code="serverip"></spring:message></form:option> <form:option value=""><spring:message code="protocol_type"/></form:option>
<form:option value="cljIp"><spring:message code="clj_ip"></spring:message></form:option> <c:forEach items="${fns:getDictList('LOG_PROTOCOL')}" var="dict">
<form:option value="entranceId"><spring:message code="entrance_id"></spring:message></form:option> <form:option value="${dict.itemCode}" ><spring:message code="${dict.itemValue}"/></form:option>
</c:forEach>
</form:select> </form:select>
</div></div>
</div> </div>
<input id="intype" class="form-control input-medium" type="text" value=""> <div class="pull-left">
<div class="input-group">
<div class="input-group-btn">
<span class="selectpicker form-control" ><spring:message code="clj_ip"/></span>
</div>
<input id="cljIp" name="cljIp" class="form-control input-small" type="text" value="${log.cljIp}"/>
</div> </div>
</div> </div>
@@ -124,25 +113,36 @@ $(document).ready(function(){
</a> </a>
</div> </div>
</div> </div>
<!-- /搜索内容与操作按钮栏-->
<!-- 筛选搜索内容栏默认隐藏--> <!-- 筛选搜索内容栏默认隐藏-->
<div class="col-md-12 filter-action-select-panle hide" > <div class="col-md-12 filter-action-select-panle hide" >
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-3">
<div class="form-group"> <div class="form-group">
<label class="form-label"><spring:message code="begin_date"/></label> <label class="form-label"><spring:message code="begin_date"/></label>
<input name="searchFoundStartTime" type="text" readonly="readonly" maxlength="20" class="form-control Wdate" <input id="searchFoundStartTime" name="searchFoundStartTime" type="text" readonly="readonly" class="form-control Wdate"
value="<fmt:formatDate value="${log.searchFoundStartTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> value="${log.searchFoundStartTime}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div> </div>
</div> </div>
<div class="col-md-4"> <div class="col-md-3">
<div class="form-group"> <div class="form-group">
<label><spring:message code="end_date"/></label> <label><spring:message code="end_date"/></label>
<input name="searchFoundEndTime" type="text" readonly="readonly" maxlength="20" class="form-control Wdate" <input id="searchFoundEndTime" name="searchFoundEndTime" type="text" readonly="readonly" class="form-control Wdate"
value="<fmt:formatDate value="${log.searchFoundEndTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> value="${log.searchFoundEndTime}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label><spring:message code="clientip"/></label>
<input id="clientIp" name="clientIp" class="form-control input-hide-bg" type="text" value="${log.clientIp}"/>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label><spring:message code="serverip"/></label>
<input id="serverIp" name="serverIp" class="form-control input-hide-bg" type="text" value="${log.serverIp}"/>
</div> </div>
</div> </div>
</div> </div>
@@ -157,17 +157,17 @@ $(document).ready(function(){
<thead> <thead>
<tr> <tr>
<th><spring:message code='cfg_id'/></th> <th><spring:message code='cfg_id'/></th>
<th class="sort-column r.foundTime"><spring:message code='found_time'/></th> <th><spring:message code='entrance_id'/></th>
<th class="sort-column r.recvTime"><spring:message code='recv_time'/></th> <th><spring:message code='direct'/></th>
<th><spring:message code='found_time'/></th>
<th><spring:message code='recv_time'/></th>
<th><spring:message code='protocol_type'/></th> <th><spring:message code='protocol_type'/></th>
<th><spring:message code='addr_type'/></th> <th><spring:message code='addr_type'/></th>
<th><spring:message code='serverip'/></th> <th><spring:message code='serverip'/></th>
<th><spring:message code='clientip'/></th> <th><spring:message code='clientip'/></th>
<th><spring:message code='serverport'/></th> <th><spring:message code='serverport'/></th>
<th><spring:message code='clientport'/></th> <th><spring:message code='clientport'/></th>
<th><spring:message code='entrance_id'/></th>
<th><spring:message code='deviceid'/></th> <th><spring:message code='deviceid'/></th>
<th><spring:message code='direct'/></th>
<th><spring:message code='stream_type'/></th> <th><spring:message code='stream_type'/></th>
<th><spring:message code='clj_ip'/></th> <th><spring:message code='clj_ip'/></th>
<th><spring:message code='nest_addr_list'/></th> <th><spring:message code='nest_addr_list'/></th>
@@ -182,6 +182,12 @@ $(document).ready(function(){
<c:forEach items="${page.list}" var="log" varStatus="status" step="1"> <c:forEach items="${page.list}" var="log" varStatus="status" step="1">
<tr> <tr>
<td>${log.cfgId}</td> <td>${log.cfgId}</td>
<td>${log.entranceId}</td>
<td>
<c:forEach items="${fns:getDictList('LOG_DIRECTION')}" var="dic">
<c:if test="${log.direction==dic.itemCode}"><spring:message code="${dic.itemValue }"/></c:if>
</c:forEach>
</td>
<td>${log.foundTime}</td> <td>${log.foundTime}</td>
<td>${log.recvTime}</td> <td>${log.recvTime}</td>
<td> <td>
@@ -198,13 +204,7 @@ $(document).ready(function(){
<td>${log.clientIp}</td> <td>${log.clientIp}</td>
<td>${log.serverPort}</td> <td>${log.serverPort}</td>
<td>${log.clientPort}</td> <td>${log.clientPort}</td>
<td>${log.entranceId}</td>
<td>${log.deviceId}</td> <td>${log.deviceId}</td>
<td>
<c:forEach items="${fns:getDictList('LOG_DIRECTION')}" var="dic">
<c:if test="${log.direction==dic.itemCode}"><spring:message code="${dic.itemValue }"/></c:if>
</c:forEach>
</td>
<td> <td>
<c:forEach items="${fns:getDictList('LOG_STREAM_TYPE')}" var="dic"> <c:forEach items="${fns:getDictList('LOG_STREAM_TYPE')}" var="dic">
<c:if test="${log.streamType==dic.itemCode}"><spring:message code="${dic.itemValue }"/></c:if> <c:if test="${log.streamType==dic.itemCode}"><spring:message code="${dic.itemValue }"/></c:if>
@@ -218,7 +218,7 @@ $(document).ready(function(){
<td>${log.hmac}</td> <td>${log.hmac}</td>
<td> <td>
<c:if test="${log.tunnelType==1}">TCP</c:if> <c:if test="${log.tunnelType==1}">TCP</c:if>
<c:if test="${log.tunnelType==2}">UDP"</c:if> <c:if test="${log.tunnelType==2}">UDP</c:if>
</td> </td>
</tr> </tr>
</c:forEach> </c:forEach>

View File

@@ -2367,3 +2367,8 @@ pre[class*="language-"] {
.socicon-persona:before { .socicon-persona:before {
content: ")"; } content: ")"; }
/* 隐藏的输入框与时间框同色 */
.form-control.input-hide-bg{
background-color: #eef1f5;
}