Skip to content

Commit

Permalink
Layout improvements on pdf campaign execution report pdf. #2475
Browse files Browse the repository at this point in the history
  • Loading branch information
vertigo17 committed Aug 22, 2023
1 parent 814343b commit 3056130
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public class Parameter {
public static final String VALUE_cerberus_xray_sendenvironments_enable = "cerberus_xray_sendenvironments_enable";
public static final String VALUE_cerberus_sikuli_typeDelay = "cerberus_sikuli_typeDelay";
public static final String VALUE_cerberus_testcaseautofeed_enable = "cerberus_testcaseautofeed_enable";
public static final String VALUE_cerberus_instancelogo_url = "cerberus_instancelogo_url";
public static final String VALUE_cerberus_pdfcampaignreportdisplaycountry_boolean = "cerberus_pdfcampaignreportdisplaycountry_boolean";

public static final String SECUREDPARAMINSQLCLAUSE = "(\"cerberus_accountcreation_defaultpassword\",\"cerberus_proxyauthentification_password\",\"cerberus_jenkinsadmin_password\","
+ "\"cerberus_smtp_password\",\"cerberus_executeCerberusCommand_password\",\"cerberus_xraycloud_clientsecret\",\"cerberus_xraycloud_clientid\",\"cerberus_xraydc_token\")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,60 @@ public String generatePdf(Tag tag) throws FileNotFoundException {
String mediaPath = parameterService.getParameterStringByKey(Parameter.VALUE_cerberus_exeautomedia_path, "", "");
mediaPath = StringUtil.addSuffixIfNotAlready(mediaPath, File.separator);

boolean displayCountryColumn = parameterService.getParameterBooleanByKey(Parameter.VALUE_cerberus_pdfcampaignreportdisplaycountry_boolean, "", true);

String logoURL = parameterService.getParameterStringByKey(Parameter.VALUE_cerberus_instancelogo_url, "", "https://vm.cerberus-testing.org/img/logo.png");

try ( // Creating a Document
Document document = new Document(pdfDoc)) {

AreaBreak aB = new AreaBreak();

// Tittle
document.add(new Paragraph("Campaign Execution Report").setBold().setFontSize(20).setTextAlignment(TextAlignment.CENTER));
document.add(new Paragraph(tag.getTag()).setBold().setFontSize(20).setTextAlignment(TextAlignment.CENTER).setMarginBottom(30));
Table tableTitle = new Table(new float[]{100, 500});
if (StringUtil.isNotEmptyOrNullValue(logoURL)) {
ImageData imageDataLogo = ImageDataFactory.create(logoURL);
Image image = new Image(imageDataLogo).scaleToFit(100, 70);
tableTitle.addCell(new Cell().add(image.setBorder(Border.NO_BORDER).setHorizontalAlignment(HorizontalAlignment.RIGHT)).setBorder(Border.NO_BORDER));
tableTitle.addCell(new Cell().add(new Paragraph("Campaign Execution Report").setBold().setFontSize(20).setTextAlignment(TextAlignment.CENTER))
.add(new Paragraph(tag.getTag()).setBold().setFontSize(20).setTextAlignment(TextAlignment.CENTER)).setMarginBottom(30).setBorder(Border.NO_BORDER));

}
document.add(tableTitle.setMarginLeft(0));

long tagDur = (tag.getDateEndQueue().getTime() - tag.getDateCreated().getTime()) / 60000;
document.add(new Paragraph()
.add(getTextFromString("Triggered from campaign: ", 10, false))
.add(getTextFromString(tag.getCampaign(), 12, true))
.add(getTextFromString(" by ", 10, false))
.add(getTextFromString(tag.getUsrCreated(), 12, true)));
.add(getTextFromString("Campaign started at ", 10, false))
.add(getTextFromString(String.valueOf(tag.getDateCreated()), 12, true))
.add(getTextFromString(" and ended at ", 10, false))
.add(getTextFromString(String.valueOf(tag.getDateEndQueue()), 12, true))
.add(getTextFromString(" (duration of ", 10, false))
.add(getTextFromString(String.valueOf(tagDur), 12, true))
.add(getTextFromString(" min)", 10, false))
);

if (StringUtil.isEmptyOrNullValue(tag.getCampaign())) {
if (!StringUtil.isEmptyOrNullValue(tag.getUsrCreated())) {
document.add(new Paragraph()
.add(getTextFromString("Triggered by ", 10, false))
.add(getTextFromString(tag.getUsrCreated(), 12, true))
);
}
} else {
if (StringUtil.isEmptyOrNullValue(tag.getUsrCreated())) {
document.add(new Paragraph()
.add(getTextFromString("Triggered from campaign: ", 10, false))
.add(getTextFromString(tag.getCampaign(), 12, true))
);
} else {
document.add(new Paragraph()
.add(getTextFromString("Triggered from campaign: ", 10, false))
.add(getTextFromString(tag.getCampaign(), 12, true))
.add(getTextFromString(" by ", 10, false))
.add(getTextFromString(tag.getUsrCreated(), 12, true))
);
}
}

document.add(new Paragraph()
.add(getTextFromString("Executed on Country(ies): ", 10, false))
Expand All @@ -152,22 +192,18 @@ public String generatePdf(Tag tag) throws FileNotFoundException {
.add(getTextFromString(String.valueOf(tag.getCiScoreThreshold()), 12, true))
.add(getTextFromString(")", 10, false)));

long tagDur = (tag.getDateEndQueue().getTime() - tag.getDateCreated().getTime()) / 60000;
document.add(new Paragraph()
.add(getTextFromString("Campaign started at ", 10, false))
.add(getTextFromString(String.valueOf(tag.getDateCreated()), 12, true))
.add(getTextFromString(" and ended at ", 10, false))
.add(getTextFromString(String.valueOf(tag.getDateEndQueue()), 12, true))
.add(getTextFromString(" (duration of ", 10, false))
.add(getTextFromString(String.valueOf(tagDur), 12, true))
.add(getTextFromString(" min)", 10, false)));

document.add(new Paragraph()
.add(getTextFromString(String.valueOf(tag.getNbExeUsefull()), 12, true))
.add(getTextFromString(" useful executions were performed (Over ", 10, false))
.add(getTextFromString(String.valueOf(tag.getNbExe()), 12, true))
.add(getTextFromString(" in total including retries)", 10, false)));

if (!StringUtil.isEmptyOrNullValue(tag.getDescription())) {
document.add(new Paragraph()
.add(getTextFromString(tag.getDescription(), 12, true))
);
}

/**
* Result information per status
*/
Expand Down Expand Up @@ -269,13 +305,23 @@ public String generatePdf(Tag tag) throws FileNotFoundException {
Collections.sort(listOfExecutions, new SortExecution());

// Creating a table
Table tableExe = new Table(new float[]{40, 160, 80, 80, 20, 20, 50, 50, 50, 30})
.addHeaderCell(getHeaderCell("Exe ID"))
// .addHeaderCell(getHeaderCell("Prio"))
Table tableExe;
if (displayCountryColumn) {
tableExe = new Table(new float[]{40, 140, 80, 20, 80, 20, 20, 50, 50, 50, 30});

} else {
tableExe = new Table(new float[]{40, 140, 80, 20, 80, 20, 50, 50, 50, 30});
}

tableExe.addHeaderCell(getHeaderCell("Exe ID"))
.addHeaderCell(getHeaderCell("Test Folder"))
.addHeaderCell(getHeaderCell("Test ID"))
.addHeaderCell(getHeaderCell("Application"))
.addHeaderCell(getHeaderCell("Country"))
.addHeaderCell(getHeaderCell("Prio"))
.addHeaderCell(getHeaderCell("Application"));
if (displayCountryColumn) {
tableExe.addHeaderCell(getHeaderCell("Country"));
}
tableExe
.addHeaderCell(getHeaderCell("Environment"))
.addHeaderCell(getHeaderCell("Robot"))
.addHeaderCell(getHeaderCell("Started"))
Expand All @@ -287,18 +333,27 @@ public String generatePdf(Tag tag) throws FileNotFoundException {
Calendar calStart = Calendar.getInstance();
Calendar calEnd = Calendar.getInstance();

int nbColSpan = 8;
if (displayCountryColumn) {
nbColSpan = 9;
}

for (TestCaseExecution execution : listOfExecutions) {
Cell cellID = new Cell(2, 1).add(new Paragraph(String.valueOf(execution.getId()))).setFontSize(6).setVerticalAlignment(VerticalAlignment.MIDDLE).setTextAlignment(TextAlignment.CENTER);
Cell cellRes = getStatusCell(execution.getControlStatus(), 2, 1);
Cell cellTCDesc = new Cell(1, 8).add(new Paragraph(execution.getDescription())).setFontSize(7);
Cell cellTCDesc = new Cell(1, nbColSpan).add(new Paragraph(execution.getDescription())).setFontSize(7);
calStart.setTimeInMillis(execution.getStart());
calEnd.setTimeInMillis(execution.getEnd());

tableExe
.addCell(cellID.setAction(PdfAction.createGoTo(String.valueOf(execution.getId()))))
// .addCell(String.valueOf(execution.getTestCasePriority()))
.addCell(new Cell().add(new Paragraph(execution.getTest())).setFontSize(7))
.addCell(new Cell().add(new Paragraph(execution.getTestCase())).setFontSize(7))
.addCell(new Cell().add(new Paragraph(execution.getTestCase())).setFontSize(7));
if (displayCountryColumn) {
tableExe
.addCell(new Cell().add(new Paragraph(String.valueOf(execution.getTestCasePriority()))).setFontSize(7));
}
tableExe
.addCell(new Cell().add(new Paragraph(execution.getApplication())).setFontSize(7))
.addCell(new Cell().add(new Paragraph(execution.getCountry())).setFontSize(7))
.addCell(new Cell().add(new Paragraph(execution.getEnvironment())).setFontSize(7))
Expand All @@ -325,18 +380,18 @@ public String generatePdf(Tag tag) throws FileNotFoundException {
document.add(new Paragraph()
.add(getTextFromString(String.valueOf(execution.getControlMessage()), 12, true)));

tableExe = new Table(new float[]{200, 90, 70, 80, 20, 20, 40, 20, 50})
tableExe = new Table(new float[]{200, 90, 70, 70, 80, 20, 20, 40, 20, 50})
.addHeaderCell(getHeaderCell("Test Folder"))
.addHeaderCell(getHeaderCell("Test ID"))
// .addHeaderCell(getHeaderCell("Prio"))
.addHeaderCell(getHeaderCell("Prio"))
.addHeaderCell(getHeaderCell("Application"))
.addHeaderCell(getHeaderCell("Country"))
.addHeaderCell(getHeaderCell("Environment"))
.addHeaderCell(getHeaderCell("Robot"));
tableExe
.addCell(execution.getTest())
.addCell(execution.getTestCase())
// .addCell(String.valueOf(execution.getTestCasePriority()))
.addCell(String.valueOf(execution.getTestCasePriority()))
.addCell(execution.getApplication())
.addCell(execution.getCountry())
.addCell(execution.getEnvironment())
Expand Down Expand Up @@ -506,11 +561,12 @@ private Table getImageTable(List<TestCaseExecutionFile> fileList, String mediaPa
Table tableTmp = null;
// We count the nb of images in the file list.
int nbImages = 0;
for (TestCaseExecutionFile controlFile : fileList) {
if (controlFile.isImage()) {
for (TestCaseExecutionFile exeFile : fileList) {
if (exeFile.isImage() && !exeFile.getFileDesc().contains("Picture")) {
nbImages++;
}
}

// If there is at least 1 image in the list
if (nbImages > 0) {
tableTmp = new Table(new float[]{150, 500});
Expand Down
6 changes: 6 additions & 0 deletions source/src/main/resources/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6216,3 +6216,9 @@ INSERT INTO `invariant` (`idname`, `value`, `sort`, `description`, `VeryShortDes
-- 1751
INSERT INTO `invariant` (`idname`, `value`, `sort`, `description`, `veryshortdesc`)
VALUES ('LANGUAGE', 'fa', 400, 'فارسی', 'فارسی');

-- 1752
INSERT INTO `parameter` (`system`, `param`, `value`, `description`)
VALUES ('', 'cerberus_instancelogo_url', 'https://vm.cerberus-testing.org/img/logo.png', 'URl that point to the instance logo. Use that parameter in order to personalize some screens and pdf report.'),
('', 'cerberus_pdfcampaignreportdisplaycountry_boolean', 'true', 'Boolean in order to show or hide the country column on pdf campaign execution pdf report.');

12 changes: 7 additions & 5 deletions source/src/main/webapp/ReportingExecutionByTag.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,21 @@
aria-describedby="basic-addon1">
</div>
</div>
<div class="row">
<div class="row marginTop10">
<div class="col-sm-6" id="TagcampaignCel1">
<label for="Tagcampaign">Campaign :</label>
<input type="text" class="form-control" name="Tagcampaign" id="Tagcampaign" readonly aria-describedby="basic-addon1">
</div>
<div class="col-sm-6" id="TagcampaignCICel1">
<div class="col-sm-3" id="TagcampaignCICel1">
<label for="tagDetailCI">CI Result :</label>
<div class="marginTop10" id="tagDetailCI">
</div>
</div>
<div class="col-sm-3" >
<a id="buttonDownloadPdfReport" class="pull-right">
<button type="button" class="btn btn-default" style="margin-left: 10px;">Download Report</button>
</a>
</div>
</div>
<div class="marginTop10" id="tagDetailBar">
</div>
Expand All @@ -307,9 +312,6 @@
<a id="buttonRunCampaign" class="pull-right">
<button type="button" class="btn btn-default" style="margin-left: 10px;">(Re)Run Campaign</button>
</a>
<a id="buttonDownloadPdfReport" class="pull-right">
<button type="button" class="btn btn-default" style="margin-left: 10px;">Download Report</button>
</a>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion source/src/main/webapp/js/pages/ReportingExecutionByTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ function loadReportingData(selectTag) {
$("#Tagcampaign").val(data.tagObject.campaign);
$("#TagComment").val(data.tagObject.comment);
$("#TagDesc").val(data.tagObject.description);
$("#buttonDownloadPdfReport").attr("href", "./api/public/campaignexecutions/pdf/" + data.tagObject.tag);
if (isEmpty(data.tagObject.campaign)) {
$("#TagcampaignCel1").addClass("hidden");
$("#TagcampaignCel2").addClass("hidden");
Expand All @@ -363,7 +364,6 @@ function loadReportingData(selectTag) {
$("#TagcampaignCel2").removeClass("hidden");
$("#buttonRunCampaign").attr("href", "./RunTests.jsp?campaign=" + data.tagObject.campaign);
$("#buttonSeeStatsCampaign").attr("href", "./ReportingCampaignOverTime.jsp?campaigns=" + data.tagObject.campaign);
$("#buttonDownloadPdfReport").attr("href", "./api/public/campaignexecutions/pdf/" + data.tagObject.tag);
}
if (isEmpty(data.tagObject.xRayTestExecution)) {
$("#xRayTestExecutionBlock").addClass("hidden");
Expand Down
3 changes: 2 additions & 1 deletion source/src/main/webapp/js/pages/TestCaseList.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ function loadTable(selectTest, sortColumn) {
$.when(jqxhr).then(function (data) {
sortColumn = 2;

var config = new TableConfigurationsServerSide("testCaseTable", contentUrl, "contentTable", aoColumnsFunc(data, "testCaseTable"), [2, 'asc']);
var lengthMenu = [10, 25, 50, 100, 500, 1000];
var config = new TableConfigurationsServerSide("testCaseTable", contentUrl, "contentTable", aoColumnsFunc(data, "testCaseTable"), [2, 'asc'], lengthMenu);

var table = createDataTableWithPermissions(config, renderOptionsForTestCaseList, "#testCaseList", undefined, true);

Expand Down

0 comments on commit 3056130

Please sign in to comment.