mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-30 04:28:17 +01:00
52 lines
1.1 KiB
JavaScript
52 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) {
|
|
console.log('Failed search:' + data);
|
|
}
|
|
|
|
}
|
|
|
|
function search() {
|
|
var directive = {
|
|
'restrict': 'E',
|
|
'templateUrl': '/static/resources/js/components/search/search.directive.html',
|
|
'scope': {
|
|
'filterBy': '='
|
|
},
|
|
'controller': SearchController,
|
|
'controllerAs': 'vm',
|
|
'bindToController': true
|
|
};
|
|
|
|
return directive;
|
|
}
|
|
|
|
})(); |