зеркало из https://github.com/mozilla/treeherder.git
markup full log directive
This commit is contained in:
Родитель
16a29a5ff6
Коммит
ba3b614cd9
|
@ -34,4 +34,9 @@ body{
|
|||
.lv-log-line {
|
||||
width: 100%;
|
||||
float: left;
|
||||
}
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
.lv-line-highlight {
|
||||
background-color: LightGrey;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var treeherder = angular.module('treeherder',
|
||||
['ngResource','ui.bootstrap', 'ngSanitize']);
|
||||
['ngResource','ui.bootstrap', 'ngSanitize', 'treeherder.directives']);
|
||||
|
||||
treeherder.config(function($routeProvider, $httpProvider) {
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
treeherder.controller('LogviewerCtrl',
|
||||
function Logviewer($scope, $rootScope, $location, $routeParams, $http, $timeout, thArtifact) {
|
||||
function Logviewer($anchorScroll, $scope, $rootScope, $location, $routeParams, $http, $timeout, thArtifact) {
|
||||
|
||||
if ($location.$$search.hasOwnProperty("repo") &&
|
||||
$location.$$search.repo !== "") {
|
||||
|
@ -13,19 +13,11 @@ treeherder.controller('LogviewerCtrl',
|
|||
}
|
||||
|
||||
|
||||
$scope.jsonObj = {};
|
||||
$scope.displayedStep;
|
||||
|
||||
// @@@ should this be a directive?
|
||||
// @@@ making me re-think my request to not use jquery. jquery would be better
|
||||
// than getElementById. Though seems like there must be a $scope way to
|
||||
// do this?
|
||||
$scope.scrollTo = function(step, linenumber) {
|
||||
if($scope.displayedStep === step) {
|
||||
var pos = document.getElementById("lv-line-"+linenumber).offsetTop -
|
||||
document.getElementById("lv-log-container").offsetTop;
|
||||
document.getElementById("lv-log-container").scrollTop = pos;
|
||||
}
|
||||
$location.hash('lv-line-'+linenumber);
|
||||
$anchorScroll();
|
||||
};
|
||||
|
||||
// @@@ it may be possible to do this with the angular date filter?
|
||||
|
@ -47,85 +39,20 @@ treeherder.controller('LogviewerCtrl',
|
|||
|
||||
$scope.displayLog = function(step) {
|
||||
$scope.displayedStep = step;
|
||||
var start = step.started_linenumber;
|
||||
var end = step.finished_linenumber+1;
|
||||
var errors = step.errors;
|
||||
|
||||
// @@@ I think we should only fetch the log once and keep it
|
||||
// in the scope. Then we can slice that to the start/end and
|
||||
// display the appropriate part.
|
||||
|
||||
// @@@ we should display some kind of "loading" indicator in the
|
||||
// logs area in case the log is really large
|
||||
|
||||
$http.get($scope.logUrl).
|
||||
success(function(data) {
|
||||
data = data.split("\n").slice(start, end);
|
||||
|
||||
$scope.log_text = [];
|
||||
data.forEach(function(item) {
|
||||
$scope.log_text.push({
|
||||
text: item,
|
||||
hasError: false
|
||||
});
|
||||
});
|
||||
if(errors.length > 0) {
|
||||
errors.forEach(function(err) {
|
||||
$scope.log_text[err.linenumber-start].hasError = true;
|
||||
$scope.log_text[err.linenumber-start].errLine = err.linenumber;
|
||||
|
||||
});
|
||||
}
|
||||
}).
|
||||
error(function(data, status, headers, config) {
|
||||
console.log("error" + data + status +headers + config);
|
||||
});
|
||||
$scope.log_text = $scope.full_log[step.order];
|
||||
};
|
||||
|
||||
$scope.init = function() {
|
||||
thArtifact.getArtifact($scope.lvArtifactId).
|
||||
success(function(data) {
|
||||
$scope.jsonObj = data.blob;
|
||||
$scope.logUrl = data.blob.logurl;
|
||||
console.log("logUrl: " + $scope.logUrl);
|
||||
});
|
||||
|
||||
$http.get('resources/logs/mozilla-inbound_ubuntu64_vm-debug_test-mochitest-other-bm53-tests1-linux-build122.logview.json').success(function(data) {
|
||||
$scope.jsonObj = data;
|
||||
});
|
||||
$http.get('resources/logs/mozilla-inbound_ubuntu64_vm-debug_test-mochitest-other-bm53-tests1-linux-build122.txt').success(function(data) {
|
||||
$scope.logData = data.split("\n");
|
||||
});
|
||||
};
|
||||
|
||||
$scope.insertText = function(data, start, end, errors) {
|
||||
var logviewer = document.getElementById("lv_logview");
|
||||
logviewer.innerText = '';
|
||||
var offset = start;
|
||||
var startText = data.splice(0, 1);
|
||||
var startDiv = document.createElement("div");
|
||||
startDiv.className = "lv-purple-font";
|
||||
startDiv.appendChild(document.createTextNode(startText[0]));
|
||||
logviewer.appendChild(startDiv);
|
||||
var endText = data.splice(-1, 1);
|
||||
var endDiv = document.createElement("div");
|
||||
endDiv.className = "lv-purple-font";
|
||||
endDiv.appendChild(document.createTextNode(endText[0]));
|
||||
|
||||
if(errors.length > 0) {
|
||||
errors.forEach(function(err) {
|
||||
var tempData = data.splice(0, err.linenumber-offset-1);
|
||||
var tempText = tempData.join("\n");
|
||||
logviewer.appendChild(document.createTextNode(tempText));
|
||||
var errData = data.splice(0, 1);
|
||||
var errDiv = document.createElement("div");
|
||||
errDiv.className = "label label-important lv-logview-error lv-line-"+err.linenumber;
|
||||
errDiv.appendChild(document.createTextNode(errData[0]));
|
||||
logviewer.appendChild(errDiv);
|
||||
offset = err.linenumber;
|
||||
});
|
||||
var lastDiv = document.createTextNode(data.join("\n"));
|
||||
logviewer.appendChild(lastDiv);
|
||||
}
|
||||
else {
|
||||
logviewer.appendChild(document.createTextNode(data.join("\n")));
|
||||
}
|
||||
logviewer.appendChild(endDiv);
|
||||
document.getElementById("lv_logview_holder").scrollTop = 0;
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
|
|
|
@ -1,3 +1,36 @@
|
|||
'use strict';
|
||||
|
||||
/* Directives */
|
||||
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);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
<link href="css/treeherder.css" rel="stylesheet" type="text/css">
|
||||
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
|
||||
</head>
|
||||
<body ng-controller="LogviewerCtrl">
|
||||
<body ng-controller="LogviewerCtrl" ng-init="init()">
|
||||
<div process-log></div>
|
||||
<div class="container-fluid">
|
||||
<div ng-init="init()" class="row-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<dl class="dl-horizontal">
|
||||
<span ng-repeat="(label, value) in jsonObj.header">
|
||||
|
@ -30,6 +31,7 @@
|
|||
<div ng-repeat="error in step.errors"
|
||||
ng-mouseover="check=(step==displayedStep)"
|
||||
ng-mouseleave="check=false"
|
||||
ng-class="{'lv-line-highlight': check}"
|
||||
ng-click="scrollTo(step, error.linenumber);
|
||||
$event.stopPropagation()"
|
||||
class="text-left pull-left lv-error-line">
|
||||
|
|
Загрузка…
Ссылка в новой задаче