2016-06-14 07:56:25 +02:00
|
|
|
(function() {
|
|
|
|
|
2016-07-01 12:37:17 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.top.repository')
|
|
|
|
.directive('topRepository', topRepository);
|
2016-06-14 07:56:25 +02:00
|
|
|
|
2016-07-01 12:37:17 +02:00
|
|
|
TopRepositoryController.$inject = ['$scope', 'ListTopRepositoryService', '$filter', 'trFilter'];
|
|
|
|
|
|
|
|
function TopRepositoryController($scope, ListTopRepositoryService, $filter, trFilter) {
|
|
|
|
var vm = this;
|
2016-06-14 07:56:25 +02:00
|
|
|
|
2016-07-01 12:37:17 +02:00
|
|
|
ListTopRepositoryService(5)
|
|
|
|
.success(listTopRepositorySuccess)
|
|
|
|
.error(listTopRepositoryFailed);
|
|
|
|
|
|
|
|
function listTopRepositorySuccess(data) {
|
|
|
|
vm.top10Repositories = data || [];
|
2016-06-14 07:56:25 +02:00
|
|
|
}
|
2016-07-01 12:37:17 +02:00
|
|
|
|
|
|
|
function listTopRepositoryFailed(data, status) {
|
|
|
|
$scope.$emit('modalTitle', $filter('tr')('error'));
|
2016-07-04 06:34:34 +02:00
|
|
|
$scope.$emit('modalMessage', $filter('tr')('failed_to_get_top_repo'));
|
2016-07-01 12:37:17 +02:00
|
|
|
$scope.$emit('raiseError', true);
|
2016-07-04 06:34:34 +02:00
|
|
|
console.log('Failed to get top repo:' + data);
|
2016-06-14 07:56:25 +02:00
|
|
|
}
|
2016-07-01 12:37:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function topRepository() {
|
|
|
|
var directive = {
|
|
|
|
'restrict': 'E',
|
|
|
|
'templateUrl': '/static/resources/js/components/top-repository/top-repository.directive.html',
|
|
|
|
'controller': TopRepositoryController,
|
|
|
|
'scope' : {
|
|
|
|
'customBodyHeight': '='
|
|
|
|
},
|
|
|
|
'controllerAs': 'vm',
|
|
|
|
'bindToController': true
|
|
|
|
};
|
|
|
|
return directive;
|
|
|
|
}
|
2016-06-14 07:56:25 +02:00
|
|
|
|
2016-06-28 08:17:28 +02:00
|
|
|
})();
|