Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/planemo/reports/custom.js @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author | shellac |
---|---|
date | Sat, 02 May 2020 07:14:21 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:26e78fe6e8c4 |
---|---|
1 | |
2 var renderTestResults = function(testData) { | |
3 var summary = testData["summary"]; | |
4 var numTests = summary["num_tests"]; | |
5 var numProblems = summary["num_errors"] + summary["num_failures"] + summary["num_skips"]; | |
6 var $overview = $("#overview-content"); | |
7 var $progress = $(".progress"); | |
8 if(numTests == 0) { | |
9 $overview.addClass("alert").addClass("alert-danger").text("No tests were executed."); | |
10 $progress.append($('<div class="progress-bar progress-bar-warning" role="progressbar" style="width: 100%" />')); | |
11 } else if(numProblems > 0) { | |
12 $overview.addClass("alert").addClass("alert-danger").text("There were problems with " + numProblems + " test(s) out of " + numTests + "."); | |
13 var problemPercent = (numProblems/(1.0 * numTests)) * 100.0; | |
14 var successPercent = 100.0 - problemPercent; | |
15 $progress.append($('<div class="progress-bar progress-bar-success" role="progressbar" style="width: ' + successPercent + '%" />')); | |
16 $progress.append($('<div class="progress-bar progress-bar-danger" role="progressbar" style="width: ' + problemPercent + '%" />')); | |
17 } else { | |
18 $overview.addClass("alert").addClass("alert-success").text("All " + numTests + " test(s) successfully executed."); | |
19 $progress.append($('<div class="progress-bar progress-bar-success" role="progressbar" style="width: 100%" />')); | |
20 } | |
21 | |
22 var $sidebar = $("#nav-sidebar-tests"); | |
23 for(var index in testData["tests"]) { | |
24 var test = testData["tests"][index]; | |
25 var testResult = new TestResult(index, test); | |
26 var rawId = testResult.rawId; | |
27 | |
28 var panelType = testResult.passed ? "panel-success panel-success-custom" : "panel-danger panel-danger-custom"; | |
29 var $panel = $('<div class="panel">'); | |
30 $panel.addClass(panelType); | |
31 | |
32 var $panelHeading = $('<div class="panel-heading">'); | |
33 var $panelTitle = $('<div class="panel-title">'); | |
34 var $a = $('<a class="collapsed" data-toggle="collapse">'); | |
35 $a.attr("id", rawId); | |
36 $a.attr("data-target", "#collapse" + index); | |
37 var testName = testResult.toolName + " (Test #" + (testResult.testIndex + 1) + (testResult.passed ? "" : ", Failed") + ")"; | |
38 $a.text(testName); | |
39 var $navLink = $('<a>').attr('href', '#' + rawId).text(testName) | |
40 if(!testResult.passed) { | |
41 $navLink.addClass("text-danger text-danger-custom"); | |
42 } else { | |
43 $navLink.addClass("text-success text-success-custom"); | |
44 } | |
45 $sidebar.append($('<li>').append( $navLink ) ); | |
46 $panelTitle.append($a) | |
47 $panelHeading.append($panelTitle); | |
48 | |
49 var $panelBody = $('<div class="panel-body panel-collapse collapse" >'); | |
50 $panelBody.attr("id", "collapse" + index); | |
51 | |
52 var $status = $('<div>').text("status: " + testResult.status); | |
53 $panelBody.append($status); | |
54 if(testResult.problems.length > 0) { | |
55 var $problemsLabel = $('<div>').text("problems: "); | |
56 var $problemsDiv = $('<div style="margin-left:10px;">'); | |
57 var $problemsUl = $('<ul>'); | |
58 for(var problemIndex in testResult.problems) { | |
59 $problemsUl.append($('<li>').append($('<pre>').text(testResult.problems[problemIndex]))); | |
60 } | |
61 $problemsDiv.append($problemsUl); | |
62 $panelBody.append($problemsLabel).append($problemsDiv); | |
63 } | |
64 var $commandLabel = $('<div>command:</div>'); | |
65 var $stdoutLabel = $('<div>job standard output:</div>'); | |
66 var $stderrLabel = $('<div>job standard error:</div>'); | |
67 var $command; | |
68 if(testResult.command !== null) { | |
69 $command = $('<pre class="pre-scrollable" style="margin-left:10px;">').text(testResult.command); | |
70 } else { | |
71 $command = $('<div class="alert alert-warning" style="margin-left:10px;">').text("No command recorded."); | |
72 } | |
73 var $stdout; | |
74 if(testResult.stdout !== null) { | |
75 $stdout = $('<pre class="pre-scrollable" style="margin-left:10px;">').text(testResult.stdout); | |
76 } else { | |
77 $stdout = $('<div class="alert alert-warning" style="margin-left:10px;">').text("No standard output recorded."); | |
78 } | |
79 var $stderr; | |
80 if(testResult.stderr !== null) { | |
81 $stderr = $('<pre class="pre-scrollable" style="margin-left:10px;">').text(testResult.stderr); | |
82 } else { | |
83 $stderr = $('<div class="alert alert-warning" style="margin-left:10px;">').text("No standard error recorded."); | |
84 } | |
85 $panelBody | |
86 .append($commandLabel) | |
87 .append($command) | |
88 .append($stdoutLabel) | |
89 .append($stdout) | |
90 .append($stderrLabel) | |
91 .append($stderr); | |
92 if(!testResult.passed) { | |
93 var $logLabel = $('<div>log:</div>'); | |
94 var $log = $('<pre class="pre-scrollable" style="margin-left: 10px;">').text(testResult.problemLog); | |
95 $panelBody.append($logLabel).append($log); | |
96 } | |
97 | |
98 $panel.append($panelHeading).append($panelBody); | |
99 $(".main").append($panel); | |
100 } | |
101 } | |
102 | |
103 var TestResult = function(index, data) { | |
104 this.rawId = data["id"]; | |
105 | |
106 var idParts = this.rawId.split("TestForTool_"); | |
107 var testMethod = idParts[idParts.length-1]; | |
108 var splitParts; | |
109 if(testMethod.indexOf(".test_tool_") > -1) { | |
110 splitParts = testMethod.split(".test_tool_"); | |
111 } else { | |
112 splitParts = rSplit(testMethod, "-", 1); | |
113 } | |
114 var toolName = splitParts[0]; | |
115 var testIndex; | |
116 if(data["data"]["test_index"] !== null) { | |
117 testIndex = data["data"]["test_index"]; | |
118 } else { | |
119 testIndex = splitParts[1]; | |
120 } | |
121 this.toolName = toolName; | |
122 this.testIndex = parseInt(testIndex === undefined ? index : testIndex); | |
123 this.status = data["data"]["status"]; | |
124 var job = data["data"]["job"]; | |
125 if(job) { | |
126 this.stdout = data["data"]["job"]["stdout"]; | |
127 this.stderr = data["data"]["job"]["stderr"]; | |
128 this.command = data["data"]["job"]["command_line"]; | |
129 } else { | |
130 this.stdout = null; | |
131 this.stderr = null; | |
132 this.command = null; | |
133 } | |
134 this.problems = []; | |
135 var outputProblems = data["data"]["output_problems"] || []; | |
136 var executionProblem = data["data"]["execution_problem"]; | |
137 this.problems.push.apply(this.problems, outputProblems); | |
138 if(executionProblem) { | |
139 this.problems.push(executionProblem); | |
140 } | |
141 this.problemLog = data["data"]["problem_log"]; | |
142 this.passed = (this.status == "success"); | |
143 } | |
144 | |
145 // http://stackoverflow.com/questions/5202085/javascript-equivalent-of-pythons-rsplit | |
146 function rSplit(str, sep, maxsplit) { | |
147 var split = str.split(sep); | |
148 return maxsplit ? [ split.slice(0, -maxsplit).join(sep) ].concat(split.slice(-maxsplit)) : split; | |
149 } | |
150 | |
151 | |
152 // http://stackoverflow.com/questions/19491336/get-url-parameter-jquery | |
153 function getUrlParameter(sParam) | |
154 { | |
155 var sPageURL = window.location.search.substring(1); | |
156 var sURLVariables = sPageURL.split('&'); | |
157 for (var i = 0; i < sURLVariables.length; i++) | |
158 { | |
159 var sParameterName = sURLVariables[i].split('='); | |
160 if (sParameterName[0] == sParam) | |
161 { | |
162 return sParameterName[1]; | |
163 } | |
164 } | |
165 } |