2015-02-19 21:21:54 +00:00
|
|
|
/**
|
|
|
|
* 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'
|
|
|
|
},
|
2015-08-20 23:24:51 +00:00
|
|
|
controller: function($scope, $element, ApiService) {
|
2015-02-19 21:21:54 +00:00
|
|
|
$scope.building = false;
|
|
|
|
$scope.uploading = false;
|
|
|
|
$scope.startCounter = 0;
|
2015-08-20 23:24:51 +00:00
|
|
|
$scope.viewTriggers = false;
|
|
|
|
$scope.triggers = null;
|
|
|
|
$scope.startTriggerCounter = 0;
|
|
|
|
$scope.startTrigger = null;
|
2015-02-19 21:21:54 +00:00
|
|
|
|
|
|
|
$scope.handleBuildStarted = function(build) {
|
2015-08-20 23:24:51 +00:00
|
|
|
$element.find('.dockerfilebuildModal').modal('hide');
|
2015-02-19 21:21:54 +00:00
|
|
|
if ($scope.buildStarted) {
|
|
|
|
$scope.buildStarted({'build': build});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.handleBuildFailed = function(message) {
|
|
|
|
$scope.errorMessage = message;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.startBuild = function() {
|
|
|
|
$scope.errorMessage = null;
|
|
|
|
$scope.startCounter++;
|
|
|
|
};
|
|
|
|
|
2015-08-20 23:24:51 +00:00
|
|
|
$scope.showTriggers = function(value) {
|
|
|
|
$scope.viewTriggers = value;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.runTriggerNow = function(trigger) {
|
|
|
|
$element.find('.dockerfilebuildModal').modal('hide');
|
|
|
|
$scope.startTrigger = trigger;
|
|
|
|
$scope.startTriggerCounter++;
|
|
|
|
};
|
|
|
|
|
2015-02-19 21:21:54 +00:00
|
|
|
$scope.$watch('showNow', function(sn) {
|
|
|
|
if (sn && $scope.repository) {
|
2015-08-20 23:24:51 +00:00
|
|
|
$scope.viewTriggers = false;
|
|
|
|
$scope.startTrigger = null;
|
2015-10-16 17:34:10 +00:00
|
|
|
$scope.errorMessage = null;
|
2015-08-20 23:24:51 +00:00
|
|
|
|
|
|
|
$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;
|
|
|
|
});
|
2015-02-19 21:21:54 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return directiveDefinitionObject;
|
|
|
|
});
|