"use strict";function scroll_to_bottom(){messages_list.length>0&&messages_list.scrollTop(messages_list[0].scrollHeight)}angular.module("AlertsAddApp",["underscore","BaseModule"]).controller("AlertsCtrl",["$scope","$attrs","Requests","LoadingGlobalOptions",function(e,t,r,n){e.server_metrics=[],e.show_server_metrics=!0,e.show_metrics=!1,e.show_metric_types=!1,e.show_tags=!1,e.show_execute=!1,e.metric_types=["%"],e.show_is=!1,e.show_for=!1,e.update=function(t,n){var o={server_id:t};r.post(n,o).then(function(t){e.server_metrics=t}),e.show_metrics=!0,e.show_tags=!0,e.show_execute=!1,"all"!=t&&(e.show_execute=!0,e.show_tags=!1)},e.update_metric_types=function(t){e.show_metric_types=!0,e.show_is=!0,e.show_for=!0,t=t.toLowerCase().replace(/\s/g,""),"memory"===t?e.metric_types=["%","MB"]:"cpu"===t?e.metric_types=["%"]:"disk"===t?e.metric_types=["%","MB","GB"]:"down"===t?(e.metric_types=[],e.show_is=!1):"network/inbound"===t?e.metric_types=["KB/s"]:"network/outbound"===t?e.metric_types=["KB/s"]:"notsendingdata"===t?(e.metric_types=[],e.show_is=!1):"plugin"===t?(e.metric_types=[],e.show_is=!0):(e.metric_types=[],e.show_metric_types=!1),e.$apply()}}]).directive("serverDropdown",["Select2Options",function(e){var t;return{restrict:"A",scope:{},link:function(r,n,o){t=$(n);var a=e.array(t);t.select2({width:a.size,minimumResultsForSearch:5,placeholder:a.placeholder});var s=t.val();s&&r.$parent.update(s,a.url),t.on("change",function(){var e=t.val();r.$parent.update(e,a.url)})}}}]).directive("metricDropdown",["Select2Options",function(e){var t;return{restrict:"A",scope:{server_metrics:"@"},link:function(r,n,o){t=$(n);var a=e.array(t),s=t.select2({width:a.size,minimumResultsForSearch:5,placeholder:a.placeholder});t.on("change",function(){var e=s.find(":selected").data("type");r.$parent.update_metric_types(e),$("#metric_type").find("option:first-child").attr("selected","selected").trigger("change")})}}}]),angular.module("AlertsEditApp",["underscore","BaseModule"]).controller("AlertsCtrl",["$scope","$attrs","Requests","LoadingGlobalOptions",function(e,t,r,n){e.server_metrics=[],e.show_server_metrics=!0,e.show_metric_types=!0,e.show_is=!0,e.show_tags=!0,e.show_execute=!1,e.update=function(t){"all"!=t&&(e.show_execute=!0,e.show_tags=!1)},e.update_metric_types=function(t){e.show_metric_types=!0,e.show_is=!0,t=t.toLowerCase(),"down"===t?e.show_is=!1:"loadavg"===t?e.show_metric_types=!1:"notsendingdata"==t&&(e.show_is=!1)}}]).directive("serverDropdown",["Select2Options",function(e){var t;return{restrict:"A",scope:{},link:function(r,n,o){t=$(n);var a=e.array(t);t.select2({width:a.size,minimumResultsForSearch:5,placeholder:a.placeholder});var s=t.val();s&&r.$parent.update(s),t.select2("disable")}}}]).directive("metricDropdown",["Select2Options",function(e){var t;return{restrict:"A",priority:1,scope:{server_metrics:"@"},link:function(r,n,o){t=$(n);var a=e.array(t),s=t.data("selected"),i=t.data("type")||"";r.$parent.update_metric_types(i);var c=t.select2({width:a.size,minimumResultsForSearch:5,placeholder:a.placeholder});c.val(s).trigger("change"),c.select2("disable")}}}]),angular.module("AlertsMuteApp",["underscore","BaseModule"]).controller("AlertsMuteCtrl",["$scope","$attrs","LoadingGlobalOptions",function(e,t,r){e.show_tags=!0,e.update=function(t){e.show_tags=!1,"all"==t&&(e.show_tags=!0),e.$apply()}}]).directive("serverDropdown",["Select2Options",function(e){var t;return{restrict:"A",scope:{},link:function(r,n,o){t=$(n);var a=e.array(t);t.select2({width:a.size,minimumResultsForSearch:10,placeholder:a.placeholder}),t.on("change",function(e){var n=t.val();r.$parent.update(n)})}}}]),angular.module("RickshawApp",["underscore","BaseModule"]),angular.module("RickshawApp").factory("RickshawTimeFixtures",["$rootScope",function(e){var t,r,n=new Rickshaw.Fixtures.Time;return n.formatTime=function(e){return t=window.moment(e).utc().format("HH:mm")},n.units.push({name:"five_minutes",seconds:300,formatter:function(e){return n.formatTime(e)}}),n.units.push({name:"fifteen_minutes",seconds:900,formatter:function(e){return n.formatTime(e)}}),n.units.push({name:"thirty_minutes",seconds:1800,formatter:function(e){return n.formatTime(e)}}),n.units.push({name:"two_minutes",seconds:120,formatter:function(e){return n.formatTime(e)}}),{SetTimeUnit:function(t){var o,a=["two_minutes","five_minutes","fifteen_minutes","thirty_minutes","hour","6 hour"];return 1800>=t?o=0:t>1800&&10800>t?o=1:t>=10800&&21600>t?o=2:t>=21600&&43200>t?o=3:t>=43200&&86400>=t?o=4:t>86400&&(o=5),("S"==e.size||"M"==e.size)&&(o+=1),o=o>5?5:o,r=n.unit(a[o])}}}]).factory("RickshawGraphSize",["$rootScope",function(e){return{width:function(t){var r=40,n=$("body")[0].offsetWidth-r,o=parseInt(n);"M"==e.size?o=parseInt(n)/2:"S"==e.size&&(o=parseInt(n)/3);var a=$(".chart-wrapper");a.length>0&&(o=a[0].offsetWidth);var s=o-70;return{el:o,graph:s}}}}]).controller("RickshawSizer",["$scope","$rootScope","$window",function(e,t,r){t.size="M",e.sizes=["S","M","L"];var n=$.url().param("size")||!1;e.init=function(r){1==parseInt(r)&&(t.size="L"),2==parseInt(r)&&(t.size="M"),0!=n&&e.sizes.indexOf(n)>-1&&(t.size=n.toUpperCase())},e.define_size=function(){void 0!=t.charts_on_page?(1==parseInt(t.charts_on_page)&&(t.size="L"),2==parseInt(t.charts_on_page)&&(t.size="M"),parseInt(t.charts_on_page)>=3&&(t.size="S")):t.size="L"},e.set_size=function(e){t.size=e,t.$broadcast("setchartsize")},e.set_class=function(e){return e===t.size?"active":void 0},e.set_class(t.size),e.set_size(t.size),e.$on("resize_charts",function(){e.define_size(),t.$broadcast("setchartsize")})}]).controller("RickshawChartNoData",["$scope","$rootScope",function(e,t){t.empty_charts=[]}]).controller("RickshawTimer",["$scope","$rootScope","$timeout",function(e,t,r){var n=!1,o=$("#rickshaw-timfer-daterange").val();"custom"==o&&(n=!0),e.when=function(e,t,r){return e?t:r},e.set_timer=function(){n||(r(e.set_timer,15e3),t.$broadcast("data.update"))},e.toggleCounter=function(){n=!n,e.set_timer()},e.isPaused=function(){return n},r(function(){e.set_timer()},15e3)}]).controller("RickshawChartType",["$scope","$rootScope",function(e,t){}]).directive("rickshawChart",["$window","$rootScope","$timeout","_","RickshawTimeFixtures","RickshawGraphSize","Requests","Template","LoadingGlobalOptions",function(e,t,r,n,o,a,s,i,c){return{restrict:"E",scope:{},controller:["$scope","$element","$attrs",function(e,t,r){var n;e.$on("data.update",function(){var t=r.url.substr(-1),o="&";"/"==t&&(o="?"),n=i("{{{url}}}{{url_separator}}timestamp={{ timestamp }}",{url:r.url,url_separator:o,timestamp:r.timestamp}),e.get_data(n)}),e.get_data=function(t){s.get(t).then(function(t){e.data=t,r.timestamp=e.data.last_update,t.now_local&&($("#now_local").val(t.now_local),$("#dropdown_now_local").text(t.now_local))})}}],link:function(r,s,l){var u,d,p,h,m,f,_,g,v,w,y,x,S=angular.element(e),k=$(s).find(".loading").get(0),b=a.width(s);$(s).css("width",b.el),_=new Spinner(c).spin(k),r.set_current_value=function(){var e=d.series.length,t=$(s).find(".charts__current"),r="<li><span class='color' style='background:{{color}};'></span>{{name}}: {{value}}{{unit}}</li>",o=$(s).data("yaxis");t.empty(),n(e).times(function(e){var a=d.series[e],s=n.last(a.data).y,c=i(r,{color:a.color,name:a.name,value:s,unit:o});t.append(c)})},r.get_window_width=function(){return $("body")[0].offsetWidth},r.get_window_height=function(){return $("body")[0].offsetHeight},r.$watch("data",function(){r.update()}),r.$on("setchartsize",function(){r.resize()}),r.$on("set_type",function(){r.resize()}),r.$watch(r.get_window_height,function(){r.resize()}),r.$watch(r.get_window_width,function(){r.resize()}),S.bind("resize",function(){r.$apply()}),r.update=function(){if(r.data&&d.series){if(v=d.series.length,v>0){var e=r.data.data.length;r.data.data.length>0&&n(e).times(function(e){var t=r.data.data[e].data,o=r.data.data[e].name;n.each(d.series,function(e,r){if(e.name==o){var a=n.last(d.series[r].data);n.each(t,function(e){e.x>a.x&&d.series[r].data.push(e)}),d.series[r].data.splice(0,t.length)}})}),w=n.last(d.series[0].data);var t=n.first(d.series[0].data),a=w.x-t.x+60;g=o.SetTimeUnit(a),h.fixedTimeUnit=g}d.render()}},r.resize=function(){u=s[0];var e=a.width(u);$(u).css("width",e.el),$(u).find(".chart-slider").css("width",e.graph),d?d.configure&&(d.configure({width:e.graph,height:300,renderer:t.type}),g=o.SetTimeUnit(l.duration),h.fixedTimeUnit=g,d.render()):r.render()},r.loading=function(e,r){var o=[];if(void 0!=e&&n.size(e.data)>0)var o=e.data.data||e.data[0].data;var a=n.size(o);_.stop(),$(r).show();$(r);if(1>=a){$(r).hide();var s=$(r).data("name"),i=$(r).attr("id");t.empty_charts.push({name:s,id:i}),t.$apply()}else $(r).find(".chart, .y_axis, .chart-slider").show()},r.render=function(){u=s[0],x=l.enddate?l.enddate-l.duration:l.timestamp-l.duration;var e=l.url.substr(-1),n="&";"/"==e&&(n="?"),y=i("{{{url}}}{{ url_separator }}timestamp={{ timestamp }}",{url:l.url,url_separator:n,timestamp:x}),l.enddate&&(y=i("{{{url}}}&enddate={{ enddate }}",{url:y,enddate:l.enddate}));var c=a.width(u);d=new Rickshaw.Graph.Ajax({element:$(u).find(".chart").get(0),padding:{top:.2,right:0,bottom:.02,left:0},renderer:$(u).data("type")||"line",stroke:!0,width:c.graph,height:250,dataURL:y,interpolation:"linear",onData:function(e){return r.loading(e,u),e.data},onComplete:function(e){d=e.graph,r.set_current_value(),p||(p=new Rickshaw.Graph.HoverDetail({graph:d})),h||(g=o.SetTimeUnit(l.duration),h=new Rickshaw.Graph.Axis.Time({graph:d,grid:!0,ticks:15,timeUnit:g}),h.render()),m||(m=new Rickshaw.Graph.Axis.Y({graph:d,tickFormat:function(e){return e+l.yaxis},element:$(u).find(".y_axis").get(0)}),m.render()),f||(f=new Rickshaw.Graph.RangeSlider({graph:d,element:$(u).find(".chart-slider").get(0)})),t.$apply()}})}}}}]),angular.module("RickshawApp").controller("CounterTimer",["$scope","$rootScope","$timeout",function(e,t,r){e.set_timer=function(){r(e.set_timer,15e3),t.$broadcast("update_count")},r(function(){e.set_timer()},3e3)}]).directive("counterBlock",["$window","Requests","$timeout","$rootScope",function(e,t,r,n){return{restrict:"E",scope:{},controller:["$scope","$element","$attrs",function(e,r,n){e.update=function(){var n=r.data("url");t.get(n).then(function(t){e.data=t})},e.$on("update_count",function(){e.update()})}],link:function(e,t,r){e.update()},template:'<span class="title">{{data.name}}</span> <span class="count">{{data.count}}</span>'}}]);var metric_array,metric_dropdown,metric_value,values,json_data,tags,tags_dropdown;angular.module("DashboardApp",["underscore","BaseModule","RickshawApp"]).controller("DashboardCtrl",["$scope","$attrs","Requests","LoadingGlobalOptions",function(e,t,r,n){var o=$(".loading").get(0),a=new Spinner(n);e.placeholder="Untitled Dashboard",t.name&&(e.name=t.name),t.shared&&(e.shared="true"==t.shared?!0:!1),e.UpdateName=function(e){a.spin(o);var n={name:e};r.post(t.updateurl,n).then(function(e){a.stop()})},e.UpdateShared=function(e){a.spin(o);var n={shared:e};r.post(t.updateurl,n).then(function(e){a.stop()})}}]).controller("DashboardMetricsCtrl",["$scope","$rootScope","$attrs","Requests",function(e,t,r,n){e.metrics=[],e.update=function(){t.empty_charts=[],n.get(r.geturl).then(function(r){e.metrics=r.data,t.charts_on_page=e.metrics.length,t.$broadcast("resize_charts")})},e.RemoveMetric=function(t){var o={metric_id:t};window.confirm("Are you sure you want to remove this metric?")&&n.post(r.removeurl,o).then(function(t){e.update()})},e.AddMetric=function(){if(values=new Array,metric_value=metric_dropdown.select2("val"),tags_dropdown=$("#tags_dropdown"),metric_value&&"Server"==t.metric_type){var o=_.chain(metric_value.split(".")).map(function(e){return e?e.split(":"):void 0}).compact().object().value();tags=tags_dropdown.select2("val"),tags.length>0&&(o.tags=tags),n.post(r.addurl,o).then(function(t){e.update()})}else if("App"==t.metric_type){var a=$("#app_metric_type").select2("val");a&&n.post(r.addurl,{metric_id:a,check:"metric"}).then(function(t){e.update()})}else if("HealthChecks"==t.metric_type){var s=$("#healthcheck").select2("val");s&&n.post(r.addurl,{healthcheck_id:s,check:"healthcheck",metric_type:"healthcheck"}).then(function(t){e.update()})}},e.update()}]).controller("DashboardMetricTypesCtrl",["$scope","$rootScope","$attrs","LoadingGlobalOptions",function(e,t,r,n){e.chart_types=["Server","HealthChecks"],t.metric_type="Server",e.set_type=function(e){t.metric_type=e,t.$broadcast("set_metric_type")},e.isActive=function(e){return e==t.metric_type?!0:void 0}}]).controller("DashboardServerMetricsCtrl",["$scope","$rootScope","$attrs","Requests","LoadingGlobalOptions",function(e,t,r,n,o){e.show=!1,e.nodata=!0,e.show_tags=!1,e.LoadServerMetrics=function(t,r){"all"==t?e.show_tags=!0:e.show_tags=!1;var a=$(".loading-metrics").get(0),s=new Spinner(o).spin(a),i={server_id:t};n.post(r,i).then(function(t){var r=[];_.each(t.data,function(e){var t=_.object(["value","label","type"],e);r.push(t)}),e.server_metrics=r,e.nodata=!1,e.show=!0,s.stop()})},e.SetMetricType=function(){"App"==t.metric_type?(e.show_server_metrics=!1,e.show_app_metrics=!0,e.show_healthchecks=!1):"HealthChecks"==t.metric_type?(e.show_server_metrics=!1,e.show_app_metrics=!1,e.show_healthchecks=!0):(e.show_server_metrics=!0,e.show_app_metrics=!1,e.show_healthchecks=!1)},e.$on("set_metric_type",function(){e.SetMetricType()}),e.SetMetricType()}]).directive("serverDropdown",["$window","$rootScope",function(e,t){var r;return{restrict:"A",scope:{},controller:["$scope","$element","$attrs",function(e,t,r){}],link:function(e,n,o){r=$(n);var a=r.data("url"),s=r.data("placeholder");r.select2({width:"300",minimumResultsForSearch:5,placeholder:s}),r.on("change",function(){var n=r.val();e.$parent.LoadServerMetrics(n,a),t.$broadcast("resize_charts")}),r.on("select2-open",function(){t.$broadcast("resize_charts")})}}}]).directive("servermetricDropdown",["$window","$rootScope",function(e,t){return{restrict:"A",scope:{server_metrics:"@"},controller:["$scope","$element","$attrs",function(e,t,r){}],link:function(e,r,n){metric_dropdown=$(r);var o=metric_dropdown.data("placeholder");metric_dropdown.select2({width:"300",minimumResultsForSearch:5,placeholder:o}),metric_dropdown.select2("enable",!0),metric_dropdown.on("select2-open",function(){t.$broadcast("resize_charts")})}}}]),angular.module("DashboardReorderApp",["underscore","BaseModule",angularDragula(angular)]).controller("DashboardReorderCtrl",["$scope","$attrs","Requests","LoadingGlobalOptions",function(e,t,r,n){e.charts=[],e.checks=[],e.init=function(){r.get(t.geturl).then(function(t){_.each(t.data,function(t){"healthcheck"==t.type?e.checks.push(t):e.charts.push(t)})})},e.$on("charts-list.drop-model",function(n,o,a){var s=_.pluck(e.charts,"id"),i={new_order:s};r.post(t.orderurl,i).then(function(e){})}),e.$on("checks-list.drop-model",function(n,o,a){var s=_.pluck(e.checks,"id"),i={new_order:s};r.post(t.orderurl,i).then(function(e){})}),e.init()}]);var underscore=angular.module("underscore",[]);underscore.factory("_",function(){return window._});var messages_list=$(".remote--messages");angular.module("BaseModule",[]).config(["$httpProvider",function(e){e.defaults.xsrfCookieName="csrftoken",e.defaults.xsrfHeaderName="X-CSRFToken"}]).factory("Requests",["$http",function(e){return{post:function(t,r){return json_data=JSON.stringify(r),e.post(t,json_data).then(function(e){return e.data})},get:function(t){return e.get(t).then(function(e){return e.data})}}}]).factory("_",function(){return window._}).factory("Template",function(){return function(e,t){return Mustache.render(e,t)}}).factory("Globals",function(){return{generate_uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,r="x"==e?t:3&t|8;return r.toString(16)})}}}).factory("LoadingGlobalOptions",function(){return{lines:6,length:2,width:3,radius:3,corners:1,rotate:0,direction:1,color:"#464646",speed:3,trail:0,shadow:!1,hwaccel:!0,className:"spinner",zIndex:2e9,position:"absolute",top:"20px",left:"11px"}}).service("Select2Options",function(){this.array=function(e){return{url:e.data("url")||!1,size:e.data("size")||360,type:e.data("type")||!1,placeholder:e.data("placeholder")}}}).directive("select2Dropdown",["Select2Options",function(e){var t;return{restrict:"A",scope:{},priority:1,link:function(r,n,o){t=$(n);var a=e.array(t);t.select2({width:a.size,minimumResultsForSearch:10,placeholder:a.placeholder}),void 0!=o.withRedirect&&t.on("change",function(e){var t=e.val;window.location.href=t})}}}]).directive("timeAgo",function(){var e;return{restrict:"A",scope:{},priority:1,link:function(t,r,n){e=r[0];var o=$(r[0]),a=o.html(),s=moment.unix(a).fromNow();o.html(s)}}}).directive("tagsDropdown",["Select2Options","Requests","_","Template","$rootScope",function(e,t,r,n,o){var a;return{restrict:"A",scope:{},link:function(o,s,i){a=$(s);var c=e.array(a),l=a.data("tags-url");a.select2({width:c.size,minimumResultsForSearch:5,placeholder:c.placeholder,tags:!0,createSearchChoice:function(e){return 1!=i.readOnly&&e.length>2?{id:$.trim(e),text:$.trim(e)+" (new tag)"}:void 0},ajax:{url:l,dataType:"json",data:function(e,t){return{q:e}},results:function(e,t){return{results:e}}},initSelection:function(e,n){var o=[],a=e.val().split(",");t.get(c.url,a).then(function(e){r.each(e,function(e){r.contains(a,e.id)&&o.push({id:e.id,text:e.text})}),n(o)})},maximumSelectionSize:10,formatSelectionTooBig:function(e){return"Max tags is only "+e}}),void 0!=i.withRedirect&&a.on("change",function(e){var t=a.data("redirect-url"),r=e.val.join(",");r.length>0&&(t=n("{{{url}}}?tags={{ tags }}",{url:t,tags:r})),window.location.href=t})}}}]).controller("ChatCtrl",["$scope","$attrs","Requests","$timeout","Globals","$rootScope","_",function(e,t,r,n,o,a,s){e.messageText="",e.responses=[],e.in_progress=[],e.history=0,e.selected_servers=[],e.servers_list,e.update_servers=function(t){e.selected_servers=t},e.appendCommand=function(t){e.messageText=e.messageText+t},e.sendMessage=function(n){if(n){if(13!=n.which)return;if(13===n.which){n.preventDefault();var a=e.messageText;if(0==a.length)return;0==e.selected_servers.length&&window.show_notification("Please select a server"),s.each(e.selected_servers,function(n){var i=s.findWhere(e.servers_list,{id:n}),c=o.generate_uuid(),l={command:a,server_id:n,uuid:c},u={host:i.name,command:a,uuid:c};e.in_progress.push(u),e.messageText=" ",r.post(t.url,l).then(function(t){e.responses.push(t);var r=s.findIndex(e.in_progress,{uuid:c});e.in_progress.splice(r,1)})})}}},e.$watch("in_progress.length",function(e){n(function(){scroll_to_bottom()})}),e.$watch("switch",function(t){e["switch"]=t}),e.$watch("responses.length",function(e){$(".remote--messages");n(function(){scroll_to_bottom()})}),e.closePanel=function(){a.$broadcast("close_remote_panel")},e.init=function(){r.get(t.serversurl).then(function(t){e.servers_list=s.map(t.servers,function(e){return s.pick(e,"id","name")}),n(function(){a.$broadcast("servers_populated")})})},e.$on("init_remote_panel",function(t){e.init()})}]).directive("remoteTextarea",["$window","$rootScope","_",function(e,t,r){var n,o=["ab","awk","bash","beep","cat","cc","cd","chown","chmod","chroot","clear","cp","curl","cut","diff","echo","find","gawk","gcc","get","git","grep","kill","killall","ln","ls","make","mkdir","mv","nc","node","npm","ping","ps","restart","rm","rmdir","sed","service","sh","shopt","shred","source","sort","sleep","ssh","start","stop","su","sudo","tee","telnet","top","touch","vi","vim","wall","wc","wget","who","write","yes","apt-get","install","version","yum","apt-add","remove","upgrade","status","service","systemctl","home","var","etc","ifconfig","gem","pip","proc","uname","python","--version"];return{restrict:"A",scope:{},controller:["$scope","$element","$attrs",function(e,t,r){}],link:function(e,t,r){n=$(t),$(n).textcomplete([{match:/(^|\s)(\w{2,})$/,search:function(e,t){t($.map(o,function(t){return 0===t.indexOf(e)?t:null}))},replace:function(e){return" "+e+" "}}],{maxCount:20,debounce:500,zIndex:10001})}}}]).directive("remoteserverDropdown",["Select2Options","Requests","_",function(e,t,r){var n;return{restrict:"A",scope:{},controller:["$scope","$element","$attrs",function(t,r,o){t.$on("clear_servers",function(){n.val("").change()}),t.$on("servers_populated",function(){var t=e.array(n);n.select2({width:t.size,minimumResultsForSearch:5,placeholder:t.placeholder})})}],link:function(e,t,r){n=$(t),n.on("change",function(t){var r=n.val();e.$parent.update_servers(r)})}}}]).directive("remoteTrigger",["$rootScope","$timeout",function(e,t){return{restrict:"A",scope:{},controller:["$scope","$element","$attrs",function(e,t,r){}],link:function(t,r,n){t.remote_panel=!1,t.$on("close_remote_panel",function(){t.remote_panel=!1,$(".remote_commands--sidebar").removeClass("shown")}),r.on("click",function(r){r.preventDefault(),t.remote_panel=t.remote_panel===!1?!0:!1,1==t.remote_panel?(e.$broadcast("init_remote_panel"),$(".remote_commands--sidebar").addClass("shown"),scroll_to_bottom()):$(".remote_commands--sidebar").removeClass("shown")})}}}]).directive("notificationsDropdown",["Select2Options","Template",function(e,t){var r;return{restrict:"A",scope:{},priority:1,link:function(n,o,a){function s(e){var r=e.element,n=$(r).data("image"),o=t("<img style='width:24px; position:relative; top:8px; left:0px;' src='{{ image }}'/>{{text}}",{image:n,text:e.text});return o}function i(e){var r=e.element,n=$(r).data("image"),o=t("<img style='width:24px;float:left; margin-right:10px;' src='{{ image }}'/><span style='float:left;margin-top:4px;'>{{text}}</span>",{image:n,text:e.text});return o}r=$(o);var c=e.array(r);r.select2({width:c.size,minimumResultsForSearch:10,placeholder:c.placeholder,formatResult:s,formatSelection:i})}}}]),angular.module("HealthCheckAddAlertApp",["underscore","BaseModule"]).controller("HealthCheckAlertsCtrl",["$scope","$attrs","Requests","LoadingGlobalOptions",function(e,t,r,n){e.commands=[],e.params=[],e.show_commands=!1,e.show_params=!1,e.show_tags=!1,e.show_status=!1,e.show_for=!1,e.update_servers=function(t,n){var o={server_id:t};e.commands=[],e.params=[],r.post(n,o).then(function(t){e.commands=t}),e.show_status=!0,e.show_commands=!0,e.show_for=!0,e.show_params=!0,e.show_tags=!0,"all"!=t&&(e.show_tags=!1,e.show_params=!1)},e.update_params=function(t,n){e.params=[];var o={command:t};r.post(n,o).then(function(t){e.params=t})}}]).directive("serverDropdown",["Select2Options",function(e){var t;return{restrict:"A",scope:{},link:function(r,n,o){t=$(n);var a=e.array(t);t.select2({width:a.size,minimumResultsForSearch:5,placeholder:a.placeholder});var s=t.val();s&&r.$parent.update_servers(s,a.url),t.on("change",function(){var e=t.val();r.$parent.update_servers(e,a.url)})}}}]).directive("commandDropdown",["Select2Options",function(e){var t;return{restrict:"A",scope:{server_metrics:"@"},link:function(r,n,o){t=$(n);var a=e.array(t),s=(t.select2({width:a.size,minimumResultsForSearch:5,placeholder:a.placeholder}),t.val());s&&r.$parent.update_params(s,a.url),t.on("change",function(){var e=t.val();r.$parent.update_params(e,a.url)})}}}]),angular.module("HealthCheckEditAlertsApp",["underscore","BaseModule"]).controller("HealthCheckAlertsCtrl",["$scope","$attrs","Requests","LoadingGlobalOptions",function(e,t,r,n){e.show_tags=!1,e.show_status=!0,e.show_for=!0,e.update_servers=function(t,r){"all"==t&&(e.show_tags=!0)}}]).directive("serverDropdown",["Select2Options",function(e){var t;return{restrict:"A",scope:{},link:function(r,n,o){t=$(n);var a=e.array(t);t.select2({width:a.size,minimumResultsForSearch:5,placeholder:a.placeholder});var s=t.val();r.$parent.update_servers(s),t.select2("disable")}}}]).directive("commandDropdown",["Select2Options",function(e){var t;return{restrict:"A",scope:{server_metrics:"@"},link:function(r,n,o){t=$(n);var a=e.array(t);t.select2({width:a.size,minimumResultsForSearch:5,placeholder:a.placeholder});t.select2("disable")}}}]),angular.module("InlineEditor",["underscore","BaseModule"]),angular.module("InlineEditor").controller("BaseEditorController",["$scope","Requests","$attrs",function(e,t,r){e.openEditDialog=function(t){e.open_editor=t,e.open_dialog=t},e.closeDialog=function(t){e.open_editor=!1,e.open_dialog=!1,e.open_delete=!1},e.openDeleteDialog=function(t){e.open_delete=t,e.open_dialog=t}}]),angular.module("ProfileApp",["BaseModule"]).controller("ProfileCtrl",["$scope","$attrs","Requests",function(e,t,r){}]),angular.module("ServersApp",["underscore","BaseModule"]).directive("progressBar",function(){var e;return{restrict:"A",scope:{},priority:1,link:function(t,r,n){var o=1.2,a=120;e=r[0];var s=$(r[0]),i=s.data("value"),c=s.data("total"),l=0;if(void 0!==c){var u=c/100,d=i/u;l=Math.floor(a/100*d)}else i>0&&(l=Math.floor(o*i));l>a&&(l=a),s.css("width",l);var p=Math.floor(l/o);p>85&&(s.addClass("red"),s.siblings("span.data").addClass("red"))}}}).directive("serversTagsDropdown",["Select2Options","Requests","_","Template",function(e,t,r,n){var o;return{restrict:"A",scope:{},link:function(a,s,i){o=$(s);var c=e.array(o);o.select2({width:c.size,minimumResultsForSearch:5,placeholder:c.placeholder,tags:!0,ajax:{url:c.url,dataType:"json",data:function(e,t){return{q:e}},results:function(e,t){return{results:e}}},maximumSelectionSize:5,formatSelectionTooBig:function(e){return"Max tags is only "+e},initSelection:function(e,n){var o=[],a=e.val().split(",");t.get(c.url,a).then(function(e){r.each(e,function(e){r.contains(a,e.id)&&o.push({id:e.id,text:e.text})}),n(o)})}}),o.on("change",function(e){var t=o.data("page-url"),r=e.val.join(",");r.length>0&&(t=n("{{{url}}}?tags={{ tags }}",{url:t,tags:r})),window.location.href=t})}}}]),angular.module("ServersMapApp",["underscore","BaseModule"]).directive("progressBar",function(){var e;return{restrict:"A",scope:{},priority:1,link:function(t,r,n){var o=1.2,a=120;e=r[0];var s=$(r[0]),i=s.data("value"),c=s.data("total"),l=0;if(void 0!==c){var u=c/100,d=i/u;l=Math.floor(a/100*d)}else i>0&&(l=Math.floor(o*i));l>a&&(l=a),s.css("width",l);var p=Math.floor(l/o);p>85&&(s.addClass("red"),s.siblings("span.data").addClass("red"))}}}),$.each($(".timeago"),function(e,t){var r=$(this).html(),n=moment.unix(r).fromNow();$(this).html(n)}),$("a.plugin-error, .dashed, .timeago").each(function(){$(this).qtip({style:{classes:"qtip-bootstrap",width:200},position:{at:"bottom center",my:"top center"},content:{text:$(this).next(".qtip-tooltip")}})}),angular.module("InlineEditor").controller("TagGroupsController",["$scope","Requests","$attrs","$controller",function(e,t,r,n){angular.extend(this,n("BaseEditorController",{$scope:e,Requests:t,$attrs:r})),e.groups=[],e.createTag=function(n){t.post(r.createturl,{name:e.newgroup}).then(function(t){e.groups.push(t.group),e.newgroup=""})},e.deleteTag=function(n,o){var a={id:n.id};t.post(r.deleteurl,a).then(function(t){e.closeDialog(n.id),e.groups.splice(o,1)})},e.updateTag=function(n){var o={name:n.name,id:n.id};t.post(r.updateurl,o).then(function(t){e.closeDialog(n.id)})},e.init=function(){t.get(r.list).then(function(t){e.groups=t.groups})},e.init()}]),angular.module("InlineEditor").controller("TagsController",["$scope","Requests","$attrs","$controller",function(e,t,r,n){angular.extend(this,n("BaseEditorController",{$scope:e,Requests:t,$attrs:r})),e.tags=[],e.tag_groups=[],e.createTag=function(){var n={name:e.newtag.name,group:e.newtag.group};t.post(r.createturl,n).then(function(t){e.tags.push(t.tag),e.newtag=""})},e.deleteTag=function(n,o){var a={id:n.id};t.post(r.deleteurl,a).then(function(t){e.closeDialog(n.id),e.tags.splice(o,1)})},e.updateTag=function(n){var o={name:n.name,id:n.id,group:n.group};t.post(r.updateurl,o).then(function(t){e.closeDialog(n.id)})},e.init=function(){t.get(r.list).then(function(t){e.tags=t.tags}),t.get(r.listgroups).then(function(t){e.tag_groups=t.groups})},e.init()}]).directive("groupsDropdown",["Select2Options","$timeout",function(e,t){var r;return{require:"ngModel",priority:1,restrict:"A",scope:{},controller:["$scope","$element","$attrs",function(e,t,r){}],link:function(t,n,o,a){r=$(n);var s=e.array(r);r.select2({width:s.size,minimumResultsForSearch:15,placeholder:s.placeholder})}}}]);