Merge branch 'master' of https://github.com/justinliucs/haflow.git
This commit is contained in:
commit
9312ac6b14
|
@ -64,6 +64,7 @@ public class FlowExecuteService {
|
|||
StringBuilder messageBuilder = new StringBuilder();
|
||||
|
||||
Flow flow = (Flow) this.getFlowService().getFlow(flowId, userid);
|
||||
|
||||
if (flow == null) {
|
||||
messageBuilder.append("Flow " + flowId + " not found!");
|
||||
result.setMessage(messageBuilder.toString());
|
||||
|
|
|
@ -3,7 +3,6 @@ package haflow.service;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import haflow.dto.entity.Flow;
|
||||
import haflow.dto.entity.MainUser;
|
||||
import haflow.util.SessionHelper;
|
||||
|
||||
|
@ -13,7 +12,6 @@ import org.hibernate.HibernateException;
|
|||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hsqldb.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
|
@ -125,7 +123,7 @@ public class UserService {
|
|||
Session session=this.getSessionHelper().openSession();
|
||||
|
||||
try {
|
||||
Query query=session.createQuery("from MainUser as mainUser where role=0");
|
||||
Query query=session.createQuery("from MainUser as mainUser");
|
||||
List<MainUser> list=query.list();
|
||||
session.close();
|
||||
return list;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package haflow.ui.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import haflow.dto.entity.MainUser;
|
||||
import haflow.module.util.Md5Util;
|
||||
import haflow.ui.helper.UserHelper;
|
||||
|
||||
|
@ -37,7 +35,7 @@ public class AdminLogonController {
|
|||
else
|
||||
return new ModelAndView("logon");
|
||||
}
|
||||
@RequestMapping(value="/adminusermana")
|
||||
/*@RequestMapping(value="/adminusermana")
|
||||
public ModelAndView adminmana(HttpServletRequest request){
|
||||
|
||||
if(UserHelper.isUserLogon(request,1)){
|
||||
|
@ -48,7 +46,7 @@ public class AdminLogonController {
|
|||
|
||||
else
|
||||
return new ModelAndView("logon");
|
||||
}
|
||||
}*/
|
||||
@RequestMapping(value="/adminhome")
|
||||
public ModelAndView aminhome(HttpServletRequest request){
|
||||
if(UserHelper.isUserLogon(request,1))
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package haflow.ui.controller;
|
||||
|
||||
import haflow.ui.helper.FlowHelper;
|
||||
import haflow.ui.helper.UserHelper;
|
||||
import haflow.ui.model.SaveFlowModel;
|
||||
import haflow.ui.model.FlowListModel;
|
||||
import haflow.ui.model.FlowModel;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package haflow.ui.controller;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import haflow.ui.helper.UserHelper;
|
||||
import haflow.ui.model.SaveUserResultModel;
|
||||
import haflow.ui.model.UserListModel;
|
||||
import haflow.ui.model.UserModel;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -13,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
@Controller
|
||||
|
@ -30,7 +31,16 @@ public class UserController {
|
|||
public void setUserHelper(UserHelper userHelper) {
|
||||
this.userHelper = userHelper;
|
||||
}
|
||||
|
||||
@RequestMapping(value="/get",method=RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public UserListModel get(HttpServletRequest request){
|
||||
if(UserHelper.isUserLogon(request,1)){
|
||||
return this.getUserHelper().getAllUser();
|
||||
}
|
||||
|
||||
else
|
||||
return null;
|
||||
}
|
||||
@RequestMapping(value = "/get/{userid}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public UserModel get(@PathVariable int userid,HttpServletRequest request){
|
||||
|
@ -48,8 +58,6 @@ public class UserController {
|
|||
@RequestMapping(value = "/update/{userid}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public SaveUserResultModel post(@PathVariable int userid,@RequestBody UserModel user,HttpServletRequest request){
|
||||
System.out.println(userid);
|
||||
System.out.println("!!!!!!!!!!!success update");
|
||||
boolean flag=UserHelper.isUserLogon(request, 0);
|
||||
|
||||
if(flag){
|
||||
|
@ -60,23 +68,18 @@ public class UserController {
|
|||
return null;
|
||||
|
||||
}
|
||||
@RequestMapping(value = "/remove/{userid}", method = RequestMethod.GET)
|
||||
public String delete(@PathVariable int userid,HttpServletRequest request,RedirectAttributes redirectAttributes){
|
||||
@RequestMapping(value = "/remove/{userid}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public SaveUserResultModel delete(@PathVariable int userid,HttpServletRequest request,RedirectAttributes redirectAttributes){
|
||||
boolean flag=UserHelper.isUserLogon(request, 1);
|
||||
|
||||
if(flag){
|
||||
|
||||
if(this.getUserHelper().deleteUser(userid)){
|
||||
redirectAttributes.addFlashAttribute("message", "success removed a user!");
|
||||
return "redirect:/adminhome";
|
||||
// mav.addObject("message", "success!");
|
||||
// return mav;
|
||||
}
|
||||
return this.getUserHelper().deleteUser(userid);
|
||||
|
||||
}
|
||||
redirectAttributes.addFlashAttribute("message", "failed removed a user!");
|
||||
return "redirect:/adminhome";
|
||||
// mav.addObject("message", "failed!");
|
||||
// return mav;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -151,6 +151,8 @@ public class FlowHelper {
|
|||
node.setFlow(null);
|
||||
node.setId(nodeModel.getId());
|
||||
node.setModuleId(nodeModel.getModuleId());
|
||||
System.out.println("return node moduleId");
|
||||
System.out.println(nodeModel.getModuleId());
|
||||
node.setName(nodeModel.getName());
|
||||
this.getNodeAppearanceService().mergeNodeAppearance(
|
||||
nodeModel.getId(), nodeModel.getPosition().getLeft(),
|
||||
|
|
|
@ -2,12 +2,14 @@ package haflow.ui.helper;
|
|||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import haflow.service.UserService;
|
||||
import haflow.ui.model.SaveUserResultModel;
|
||||
import haflow.ui.model.UserListModel;
|
||||
import haflow.ui.model.UserModel;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -60,8 +62,17 @@ public class UserHelper {
|
|||
public boolean updateUserEmail(int userid,String email){
|
||||
return this.getUserService().updateUserEmail(userid, email);
|
||||
}
|
||||
public boolean deleteUser(int userid){
|
||||
return this.getUserService().deleteUser(userid);
|
||||
public SaveUserResultModel deleteUser(int userid){
|
||||
boolean success=this.getUserService().deleteUser(userid);
|
||||
SaveUserResultModel result=new SaveUserResultModel();
|
||||
result.setSuccess(success);
|
||||
result.setUserid(userid);
|
||||
if(success){
|
||||
result.setMessage("success");
|
||||
}
|
||||
else
|
||||
result.setMessage("failed");
|
||||
return result;
|
||||
}
|
||||
public int validate(String username,String password,String mora){
|
||||
return this.getUserService().validate(username,password,mora);
|
||||
|
@ -69,9 +80,26 @@ public class UserHelper {
|
|||
public boolean saveUser(String username,String password,String email,String mora){
|
||||
return this.getUserService().saveUser(username,password,email,mora);
|
||||
}
|
||||
public List<MainUser> getAllUser(){
|
||||
return this.getUserService().getAllUser();
|
||||
|
||||
public UserListModel getAllUser(){
|
||||
List<MainUser> list= this.getUserService().getAllUser();
|
||||
if(list==null)
|
||||
return null;
|
||||
UserListModel userListModel= new UserListModel();
|
||||
List<UserModel> users=new ArrayList<UserModel>();
|
||||
for(MainUser user:list){
|
||||
UserModel userModel=new UserModel();
|
||||
userModel.setId(user.getId());
|
||||
userModel.setName(user.getName());
|
||||
userModel.setPassword(user.getPassword());
|
||||
userModel.setRealname(user.getRealname());
|
||||
userModel.setRole(user.getRole());
|
||||
userModel.setSpace(user.getSpace());
|
||||
userModel.setUsedspace(user.getUsedspace());
|
||||
userModel.setEmail(user.getEmail());
|
||||
users.add(userModel);
|
||||
}
|
||||
userListModel.setUsers(users);
|
||||
return userListModel;
|
||||
}
|
||||
public static boolean isUserLogon(HttpServletRequest request,int authscope) {
|
||||
String username = (String) request.getSession()
|
||||
|
|
|
@ -21,3 +21,4 @@ public class FlowListModel {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package haflow.ui.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "userList")
|
||||
public class UserListModel {
|
||||
private List<UserModel> users;
|
||||
|
||||
@XmlElementWrapper(name = "users")
|
||||
@XmlElement(name = "user")
|
||||
public List<UserModel> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(List<UserModel> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package haflow.ui.model;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
@XmlRootElement(name = "mainuser")
|
||||
public class UserModel {
|
||||
|
|
|
@ -6,74 +6,90 @@
|
|||
String basePath = request.getScheme() + "://"
|
||||
+ request.getServerName() + ":" + request.getServerPort()
|
||||
+ path + "/";
|
||||
String username=request.getSession().getAttribute("username").toString();
|
||||
String username = request.getSession().getAttribute("username")
|
||||
.toString();
|
||||
boolean flag;
|
||||
Object message=request.getAttribute("message");
|
||||
if(request.getAttribute("message")!=null){
|
||||
|
||||
flag=true;
|
||||
Object message = request.getAttribute("message");
|
||||
if (request.getAttribute("message") != null) {
|
||||
|
||||
flag = true;
|
||||
} else {
|
||||
|
||||
flag = false;
|
||||
}
|
||||
else{
|
||||
System.out.println("fa");
|
||||
flag=false;
|
||||
}
|
||||
%>
|
||||
<html >
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<link rel="stylesheet"
|
||||
href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.0/dijit/themes/claro/claro.css">
|
||||
<style type="text/css">
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
overflow:hidden;
|
||||
<link rel="stylesheet"
|
||||
href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.0/dijit/themes/claro/claro.css">
|
||||
<style type="text/css">
|
||||
html,body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#borderContainer {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
<script>dojoConfig = {parseOnLoad: true}</script>
|
||||
<script src='http://dojotoolkit.org/reference-guide/1.9/_static/js/dojo/dojo.js'></script>
|
||||
|
||||
<script>
|
||||
require(["dojo/parser", "dijit/layout/TabContainer", "dijit/layout/ContentPane","dijit/MenuBar","dijit/layout/BorderContainer"]);
|
||||
</style>
|
||||
<script>dojoConfig = {parseOnLoad: true}</script>
|
||||
|
||||
<script type="text/javascript"
|
||||
src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="script/jsPlumb/jquery.ui.touch-punch.min.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="script/jsPlumb/jquery.jsPlumb-1.4.1-all.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="http://ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojo/dojo.js"></script>
|
||||
|
||||
<script>
|
||||
require(["dojo/parser", "dijit/layout/TabContainer", "dojox/layout/ContentPane","dijit/MenuBar","dijit/layout/BorderContainer"]);
|
||||
var flag=<%=flag%>
|
||||
|
||||
if(flag){
|
||||
var message="<%=message%>"
|
||||
var message="<%=message%>";
|
||||
alert(message);
|
||||
}
|
||||
</script>
|
||||
var basePath="<%=basePath%>";
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body class="claro">
|
||||
|
||||
<script type="text/javascript"
|
||||
src="<%=basePath%>script/adminusermana.js"></script>
|
||||
<div data-dojo-type="dijit/layout/BorderContainer"
|
||||
data-dojo-props="design:'sidebar', gutters:true, liveSplitters:true"
|
||||
id="borderContainer">
|
||||
<div data-dojo-type="dijit/MenuBar"
|
||||
data-dojo-props="region:'top', splitter:false">
|
||||
<div data-dojo-type="dijit/layout/ContentPane" style="float: left">
|
||||
<h2>Haflow Background</h2>
|
||||
<div id="title" data-dojo-type="dojox/layout/ContentPane" style="float: left">
|
||||
|
||||
</div>
|
||||
<div data-dojo-type="dijit/layout/ContentPane" style="float: right">
|
||||
<div data-dojo-type="dojox/layout/ContentPane" style="float: right">
|
||||
<h5>
|
||||
hello:<font color=red><%=username %></font> | <a href="quit">quit</a>
|
||||
hello:<font color=red><%=username%></font> | <a href="quit">quit</a>
|
||||
</h5>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div data-dojo-type="dijit/layout/TabContainer"
|
||||
data-dojo-props="region:'center', tabStrip:false">
|
||||
<div data-dojo-type="dijit/layout/ContentPane" title="Module List"
|
||||
<div data-dojo-type="dojox/layout/ContentPane" title="Module List"
|
||||
href="admin"></div>
|
||||
<div data-dojo-type="dijit/layout/ContentPane" title="User List"
|
||||
href="adminusermana"></div>
|
||||
|
||||
<div id="table_pane" data-dojo-type="dojox/layout/ContentPane" title="User List">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,63 +0,0 @@
|
|||
<%@page import="haflow.dto.entity.MainUser"%>
|
||||
<%@page import="haflow.ui.helper.UserHelper"%>
|
||||
<%@ page language="java" contentType="text/html; charset=utf-8"
|
||||
pageEncoding="utf-8"%>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<%
|
||||
String path = request.getContextPath();
|
||||
String basePath = request.getScheme() + "://"
|
||||
+ request.getServerName() + ":" + request.getServerPort()
|
||||
+ path + "/";
|
||||
%>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>HA Flow UserManagement</title>
|
||||
<link rel="stylesheet" href="<%=basePath%>/style/site.css">
|
||||
<script type="text/javascript" src="<%=basePath%>script/adminusermana.js"></script>
|
||||
<body>
|
||||
<h1>Haflow Administration</h1>
|
||||
<h2>User List</h2>
|
||||
|
||||
<table id="userList">
|
||||
<tr>
|
||||
<th>User Id</th>
|
||||
<th>Name</th>
|
||||
<th>Role</th>
|
||||
<th>Space</th>
|
||||
<th>UsedSpace</th>
|
||||
<th>Operation</th>
|
||||
<th>Operation</th>
|
||||
</tr>
|
||||
<% if(request.getAttribute("list")!=null){
|
||||
java.util.List<MainUser> list=(java.util.List<MainUser>)request.getAttribute("list");
|
||||
|
||||
if(list!=null){
|
||||
for(MainUser user:list){
|
||||
%><tr>
|
||||
<td id="id"><%=user.getId()%></td>
|
||||
<td><%=user.getName()%></td>
|
||||
<td><% System.out.print(user.getRole());
|
||||
if(user.getRole()==0) out.print("user");
|
||||
if(user.getRole()==1) out.print("admin");
|
||||
%></td>
|
||||
<td><%=user.getSpace() %></td>
|
||||
<td><%=user.getUsedspace() %></td>
|
||||
|
||||
<td><a
|
||||
href="user/remove/<%=user.getId()%>" onclick="return confirm('确认删除')">Remove</a></td>
|
||||
|
||||
<td><a
|
||||
href="javascript:void(0)" onclick="return openEdit(this);" style="color:blue">Edit</a></td>
|
||||
</tr>
|
||||
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,15 +1,286 @@
|
|||
dojo.require("dojox.grid.DataGrid");
|
||||
dojo.require("dojo.data.ItemFileReadStore");
|
||||
dojo.require("dijit.form.Button");
|
||||
dojo.require("dijit.form.TextBox");
|
||||
dojo.require("dijit.form.Form");
|
||||
dojo.require("dijit.Dialog");
|
||||
|
||||
showDialog = function(title, content) {
|
||||
var dialog = new dijit.Dialog({
|
||||
title : title,
|
||||
content : content,
|
||||
style : "width:400px"
|
||||
});
|
||||
dialog.show();
|
||||
};
|
||||
var confirmDialog=function(){};
|
||||
confirmDialog.userid;
|
||||
|
||||
function openEdit(obj){
|
||||
var row = obj.parentNode.parentNode;
|
||||
var userId = document.getElementById("userList").rows[row.rowIndex]
|
||||
.cells[0].innerHTML;
|
||||
confirmDialog.init=function(){
|
||||
content="Are You Sure?"+
|
||||
"<br/><div><span id='yesButton'>Yes</span>" +
|
||||
"<span id='noButton'>No</span></div>";
|
||||
dialog=new dijit.Dialog({
|
||||
title:"confirm",
|
||||
content:content,
|
||||
Style: "width:400px",
|
||||
onHide : function() {
|
||||
this.destroyRecursive();
|
||||
}
|
||||
});
|
||||
|
||||
// window.open("user/get/"+scriptId,"_blank","width=400,height=300,toolbar=no,scrollbars");
|
||||
}
|
||||
function openDel(obj){
|
||||
|
||||
var confirmButton=new dijit.form.Button({
|
||||
label:"Yes",
|
||||
|
||||
},"yesButton");
|
||||
|
||||
|
||||
var cancelButton=new dijit.form.Button({
|
||||
label:"No",
|
||||
},"noButton");
|
||||
dialog.startup();
|
||||
dojo.connect(confirmButton,"onClick",delUser);
|
||||
dojo.connect(cancelButton,"onClick",function(mouseEvent) {
|
||||
dialog.hide();});
|
||||
//dialog.addChild(confirmButton);
|
||||
//dialog.addChild(cancelButton);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
var newDialog=function(){};
|
||||
newDialog.userid=1;
|
||||
newDialog.user;
|
||||
newDialog.init=function(){
|
||||
|
||||
var text = "";
|
||||
text += "<div >";
|
||||
text += "<div ><span style=\"float: left; width: 80px;\"><strong>Name:</strong></span>";
|
||||
text += "<span id=\"user_name_text_box\" ></span></div>";
|
||||
text += "<div ><span style=\"float: left; width: 80px;\"><strong>Role:</strong></span>";
|
||||
text += "<span id=\"user_role_text_box\"></span></div>";
|
||||
text += "<div ><span style=\"float: left; width: 80px;\"><strong>Space:</strong></span>";
|
||||
text += "<span id=\"user_space_text_box\"></span></div>";
|
||||
text += "<div class=\"field\"><span style=\"float: left; width: 80px;\"><strong>UsedSpace:</strong></span>";
|
||||
text += "<span id=\"user_used_text_box\"></span></div>";
|
||||
|
||||
text += "<div>";
|
||||
text += "<span id=\"save_user_button\" ></span></div>";
|
||||
text += "</div>";
|
||||
userForm=new dijit.form.Form({
|
||||
innerHTML:text
|
||||
});
|
||||
userForm.startup();
|
||||
userDialog = new dijit.Dialog({
|
||||
title: "User Infomation",
|
||||
style: "width: 400px"
|
||||
});
|
||||
userDialog.addChild(userForm);
|
||||
var userRoleTextBox = new dijit.form.TextBox({
|
||||
id : "userRoleTextBox",
|
||||
style : "width:200px;"
|
||||
},"user_role_text_box");
|
||||
|
||||
var userSpaceTextBox = new dijit.form.TextBox({
|
||||
id : "userSpaceTextBox",
|
||||
style : "width:200px;"
|
||||
},"user_space_text_box");
|
||||
|
||||
var userUsedTextBox =new dijit.form.TextBox({
|
||||
id:"userUsedTextBox",
|
||||
style:"width:200px;"
|
||||
},"user_used_text_box");
|
||||
|
||||
|
||||
|
||||
var button = new dijit.form.Button({
|
||||
label : "Save",
|
||||
onClick : function() {
|
||||
user.role=userRoleTextBox.get("value");
|
||||
user.space=userSpaceTextBox.get("value");
|
||||
user.usedspace=userUsedTextBox.get("value");
|
||||
|
||||
$.ajax({
|
||||
url : basePath + "user/update/"+userid,
|
||||
type : "Post",
|
||||
dataType : "json",
|
||||
contentType : "application/json",
|
||||
data:JSON.stringify(user),
|
||||
success :function(data,status){
|
||||
userDialog.hide();
|
||||
if(data.success==true){
|
||||
showDialog("Success", "Successfully update user information! ");
|
||||
loadUsers();
|
||||
}
|
||||
else{
|
||||
showDialog("Error", "An error occurred while updating user information: ");
|
||||
}
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
userDialog.hide();
|
||||
showDialog("Error", "An error occurred while updating user information: "
|
||||
+ error);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
button.placeAt(dojo.byId("save_user_button"));
|
||||
button.startup();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
function editRow(r){
|
||||
|
||||
var row = r.parentNode.parentNode;
|
||||
userid = document.getElementById("userlist").rows[row.rowIndex].cells[0].innerHTML;
|
||||
|
||||
$.ajax({
|
||||
url : basePath + "user/get/"+userid,
|
||||
type : "GET",
|
||||
cache : false,
|
||||
dataType : "json",
|
||||
success : function(data, status) {
|
||||
user = data;
|
||||
|
||||
dojo.byId("user_name_text_box").innerHTML = data.name;
|
||||
dojo.byId("userRoleTextBox").value=data.role;
|
||||
dojo.byId("userSpaceTextBox").value=data.space;
|
||||
dojo.byId("userUsedTextBox").value=data.usedspace;
|
||||
newDialog.user=user;
|
||||
newDialog.userid=userid;
|
||||
userDialog.show();
|
||||
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
showDialog("Error",
|
||||
"An error occurred while refreshing user list: " + error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var users;
|
||||
var loadUsers = function() {
|
||||
|
||||
$.ajax({
|
||||
url : basePath + "user/get",
|
||||
type : "GET",
|
||||
cache : false,
|
||||
dataType : "json",
|
||||
success : function(data, status) {
|
||||
if (data.success == false) {
|
||||
dojo
|
||||
.create(
|
||||
"message",
|
||||
{
|
||||
innerHTML : "<p><font color=red>An Error while loading users!</font></p>"
|
||||
}, dojo.byId("table_pane"));
|
||||
} else {
|
||||
users = data;
|
||||
|
||||
var table = "<table id=\"userlist\" border=\"1\">";
|
||||
table += "<tr><th>Id</th><th>Name</th><th>RealName</th><th>Role</th><th>Space</th><th>UsedSpace</th><th>Operation</th><th>Operation</th></tr>";
|
||||
dojo
|
||||
.forEach(
|
||||
data.users,
|
||||
function(user) {
|
||||
table += "<tr><td>";
|
||||
table += user.id;
|
||||
table += "</td><td>";
|
||||
table += user.name;
|
||||
table += "</td><td>";
|
||||
table += user.realname;
|
||||
table += "</td><td>";
|
||||
table += user.role;
|
||||
table += "</td><td>";
|
||||
table += user.space;
|
||||
table += "</td><td>";
|
||||
table += user.usedspace;
|
||||
table += "</td><td >";
|
||||
table += "<input type=\"button\" value=\"edit\" onclick=\"editRow(this)\">";
|
||||
table += "</td><td >";
|
||||
table += "<input type=\"button\" value=\"delete\" onclick=\"deleteRow(this)\">";
|
||||
|
||||
table += "</td></tr>";
|
||||
|
||||
});
|
||||
table += "</table>";
|
||||
dojo.empty(dojo.byId("table_pane"));
|
||||
dojo
|
||||
.create(
|
||||
"message",
|
||||
{
|
||||
innerHTML : "<p><font color=red>NOTE: 0=users;1=administrators(Role)</font></p>"
|
||||
}, dojo.byId("table_pane"));
|
||||
dojo.place(table, dojo.byId("table_pane"));
|
||||
|
||||
/*
|
||||
* var editbutton=new dijit.form.Button({ label:"edit"
|
||||
* });
|
||||
*/
|
||||
// dojo.connect(editbutton,"onclick",null,showUserInfoDia());
|
||||
/*
|
||||
* for(var j=0;j<i;j++)
|
||||
* editbutton.placeAt(dojo.byId("edit_user_button"+j));
|
||||
* editbutton.startup();
|
||||
*/
|
||||
}
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
showDialog("Error",
|
||||
"An error occurred while refreshing user list: " + error);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
dojo.addOnLoad(function() {
|
||||
|
||||
dojo.byId("title").innerHTML="<h2>Haflow Background</h2>";
|
||||
|
||||
loadUsers();
|
||||
newDialog.init();
|
||||
confirmDialog.init();
|
||||
|
||||
});
|
||||
|
||||
function deleteRow(obj) {
|
||||
var row = obj.parentNode.parentNode;
|
||||
var scriptId = document.getElementById("userList").rows[row.rowIndex]
|
||||
.cells[0].innerHTML;
|
||||
window.open("user/remove/"+scriptId,"_blank","width=400,height=300,toolbar=no,scrollbars");
|
||||
}
|
||||
confirmDialog.userid = document.getElementById("userlist").rows[row.rowIndex].cells[0].innerHTML;
|
||||
dialog.show();
|
||||
};
|
||||
var haha=function(){
|
||||
alert("helo wangjie");
|
||||
|
||||
}
|
||||
var delUser=function(){
|
||||
dialog.hide();
|
||||
$.ajax({
|
||||
url : basePath + "user/remove/"+confirmDialog.userid,
|
||||
type : "DELETE",
|
||||
cache : false,
|
||||
dataType : "json",
|
||||
success : function(data, status) {
|
||||
alert(data.success);
|
||||
if (data.success == true) {
|
||||
showDialog("Success", "Successfully delete the user! ");
|
||||
loadUsers();
|
||||
}
|
||||
else
|
||||
showDialog("Error",
|
||||
"An error occurred while delete the user " );
|
||||
|
||||
},
|
||||
error : function(request, status, error) {
|
||||
showDialog("Error",
|
||||
"An error occurred while delete the user " + error);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
|
@ -12,6 +12,7 @@ HAFlow.UI = function() {
|
|||
|
||||
};
|
||||
|
||||
|
||||
HAFlow.UI.prototype.init = function() {
|
||||
this.initId();
|
||||
this.initMainContainer();
|
||||
|
|
|
@ -30,21 +30,21 @@ function checkField(){
|
|||
}else if(usernameValue == "" && passwordValue == ""){
|
||||
|
||||
document.getElementById("errorSpan").innerHTML="";
|
||||
document.getElementById("error_username").innerHTML = "用户名不能为空!";
|
||||
document.getElementById("error_password").innerHTML = "密码不能为空!";
|
||||
document.getElementById("error_username").innerHTML = "username can not be blank";
|
||||
document.getElementById("error_password").innerHTML = "password can not be blank";
|
||||
|
||||
return false ;
|
||||
}else if(usernameValue !== "" && passwordValue == ""){
|
||||
document.getElementById("errorSpan").innerHTML="";
|
||||
document.getElementById("password").focus() ;
|
||||
document.getElementById("error_username").innerHTML = "";
|
||||
document.getElementById("error_password").innerHTML = "密码不能为空!";
|
||||
document.getElementById("error_password").innerHTML = "password can not be blank";
|
||||
return false ;
|
||||
}else if(passwordValue !== "" && usernameValue == ""){
|
||||
document.getElementById("errorSpan").innerHTML="";
|
||||
document.getElementById("username").focus() ;
|
||||
document.getElementById("error_password").innerHTML = "";
|
||||
document.getElementById("error_username").innerHTML = "用户名不能为空!";
|
||||
document.getElementById("error_username").innerHTML = "username can not be blank";
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ function RePass(){
|
|||
return true;
|
||||
}
|
||||
else{
|
||||
document.getElementById("password1_err").innerHTML="两次密码不一致!";
|
||||
document.getElementById("password1_err").innerHTML="Password doesn't match the confirmation";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -51,25 +51,25 @@ function checkPass() {
|
|||
|
||||
|
||||
if(user_name==""){
|
||||
document.getElementById("username_err").innerHTML="用户名不能为空!";
|
||||
document.getElementById("username_err").innerHTML="username can not be blank";
|
||||
document.getElementsByName('username')[0].value="";
|
||||
document.getElementsByName('username')[0].style.border="1px solid red";
|
||||
null_flag=1;}
|
||||
|
||||
if(eml_msg==""){
|
||||
document.getElementById("email_err").innerHTML="邮箱不能为空!";
|
||||
document.getElementById("email_err").innerHTML="email can not be blank";
|
||||
document.getElementsByName('email')[0].value="";
|
||||
document.getElementsByName('email')[0].style.border="1px solid red";
|
||||
null_flag=1;}
|
||||
if(input_pwd==""){
|
||||
|
||||
document.getElementById("password_err").innerHTML="密码不能为空!";
|
||||
document.getElementById("password_err").innerHTML="password can not be blank";
|
||||
document.getElementsByName('password')[0].value="";
|
||||
document.getElementsByName('password')[0].style.border="1px solid red";
|
||||
null_flag=1;}
|
||||
|
||||
if(retype_pwd==""){
|
||||
document.getElementById("password1_err").innerHTML="密码不能为空!";
|
||||
document.getElementById("password1_err").innerHTML="password can not be blank";
|
||||
document.getElementsByName('password1')[0].value="";
|
||||
document.getElementsByName('password1')[0].style.border="1px solid red";
|
||||
null_flag=1;
|
||||
|
@ -91,15 +91,15 @@ function form_validation(name) {
|
|||
var err=null;
|
||||
if(name=="username"){
|
||||
regx=/^[a-z0-9_-]{3,8}$/;
|
||||
err="3-8位数字或字母!";
|
||||
err="please write 3 to 8 letters or numbers";
|
||||
}
|
||||
if(name=="password"){
|
||||
regx=/^[a-z0-9_-]{4,18}$/;
|
||||
err="4-18位数字或字母!";
|
||||
err="please write 4 to 18 letters or numbers";
|
||||
}
|
||||
if (name == "email") {
|
||||
regx = /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/;
|
||||
err = "请填写有效的邮箱地址!";
|
||||
err = "please write valid email address";
|
||||
}
|
||||
if(!regx.test(input_value)){
|
||||
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
@CHARSET "UTF-8";
|
||||
.dijitDisabled.dijitButtonDisabled .dijitButtonNode {
|
||||
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
.node {
|
||||
width: 8em;
|
||||
|
|
Loading…
Reference in New Issue