var app = angular.module("TreeTestReportApp", ['treeGrid', 'ui.bootstrap', 'angular-clipboard']) .directive('selectOnClick', ['$window', function ($window) { return { link: function (scope, element) { element.on('click', function () { var selection = $window.getSelection(); var range = document.createRange(); range.selectNodeContents(element[0]); selection.removeAllRanges(); selection.addRange(range); }); } }; }]) .directive('preEx', function () { return { restrict: 'E', replace: true, transclude: true, scope: { title: '@', text: '=', textArray: '=', }, template: "
", link: function (scope, elm, attrs, ctrl) { if (!scope.text && !scope.textArray) { console.log('No data was defined for the directive!'); return; } var singleTextRowTemplate = "
{{::title}}
{{::value}}
"; if(scope.text) { scope.temp = singleTextRowTemplate; scope.value = scope.text; } else if(scope.textArray) { if(scope.textArray.length === 1) { scope.value = scope.textArray[0]; scope.temp = singleTextRowTemplate; } else { scope.temp = "

{{::title}}

{{::text}}
"; scope.value = scope.textArray; } } scope.success = function() { console.log('copied'); } scope.fail = function () { console.log('copy failed'); } } }; }) .directive('detailsWrapper', function () { return { restrict: 'E', replace: true, transclude: true, scope: { iconClass: '@' }, template: "
", link: function (scope, elm, attrs, ctrl) { } }; }) .controller("TreeController", function($scope, $timeout){ angular.element(function () { $timeout(function() { $scope.my_tree.expand_all_error(); }, 0); }); $scope.today = new Date(); var data = JSON.parse(document.getElementById("data").innerHTML); //$scope.expand_to = {}; $scope.row_filter = {filtered: true}; $scope.filter = {}; $scope.filter.info = {value: false, type: 'Info'}; $scope.filter.warning = {value: false, type: 'Warning'}; $scope.filter.error = {value: true, type: 'Error'}; $scope.filter.artifact = {value: false, type: 'ArtifactPublish'}; $scope.filters = ['Info', 'InfoPartial', 'Warning', 'ArtifactPublish']; $scope.filterSelected = function(model){ if(!model.value) { $scope.filters.push(model.type); } else { var index = $scope.filters.indexOf(model.type); if(index !== -1) $scope.filters.splice(index, 1); } } $scope.additionalFilter = { filterPropertyKey: 'type', filterPropertyValue: 'TestStatus', filterAttribute: 'state', filterAttributeValues: ['1', '2', '3', '4', '7'], hideSuccessfulSuites: true // temporary property, should be changed to something more generic as the other properties }; $scope.testStatusFilter = {}; $scope.testStatusFilter.ignored = {selected: false, values: ['1', '2', '3', '7']}; // NotRunnable = 1, Skipped = 2, Ignored = 3, Cancelled = 7 $scope.testStatusFilter.passed = {selected: false, values: ['4']}; $scope.testStatusFilter.failed = {selected: true, values: ['5','6']}; // Failure = 5, Error = 6 $scope.testStatusFilter.inconclusive = {selected: true, values: ['0']}; $scope.testStatusFilter.hideSuccessfulSuites = true; $scope.testStatusFilterChanged = function(model){ if(!model.selected) { for(var i=0; i 0 && branch.children.length === 0; } $scope.getIconByTestState = function(state) { switch(state) { case 5: case 6: return "glyphicon glyphicon-minus-sign icon-red"; case 1: case 2: case 3: case 7: return "glyphicon glyphicon-question-sign icon-gray"; case 0: return "glyphicon glyphicon-exclamation-sign icon-yellow"; case 4: return "glyphicon glyphicon-ok-sign icon-green"; } } $scope.onLeafNodeCreate = function(branch){ var type = branch['type']; if(type === 'TestStatus') { return $scope.getIconByTestState(branch['state']) + " leaf-icon"; //return branch['state'] === 5 || branch['state'] === 6 ? "glyphicon glyphicon-remove-sign icon-red" : "glyphicon glyphicon-ok-sign icon-green"; } if(type === 'Info' || type === 'InfoPartial') { return "glyphicon glyphicon-file icon-blue leaf-icon"; } if(type === 'Warning') { return "glyphicon glyphicon-file icon-yellow leaf-icon"; } if(type === 'Error') { return "glyphicon glyphicon-file icon-red leaf-icon"; } if(type === 'TestPlan') { return "glyphicon glyphicon-list-alt icon-black leaf-icon"; } if(type === 'AssemblyCompilationErrors') { return "glyphicon glyphicon-remove-sign icon-red leaf-icon"; } return "glyphicon glyphicon-file leaf-icon"; //return $scope.icons_defs[branch['type']] ? $scope.icons_defs[branch['type']] : $scope.icons_defs['default']; } //var errorsMarkup = "

0\">Errors ({{row.branch['errors'].length}}):

" + // ""; var errorsMarkup = "

0\">

"; var artifactsMarkup = "

0\">Artifacts ({{::row.branch['artifacts'].length}}):

"; $scope.details_defs = { default: "
{{::row.branch['message'] ? row.branch['message'] : row.branch['description']}}
" + "

" + errorsMarkup, ArtifactPublish: "

{{::row.branch['destination']}}
", ProcessInfo: "
" + "" + "

Process Id: {{::row.branch['processId']}}

"+ "

"+ "

"+ errorsMarkup + artifactsMarkup + "
" + "
", TestGroup: "
" + "" + artifactsMarkup + errorsMarkup + "" + "
", TestPlan: "
"+ "" + "

Ready to run {{::row.branch['tests'].length}} tests:

  • {{::t}}
" + "
" + "
", TestSuite: "
" + "" + "

Name: {{::row.branch['name']}}

" + "

Scope: {{::row.branch['scope']}}

" + "

Platform: {{::row.branch['platform']}}

" + "

"+ artifactsMarkup + errorsMarkup + "
" + "
", TestStatus: "
" + "" + //"
" + "

Test Name: {{::row.branch['name']}}

" + "

Test Fixture: {{::row.branch['fixture']}}

" + "

Test Status: {{::row.branch['state'] ? $parent.$parent.$parent.$parent.$parent.convertTestStateToString(row.branch['state']) : $parent.$parent.$parent.$parent.$parent.convertTestStateToString(0)}}

" + "

Test Execution Time: {{::row.branch['durationMicroseconds'] ? (row.branch['durationMicroseconds']/1000).toHHMMSS() : (row.branch['duration']).toHHMMSS()}}

" + "

"+ "

"+ artifactsMarkup + errorsMarkup + //"
"+ "
" + "
", AssemblyCompilationErrors: "
" + "" + "

Assembly: {{::row.branch['assembly']}}

" + errorsMarkup + "
" + "
", TestSession: "
" + "" + //"
" + "

Run {{::row.branch['summary'].testsCount}} test(s). Passed: {{::row.branch['summary'].successCount}}, Failed: {{::row.branch['summary'].failedCount + row.branch['summary'].errorCount}}, Inconclusive: {{::row.branch['summary'].inconclusiveCount}}, Ignored: {{::row.branch['summary'].ignoredCount}}, Skipped: {{::row.branch['summary'].skippedCount}}, Not Runnable: {{::row.branch['summary'].notRunCount}}

" + "

Overall result: {{::row.branch['summary'].success ? 'PASS' : 'FAIL'}}

" + "

Suites count: {{::row.branch['summary'].suitesCount}}

" + "

"+ artifactsMarkup + errorsMarkup + //"
"+ "
" + "
", Action: "
" + "" + "

Name: {{::row.branch['name']}}

" + artifactsMarkup + errorsMarkup + "
" + "
", }; $scope.formatCommandLine = function(cmdParams) { if(cmdParams == null || cmdParams.length === 0) { return ""; } var cmdLine = "perl utr.pl "; for(var i=0; i{{::row.branch['destination']}}", ProcessInfo: "
{{::row.branch['path']}}
", TestPlan: "
Ready to run {{::row.branch['tests'].length}} tests
", TestStatus: "
{{::row.branch['name']}}
", TestSuite: "
Run {{::row.branch['name']}} tests for {{::row.branch['scope']}}: PASS ({{::row.branch['summary'].successCount}} test(s) passed)
" + "
0\" class=\"clipped\">Run {{::row.branch['name']}} tests for {{::row.branch['scope']}}: FAIL ({{::row.branch['summary'].successCount}} test(s) passed, {{::row.branch['summary'].failedCount + row.branch['summary'].errorCount + row.branch['summary'].inconclusiveCount}} test(s) failed, {{::row.branch['summary'].compilationErrorsCount}} compilation errors)
", Info: "
{{::row.branch['message']}}
", Warning: "
{{::row.branch['message']}}
", Error: "
{{::row.branch['message']}}
", InfoPartial: "
{{::row.branch['message']}}
", AssemblyCompilationErrors: "
Assembly compilation failed: {{::row.branch['assembly']}}
", TestSession: "
{{::row.branch['summary'].success ? 'Test Session Passed' : 'Test Session Failed'}}: {{::row.branch['summary'].successCount}} test(s) passed, {{::row.branch['summary'].failedCount + row.branch['summary'].errorCount + row.branch['summary'].inconclusiveCount}} test(s) failed, {{::row.branch['summary'].compilationErrorsCount}} compilation error(s)
", TestGroup: "
{{::row.branch['name']}}
", default: "
{{::row.branch['name']}} {{::row.branch['description']}}
", }, filterable: true, width: "65%" } $scope.col_defs = [ { field: "time", displayName: "Time", cellCustomTemplate: { default: "
{{::row.branch[col.field] | date : \"HH:mm:ss\"}}
" }, width: "5%", class: "text-right", }, { displayName: "Artifacts", cellCustomTemplate: { //default: "
" //default: "" default: "
0\"> {{::row.branch['artifacts'].length}}
" }, width: "23%" }, { field: "duration", displayName: "Duration", width: "7%", cellCustomTemplate: { default: "
{{::row.branch['durationMicroseconds'] ? (row.branch['durationMicroseconds']/1000).toHHMMSS() : (row.branch['duration']).toHHMMSS()}}
" }, class: "text-right", //sortable : true, //filterable : true }, ]; }); Number.prototype.toHHMMSS = function () { //var sec_num = parseInt(this, 10); sec_num = this / 1000; if(sec_num < 0.0005) return "0"; var hours = Math.floor(sec_num / 3600); var minutes = Math.floor((sec_num - (hours * 3600)) / 60); var seconds = sec_num - (hours * 3600) - (minutes * 60); if (hours < 10) {hours = "0"+hours;} if (minutes < 10) {minutes = "0"+minutes;} if (seconds < 10) {seconds = "0"+seconds.toFixed(3);} else {seconds = seconds.toFixed(3);} return hours+':'+minutes+':'+seconds; };