2016-07-07 18:03:32 +02:00
|
|
|
/*
|
|
|
|
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
2016-04-18 10:33:30 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
2016-04-19 11:58:07 +02:00
|
|
|
.module('harbor.details')
|
2016-05-12 12:30:01 +02:00
|
|
|
.filter('name', nameFilter);
|
|
|
|
|
2016-04-26 12:23:34 +02:00
|
|
|
function nameFilter() {
|
|
|
|
|
|
|
|
return filter;
|
|
|
|
|
|
|
|
function filter(input, filterInput, key) {
|
2016-05-03 12:29:58 +02:00
|
|
|
input = input || [];
|
2016-04-26 12:23:34 +02:00
|
|
|
var filteredResults = [];
|
|
|
|
|
2016-05-23 12:29:17 +02:00
|
|
|
if (filterInput !== '') {
|
2016-04-26 12:23:34 +02:00
|
|
|
for(var i = 0; i < input.length; i++) {
|
|
|
|
var item = input[i];
|
2016-05-23 12:29:17 +02:00
|
|
|
if((key === "" && item.indexOf(filterInput) >= 0) || (key !== "" && item[key].indexOf(filterInput) >= 0)) {
|
2016-04-26 12:23:34 +02:00
|
|
|
filteredResults.push(item);
|
|
|
|
continue;
|
2016-05-03 12:29:58 +02:00
|
|
|
}
|
2016-04-26 12:23:34 +02:00
|
|
|
}
|
|
|
|
input = filteredResults;
|
|
|
|
}
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
}
|
2016-05-12 12:30:01 +02:00
|
|
|
|
2016-04-28 19:36:39 +02:00
|
|
|
|
2016-04-18 10:33:30 +02:00
|
|
|
})();
|