mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 08:18:43 -03:30
Merge pull request #4085 from jlmitch5/updateJobResultsController
Update job results controller
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile) {
|
export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log) {
|
||||||
var getTowerLinks = function() {
|
var getTowerLinks = function() {
|
||||||
var getTowerLink = function(key) {
|
var getTowerLink = function(key) {
|
||||||
if ($scope.job.related[key]) {
|
if ($scope.job.related[key]) {
|
||||||
@@ -104,6 +104,8 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count'
|
|||||||
$scope.followTooltip = "Currently following standard out as it comes in. Click to unfollow.";
|
$scope.followTooltip = "Currently following standard out as it comes in. Click to unfollow.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.events = {};
|
||||||
|
|
||||||
// EVENT STUFF BELOW
|
// EVENT STUFF BELOW
|
||||||
|
|
||||||
// This is where the async updates to the UI actually happen.
|
// This is where the async updates to the UI actually happen.
|
||||||
@@ -153,10 +155,21 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count'
|
|||||||
|
|
||||||
if(change === 'stdout'){
|
if(change === 'stdout'){
|
||||||
// put stdout elements in stdout container
|
// put stdout elements in stdout container
|
||||||
|
|
||||||
|
// this scopes the event to that particular
|
||||||
|
// block of stdout.
|
||||||
|
// If you need to see the event a particular
|
||||||
|
// stdout block is from, you can:
|
||||||
|
// angular.element($0).scope().event
|
||||||
|
$scope.events[mungedEvent.counter] = $scope.$new();
|
||||||
|
$scope.events[mungedEvent.counter]
|
||||||
|
.event = mungedEvent;
|
||||||
|
|
||||||
angular
|
angular
|
||||||
.element(".JobResultsStdOut-stdoutContainer")
|
.element(".JobResultsStdOut-stdoutContainer")
|
||||||
.append($compile(mungedEvent
|
.append($compile(mungedEvent
|
||||||
.stdout)($scope));
|
.stdout)($scope.events[mungedEvent
|
||||||
|
.counter]));
|
||||||
|
|
||||||
// move the followAnchor to the bottom of the
|
// move the followAnchor to the bottom of the
|
||||||
// container
|
// container
|
||||||
@@ -166,6 +179,11 @@ export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count'
|
|||||||
// if follow is engaged,
|
// if follow is engaged,
|
||||||
// scroll down to the followAnchor
|
// scroll down to the followAnchor
|
||||||
if ($scope.followEngaged) {
|
if ($scope.followEngaged) {
|
||||||
|
if (!$scope.followScroll) {
|
||||||
|
$scope.followScroll = function() {
|
||||||
|
$log.error("follow scroll undefined, standard out directive not loaded yet?");
|
||||||
|
};
|
||||||
|
}
|
||||||
$scope.followScroll();
|
$scope.followScroll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ describe('Controller: jobResultsController', () => {
|
|||||||
// Setup
|
// Setup
|
||||||
let jobResultsController;
|
let jobResultsController;
|
||||||
|
|
||||||
let jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, eventResolve, populateResolve, $rScope, q;
|
let jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, eventResolve, populateResolve, $rScope, q, $log;
|
||||||
|
|
||||||
jobData = {
|
jobData = {
|
||||||
related: {}
|
related: {}
|
||||||
@@ -39,7 +39,6 @@ describe('Controller: jobResultsController', () => {
|
|||||||
'populate',
|
'populate',
|
||||||
'markProcessed'
|
'markProcessed'
|
||||||
]);
|
]);
|
||||||
$compile = jasmine.createSpy('$compile');
|
|
||||||
|
|
||||||
$provide.value('jobData', jobData);
|
$provide.value('jobData', jobData);
|
||||||
$provide.value('jobDataOptions', jobDataOptions);
|
$provide.value('jobDataOptions', jobDataOptions);
|
||||||
@@ -50,12 +49,11 @@ describe('Controller: jobResultsController', () => {
|
|||||||
$provide.value('ParseVariableString', ParseVariableString);
|
$provide.value('ParseVariableString', ParseVariableString);
|
||||||
$provide.value('jobResultsService', jobResultsService);
|
$provide.value('jobResultsService', jobResultsService);
|
||||||
$provide.value('eventQueue', eventQueue);
|
$provide.value('eventQueue', eventQueue);
|
||||||
$provide.value('$compile', $compile);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let injectVals = () => {
|
let injectVals = () => {
|
||||||
angular.mock.inject((_jobData_, _jobDataOptions_, _jobLabels_, _jobFinished_, _count_, _ParseTypeChange_, _ParseVariableString_, _jobResultsService_, _eventQueue_, _$compile_, $rootScope, $controller, $q, $httpBackend) => {
|
angular.mock.inject((_jobData_, _jobDataOptions_, _jobLabels_, _jobFinished_, _count_, _ParseTypeChange_, _ParseVariableString_, _jobResultsService_, _eventQueue_, _$compile_, $rootScope, $controller, $q, $httpBackend, _$log_) => {
|
||||||
// when you call $scope.$apply() (which you need to do to
|
// when you call $scope.$apply() (which you need to do to
|
||||||
// to get inside of .then blocks to test), something is
|
// to get inside of .then blocks to test), something is
|
||||||
// causing a request for all static files.
|
// causing a request for all static files.
|
||||||
@@ -81,6 +79,7 @@ describe('Controller: jobResultsController', () => {
|
|||||||
ParseVariableString.and.returnValue(jobData.extra_vars);
|
ParseVariableString.and.returnValue(jobData.extra_vars);
|
||||||
jobResultsService = _jobResultsService_;
|
jobResultsService = _jobResultsService_;
|
||||||
eventQueue = _eventQueue_;
|
eventQueue = _eventQueue_;
|
||||||
|
$log = _$log_;
|
||||||
|
|
||||||
jobResultsService.getEvents.and
|
jobResultsService.getEvents.and
|
||||||
.returnValue($q.when(eventResolve));
|
.returnValue($q.when(eventResolve));
|
||||||
@@ -99,7 +98,8 @@ describe('Controller: jobResultsController', () => {
|
|||||||
ParseTypeChange: ParseTypeChange,
|
ParseTypeChange: ParseTypeChange,
|
||||||
jobResultsService: jobResultsService,
|
jobResultsService: jobResultsService,
|
||||||
eventQueue: eventQueue,
|
eventQueue: eventQueue,
|
||||||
$compile: $compile
|
$compile: $compile,
|
||||||
|
$log: $log
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -554,6 +554,31 @@ describe('Controller: jobResultsController', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: stdout change tests
|
describe('populate - stdout', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
|
||||||
|
populateResolve = {
|
||||||
|
counter: 12,
|
||||||
|
stdout: "line",
|
||||||
|
changes: ['stdout']
|
||||||
|
};
|
||||||
|
|
||||||
|
bootstrapTest();
|
||||||
|
|
||||||
|
spyOn($log, 'error');
|
||||||
|
|
||||||
|
$scope.followEngaged = true;
|
||||||
|
|
||||||
|
$scope.$apply();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('creates new child scope for the event', () => {
|
||||||
|
expect($scope.events[12].event).toBe(populateResolve);
|
||||||
|
|
||||||
|
// in unit test, followScroll should not be defined as
|
||||||
|
// directive has not been instantiated
|
||||||
|
expect($log.error).toHaveBeenCalledWith("follow scroll undefined, standard out directive not loaded yet?");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user