/*! grafana - v3.1.0 - 2016-07-18
 * Copyright (c) 2016 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["lodash","../../../features/panel/panel_ctrl"],function(a){var b,c,d,e=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};return{setters:[function(a){b=a},function(a){c=a}],execute:function(){d=function(a){function c(c,d,e,f){a.call(this,c,d),this.backendSrv=e,this.$location=f,this.panelDefaults={},b["default"].defaults(this.panel,this.panelDefaults),this.events.on("init-edit-mode",this.onInitEditMode.bind(this)),this.pluginList=[],this.viewModel=[{header:"Installed Apps",list:[],type:"app"},{header:"Installed Panels",list:[],type:"panel"},{header:"Installed Datasources",list:[],type:"datasource"}],this.update()}return e(c,a),c.$inject=["$scope","$injector","backendSrv","$location"],c.prototype.onInitEditMode=function(){this.editorTabIndex=1,this.addEditorTab("Options","public/app/plugins/panel/pluginlist/editor.html")},c.prototype.gotoPlugin=function(a,b){b&&b.stopPropagation(),this.$location.url("plugins/"+a.id+"/edit")},c.prototype.updateAvailable=function(a,b){b.stopPropagation(),b.preventDefault();var c=this.$scope.$new(!0);c.plugin=a,this.publishAppEvent("show-modal",{src:"public/app/features/plugins/partials/update_instructions.html",scope:c})},c.prototype.update=function(){var a=this;this.backendSrv.get("api/plugins",{embedded:0,core:0}).then(function(c){a.pluginList=c,a.viewModel[0].list=b["default"].filter(c,{type:"app"}),a.viewModel[1].list=b["default"].filter(c,{type:"panel"}),a.viewModel[2].list=b["default"].filter(c,{type:"datasource"});for(var d=0,e=a.pluginList;d<e.length;d++){var f=e[d];f.hasUpdate?f.state="has-update":f.enabled||(f.state="not-enabled")}})},c.templateUrl="module.html",c}(c.PanelCtrl),a("PluginListCtrl",d),a("PanelCtrl",d)}}});