Files
grafana/dist/app/panels/dashcontrol/module.js
T
2013-09-13 13:52:13 -07:00

4 lines
3.5 KiB
JavaScript
Executable File

define("panels/dashcontrol/module",["angular","app","underscore"],function(e,t,n){var r=e.module("kibana.panels.dashcontrol",[]);t.useModule(r),r.controller("dashcontrol",["$scope","$http","timer","dashboard","alertSrv",function(e,t,r,i,s){e.panelMeta={status:"Deprecated",description:"This panel has been moved to the navigation bar. See the dashboard setting editor to configure it."},e.panel=e.panel||{};var o={save:{gist:!1,elasticsearch:!0,local:!0,"default":!0},load:{gist:!0,elasticsearch:!0,local:!0},hide_control:!1,elasticsearch_size:20,temp:!0,ttl_enable:!0,temp_ttl:"30d"};n.defaults(e.panel,o),e.init=function(){e.gist_pattern=/(^\d{5,}$)|(^[a-z0-9]{10,}$)|(gist.github.com(\/*.*)\/[a-z0-9]{5,}\/*$)/,e.gist={},e.elasticsearch={}},e.set_default=function(){i.set_default()?s.set("Local Default Set",i.current.title+" has been set as your local default","success",5e3):s.set("Incompatible Browser","Sorry, your browser is too old for this feature","error",5e3)},e.purge_default=function(){i
.purge_default()?s.set("Local Default Clear","Your local default dashboard has been cleared","success",5e3):s.set("Incompatible Browser","Sorry, your browser is too old for this feature","error",5e3)},e.elasticsearch_save=function(t,r){i.elasticsearch_save(t,e.elasticsearch.title||i.current.title,e.panel.ttl_enable?r:!1).then(function(r){n.isUndefined(r._id)?s.set("Save failed","Dashboard could not be saved to Elasticsearch","error",5e3):(s.set("Dashboard Saved",'This dashboard has been saved to Elasticsearch as "'+r._id+'"',"success",5e3),t==="temp"&&(e.share=i.share_link(i.current.title,"temp",r._id)))})},e.elasticsearch_delete=function(t){i.elasticsearch_delete(t).then(function(r){if(!n.isUndefined(r))if(r.found){s.set("Dashboard Deleted",t+" has been deleted","success",5e3);var i=n.where(e.elasticsearch.dashboards,{_id:t})[0];e.elasticsearch.dashboards=n.without(e.elasticsearch.dashboards,i)}else s.set("Dashboard Not Found","Could not find "+t+" in Elasticsearch","warning",5e3);else s
.set("Dashboard Not Deleted","An error occurred deleting the dashboard","error",5e3)})},e.elasticsearch_dblist=function(t){i.elasticsearch_list(t,e.panel.elasticsearch_size).then(function(t){n.isUndefined(t.hits)||(e.panel.error=!1,e.hits=t.hits.total,e.elasticsearch.dashboards=t.hits.hits)})},e.save_gist=function(){i.save_gist(e.gist.title).then(function(t){n.isUndefined(t)?s.set("Save failed","Gist could not be saved","error",5e3):(e.gist.last=t,s.set("Gist saved",'You will be able to access your exported dashboard file at <a href="'+t+'">'+t+"</a> in a moment","success"))})},e.gist_dblist=function(t){i.gist_list(t).then(function(t){t&&t.length>0?e.gist.files=t:s.set("Gist Failed","Could not retrieve dashboard list from gist","error",5e3)})}}]),r.directive("dashUpload",["timer","dashboard","alertSrv",function(e,t,n){return{restrict:"A",link:function(e){function r(n){var r=n.target.files,i=function(){return function(n){t.dash_load(JSON.parse(n.target.result)),e.$apply()}};for(var s=0,o
;o=r[s];s++){var u=new FileReader;u.onload=i(o),u.readAsText(o)}}window.File&&window.FileReader&&window.FileList&&window.Blob?document.getElementById("dashupload").addEventListener("change",r,!1):n.set("Oops","Sorry, the HTML5 File APIs are not fully supported in this browser.","error")}}}]),r.filter("gistid",function(){var e=/(\d{5,})|([a-z0-9]{10,})|(gist.github.com(\/*.*)\/[a-z0-9]{5,}\/*$)/;return function(t){if(!n.isUndefined(t)){var r=t.match(e);if(!n.isNull(r)&&!n.isUndefined(r))return r[0].replace(/.*\//,"")}}})});