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

System.register(["lodash","angular","./transformers","app/core/utils/kbn"],function(a){function b(a,b){"use strict";return{restrict:"E",scope:!0,templateUrl:"public/app/plugins/panel/table/editor.html",controller:g}}b.$inject=["$q","uiSegmentSrv"];var c,d,e,f,g;return a("tablePanelEditor",b),{setters:[function(a){c=a},function(a){d=a},function(a){e=a},function(a){f=a}],execute:function(){g=function(){function a(a,b,d){var g=this;this.$q=b,this.uiSegmentSrv=d,a.editor=this,this.panelCtrl=a.ctrl,this.panel=this.panelCtrl.panel,this.transformers=e.transformers,this.unitFormats=f["default"].getUnitFormats(),this.colorModes=[{text:"Disabled",value:null},{text:"Cell",value:"cell"},{text:"Value",value:"value"},{text:"Row",value:"row"}],this.columnTypes=[{text:"Number",value:"number"},{text:"String",value:"string"},{text:"Date",value:"date"}],this.fontSizes=["80%","90%","100%","110%","120%","130%","150%","160%","180%","200%","220%","250%"],this.dateFormats=[{text:"YYYY-MM-DD HH:mm:ss",value:"YYYY-MM-DD HH:mm:ss"},{text:"MM/DD/YY h:mm:ss a",value:"MM/DD/YY h:mm:ss a"},{text:"MMMM D, YYYY LT",value:"MMMM D, YYYY LT"}],this.addColumnSegment=d.newPlusButton(),this.getColumnNames=function(){return g.panelCtrl.table?c["default"].map(g.panelCtrl.table.columns,function(a){return a.text}):[]}}return a.$inject=["$scope","$q","uiSegmentSrv"],a.prototype.getColumnOptions=function(){var a=this;if(!this.panelCtrl.dataRaw)return this.$q.when([]);var b=this.transformers[this.panel.transform].getColumns(this.panelCtrl.dataRaw),d=c["default"].map(b,function(b){return a.uiSegmentSrv.newSegment({value:b.text})});return this.$q.when(d)},a.prototype.addColumn=function(){var a=e.transformers[this.panel.transform].getColumns(this.panelCtrl.dataRaw),b=c["default"].findWhere(a,{text:this.addColumnSegment.value});b&&(this.panel.columns.push(b),this.render());var d=this.uiSegmentSrv.newPlusButton();this.addColumnSegment.html=d.html,this.addColumnSegment.value=d.value},a.prototype.transformChanged=function(){this.panel.columns=[],this.render()},a.prototype.render=function(){this.panelCtrl.render()},a.prototype.removeColumn=function(a){this.panel.columns=c["default"].without(this.panel.columns,a),this.panelCtrl.render()},a.prototype.setUnitFormat=function(a,b){a.unit=b.value,this.panelCtrl.render()},a.prototype.addColumnStyle=function(){var a={unit:"short",type:"number",decimals:2,colors:["rgba(245, 54, 54, 0.9)","rgba(237, 129, 40, 0.89)","rgba(50, 172, 45, 0.97)"],colorMode:null,pattern:"/.*/",dateFormat:"YYYY-MM-DD HH:mm:ss",thresholds:[]};this.panel.styles.push(d["default"].copy(a))},a.prototype.removeColumnStyle=function(a){this.panel.styles=c["default"].without(this.panel.styles,a)},a.prototype.invertColorOrder=function(a){var b=this.panel.styles[a].colors,c=b[0];b[0]=b[2],b[2]=c,this.panelCtrl.render()},a}(),a("TablePanelEditorCtrl",g)}}});