2015-03-10 05:03:39 +00:00
|
|
|
/**
|
|
|
|
* An element which displays the information panel for a repository view.
|
|
|
|
*/
|
|
|
|
angular.module('quay').directive('repoPanelInfo', function () {
|
|
|
|
var directiveDefinitionObject = {
|
|
|
|
priority: 0,
|
|
|
|
templateUrl: '/static/directives/repo-view/repo-panel-info.html',
|
|
|
|
replace: false,
|
|
|
|
transclude: false,
|
|
|
|
restrict: 'C',
|
|
|
|
scope: {
|
2015-03-11 00:22:46 +00:00
|
|
|
'repository': '=repository',
|
2015-11-12 20:42:45 +00:00
|
|
|
'builds': '=builds',
|
|
|
|
'isEnabled': '=isEnabled'
|
2015-03-10 05:03:39 +00:00
|
|
|
},
|
2017-08-07 19:24:36 +00:00
|
|
|
controller: function($scope, $element, ApiService, Config, Features) {
|
|
|
|
$scope.Features = Features;
|
|
|
|
|
2015-03-19 19:08:18 +00:00
|
|
|
$scope.$watch('repository', function(repository) {
|
|
|
|
if (!$scope.repository) { return; }
|
|
|
|
|
|
|
|
var namespace = $scope.repository.namespace;
|
|
|
|
var name = $scope.repository.name;
|
|
|
|
|
|
|
|
$scope.pullCommand = 'docker pull ' + Config.getDomain() + '/' + namespace + '/' + name;
|
|
|
|
});
|
|
|
|
|
2015-03-10 05:03:39 +00:00
|
|
|
$scope.updateDescription = function(content) {
|
|
|
|
$scope.repository.description = content;
|
|
|
|
$scope.repository.put();
|
|
|
|
};
|
2016-06-22 18:50:59 +00:00
|
|
|
|
|
|
|
$scope.getAggregatedUsage = function(stats, days) {
|
2016-06-22 19:43:15 +00:00
|
|
|
if (!stats || !stats.length) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-22 18:50:59 +00:00
|
|
|
var count = 0;
|
|
|
|
var startDate = moment().subtract(days + 1, 'days');
|
|
|
|
for (var i = 0; i < stats.length; ++i) {
|
|
|
|
var stat = stats[i];
|
|
|
|
var statDate = moment(stat['date']);
|
|
|
|
if (statDate.isBefore(startDate)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
count += stat['count'];
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
};
|
2015-03-10 05:03:39 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
return directiveDefinitionObject;
|
|
|
|
});
|