This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/directives/ui/build-log-command.js
2019-11-12 11:09:47 -05:00

49 lines
1.3 KiB
JavaScript

/**
* An element which displays a command in a build.
*/
angular.module('quay').directive('buildLogCommand', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/build-log-command.html',
replace: false,
transclude: false,
restrict: 'C',
scope: {
'command': '<command'
},
controller: function($scope, $element) {
$scope.getWithoutStep = function(fullTitle) {
var colon = fullTitle.indexOf(':');
if (colon <= 0) {
return '';
}
return $.trim(fullTitle.substring(colon + 1));
};
$scope.isSecondaryFrom = function(fullTitle) {
if (!fullTitle) { return false; }
var command = $scope.getWithoutStep(fullTitle);
return command.indexOf('FROM ') == 0 && fullTitle.indexOf('Step 1 ') < 0;
};
$scope.fromName = function(fullTitle) {
var command = $scope.getWithoutStep(fullTitle);
if (command.indexOf('FROM ') != 0) {
return null;
}
var parts = command.split(' ');
for (var i = 0; i < parts.length - 1; i++) {
var part = parts[i];
if ($.trim(part) == 'as') {
return parts[i + 1];
}
}
return null;
}
}
};
return directiveDefinitionObject;
});