diff --git a/pom.xml b/pom.xml index e9869d0..6435ea9 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ 4.0.0 org.catrobat.jira timesheet - 2.4 + 2.4.1 International Catrobat Association diff --git a/src/main/java/org/catrobat/jira/timesheet/servlet/ImportConfigAsJsonServlet.java b/src/main/java/org/catrobat/jira/timesheet/servlet/ImportConfigAsJsonServlet.java index c46250c..db70d9c 100644 --- a/src/main/java/org/catrobat/jira/timesheet/servlet/ImportConfigAsJsonServlet.java +++ b/src/main/java/org/catrobat/jira/timesheet/servlet/ImportConfigAsJsonServlet.java @@ -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 { @@ -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 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:
" + - "" + - "

" + - "Following errors occurred:
" + errorString); } private void jsonToConfig(JsonConfig jsonConfig, ConfigService configService) throws ServletException { diff --git a/src/main/resources/js/timesheet.js b/src/main/resources/js/timesheet.js index 1b2142b..a670e50 100644 --- a/src/main/resources/js/timesheet.js +++ b/src/main/resources/js/timesheet.js @@ -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(); diff --git a/src/main/resources/js/timesheet/coordinator.js b/src/main/resources/js/timesheet/coordinator.js index a87b773..8788ae9 100644 --- a/src/main/resources/js/timesheet/coordinator.js +++ b/src/main/resources/js/timesheet/coordinator.js @@ -4,7 +4,7 @@ var coordUsersList = ""; var idOfCurrentTimesheet = ""; function initCoordinatorUserList(userInformation) { - + AJS.$(".loadingDiv").show(); var userListToSort = []; for (var i = 0; i < userInformation.length; i++) { @@ -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) { diff --git a/src/main/resources/js/user_information.js b/src/main/resources/js/user_information.js index b6cdfe1..3d71784 100644 --- a/src/main/resources/js/user_information.js +++ b/src/main/resources/js/user_information.js @@ -51,20 +51,20 @@ 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"); @@ -72,8 +72,6 @@ AJS.toInit(function () { var enabled = userInformation[i].state !== "DISABLED"; - var done = userInformation[i].state === "DONE"; - var timesheetId = userInformation[i].timesheetID; var dropdown = "Actions"; dropdown += ""; @@ -103,8 +101,6 @@ AJS.toInit(function () { break; } - var profile_link = AJS.params.baseURL + "\/secure\/ViewProfile.jspa?name=" ; - var enabledColumn = "" + dropdown; var row = "" + "" + @@ -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) { diff --git a/src/main/resources/timesheet.vm b/src/main/resources/timesheet.vm index 3be162b..b28d2f9 100644 --- a/src/main/resources/timesheet.vm +++ b/src/main/resources/timesheet.vm @@ -127,6 +127,7 @@
+
diff --git a/src/main/resources/upload_conf_result.vm b/src/main/resources/upload_conf_result.vm new file mode 100644 index 0000000..a0a0e84 --- /dev/null +++ b/src/main/resources/upload_conf_result.vm @@ -0,0 +1,55 @@ + + + Upload Result + + + + +
+

+ +

+

Following errors occured:

+
+ +

+
+ +
+ + \ No newline at end of file diff --git a/src/main/resources/upload_result.vm b/src/main/resources/upload_result.vm index fcc5a08..c27736a 100644 --- a/src/main/resources/upload_result.vm +++ b/src/main/resources/upload_result.vm @@ -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) { @@ -107,7 +107,7 @@

-