/*! grafana - v1.5.4 - 2014-05-13
 * Copyright (c) 2014 Torkel Ödegaard; Licensed Apache License */

define("panels/filtering/module",["angular","app","underscore"],function(a,b,c){var d=a.module("kibana.panels.filtering",[]);b.useModule(d),d.controller("filtering",["$scope","filterSrv","datasourceSrv","$rootScope","dashboard",function(a,b,d,e,f){a.panelMeta={status:"Stable",description:"graphite target filters"};var g={};c.defaults(a.panel,g),a.init=function(){a.filterSrv=b},a.remove=function(a){b.remove(a)},a.filterOptionSelected=function(c,d){b.filterOptionSelected(c,d),a.applyFilterToOtherFilters(c)},a.applyFilterToOtherFilters=function(d){c.each(b.list,function(b){b!==d&&-1!==b.query.indexOf(d.name)&&a.applyFilter(b)})},a.applyFilter=function(a){var e=b.applyFilterToTarget(a.query);d.default.metricFindQuery(e).then(function(d){if(a.editing=void 0,a.options=c.map(d,function(a){return{text:a.text,value:a.text}}),a.includeAll){var e="{";c.each(a.options,function(a){e+=a.text+","}),e=e.substring(0,e.length-1)+"}",a.options.unshift({text:"All",value:e})}b.filterOptionSelected(a,a.options[0])})},a.add=function(){b.add({type:"filter",name:"filter name",editing:!0,query:"metric.path.query.*"})},a.refresh=function(){f.refresh()},a.render=function(){e.$broadcast("render")}}])});