Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update avatar URL for a user + refactoring #15

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ dist
/RUNNING_PID
/bin
/.project
.settings/org.eclipse.jdt.core.prefs
2 changes: 1 addition & 1 deletion app/analysis/analyzers/RunAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public Build analyze()
{
Build build = new Build();
build.setBuildNumber(m_buildParser.getBuildNumber());

build.setStatus(m_buildParser.getStatus());
build.setTimestamp(m_buildParser.getTimestamp());
build.setDuration(m_buildParser.getDuration());
build.setJob(m_job);
build.setUrl(m_buildParser.getUrl());
setDisplayName(build);
Expand Down
19 changes: 18 additions & 1 deletion app/jsonhandling/RunParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public long getTimestamp()
{
return path("timestamp").asLong();
}

public long getDuration()
{
return path("duration").asLong();
}

public long getEstimatedDuration()
{
Expand Down Expand Up @@ -93,6 +98,18 @@ public TestReportParser loadTestReport(final JsonReader reader)
{
throw new IllegalStateException("There is not testReport available");
}
return new TestReportParser(reader.getJSonResult(getUrl() + "testReport"));
String filterForJSONOutput = "";
// Commented out below lines because not all test-failure related data is retrieved using below filter
/*
// Below filterForJSONOutput is added because 'stdout' in 'suites[cases[stdout]]]' can blow up returned JSON response above 1GB but it is never used
String suitesSelector = "suites[duration,id,name,timestamp,cases[age,className,duration,errorDetails,errorStackTrace,failedSince,name,skipped,status]]";
String testReportSelector = "*,childReports[child[number,url],result[*,"+suitesSelector+"]],"+suitesSelector;

try {
filterForJSONOutput = "/api/json?tree=" + java.net.URLEncoder.encode(testReportSelector,"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}*/
return new TestReportParser(reader.getJSonResult(getUrl() + "testReport" + filterForJSONOutput));
}
}
14 changes: 13 additions & 1 deletion app/model/jenkins/Build.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class Build extends EntityBase

@Required
private Long timestamp;

private Long duration;

private String displayName;

Expand Down Expand Up @@ -99,6 +101,16 @@ public void setTimestamp(final Long timestamp)
this.timestamp = timestamp;
}

public Long getDuration()
{
return duration;
}

public void setDuration(final Long duration)
{
this.duration = duration;
}

public void setStatus(final BuildStatus buildStatus)
{
status = buildStatus.asText();
Expand Down Expand Up @@ -183,7 +195,7 @@ public String getUrl()
return url;
}

public void setUrl(String url)
public void setUrl(final String url)
{
this.url = url;
}
Expand Down
6 changes: 3 additions & 3 deletions app/model/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public String getUserName()
return userName;
}

public void setUserName(String userName)
public void setUserName(final String userName)
{
this.userName = userName;
}
Expand All @@ -48,7 +48,7 @@ public String getFullName()
return fullName;
}

public void setFullName(String fullName)
public void setFullName(final String fullName)
{
this.fullName = fullName;
}
Expand All @@ -58,7 +58,7 @@ public String getEmailAddress()
return emailAddress;
}

public void setEmailAddress(String emailAddress)
public void setEmailAddress(final String emailAddress)
{
this.emailAddress = emailAddress;
}
Expand Down
2 changes: 1 addition & 1 deletion public/partials/task/task.item.dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{task.summary}}
<span class="pull-right smaller-font">
Updated: {{task.updateDate | date:'MM/dd/yy HH:mm'}}<BR>
<img class="pull-right" tooltip="{{task.assignee.fullName}}" ng-show="task.assignee" ng-src="http://srv-ind-scrat:8060/avatar/{{task.assignee.userName}}?s=32"/>
<img class="pull-right" tooltip="{{task.assignee.fullName}}" ng-show="task.assignee" ng-src="http://srv-ind-scrat.vanenburg.com:8060/avatar/{{task.assignee.userName}}?s=32"/>
</span>
<BR>
<span class="smaller-font" ng-show="task.details" ng-bind-html="task.details">
Expand Down
2 changes: 1 addition & 1 deletion public/partials/task/task.item.panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{task.summary}}
<span class="pull-right" style="font-size: 12px;" >
{{task.updateDate | date:'MM/dd/yy @ h:mma'}}
<img ng-show="task.assignee" ng-src="http://srv-ind-scrat:8060/avatar/{{task.assignee.userName}}?s=32"/>
<img ng-show="task.assignee" ng-src="http://srv-ind-scrat.vanenburg.com:8060/avatar/{{task.assignee.userName}}?s=32"/>
</span>
<BR>
</div>
2 changes: 1 addition & 1 deletion public/partials/user/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<fieldset>
<legend>Edit user {{user.userName}}</legend>
<div class="pull-right">
<img ng-src="http://srv-ind-scrat:8060/avatar/{{user.userName}}?s=40" />
<img ng-src="http://srv-ind-scrat.vanenburg.com:8060/avatar/{{user.userName}}?s=40" />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the username is filled in this form, the {{user.userName}} is updated dynamically.
So while changing the user name, you can directly see the results for the avatar.
In the pull request, that changes as the url is only set in the backend, changes are only visible after save.

Do you have a specific use case for changing the way of setting the avatar link?
In case you want to support other location in future, it is better to put the ?s= also in saved url and give the img tags a size. In that case the avatars can be requested with s=40 in all cases, can it can be resized to 32x32.
Using ?=s was introduced to request the images as small as possible (network load) and still have good pictures.

In case you put a size on the image tags and get the avatar from a different location, then it will still be displayed with the right size.

</div>
<div class="form-group" ng-class="{'has-error': myForm.userName.$invalid}">
<label for="userName" class="col-sm-2 control-label">Username</label>
Expand Down
2 changes: 1 addition & 1 deletion public/partials/user/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<td>{{user.userName}}</td>
<td>{{user.fullName}}</td>
<td>{{user.emailAddress}}</td>
<td><img ng-src="http://srv-ind-scrat:8060/avatar/{{user.userName}}?s=32"/></td>
<td><img ng-src="http://srv-ind-scrat.vanenburg.com:8060/avatar/{{user.userName}}?s=32"/></td>
</tr>
</tbody>
</table>
Expand Down