Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/main/java/org/catrobat/jira/adminhelper/rest/UserRest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.exception.PermissionException;
import com.atlassian.jira.exception.RemoveException;
import com.atlassian.jira.ofbiz.OfBizDelegator;
import com.atlassian.jira.security.PermissionManager;
import com.atlassian.jira.security.groups.GroupManager;
import com.atlassian.jira.user.ApplicationUser;
Expand All @@ -49,6 +50,7 @@
import org.catrobat.jira.adminhelper.rest.json.JsonResource;
import org.catrobat.jira.adminhelper.rest.json.JsonTeam;
import org.catrobat.jira.adminhelper.rest.json.JsonUser;
import org.ofbiz.core.entity.GenericValue;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
Expand All @@ -57,7 +59,9 @@
import javax.ws.rs.core.Response;

import java.security.SecureRandom;
import java.sql.Timestamp;
import java.util.*;
import com.google.gson.Gson;

@Path("/user")
public class UserRest extends RestHelper {
Expand Down Expand Up @@ -203,6 +207,10 @@ public Response getUsers(@Context HttpServletRequest request) {
List<JsonUser> jsonUserList = new ArrayList<JsonUser>();
Collection<ApplicationUser> allUsers = ComponentAccessor.getUserManager().getAllUsers();
Collection<ApplicationUser> systemAdmins = userUtil.getJiraSystemAdministrators();

OfBizDelegator delegator = ComponentAccessor.getOfBizDelegator();
List<GenericValue> ofBisUsers = delegator.findAll("User");

for (ApplicationUser user : allUsers) {
if (systemAdmins.contains(user)) {
continue;
Expand Down Expand Up @@ -230,6 +238,15 @@ public Response getUsers(@Context HttpServletRequest request) {
}
jsonUser.setActive(isActive);

for(GenericValue ofBizUser : ofBisUsers)
{
String obUserName = ofBizUser.getString("userName");
if(obUserName.equals(user.getUsername())) {
Timestamp timestamp = ofBizUser.getTimestamp("createdDate");
jsonUser.setCreatedDate(new Date(timestamp.getTime()));
}
}

ExtendedPreferences extendedPreferences = userPreferencesManager.getExtendedPreferences(user);
jsonUser.setGithubName(extendedPreferences.getText(GITHUB_PROPERTY));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
import java.util.List;

@SuppressWarnings("unused")
Expand Down Expand Up @@ -50,6 +51,8 @@ public final class JsonUser {
private boolean active;
@XmlElement
private boolean addToDefaultGithubTeam;
@XmlElement
private Date createdDate;

public String getUserName() {
return userName;
Expand Down Expand Up @@ -146,4 +149,12 @@ public boolean isAddToDefaultGithubTeam() {
public void setAddToDefaultGithubTeam(boolean addToDefaultGithubTeam) {
this.addToDefaultGithubTeam = addToDefaultGithubTeam;
}

public Date getCreatedDate() {
return createdDate;
}

public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
}
5 changes: 4 additions & 1 deletion src/main/resources/js/modify_user.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,16 @@ AJS.toInit(function () {
AJS.$("#user-body").empty();
for (var i = 0; i < users.length; i++) {
var obj = users[i];
var createdDate = new Date(obj['createdDate']);
var username = obj['active'] ? obj['userName'] : "<del>" + obj['userName'] + "</del>";
var actionClass = obj['active'] ? "disable" : "enable";
var githubColumnText = obj['githubName'] ? obj['githubName'] : "add GitHub name";
var githubColumn = obj['active'] ?
"<a id=\"" + obj['userName'] + "\" class=\"change-github\" href=\"#\">" + githubColumnText + "</a>" :
(obj['githubName'] ? obj['githubName'] : "");
AJS.$("#user-body").append("<tr><td headers=\"basic-username\" class=\"username\">" + username + "</td>" +
AJS.$("#user-body").append("<tr>" +
"<td headers=\"basic-created-date\" class=\"creatied-date\">" + createdDate.toLocaleDateString() + "</td>" +
"<td headers=\"basic-username\" class=\"username\">" + username + "</td>" +
"<td headers=\"basic-first-name\" class=\"first-name\">" + obj['firstName'] + "</td>" +
"<td headers=\"basic-last-name\" class=\"last-name\">" + obj['lastName'] + "</td>" +
"<td headers=\"basic-email\" class=\"email\">" + obj['email'] + "</td>" +
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/modify_user.vm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<table id="user-table" class="aui aui-table-interactive aui-table-sortable">
<thead>
<tr>
<th id="basic-created-date">Creation Date</th>
<th id="basic-username">Username</th>
<th id="basic-fist-name">First Name</th>
<th id="basic-last-name">Last Name</th>
Expand Down