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/dockerfile-build-dialog.js

78 lines
2.3 KiB
JavaScript
Raw Normal View History

/**
* An element which displays a dialog for manually starting a dockerfile build.
*/
angular.module('quay').directive('dockerfileBuildDialog', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/dockerfile-build-dialog.html',
replace: false,
transclude: false,
restrict: 'C',
scope: {
'repository': '=repository',
'showNow': '=showNow',
'buildStarted': '&buildStarted'
},
controller: function($scope, $element, ApiService) {
$scope.building = false;
$scope.uploading = false;
$scope.startCounter = 0;
$scope.viewTriggers = false;
$scope.triggers = null;
$scope.startTriggerCounter = 0;
$scope.startTrigger = null;
$scope.handleBuildStarted = function(build) {
$element.find('.dockerfilebuildModal').modal('hide');
if ($scope.buildStarted) {
$scope.buildStarted({'build': build});
}
};
$scope.handleBuildFailed = function(message) {
$scope.errorMessage = message;
};
$scope.startBuild = function() {
$scope.errorMessage = null;
$scope.startCounter++;
};
$scope.showTriggers = function(value) {
$scope.viewTriggers = value;
};
$scope.runTriggerNow = function(trigger) {
$element.find('.dockerfilebuildModal').modal('hide');
$scope.startTrigger = trigger;
$scope.startTriggerCounter++;
};
$scope.$watch('showNow', function(sn) {
if (sn && $scope.repository) {
$scope.viewTriggers = false;
$scope.startTrigger = null;
$element.find('.dockerfilebuildModal').modal({});
// Load the triggers (if necessary).
if (!$scope.repository || !$scope.repository.can_admin) {
$scope.triggersResource = null;
$scope.triggers = null;
return;
}
var params = {
'repository': $scope.repository.namespace + '/' + $scope.repository.name
};
$scope.triggersResource = ApiService.listBuildTriggersAsResource(params).get(function(resp) {
$scope.triggers = resp.triggers;
$scope.viewTriggers = $scope.triggers.length > 0;
});
}
});
}
};
return directiveDefinitionObject;
});