Authored by zhengyouwei

add user

... ... @@ -5,16 +5,12 @@ import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import com.ui.model.req.AuthModule;
import com.ui.model.req.User;
import org.apache.commons.lang.ArrayUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
... ... @@ -35,8 +31,8 @@ public class UserAuthLocal {
@Autowired
HttpRestClient httpRestClient;
@PostConstruct
public void init() throws Exception {
//@PostConstruct
public synchronized void init() {
//加载用户信息
BaseResponse<List<User>> response = httpRestClient.exchangeForget(HttpUriContants.GET_All_USER, new ParameterizedTypeReference<BaseResponse<List<User>>>() {
... ... @@ -62,6 +58,9 @@ public class UserAuthLocal {
* @return
*/
public boolean auth(String user,String module){
if(usermap.isEmpty()){//改用延时加载
init();
}
User u = usermap.get(user);
if (u == null){
return false;
... ... @@ -83,10 +82,26 @@ public class UserAuthLocal {
* @return
*/
public User getUserByname(String name) {
if(usermap.isEmpty()){//改用延时加载
init();
}
return usermap.get(name);
}
/**
* 获取用户
*
* @param name
* @return
*/
public AuthModule getAuthModuleByname(String name) {
if(modulemap.isEmpty()){//改用延时加载
init();
}
return modulemap.get(name);
}
/**
* 更新用户信息
*
* @param name
... ... @@ -98,6 +113,30 @@ public class UserAuthLocal {
BaseResponse<User> response = httpRestClient.exchangeForget(HttpUriContants.GET_USER_BY_NAME, new ParameterizedTypeReference<BaseResponse<User>>() {
}, map);
User user = response.getData();
usermap.put(name, user);
if (user == null){
usermap.remove(name);
}else{
usermap.put(name, user);
}
}
/**
* 更新用户信息
*
* @param name
*/
@Async
public void flushModule(String name) {
Map<String, String> map = new HashMap<>();
map.put("name", name);
BaseResponse<AuthModule> response = httpRestClient.exchangeForget(HttpUriContants.MODULE_GET_BYNAME, new ParameterizedTypeReference<BaseResponse<AuthModule>>() {
}, map);
AuthModule authModule = response.getData();
if (authModule == null){
modulemap.remove(name);
}else{
modulemap.put(name, authModule);
}
}
}
... ...
... ... @@ -73,10 +73,11 @@ public class HttpUriContants {
*/
public static final String GET_All_USER = "/user/getAllUser";
public static final String GET_USER_BY_NAME = "/user/getUserByName";
public static final String GET_USERS = "/user/getUsers";
public static final String GET_USER_BY_ID = "/user/getUserById";
public static final String USER_INSERT = "/user/insert";
public static final String USER_UPDATE_PWD = "/user/updatePwd";
public static final String USER_UPDATE_AUTH = "/user/updateAuth";
public static final String USER_UPDATE = "/user/update";
public static final String USER_DELETE_NAME = "/user/deleteByName";
public static final String USER_DELETE_ID = "/user/deleteById";
... ... @@ -84,6 +85,11 @@ public class HttpUriContants {
* module
*/
public static final String GET_All_MODULE= "/module/getAll";
public static final String MODULE_INSERT= "/module/insert";
public static final String MODULE_UPDATE= "/module/updateLevel";
public static final String MODULE_GET_BYNAME= "/module/getAuthModuleByName";
public static final String GET_MODULES= "/module/getAuthModules";
public static final String MODULE_DELETE_NAME = "/module/deleteByName";
}
... ...
... ... @@ -22,4 +22,7 @@ public class User {
private int level;
private String email;
private String mobile;
}
... ...
... ... @@ -10,9 +10,9 @@ public class ProjectEnvironment {
private static Map<String,String> map = new HashMap<>();
static{
map.put("aws", "http://172.31.16..167:8083/web/");
map.put("qcloud","http://172.31.16..167:8083/web/");
map.put("qcloud_gray","http://172.31.16..167:8083/web/");
map.put("aws", "http://172.31.16.167:8083/web/");
map.put("qcloud","http://172.31.16.167:8083/web/");
map.put("qcloud_gray","http://172.31.16.167:8083/web/");
//map.put("test","http://192.168.102.220:8083/web/");
//map.put("dev");
... ...
package com.ui.ctrl;
import com.ui.User.MD5Util;
import com.ui.User.UserAuthLocal;
import com.ui.contants.HttpUriContants;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import com.ui.model.req.AuthModule;
import com.ui.model.req.PageRequest;
import com.ui.model.req.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("manage")
public class ManagerCtrl {
Logger log = LoggerFactory.getLogger(ManagerCtrl.class);
@Autowired
HttpRestClient httpRestClient;
@Autowired
UserAuthLocal userAuthLocal;
@RequestMapping("/toUser")
public ModelAndView toAddUser() {
return new ModelAndView("manager/user");
}
@RequestMapping("/toModule")
public ModelAndView toAddModule() {
return new ModelAndView("manager/module");
}
@RequestMapping("/saveUser")
@ResponseBody
public BaseResponse saveUser(@RequestBody User user) {
BaseResponse baseResponse = null;
if(user.getId() < 1){//add
if(userAuthLocal.getUserByname(user.getName()) != null){
return new BaseResponse(201,"用户已经存在");
}
user.setPwd(MD5Util.encryption(user.getPwd()));
baseResponse = httpRestClient.defaultPost(HttpUriContants.USER_INSERT,user,BaseResponse.class);
}else{
if("admin".equals(user.getName())){
return new BaseResponse(201,"此用户无法修改");
}
baseResponse = httpRestClient.defaultPost(HttpUriContants.USER_UPDATE,user,BaseResponse.class);
}
userAuthLocal.flushUser(user.getName());
return baseResponse;
}
@RequestMapping("/getUsers")
@ResponseBody
public BaseResponse getUsers(PageRequest req) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.GET_USERS, req, BaseResponse.class);
return response;
}
@RequestMapping("/deleteUser")
@ResponseBody
public BaseResponse deleteUser(String name) {
Map map = new HashMap<>();
map.put("name",name);
BaseResponse response = httpRestClient.defaultGet(HttpUriContants.USER_DELETE_NAME, BaseResponse.class, map);
userAuthLocal.flushUser(name);
return response;
}
@RequestMapping("/saveAuthModule")
@ResponseBody
public BaseResponse saveAuthModule(@RequestBody AuthModule authModule) {
BaseResponse baseResponse = null;
if(authModule.getId() < 1){//add
if(userAuthLocal.getAuthModuleByname(authModule.getModuleName()) != null){
return new BaseResponse(201,"模块已经存在");
}
baseResponse = httpRestClient.defaultPost(HttpUriContants.MODULE_INSERT,authModule,BaseResponse.class);
}else{
baseResponse = httpRestClient.defaultPost(HttpUriContants.MODULE_UPDATE,authModule,BaseResponse.class);
}
userAuthLocal.flushModule(authModule.getModuleName());
return baseResponse;
}
@RequestMapping("/getAuthModules")
@ResponseBody
public BaseResponse getAuthModules(PageRequest req) {
BaseResponse response = httpRestClient.defaultPost(HttpUriContants.GET_MODULES, req, BaseResponse.class);
return response;
}
@RequestMapping("/deleteAuthModule")
@ResponseBody
public BaseResponse deleteAuthModule(String name) {
Map map = new HashMap<>();
map.put("name",name);
BaseResponse response = httpRestClient.defaultGet(HttpUriContants.MODULE_DELETE_NAME, BaseResponse.class, map);
userAuthLocal.flushModule(name);
return response;
}
}
... ...
... ... @@ -78,7 +78,8 @@
<div class="form-inline" role="form" id="inBoxQueryDiv"
style=" margin-top: 12px;margin-left: 25px;float: left;">
</div>
<a href="#" id="addHostGroup" class="btn btn-success" style="margin-top: 12px;margin-left: 0px;" onclick="editHostGroup(0,0)">新增标签</a></div>
<a href="#" id="addHostGroup" class="btn btn-success" style="margin-top: 12px;margin-left: 0px;"
onclick="editHostGroup(0,0)">新增标签</a></div>
</div>
</div>
<div id="hostGroupTable">
... ... @@ -98,15 +99,18 @@
<h4 class="modal-title" id="myModalLabel"></h4>
</div>
<div class="modal-body">
<form id="hostGroupForm" class="form-horizontal">
<div class="form-group" >
<form id="hostGroupForm" class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>标签名称:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="editGroupName" name="editGroupName" placeholder="输入标签名称" maxlength="30" size="40"/>
<input type="text" class="form-control" id="editGroupName" name="editGroupName"
placeholder="输入标签名称" maxlength="30" size="40"/>
</div>
</div>
<div class="form-group" >
<div class="form-group">
<label class="col-sm-2 control-label"> </label>
<div class="col-sm-8" id="messageAlert"></div>
</div>
<input type="hidden" name="editGroupId"/>
... ... @@ -121,7 +125,6 @@
</div>
<!-- /.modal -->
</div>
</div>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script type="text/javascript">
... ... @@ -152,7 +155,7 @@
//加载表格
$("#hostGroupTable").table({
columnAutoWidth: false,
url:"getHostGroups",
url: "getHostGroups",
striped: true,
title: "标签信息列表",
pagination: true,
... ... @@ -198,8 +201,8 @@
var groupName = $("input[name='editGroupName']").val();
if (groupName == null || groupName == "") {
$("#hostGroupForm #messageAlert").alerts({
content : "请输入标签名称!",
type : "danger"
content: "请输入标签名称!",
type: "danger"
});
return;
}
... ... @@ -209,19 +212,19 @@
}
$.ajax({
type: 'post',
url:"saveHostGroup.do",
url: "saveHostGroup.do",
data: param,
dataType: 'json',
success: function (data) {
if (!data || data.code != 200) {
localAlert('删除失败',data.message);
}else{
localAlert('删除失败', data.message);
} else {
$("#myModal").modal('hide');
$("#hostGroupTable").table("load");
}
},
error: function (data) {
localAlert('系统异常',data.message);
localAlert('系统异常', data.message);
}
});
}
... ... @@ -230,31 +233,31 @@
function deleteHostGroup(id) {
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title : "你确定删除吗",
backdrop : "static",
content : "你确定要删除该标签信息吗?",
buttons : [{
text : "否",
className : "btn-danger",
onclick : function() {
title: "你确定删除吗",
backdrop: "static",
content: "你确定要删除该标签信息吗?",
buttons: [{
text: "否",
className: "btn-danger",
onclick: function () {
$(dialog).dialog("hide");
}
}, {
text : "是",
className : "btn-success",
onclick : function() {
text: "是",
className: "btn-success",
onclick: function () {
$(dialog).dialog("hide");
$.ajax({
url: "deleteHostGroup",
type : 'post',
async : false,
data : {
id : id
type: 'post',
async: false,
data: {
id: id
},
dataType : "json",
success : function(data) {
dataType: "json",
success: function (data) {
if (!data || data.code != 200) {
localAlert('删除失败',data.message);
localAlert('删除失败', data.message);
}
$("#hostGroupTable").table("load");
}
... ...
<%@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/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/bootstrap-responsive.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
<link rel="stylesheet" href="<%=basePath %>css/select2.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>
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">管理员</a>
</div>
<div class="container-fluid">
<div class="widget-box">
<div class="widget-title">
<h5>模块操作</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-title" style="height: 53px;">
<div class="form-inline">
<a href="#" id="toAddAuthModule" class="btn btn-success"
style="margin-top: 12px;margin-left: 0px;" onclick="editAuthModule(0,0,0)">添加模块</a>
</div>
</div>
</div>
<div id="authModuleTable">
</div>
</div>
</div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel"></h4>
</div>
<div class="modal-body">
<form id="hostGroupForm" class="form-horizontal">
<input type="hidden" name="id">
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>模块名:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="name" name="name"
placeholder="模块名" maxlength="30" size="40"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>等级:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="level" name="level"
placeholder="等级" maxlength="30" 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>
<input type="hidden" name="editGroupId"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-success" value="Validate" onclick="saveAuthModule()">提交</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script>
$("#li_manager").addClass("active open");
$("#li_module").addClass("active");
</script>
<script type="text/javascript">
$(function () {
//加载表格
$("#authModuleTable").table({
columnAutoWidth: false,
url: contextPath + "/manage/getAuthModules",
striped: true,
title: "模块信息列表",
pagination: true,
pageSize: 10,
loadFilter: function (data) {
return defaultLoadFilter(data);
},
columns: [{
title: "模块名",
field: "moduleName",
width: "30%"
}, {
title: "等级",
field: "moduleLevel",
width: "30%"
},{
title: "操作",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
$("<button onclick=\"editAuthModule(\'" + rowData.id + "\',\'" + rowData.moduleName + "\',\'" + rowData.moduleLevel + "\')\">").addClass("btn btn-xs btn-success").html("修改").appendTo(div);
div.append("&nbsp;");
$("<button onclick=\"deleteAuthModule(\'" + rowData.moduleName + "\')\">").addClass("btn btn-xs btn-danger").html("删除").appendTo(div);
return div;
}
}]
});
});
//打开新增或修改页面
function editAuthModule(id, name,level) {
$("#hostGroupForm #messageAlert").hide();
if (id == 0) {//新增页面
$("input[name='id']").val(0);
$("input[name='name']").val("");
$("input[name='level']").val("");
$("input[name='name']").removeAttr("readonly");
$("#myModalLabel").text("新增模块信息");
} else {
$("#myModalLabel").text("修改模块信息");
$("input[name='id']").val(id);
$("input[name='name']").val(name);
$("input[name='name']").attr("readonly","readonly");
$("input[name='level']").val(level);
}
$("#myModal").modal('show');
}
//打开新增或修改页面
function deleteAuthModule(name) {
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: contextPath + "/manage/deleteAuthModule",
type: 'post',
async: false,
data: {
name: name
},
dataType: "json",
success: function (data) {
if (!data || data.code != 200) {
localAlert('删除失败', data.message);
}
$("#authModuleTable").table("load");
}
});
}
}]
});
}
function saveAuthModule() {
var id = $("input[name='id']").val();
var name = $("input[name='name']").val();
var level = $("input[name='level']").val();
if (name == null || name == "") {
$("#hostGroupForm #messageAlert").alerts({
content: "请输入模块名",
type: "danger"
});
return;
}
if (level == null || level == "") {
$("#hostGroupForm #messageAlert").alerts({
content: "请输入等级",
type: "danger"
});
return;
}
var param = {
id:id,
moduleName: name,
moduleLevel: level,
}
$.ajax({
url: contextPath + 'manage/saveAuthModule',
type: 'POST',
dataType: 'json',
contentType: "application/json",
data: JSON.stringify(param),
success: function (data) {
if (!data || data.code != 200) {
$("#hostGroupForm #messageAlert").alerts({
content: data.message,
type: "danger"
});
return;
}else{
$("#myModal").modal('hide');
$("#authModuleTable").table("load");
}
},
error: function (data) {
localAlert('系统异常',data.message);
}
});
}
</script>
</body>
</html>
... ...
<%@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/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/bootstrap-responsive.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
<link rel="stylesheet" href="<%=basePath %>css/select2.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>
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">管理员</a>
</div>
<div class="container-fluid">
<div class="widget-box">
<div class="widget-title">
<h5>用户操作</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-title" style="height: 53px;">
<div class="form-inline">
<a href="#" id="toAddUser" class="btn btn-success"
style="margin-top: 12px;margin-left: 0px;" onclick="editUser(0,0,0,0,0)">添加用户</a>
</div>
</div>
</div>
<div id="userTable">
</div>
</div>
</div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel"></h4>
</div>
<div class="modal-body">
<form id="hostGroupForm" class="form-horizontal">
<input type="hidden" name="id">
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>用户名:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="name" name="name"
placeholder="用户名" maxlength="30" size="40"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>密码:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="pwd" name="pwd"
placeholder="密码" maxlength="30" size="40"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>等级:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="level" name="level"
placeholder="等级" maxlength="30" size="40"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>邮箱:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="email" name="email"
placeholder="邮箱" maxlength="30" size="40"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>手机号:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="mobile" name="mobile"
placeholder="手机号" maxlength="30" 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>
<input type="hidden" name="editGroupId"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-success" value="Validate" onclick="saveuser()">提交</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script>
$("#li_manager").addClass("active open");
$("#li_user").addClass("active");
</script>
<script type="text/javascript">
$(function () {
//加载表格
$("#userTable").table({
columnAutoWidth: false,
url: contextPath + "/manage/getUsers",
striped: true,
title: "用户信息列表",
pagination: true,
pageSize: 10,
loadFilter: function (data) {
return defaultLoadFilter(data);
},
columns: [{
title: "用户名",
field: "name",
width: "15%"
}, {
title: "等级",
field: "level",
width: "15%"
},{
title: "邮箱",
field: "email",
width: "15%"
},{
title: "手机号",
field: "mobile",
width: "15%"
},{
title: "操作",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
$("<button onclick=\"editUser(\'" + rowData.id + "\',\'" + rowData.name + "\',\'" + rowData.level + "\',\'" + rowData.email + "\',\'" + rowData.mobile + "\')\">").addClass("btn btn-xs btn-success").html("修改").appendTo(div);
div.append("&nbsp;");
$("<button onclick=\"deleteUser(\'" + rowData.name + "\')\">").addClass("btn btn-xs btn-danger").html("删除").appendTo(div);
return div;
}
}]
});
});
//打开新增或修改页面
function editUser(id, name,level,email,maobile) {
$("#hostGroupForm #messageAlert").hide();
if (id == 0) {//新增页面
$("input[name='id']").val(0);
$("input[name='name']").val("");
$("input[name='pwd']").val("");
$("input[name='level']").val("");
$("input[name='email']").val("");
$("input[name='mobile']").val("");
$("input[name='pwd']").show();
$("input[name='name']").removeAttr("readonly");
$("#myModalLabel").text("新增用户信息");
} else {
$("#myModalLabel").text("修改用户信息");
$("input[name='id']").val(id);
$("input[name='name']").val(name);
$("input[name='name']").attr("readonly","readonly");
$("input[name='level']").val(level);
$("input[name='email']").val(email);
$("input[name='mobile']").val(maobile);
$("input[name='pwd']").hide();
}
$("#myModal").modal('show');
}
//打开新增或修改页面
function deleteUser(name) {
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: contextPath + "/manage/deleteUser",
type: 'post',
async: false,
data: {
name: name
},
dataType: "json",
success: function (data) {
if (!data || data.code != 200) {
localAlert('删除失败', data.message);
}
$("#userTable").table("load");
}
});
}
}]
});
}
function saveuser() {
var id = $("input[name='id']").val();
var name = $("input[name='name']").val();
var pwd = $("input[name='pwd']").val();
var level = $("input[name='level']").val();
var email = $("input[name='email']").val();
var mobile = $("input[name='mobile']").val();
if (name == null || name == "") {
$("#hostGroupForm #messageAlert").alerts({
content: "请输入用户名",
type: "danger"
});
return;
}
if(id == 0){
if (pwd == null || pwd == "") {
$("#hostGroupForm #messageAlert").alerts({
content: "请输入密码",
type: "danger"
});
return;
}
}
if (level == null || level == "") {
$("#hostGroupForm #messageAlert").alerts({
content: "请输入等级",
type: "danger"
});
return;
}
var param = {
id:id,
name: name,
level: level,
email: email,
mobile: mobile,
pwd: pwd
}
$.ajax({
url: contextPath + 'manage/saveUser',
type: 'POST',
dataType: 'json',
contentType: "application/json",
data: JSON.stringify(param),
success: function (data) {
if (!data || data.code != 200) {
$("#hostGroupForm #messageAlert").alerts({
content: data.message,
type: "danger"
});
return;
}else{
$("#myModal").modal('hide');
$("#userTable").table("load");
}
},
error: function (data) {
localAlert('系统异常',data.message);
}
});
}
</script>
</body>
</html>
... ...
... ... @@ -20,7 +20,7 @@
<img src="<%=basePath %>img/logo.png" alt="" />
</div>
<div id="loginbox">
<form id="loginform" class="form-vertical" action="<%=basePath %>user/login">
<form id="loginform" class="form-vertical" action="<%=basePath %>user/login" method="post">
<p>Enter username and password to continue.</p>
<div class="control-group">
<div class="controls">
... ...
... ... @@ -21,7 +21,13 @@ innerHTML += "<li id='li_rabbitview'><a id='li_rabbitview_a' href=''><i class='i
innerHTML += "<li id='li_redisInfo'><a id='li_redisInfo_a' href=''><i class='icon icon-th'></i> <span>Redis监控</span></a></li>";
innerHTML += "<li id='li_nginxview'><a id='li_nginxview_a' href=''><i class='icon icon-th'></i> <span>Nginx监控</span></a></li>";
innerHTML += "<li id='li_projectRelease'><a id='li_projectRelease_a' href=''><i class='icon icon-th'></i> <span>项目发布</span></a></li>";
/*主体*/
/*manage*/
innerHTML += "<li class='submenu' id='li_manager'><a id='li_manager_a' href='#'><i class='icon icon-th-list'></i> <span>管理员</span><span class='label'>3</span></a>";
innerHTML += "<ul><li id='li_user'><a id='li_user_a' href=''>用户管理</a></li>";
innerHTML += "<li id='li_module'><a id='li_module_a' href=''>模块管理</a></li>";
innerHTML += "<li id='li_projectlist'><a id='li_projectlist_a' href=''>发布记录</a></li>";
innerHTML += "</ul></li>";
/*其他*/
innerHTML += "<li id='li_others'><a id='li_others_a' href=''><i class='icon icon-th'></i> <span>其他</span></a></li>";
... ... @@ -45,6 +51,8 @@ document.getElementById("li_others_a").setAttribute("href", path + "/dashboard/t
document.getElementById("logout_a").setAttribute("href", path + "/user/logout");
document.getElementById("li_others_a").setAttribute("href", path + "/dashboard/toOthers");
document.getElementById("li_zkMonitor_a").setAttribute("href", path + "/zkTree/tozkMonitorList");
document.getElementById("li_user_a").setAttribute("href", path + "/manage/toUser");
document.getElementById("li_module_a").setAttribute("href", path + "/manage/toModule");
function getUrlBasePath() {
var location = ( window.location + '').split('/');
... ...
... ... @@ -39,15 +39,15 @@ function getProjects() {
if ("Deploy" == operate) {//发布多选框
var order1HTML = "<div class='ckbox ckbox-primary'>";
order1HTML += " <input name='project1all' type='checkbox' id='project1all' value='project1all' onclick='projectcheckall(this,\"project1\");'/>";
order1HTML += "<label for='project1all' style='width: 150px'>yoho30 全选</label></div>";
order1HTML += "<label for='project1all' style='width: 200px'>yoho30 全选</label></div>";
var order2HTML = "<div class='ckbox ckbox-warning'>";
order2HTML += " <input name='project2all' type='checkbox' id='project2all' value='project2all' onclick='projectcheckall(this,\"project2\");'/>";
order2HTML += "<label for='project2all' style='width: 150px'>yoho-search 全选</label></div>";
order2HTML += "<label for='project2all' style='width: 200px'>yoho-search 全选</label></div>";
var order3HTML = "<div class='ckbox ckbox-success'>";
order3HTML += " <input name='project3all' type='checkbox' id='project3all' value='project3all' onclick='projectcheckall(this,\"project3\");'/>";
order3HTML += "<label for='project3all' style='width: 150px'>platform 全选</label></div>";
order3HTML += "<label for='project3all' style='width: 200px'>platform 全选</label></div>";
var order1num = 1;
var order2num = 1;
... ... @@ -59,7 +59,7 @@ function getProjects() {
if ("1" == order) {
order1HTML += "<div class='ckbox ckbox-primary' style='display: inline'>";
order1HTML += " <input name='project1' type='checkbox' id='" + name + "' value='" + name + "'/>";
order1HTML += "<label for='" + name + "' style='width: 150px'>" + name + "</label></div>";
order1HTML += "<label for='" + name + "' style='width: 200px'>" + name + "</label></div>";
if (order1num % 4 == 0) {
order1HTML += "</br>";
}
... ... @@ -69,7 +69,7 @@ function getProjects() {
if ("2" == order) {
order2HTML += "<div class='ckbox ckbox-warning' style='display: inline'>";
order2HTML += " <input name='project2' type='checkbox' id='" + name + "' value='" + name + "'/>";
order2HTML += "<label for='" + name + "' style='width: 150px'>" + name + "</label></div>";
order2HTML += "<label for='" + name + "' style='width: 200px'>" + name + "</label></div>";
if (order2num % 4 == 0) {
order2HTML += "</br>";
}
... ... @@ -79,7 +79,7 @@ function getProjects() {
if ("3" == order) {
order3HTML += "<div class='ckbox ckbox-success' style='display: inline'>";
order3HTML += " <input name='project3' type='checkbox' id='" + name + "' value='" + name + "'/>";
order3HTML += "<label for='" + name + "' style='width: 150px'>" + name + "</label></div>";
order3HTML += "<label for='" + name + "' style='width: 200px'>" + name + "</label></div>";
if (order3num % 4 == 0) {
order3HTML += "</br>";
}
... ... @@ -109,7 +109,7 @@ function getProjects() {
} else {
order1HTML += " <input name='project' type='radio' id='" + name + "' value='" + name + "' onclick='getRollbackList()'/>";
}
order1HTML += "<label for='" + name + "' style='width: 150px'>" + name + "</label></div>";
order1HTML += "<label for='" + name + "' style='width: 200px'>" + name + "</label></div>";
if (order1num % 4 == 0) {
order1HTML += "</br>";
}
... ... @@ -118,7 +118,7 @@ function getProjects() {
if ("2" == order) {
order2HTML += "<div class='rdio rdio-warning' style='display: inline'>";
order2HTML += " <input name='project' type='radio' id='" + name + "' value='" + name + "' onclick='getRollbackList()'/>";
order2HTML += "<label for='" + name + "' style='width: 150px'>" + name + "</label></div>";
order2HTML += "<label for='" + name + "' style='width: 200px'>" + name + "</label></div>";
if (order2num % 4 == 0) {
order2HTML += "</br>";
}
... ... @@ -128,7 +128,7 @@ function getProjects() {
if ("3" == order) {
order3HTML += "<div class='rdio rdio-success' style='display: inline'>";
order3HTML += " <input name='project' type='radio' id='" + name + "' value='" + name + "' onclick='getRollbackList()'/>";
order3HTML += "<label for='" + name + "' style='width: 150px'>" + name + "</label></div>";
order3HTML += "<label for='" + name + "' style='width: 200px'>" + name + "</label></div>";
if (order3num % 4 == 0) {
order3HTML += "</br>";
}
... ... @@ -242,11 +242,11 @@ function projectbuild() {
"rollbackfile": rollbackfile
};
$.ajax({
url: 'build',
type: 'POST',
dataType: 'json',
contentType: "application/json",
data: JSON.stringify(jsondata),
url: 'build',
type: 'POST',
dataType: 'json',
contentType: "application/json",
data: JSON.stringify(jsondata),
success: function (data2) {
var obj = eval("(" + data2 + ")");
var projectOrder = obj.data.projectOrder;
... ... @@ -260,7 +260,7 @@ function projectbuild() {
var p = projectOrders[i];
HTML += "<div class='ckbox ckbox-danger' id='show-" + p + "-div' style='display: inline'>";
HTML += " <input name='show-" + p + "' type='checkbox' id='show-" + p + "' value='" + p + "' checked='checked' disabled/>";
HTML += "<label for='show-" + p + "' style='width: 150px'>" + p + "</label></div>";
HTML += "<label for='show-" + p + "' style='width: 200px'>" + p + "</label></div>";
if ((i + 1) % 4 == 0) {
HTML += "</br>";
}
... ...