Skip to content

Commit c521f4b

Browse files
committed
VoiceControl
1 parent 8415023 commit c521f4b

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class MyClass {
5353
// Set Report Color for more visit http://materializecss.com/color.html
5454
reportBuilder.setReportColor(Color.PURPLE);
5555

56+
// Enable voice control for report
57+
reportBuilder.enableVoiceControl();
58+
5659
// Add additional info for Report
5760
reportBuilder.setAdditionalInfo("Environment", "My Environment");
5861

@@ -74,6 +77,12 @@ class MyClass {
7477

7578
[View Java Docs](https://oss.sonatype.org/service/local/repositories/releases/archive/com/rajatthareja/reportbuilder/1.0.2/reportbuilder-1.0.2-javadoc.jar/!/index.html) for more details.
7679

80+
## Voice Control Report
81+
82+
Use voice commands for easy navigation and search
83+
* show ( overview, features, summary, errors )
84+
* search { Keywords }
85+
7786
## Report Builder Ruby Gem
7887

7988
[Report Builder](http://reportbuilder.rajatthareja.com)

sample/report.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,5 +1404,6 @@ <h5>I am some testing scenario of other functionality</h5>
14041404
});
14051405
</script>
14061406
<script src="https://cdn.rawgit.com/rajatthareja/ReportBuilderJava/v1.0.2/js/report.builder.min.js"></script>
1407+
14071408
</body>
14081409
</html>

src/main/java/com/rajatthareja/reportbuilder/ReportBuilder.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class ReportBuilder {
2424

2525
private String reportTitle, reportDirectory, reportFileName, reportColor;
2626
private Map<String, String> additionalInfo;
27+
private boolean voiceControl;
2728

2829
/**
2930
* Get output report directory
@@ -152,6 +153,20 @@ public void setReportColor(Color reportColor) {
152153
this.reportColor = reportColor.toString();
153154
}
154155

156+
/**
157+
* Enable voice control for report
158+
*/
159+
public void enableVoiceControl() {
160+
voiceControl = true;
161+
}
162+
163+
/**
164+
* Disable voice control
165+
*/
166+
public void disableVoiceControl() {
167+
voiceControl = false;
168+
}
169+
155170
/**
156171
* Creates report builder object for customizing and building report
157172
*/
@@ -161,6 +176,7 @@ public ReportBuilder() {
161176
reportTitle = "Test Report";
162177
reportColor = Color.BROWN.toString();
163178
additionalInfo = new HashMap<>();
179+
voiceControl = false;
164180
}
165181

166182
/**
@@ -188,6 +204,7 @@ public void build(Object ... cucumberJsonReports) {
188204
data.put("reportTitle", reportTitle);
189205
data.put("reportColor", reportColor);
190206
data.put("additionalInfo", additionalInfo);
207+
data.put("voiceControl", voiceControl);
191208
data.put("report", report);
192209

193210
new File(reportDirectory).mkdirs();

src/main/resources/com/rajatthareja/reportbuilder/template/report.ftl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,31 @@
5353
});
5454
</script>
5555
<script src="https://cdn.rawgit.com/rajatthareja/ReportBuilderJava/v1.0.2/js/report.builder.min.js"></script>
56+
57+
<#if voiceControl>
58+
<script src="//cdnjs.cloudflare.com/ajax/libs/annyang/2.6.0/annyang.min.js"></script>
59+
<script>
60+
var commands = {
61+
'show :tab': function(tab) {
62+
if (tab === "overview") {
63+
$("a[data-tooltip='Results Overview']").click();
64+
} else if (tab === "features" || tab === "feature") {
65+
$("a[data-tooltip='Scenarios by Features']").click();
66+
} else if (tab === "summary") {
67+
$("a[data-tooltip='Scenarios Summary Table']").click();
68+
} else if (tab === "errors" || tab === "error" || tab === "failed" || tab === "bugs") {
69+
$("a[data-tooltip='Failed Scenarios']").click();
70+
}
71+
},
72+
'search *search': function (search) {
73+
$("a[data-tooltip='Scenarios Summary Table']").click();
74+
$("input[type='search']").val(search);
75+
$('table#summaryTable').DataTable().search(search).draw();
76+
}
77+
};
78+
annyang.addCommands(commands);
79+
annyang.start();
80+
</script>
81+
</#if>
5682
</body>
5783
</html>

src/test/resources/com/rajatthareja/reportbuilder/report.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,5 +1404,6 @@ <h5>I am some testing scenario of other functionality</h5>
14041404
});
14051405
</script>
14061406
<script src="https://cdn.rawgit.com/rajatthareja/ReportBuilderJava/v1.0.2/js/report.builder.min.js"></script>
1407+
14071408
</body>
14081409
</html>

0 commit comments

Comments
 (0)