зеркало из https://github.com/mozilla/treeherder.git
updates to logviewer to use controller to split raw log for viewing. directive wasn't the right call.
This commit is contained in:
Родитель
44f6f02e74
Коммит
71a1c715f0
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var treeherder = angular.module('treeherder',
|
||||
['ngResource','ui.bootstrap', 'ngSanitize', 'treeherder.directives']);
|
||||
['ngResource','ui.bootstrap', 'ngSanitize']);
|
||||
|
||||
treeherder.config(function($routeProvider, $httpProvider) {
|
||||
|
||||
|
|
|
@ -38,25 +38,50 @@ treeherder.controller('LogviewerCtrl',
|
|||
$scope.displayLog = function(step) {
|
||||
$scope.displayedStep = step;
|
||||
|
||||
// @@@ we should display some kind of "loading" indicator in the
|
||||
// logs area in case the log is really large
|
||||
$scope.log_text = $scope.full_log[step.order];
|
||||
|
||||
//so that all displayed steps are auto scrolled to top
|
||||
$timeout(function() {
|
||||
document.getElementById("lv-log-container").scrollTop = 0;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.sliceLog = function(data) {
|
||||
// split the log into chunks. Non-error sections are one large
|
||||
// chunk separated by \n. Each error gets its own chunk.
|
||||
|
||||
$scope.artifact.step_data.steps.forEach(function(step) {
|
||||
// slice up the raw log and add those pieces to the artifact step.
|
||||
step.logPieces = [];
|
||||
var offset = step.started_linenumber;
|
||||
step.errors.forEach(function(err) {
|
||||
var end = err.linenumber;
|
||||
if (offset !== end) {
|
||||
step.logPieces.push({
|
||||
text: (data.slice(offset, end)).join('\n'),
|
||||
hasError: false
|
||||
});
|
||||
}
|
||||
step.logPieces.push({
|
||||
text: data.slice(end, end+1),
|
||||
hasError: true,
|
||||
errLine: end
|
||||
});
|
||||
offset = end+1;
|
||||
});
|
||||
step.logPieces.push({
|
||||
text: (data.slice(offset, step.finished_linenumber+1)).join('\n'),
|
||||
hasError: false
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.init = function() {
|
||||
thArtifact.getArtifact($scope.lvArtifactId).
|
||||
success(function(data) {
|
||||
$scope.jsonObj = data.blob;
|
||||
$scope.artifact = data.blob;
|
||||
$scope.logurl = data.blob.logurl;
|
||||
console.log("logUrl: " + $scope.logurl);
|
||||
$http.get($scope.logurl).
|
||||
success(function(data) {
|
||||
$scope.logData = data.split("\n");
|
||||
$scope.sliceLog(data.split("\n"));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,36 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('treeherder.directives', []).
|
||||
directive('processLog', function() {
|
||||
return function(scope, element, attrs){
|
||||
scope.$watch('logData', function(data) {
|
||||
if(data) {
|
||||
scope.full_log = [];
|
||||
scope.jsonObj.step_data.steps.forEach(function(step) {
|
||||
var offset = step.started_linenumber;
|
||||
var procStep = [];
|
||||
step.errors.forEach(function(err) {
|
||||
var end = err.linenumber;
|
||||
if (offset !== end) {
|
||||
procStep.push({
|
||||
text: (data.slice(offset, end)).join('\n'),
|
||||
hasError: false
|
||||
});
|
||||
}
|
||||
procStep.push({
|
||||
text: data.slice(end, end+1),
|
||||
hasError: true,
|
||||
errLine: end
|
||||
});
|
||||
offset = end+1;
|
||||
});
|
||||
procStep.push({
|
||||
text: (data.slice(offset, step.finished_linenumber+1)).join('\n'),
|
||||
hasError: false
|
||||
});
|
||||
scope.full_log.push(procStep);
|
||||
});
|
||||
}
|
||||
/* Directives */
|
||||
treeherder.directive('ngRightClick', function($parse) {
|
||||
return function(scope, element, attrs) {
|
||||
var fn = $parse(attrs.ngRightClick);
|
||||
element.bind('contextmenu', function(event) {
|
||||
scope.$apply(function() {
|
||||
event.preventDefault();
|
||||
fn(scope, {$event:event});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
|
@ -6,18 +6,17 @@
|
|||
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
|
||||
</head>
|
||||
<body ng-controller="LogviewerCtrl" ng-init="init()">
|
||||
<div process-log></div>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<dl class="dl-horizontal">
|
||||
<span ng-repeat="(label, value) in jsonObj.header">
|
||||
<span ng-repeat="(label, value) in artifact.header">
|
||||
<dt class="label label-info">{{label}}</dt>
|
||||
<dd class="">{{value}}</dd>
|
||||
</span>
|
||||
</dl>
|
||||
<div class="row-fluid" >
|
||||
<div ng-repeat="step in jsonObj.step_data.steps"
|
||||
<div ng-repeat="step in artifact.step_data.steps"
|
||||
ng-class="{'btn-warning': (step.error_count > 0), 'btn-success': (step.error_count == 0)}"
|
||||
ng-click="displayLog(step)"
|
||||
class="btn btn-block clearfix">
|
||||
|
@ -45,8 +44,7 @@
|
|||
</div>
|
||||
<div class="span6 lv-log-container container well"
|
||||
id="lv-log-container">
|
||||
<div ng-bind="log_html"></div>
|
||||
<div ng-repeat="lv_line in log_text"
|
||||
<div ng-repeat="lv_line in displayedStep.logPieces"
|
||||
ng-class="{'label label-important': (lv_line.hasError == true)}"
|
||||
class="lv-log-line"
|
||||
id="lv-line-{{ lv_line.errLine }}">
|
||||
|
|
Загрузка…
Ссылка в новой задаче