mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-29 05:35:43 +01:00
53 lines
1.1 KiB
JavaScript
53 lines
1.1 KiB
JavaScript
|
(function() {
|
||
|
|
||
|
'use strict';
|
||
|
|
||
|
angular
|
||
|
.module('harbor.search')
|
||
|
.directive('search', search);
|
||
|
|
||
|
SearchController.$inject = ['SearchService', '$scope'];
|
||
|
|
||
|
function SearchController(SearchService, $scope) {
|
||
|
var vm = this;
|
||
|
vm.keywords = "";
|
||
|
vm.search = searchByFilter;
|
||
|
vm.filterBy = 'repository';
|
||
|
|
||
|
searchByFilter();
|
||
|
|
||
|
|
||
|
function searchByFilter() {
|
||
|
SearchService(vm.keywords)
|
||
|
.success(searchSuccess)
|
||
|
.error(searchFailed);
|
||
|
}
|
||
|
|
||
|
function searchSuccess(data, status) {
|
||
|
console.log('filterBy:' + vm.filterBy + ", data:" + data);
|
||
|
vm.searchResult = data[vm.filterBy];
|
||
|
|
||
|
}
|
||
|
|
||
|
function searchFailed(data, status) {
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
function search() {
|
||
|
var directive = {
|
||
|
'restrict': 'E',
|
||
|
'templateUrl': '/static/ng/resources/js/components/search/search.directive.html',
|
||
|
'scope': {
|
||
|
'filterBy': '='
|
||
|
},
|
||
|
'controller': SearchController,
|
||
|
'controllerAs': 'vm',
|
||
|
'bindToController': true
|
||
|
};
|
||
|
|
||
|
return directive;
|
||
|
}
|
||
|
|
||
|
})();
|