Skip to content

Commit

Permalink
Merge pull request #52 from Catrobat/release-2.4.1
Browse files Browse the repository at this point in the history
Release 2.4.1
  • Loading branch information
m-herold authored Mar 5, 2021
2 parents 654fa1c + a6157b7 commit dcb8c74
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.catrobat.jira</groupId>
<artifactId>timesheet</artifactId>
<version>2.4</version>
<version>2.4.1</version>

<organization>
<name>International Catrobat Association</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class ImportConfigAsJsonServlet extends HighPrivilegeServlet {

Expand Down Expand Up @@ -96,17 +98,30 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
}

Gson gson = new Gson();

JsonReader jsonReader = new JsonReader(new FileReader(new File(temp.getAbsolutePath())));
JsonConfig jsonConfig = gson.fromJson(jsonReader, JsonConfig.class);
String errorString = "";
String status = "Success";

try {
JsonReader jsonReader = new JsonReader(new FileReader(new File(temp.getAbsolutePath())));
JsonConfig jsonConfig = gson.fromJson(jsonReader, JsonConfig.class);
jsonToConfig(jsonConfig, configService);
}
catch (Exception e)
{
errorString = e.toString();
status = "Failure";
}




Map<String, Object> params = new HashMap<>();

params.put("status", status);
params.put("error_string", errorString);

jsonToConfig(jsonConfig, configService);
renderer.render("upload_conf_result.vm", params, response.getWriter());

response.getWriter().print("Successfully executed following string:<br />" +
"<textarea rows=\"20\" cols=\"200\" wrap=\"off\" disabled>" + gson.toJson(jsonConfig) + "</textarea>" +
"<br /><br />" +
"Following errors occurred:<br />" + errorString);
}

private void jsonToConfig(JsonConfig jsonConfig, ConfigService configService) throws ServletException {
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/js/timesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ function projectedFinishDate(timesheetData, entryData) {
sumLast30Days += entry.endDate - entry.beginDate;
}
}
if(sumLast30Days === 0) {
AJS.$("#timesheet-finish-date").val("Not enough entries to compute");
return;
}
var hoursLast30Days = sumLast30Days / (1000 * 60 * 60);
var remDays = rem * 30 / hoursLast30Days;
var finishDate = new Date();
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/js/timesheet/coordinator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var coordUsersList = "";
var idOfCurrentTimesheet = "";

function initCoordinatorUserList(userInformation) {
AJS.$(".loadingDiv").show();
var userListToSort = [];

for (var i = 0; i < userInformation.length; i++) {
Expand Down Expand Up @@ -56,6 +56,7 @@ function initCoordinatorUserList(userInformation) {
var timesheet_id = e.target.getAttribute("data-timesheet-id");
window.open(AJS.params.baseURL + "/plugins/servlet/timesheet?timesheetID=" + timesheet_id, "_blank");
});
AJS.$(".loadingDiv").hide();
}

function initCoordinatorTimesheetSelect(jsonConfig, jsonUser, userInformation) {
Expand Down
14 changes: 3 additions & 11 deletions src/main/resources/js/user_information.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,27 @@ AJS.toInit(function () {
for (var i = 0; i < userInformation.length; i++) {

var firstEntryDate;
if (new Date(userInformation[i].firstEntryDate).getTime() == new Date(0).getTime()) {
if (new Date(userInformation[i].firstEntryDate).getTime() === new Date(0).getTime()) {
firstEntryDate = "none";
} else {
firstEntryDate = (new Date(userInformation[i].firstEntryDate)).toLocaleDateString("en-US");
}

var latestEntryDate;
if (new Date(userInformation[i].latestEntryDate).getTime() == new Date(0).getTime()) {
if (new Date(userInformation[i].latestEntryDate).getTime() === new Date(0).getTime()) {
latestEntryDate = "none";
} else {
latestEntryDate = (new Date(userInformation[i].latestEntryDate)).toLocaleDateString("en-US");
}
var inactiveEndDate;
if (userInformation[i].inactiveEndDate == null || new Date(userInformation[i].inactiveEndDate).getTime() == new Date(0).getTime()) {
if (userInformation[i].inactiveEndDate == null || new Date(userInformation[i].inactiveEndDate).getTime() === new Date(0).getTime()) {
inactiveEndDate = "";
} else {
inactiveEndDate = (new Date(userInformation[i].inactiveEndDate)).toLocaleDateString("en-US");
}

var enabled = userInformation[i].state !== "DISABLED";

var done = userInformation[i].state === "DONE";

var timesheetId = userInformation[i].timesheetID;
var dropdown = "<aui-button id='button" + timesheetId + "' class='aui-button aui-dropdown2-trigger' aria-controls='active-timesheet" + timesheetId + "'>Actions</aui-button>";
dropdown += "<aui-dropdown-menu id='active-timesheet" + timesheetId + "' >";
Expand Down Expand Up @@ -103,8 +101,6 @@ AJS.toInit(function () {
break;
}

var profile_link = AJS.params.baseURL + "\/secure\/ViewProfile.jspa?name=" ;

var enabledColumn = "</td><td headers='ti-actions'>" + dropdown;
var row = "<tr>" +
"<td headers='ti-users' class='users'>" +
Expand Down Expand Up @@ -132,13 +128,9 @@ AJS.toInit(function () {
AJS.$("#user-information-table-content").append(row);
}


var timesheetID = userInformation[i].timesheetID;

setupDropdownButton(timesheetID, enabled);


AJS.$("[name=user-" + userInformation[i].userName + "-profile]").attr("href" , profile_link);
}

AJS.$(".view-timesheet-button").on("click", function (e) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/timesheet.vm
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
</div>
</div>
<div class="aui-page-panel">
<div class="loadingDiv"><aui-spinner></aui-spinner></div>
<div class="aui-page-panel-inner">
<section class="aui-page-panel-content">
<table id="team-information-table" class="aui aui-table-interactive aui-table-sortable">
Expand Down
55 changes: 55 additions & 0 deletions src/main/resources/upload_conf_result.vm
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<html>
<head>
<title>Upload Result</title>
<meta name="decorator" content="atl.general"/>
<script type="text/javascript">
AJS.toInit(function () {
debugger;
var unsuccessfulImportMessage;
if("$status" === "Success"){
if(unsuccessfulImportMessage)
unsuccessfulImportMessage.closeMessage();
AJS.messages.success({
title:"Success",
body:"The timesheet configuration import was successful",
fadeout: true,
delay: 5000,
duration: 5000
});
document.getElementById("status-des").innerHTML = "Timesheet configuration was successfully imported!";
document.getElementById("status-header").innerHTML = "Success";
}
else if("$status" === "Failure") {
if(unsuccessfulImportMessage)
unsuccessfulImportMessage.closeMessage();

unsuccessfulImportMessage = AJS.messages.error({
title:"Failure",
body:"The timesheet configuration import was UNSUCCESSFUL!"
});
document.getElementById("status-header").innerHTML = "Failure";
AJS.$("#errors").html("$error_string");
AJS.$("#errors").trigger("update");
}
});

function redirectToTimesheet() {
window.open(AJS.params.baseURL + "/plugins/servlet/timesheet/administration","_self");
}
</script>
</head>
<body>
<div id="aui-message-bar"></div>
<h1 id="status-header"></h1>

<h3 id="status-des" style="color: green;"></h3>
<h2 id="error-header">Following errors occured:</h2>
<div id="errors"></div>

<br><br>
<div class ="field-group">
<input type="button" value="Back to Timesheet Configuration" class="aui-button aui-button-primary"
onclick="redirectToTimesheet()"/>
</div>
</body>
</html>
4 changes: 2 additions & 2 deletions src/main/resources/upload_result.vm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
});

function redirectToTimesheet() {
window.open("$applicationProperties.getBaseUrl()/plugins/servlet/timesheet","_self");
window.open(AJS.params.baseURL + "/plugins/servlet/timesheet/administration","_self");
}

function displayFaultyEntries(json) {
Expand Down Expand Up @@ -107,7 +107,7 @@

<br><br>
<div class ="field-group">
<input type="button" value="redirect to Timesheet" class="aui-button aui-button-primary"
<input type="button" value="Back to Timesheet Configuration" class="aui-button aui-button-primary"
onclick="redirectToTimesheet()"/>
</div>
</body>
Expand Down

0 comments on commit dcb8c74

Please sign in to comment.