diff --git a/.gitignore b/.gitignore index 79eb783..519a603 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules -tmp \ No newline at end of file +tmp +/.project +/.settings/ diff --git a/dist/components/endpoint/endpoint_config.js b/dist/components/endpoint/endpoint_config.js index d7a5d68..ac03264 100644 --- a/dist/components/endpoint/endpoint_config.js +++ b/dist/components/endpoint/endpoint_config.js @@ -136,7 +136,7 @@ System.register(['lodash', 'angular'], function (_export, _context) { this.checks = {}; this.endpoint = {}; this.probes = []; - this.probesByTag = {}; + this.selectedFootprint = []; this.org = null; this.quotas = {}; @@ -327,24 +327,7 @@ System.register(['lodash', 'angular'], function (_export, _context) { }, { key: 'getProbesForCheck', value: function getProbesForCheck(check) { - if (check.route.type === "byIds") { - return check.route.config.ids || []; - } - - if (check.route.type === "byTags") { - var probeList = {}; - _.forEach(this.probes, function (p) { - _.forEach(check.route.config.tags, function (t) { - if (_.indexOf(p.tags, t) !== -1) { - probeList[p.id] = true; - } - }); - }); - return _.keys(probeList); - } - - this.alertSrv("check has unknown routing type.", "unknown route type.", "error", 5000); - return []; + return check.route.config.ids || []; } }, { key: 'totalChecks', @@ -672,6 +655,50 @@ System.register(['lodash', 'angular'], function (_export, _context) { break; } } + }, { + key: 'initialEndpointChecksFootprint', + value: function initialEndpointChecksFootprint(footprint) { + var _this15 = this; + + _.forEach(this.endpoint.checks, function (check) { + check.route = footprint.route; + _this15.checks[check.type].route = footprint.route; + }); + } + }, { + key: 'replaceAllEndpointChecksFootprint', + value: function replaceAllEndpointChecksFootprint(footprint) { + var _this16 = this; + + _.forEach(this.endpoint.checks, function (check) { + check.route = footprint.route; + }); + return this.saveEndpoint().then(function () { + _this16.alertSrv.set("All checks updated.", "", "success", 2000); + _.forEach(_this16.endpoint.checks, function (check) { + _this16.checks[check.type] = _.cloneDeep(check); + }); + }); + } + }, { + key: 'appendAllEndpointChecksFootprint', + value: function appendAllEndpointChecksFootprint(footprint) { + var _this17 = this; + + _.forEach(this.endpoint.checks, function (check) { + _.forEach(footprint.route.config.ids, function (id) { + if (check.route.config.ids.indexOf(id) === -1) { + check.route.config.ids.push(id); + } + }); + }); + return this.saveEndpoint().then(function () { + _this17.alertSrv.set("All checks updated.", "", "success", 2000); + _.forEach(_this17.endpoint.checks, function (check) { + _this17.checks[check.type] = _.cloneDeep(check); + }); + }); + } }]); return EndpointConfigCtrl; diff --git a/dist/components/endpoint/endpoint_config.js.map b/dist/components/endpoint/endpoint_config.js.map index a961511..d7902a8 100644 --- a/dist/components/endpoint/endpoint_config.js.map +++ b/dist/components/endpoint/endpoint_config.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../src/components/endpoint/endpoint_config.js"],"names":["defaultCheck","checkType","check","_","cloneDeep","_defaultCheck","type","settings","timeout","port","path","headers","body","method","host","downloadLimit","frequency","validateCert","hostname","name","protocol","server","angular","healthSettings","notifications","num_collectors","steps","route","config","EndpointConfigCtrl","$scope","$injector","$rootScope","$location","$modal","$anchorScroll","$timeout","$window","$q","backendSrv","alertSrv","self","pageReady","showCreating","insufficientQuota","frequencyOpts","freqOpt","forEach","push","value","f","label","newEndpointName","checks","endpoint","probes","probesByTag","org","quotas","ignoreChanges","promises","reset","search","getEndpoint","getQuotas","checkQuota","getProbes","getOrgDetails","all","then","err","set","showPing","showDNS","showHTTP","showHTTPS","onbeforeunload","changesPending","$on","event","next","preventDefault","baseLen","absUrl","length","url","console","log","nextUrl","substring","modalScope","$new","ignore","save","savePending","appEvent","src","modalClass","scope","idString","id","parseInt","get","resp","meta","code","message","reject","definedChecks","keys","indexOf","q","target","limit","used","probe","tags","t","statusText","getProbesForCheck","ids","probeList","p","undefined","reduce","total","enabled","totalChecks","probeCount","size","toFixed","wpPlan","checksPerMonth","discovered","discoveryInProgress","discoveryError","showConfig","history","back","delete","saveEndpoint","i","put","numProbes","num_collector","found","c","finally","delay","newChecks","post","slug","endpointReadyDelay","endpointReady","changes","seenCheckTypes","equals","templateUrl"],"mappings":";;;;;;;;;;;;;AA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AP,IAAyB,MAAzB;AACA,qBAAK7B,SAAL,CAAevB,IAAf,CAAoB,sCAApB,EAA4DoD,MAA5D,CAAmEA,MAAnE;AACA;AACF,mBAAK,OAAL;AACEA,uBAAO,cAAP,IAAyB,OAAzB;AACA,qBAAK7B,SAAL,CAAevB,IAAf,CAAoB,sCAApB,EAA4DoD,MAA5D,CAAmEA,MAAnE;AACA;AACF;AACE,qBAAK7B,SAAL,CAAevB,IAAf,CAAoB,0CAApB,EAAgEoD,MAAhE,CAAuEA,MAAvE;AACA;AApBJ;AAsBD;;;;;;AAGHjC,yBAAmBgI,WAAnB,GAAiC,yFAAjC;;oCAEQhI,kB","file":"endpoint_config.js","sourcesContent":["import _ from 'lodash';\nimport angular from 'angular';\n\nvar _defaultCheck = {\n settings: {},\n healthSettings: {\n notifications: {},\n num_collectors: 3,\n steps: 3\n },\n route: {\n type: \"byIds\",\n config: {\n \"ids\": []\n }\n }\n};\n\nfunction defaultCheck(checkType) {\n var check = _.cloneDeep(_defaultCheck);\n switch (checkType) {\n case \"http\":\n check.type = \"http\";\n check.settings = {\n timeout: 5,\n port: 80,\n path: \"/\",\n headers: \"User-Agent: worldping-api\\nAccept-Encoding: gzip\\n\",\n body: '',\n method: \"GET\",\n host: \"\",\n downloadLimit: '',\n };\n check.frequency = 120;\n break;\n case \"https\":\n check.type = \"https\";\n check.settings = {\n timeout: 5,\n port: 443,\n path: \"/\",\n headers: \"User-Agent: worldping-api\\nAccept-Encoding: gzip\\n\",\n body: '',\n method: \"GET\",\n host: \"\",\n validateCert: true,\n downloadLimit: '',\n };\n check.frequency = 120;\n break;\n case \"ping\":\n check.type = \"ping\";\n check.settings = {\n timeout: 5,\n hostname: \"\"\n };\n check.frequency = 60;\n break;\n case \"dns\":\n check.type = \"dns\";\n check.settings = {\n timeout: 5,\n name: \"\",\n port: 53,\n protocol: \"udp\",\n server: \"\",\n type: \"A\"\n };\n check.frequency = 120;\n break;\n }\n return check;\n}\n\nclass EndpointConfigCtrl {\n /** @ngInject */\n constructor($scope, $injector, $rootScope, $location, $modal, $anchorScroll, $timeout, $window, $q, backendSrv, alertSrv) {\n var self = this;\n this.backendSrv = backendSrv;\n this.$location = $location;\n this.$timeout = $timeout;\n this.$q = $q;\n this.alertSrv = alertSrv;\n this.$window = $window;\n\n this.pageReady = false;\n this.showCreating = false;\n this.insufficientQuota = false;\n\n this.frequencyOpts = [];\n var freqOpt = [10, 30, 60, 120];\n _.forEach(freqOpt, f => {\n this.frequencyOpts.push({value: f, label: \"Every \"+f+\"s\"});\n });\n\n this.newEndpointName = \"\";\n this.checks = {};\n this.endpoint = {};\n this.probes = [];\n this.probesByTag = {};\n this.org = null;\n this.quotas = {};\n\n this.ignoreChanges = false;\n\n var promises = [];\n this.reset();\n if (\"endpoint\" in $location.search()) {\n promises.push(this.getEndpoint($location.search().endpoint));\n promises.push(this.getQuotas());\n } else {\n // make sure we have sufficient quota.\n promises.push(this.checkQuota());\n this.endpoint = {name: \"\"};\n }\n\n promises.push(this.getProbes());\n promises.push(this.getOrgDetails());\n\n $q.all(promises).then(() => {\n this.pageReady = true;\n $timeout(function() {\n $anchorScroll();\n }, 0, false);\n }, function(err) {\n alertSrv.set(\"endpoint config init failed\", err, 'error', 10000);\n });\n\n if ($location.search().check) {\n switch($location.search().check) {\n case \"ping\":\n this.showPing = true;\n break;\n case \"dns\":\n this.showDNS = true;\n break;\n case \"http\":\n this.showHTTP = true;\n break;\n case \"https\":\n this.showHTTPS = true;\n break;\n }\n }\n\n $window.onbeforeunload = function() {\n if (self.ignoreChanges) { return; }\n if (self.changesPending()) {\n return \"There are unsaved changes to this dashboard\";\n }\n };\n\n $scope.$on('$locationChangeStart', function(event, next) {\n if ((!self.ignoreChanges) && (self.changesPending())) {\n event.preventDefault();\n var baseLen = $location.absUrl().length - $location.url().length;\n console.log(\"next: \", next);\n console.log(\"baseLen: \", baseLen);\n var nextUrl = next.substring(baseLen);\n console.log(\"nexUrl: \", nextUrl);\n var modalScope = $scope.$new();\n modalScope.ignore = function() {\n self.ignoreChanges = true;\n $location.url(nextUrl);\n return;\n };\n\n modalScope.save = function() {\n self.savePending(nextUrl);\n };\n\n $rootScope.appEvent('show-modal', {\n src: 'public/app/partials/unsaved-changes.html',\n modalClass: 'confirm-modal',\n scope: modalScope,\n });\n }\n });\n }\n\n getEndpoint(idString) {\n var id = parseInt(idString);\n return this.backendSrv.get('api/plugin-proxy/raintank-worldping-app/api/v2/endpoints/'+id).then(resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to get endpoint.\", resp.meta.message, 'error', 10000);\n return this.$q.reject(resp.meta.message);\n }\n this.endpoint = resp.body;\n this.newEndpointName = this.endpoint.name;\n _.forEach(resp.body.checks, check => {\n this.checks[check.type] = _.cloneDeep(check);\n });\n var definedChecks = _.keys(this.checks);\n if (definedChecks.length < 4) {\n if (_.indexOf(definedChecks, \"http\") === -1) {\n this.checks[\"http\"] = defaultCheck(\"http\");\n }\n if (_.indexOf(definedChecks, \"https\") === -1) {\n this.checks[\"https\"] = defaultCheck(\"https\");\n }\n if (_.indexOf(definedChecks, \"ping\") === -1) {\n this.checks[\"ping\"] = defaultCheck(\"ping\");\n }\n if (_.indexOf(definedChecks, \"dns\") === -1) {\n this.checks[\"dns\"] = defaultCheck(\"dns\");\n }\n }\n });\n }\n\n getQuotas() {\n return this.backendSrv.get('api/plugin-proxy/raintank-worldping-app/api/v2/quotas').then(resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to get quotas.\", resp.meta.message, 'error', 10000);\n return this.$q.reject(resp.meta.message);\n }\n _.forEach(resp.body, q => {\n this.quotas[q.target] = q;\n });\n return this.quotas;\n });\n }\n\n checkQuota() {\n return this.getQuotas().then(quotas => {\n if (quotas.endpoint) {\n const q = quotas.endpoint;\n this.insufficientQuota = q.limit > 0 && q.used >= q.limit;\n }\n if (this.insufficientQuota) {\n return this.$q.reject(\"Endpoint quota reached.\");\n }\n return true;\n });\n }\n\n getProbes() {\n return this.backendSrv.get('api/plugin-proxy/raintank-worldping-app/api/v2/probes').then(resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to get getProbes.\", resp.meta.message, 'error', 10000);\n return this.$q.reject(resp.meta.message);\n }\n this.probes = resp.body;\n _.forEach(this.probes, probe => {\n _.forEach(probe.tags, t => {\n if (!(t in this.probesByTag)) {\n this.probesByTag[t] = [];\n }\n this.probesByTag[t].push(probe);\n });\n });\n });\n }\n\n getOrgDetails() {\n return this.backendSrv.get('api/plugin-proxy/raintank-worldping-app/api/grafana-net/profile/org').then(\n resp => {\n this.org = resp;\n },\n resp => {\n this.alertSrv.set(\"failed to get Org Details\", resp.statusText, 'error', 10000);\n }\n );\n }\n\n probeCount(check) {\n if (!check) {\n return 0;\n }\n return this.getProbesForCheck(check).length;\n }\n\n getProbesForCheck(check) {\n if (check.route.type === \"byIds\") {\n return check.route.config.ids || [];\n }\n\n if (check.route.type === \"byTags\") {\n var probeList = {};\n _.forEach(this.probes, p => {\n _.forEach(check.route.config.tags, t => {\n if (_.indexOf(p.tags, t) !== -1) {\n probeList[p.id] = true;\n }\n });\n });\n return _.keys(probeList);\n }\n\n this.alertSrv(\"check has unknown routing type.\", \"unknown route type.\", \"error\", 5000);\n return [];\n }\n\n totalChecks(check) {\n if (check === undefined) {\n return _.reduce(this.checks, (total, value) => {\n if (!value.enabled) {\n return total;\n }\n\n return total + this.totalChecks(value);\n }, 0);\n }\n\n var probeCount = this.probeCount(check);\n if (probeCount < 1 || check.frequency < 1) {\n return 0;\n }\n\n return (30.4375 * 24 * (3600/check.frequency) * probeCount / 1000000);\n }\n\n formatSize(size) {\n if (size > 1024 * 1024) {\n return (size / 1024 / 1024).toFixed(2) + ' MB';\n }\n if (size > 1024) {\n return (size / 1024).toFixed(2) + ' KB';\n }\n return size;\n }\n\n currentlyTrial() {\n if (!this.org) {\n return false;\n }\n\n if (this.org.wpPlan === 'trial') {\n return true;\n }\n\n return false;\n }\n\n requiresUpgrade() {\n if (!this.org) {\n return true;\n }\n\n if (this.org.wpPlan !== '' && this.org.wpPlan !== 'free' && this.org.wpPlan !== 'trial') {\n return false;\n }\n\n if (this.org.checksPerMonth / 1000000 + this.totalChecks() > 1) {\n return true;\n }\n\n return false;\n }\n\n reset() {\n this.discovered = false;\n this.discoveryInProgress = false;\n this.discoveryError = false;\n this.showConfig = false;\n this.showCreating = false;\n this.endpoint = {};\n this.checks = {};\n }\n\n cancel() {\n this.reset();\n this.ignoreChanges = true;\n this.$window.history.back();\n }\n\n remove(endpoint) {\n return this.backendSrv.delete('api/plugin-proxy/raintank-worldping-app/api/v2/endpoints/' + endpoint.id).then(resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to delete endpoint.\", resp.meta.message, 'error', 10000);\n return this.$q.reject(resp.meta.message);\n }\n this.$location.path('plugins/raintank-worldping-app/page/endpoints');\n });\n }\n\n updateEndpoint() {\n this.endpoint.name = this.newEndpointName;\n this.saveEndpoint();\n }\n\n tagsUpdated() {\n this.saveEndpoint();\n }\n\n savePending(nextUrl) {\n _.forEach(this.checks, check => {\n if (!check.id && check.enabled) {\n //add the check\n this.endpoint.checks.push(check);\n return;\n }\n for (var i=0; i < this.endpoint.checks.length; i++) {\n if (this.endpoint.checks[i].id === check.id) {\n this.endpoint.checks[i] = _.cloneDeep(check);\n }\n }\n });\n return this.saveEndpoint().then(() => {\n this.ignoreChanges = true;\n if (nextUrl) {\n this.$location.url(nextUrl);\n } else {\n this.$location.path(\"plugins/raintank-worldping-app/page/endpoints\");\n }\n });\n }\n\n saveEndpoint() {\n return this.backendSrv.put('api/plugin-proxy/raintank-worldping-app/api/v2/endpoints', this.endpoint).then(resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to update endpoint.\", resp.meta.message, 'error', 10000);\n return this.$q.reject(resp.meta.message);\n }\n this.endpoint = resp.body;\n });\n }\n\n updateCheck(check) {\n if (check.enabled) {\n var numProbes = this.probeCount(check);\n if (numProbes < check.healthSettings.num_collector) {\n check.healthSettings.num_collectors = numProbes;\n }\n if (check.type === \"http\" || check.type === \"https\") {\n if (['PUT', 'POST', 'DELETE', 'PATCH'].indexOf(check.settings.method) < 0) {\n check.settings.body = \"\";\n }\n }\n }\n var found = false;\n for (var i=0; i < this.endpoint.checks.length; i++) {\n if (this.endpoint.checks[i].type === check.type) {\n this.endpoint.checks[i] = _.cloneDeep(check);\n found = true;\n break;\n }\n }\n if (!found) {\n this.endpoint.checks.push(check);\n }\n return this.saveEndpoint().then(() => {\n this.alertSrv.set(check.type + \" check updated.\", \"\", \"success\", 2000);\n _.forEach(this.endpoint.checks, c => {\n if (c.type === check.type) {\n this.checks[check.type] = _.cloneDeep(c);\n }\n });\n });\n }\n\n skipDiscovery() {\n this.discoveryInProgress = false;\n this.showConfig = true;\n this.discoveryError = false;\n }\n\n discover(endpoint) {\n if (!endpoint.name){\n return;\n }\n this.discoveryInProgress = true;\n this.discoveryError = false;\n return this.backendSrv.get('api/plugin-proxy/raintank-worldping-app/api/v2/endpoints/discover', endpoint).then(\n resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to update endpoint.\", resp.meta.message, 'error', 10000);\n this.discoveryError = \"Failed to discover endpoint.\";\n return this.$q.reject(resp.meta.message);\n }\n this.endpoint = resp.body;\n _.forEach(this.endpoint.checks, check => {\n this.checks[check.type] = _.cloneDeep(check);\n });\n var definedChecks = _.keys(this.checks);\n if (definedChecks.length < 4) {\n if (_.indexOf(definedChecks, \"http\") === -1) {\n this.checks[\"http\"] = defaultCheck(\"http\");\n }\n if (_.indexOf(definedChecks, \"https\") === -1) {\n this.checks[\"https\"] = defaultCheck(\"https\");\n }\n if (_.indexOf(definedChecks, \"ping\") === -1) {\n this.checks[\"ping\"] =defaultCheck(\"ping\");\n }\n if (_.indexOf(definedChecks, \"dns\") === -1) {\n this.checks[\"dns\"] = defaultCheck(\"dns\");\n }\n }\n this.showConfig = true;\n this.discovered = true;\n },\n () => {\n this.discoveryError = \"Failed to discover endpoint.\";\n }\n ).finally(() => {\n this.discoveryInProgress = false;\n });\n }\n\n addEndpoint() {\n var self = this;\n var delay = 120;\n var newChecks = [];\n _.forEach(this.checks, check => {\n if (check.enabled) {\n if (check.frequency < delay) {\n delay = check.frequency;\n }\n var numProbes = this.probeCount(check);\n if (numProbes < 3) {\n check.healthSettings.num_collectors = numProbes;\n }\n newChecks.push(check);\n }\n });\n this.endpoint.checks = newChecks;\n return this.backendSrv.post('api/plugin-proxy/raintank-worldping-app/api/v2/endpoints', this.endpoint).then(resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to add endpoint.\", resp.meta.message, 'error', 10000);\n return this.$q.reject(resp.meta.message);\n }\n this.endpoint.id = resp.body.id;\n this.endpoint.slug = resp.body.slug;\n this.ignoreChanges = true;\n this.alertSrv.set(\"endpoint added\", '', 'success', 3000);\n this.showCreating = true;\n this.endpointReadyDelay = delay;\n this.endpointReady = false;\n this.$timeout(function() {\n self.endpointReady = true;\n }, delay * 1000);\n });\n }\n\n changesPending() {\n var changes = false;\n var seenCheckTypes = {};\n\n //check if any existing checks have changed\n _.forEach(this.endpoint.checks, check => {\n seenCheckTypes[check.type] = true;\n if (!angular.equals(check, this.checks[check.type])) {\n changes = true;\n }\n });\n\n //check if any new checks added.\n _.forEach(this.checks, check => {\n if (!(check.type in seenCheckTypes) && (\"frequency\" in check) && check.enabled) {\n changes = true;\n }\n });\n\n return changes;\n }\n\n gotoDashboard(endpoint, type) {\n if (!type) {\n type = 'summary';\n }\n var search = {\n \"var-collector\": \"All\",\n \"var-endpoint\": this.endpoint.slug\n };\n switch(type) {\n case \"summary\":\n this.$location.path(\"/dashboard/db/worldping-endpoint-summary\").search(search);\n break;\n case \"ping\":\n this.$location.path(\"/dashboard/db/worldping-endpoint-ping\").search(search);\n break;\n case \"dns\":\n this.$location.path(\"/dashboard/db/worldping-endpoint-dns\").search(search);\n break;\n case \"http\":\n search['var-protocol'] = \"http\";\n this.$location.path(\"/dashboard/db/worldping-endpoint-web\").search(search);\n break;\n case \"https\":\n search['var-protocol'] = \"https\";\n this.$location.path(\"/dashboard/db/worldping-endpoint-web\").search(search);\n break;\n default:\n this.$location.path(\"/dashboard/db/worldping-endpoint-summary\").search(search);\n break;\n }\n }\n}\n\nEndpointConfigCtrl.templateUrl = 'public/plugins/raintank-worldping-app/components/endpoint/partials/endpoint_config.html';\n\nexport {EndpointConfigCtrl};\n"]} \ No newline at end of file +{"version":3,"sources":["../../../src/components/endpoint/endpoint_config.js"],"names":["defaultCheck","checkType","check","_","cloneDeep","_defaultCheck","type","settings","timeout","port","path","headers","body","method","host","downloadLimit","frequency","validateCert","hostname","name","protocol","server","angular","healthSettings","notifications","num_collectors","steps","route","config","EndpointConfigCtrl","$scope","$injector","$rootScope","$location","$modal","$anchorScroll","$timeout","$window","$q","backendSrv","alertSrv","self","pageReady","showCreating","insufficientQuota","frequencyOpts","freqOpt","forEach","push","value","f","label","newEndpointName","checks","endpoint","probes","selectedFootprint","org","quotas","ignoreChanges","promises","reset","search","getEndpoint","getQuotas","checkQuota","getProbes","getOrgDetails","all","then","err","set","showPing","showDNS","showHTTP","showHTTPS","onbeforeunload","changesPending","$on","event","next","preventDefault","baseLen","absUrl","length","url","console","log","nextUrl","substring","modalScope","$new","ignore","save","savePending","appEvent","src","modalClass","scope","idString","id","parseInt","get","resp","meta","code","message","reject","definedChecks","keys","indexOf","q","target","limit","used","probe","tags","t","probesByTag","statusText","getProbesForCheck","ids","undefined","reduce","total","enabled","totalChecks","probeCount","size","toFixed","wpPlan","checksPerMonth","discovered","discoveryInProgress","discoveryError","showConfig","history","back","delete","saveEndpoint","i","put","numProbes","num_collector","found","c","finally","delay","newChecks","post","slug","endpointReadyDelay","endpointReady","changes","seenCheckTypes","equals","footprint","templateUrl"],"mappings":";;;;;;;;;;;;;AAkBA,WAASA,YAAT,CAAsBC,SAAtB,EAAiC;AAC/B,QAAIC,QAAQC,EAAEC,SAAF,CAAYC,aAAZ,CAAZ;AACA,YAAQJ,SAAR;AACA,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ultCheck = {\n settings: {},\n healthSettings: {\n notifications: {},\n num_collectors: 3,\n steps: 3\n },\n route: {\n type: \"byIds\",\n config: {\n \"ids\": []\n }\n }\n};\n\nfunction defaultCheck(checkType) {\n var check = _.cloneDeep(_defaultCheck);\n switch (checkType) {\n case \"http\":\n check.type = \"http\";\n check.settings = {\n timeout: 5,\n port: 80,\n path: \"/\",\n headers: \"User-Agent: worldping-api\\nAccept-Encoding: gzip\\n\",\n body: '',\n method: \"GET\",\n host: \"\",\n downloadLimit: '',\n };\n check.frequency = 120;\n break;\n case \"https\":\n check.type = \"https\";\n check.settings = {\n timeout: 5,\n port: 443,\n path: \"/\",\n headers: \"User-Agent: worldping-api\\nAccept-Encoding: gzip\\n\",\n body: '',\n method: \"GET\",\n host: \"\",\n validateCert: true,\n downloadLimit: '',\n };\n check.frequency = 120;\n break;\n case \"ping\":\n check.type = \"ping\";\n check.settings = {\n timeout: 5,\n hostname: \"\"\n };\n check.frequency = 60;\n break;\n case \"dns\":\n check.type = \"dns\";\n check.settings = {\n timeout: 5,\n name: \"\",\n port: 53,\n protocol: \"udp\",\n server: \"\",\n type: \"A\"\n };\n check.frequency = 120;\n break;\n }\n return check;\n}\n\nclass EndpointConfigCtrl {\n /** @ngInject */\n constructor($scope, $injector, $rootScope, $location, $modal, $anchorScroll, $timeout, $window, $q, backendSrv, alertSrv) {\n var self = this;\n this.backendSrv = backendSrv;\n this.$location = $location;\n this.$timeout = $timeout;\n this.$q = $q;\n this.alertSrv = alertSrv;\n this.$window = $window;\n\n this.pageReady = false;\n this.showCreating = false;\n this.insufficientQuota = false;\n\n this.frequencyOpts = [];\n var freqOpt = [10, 30, 60, 120];\n _.forEach(freqOpt, f => {\n this.frequencyOpts.push({value: f, label: \"Every \"+f+\"s\"});\n });\n\n this.newEndpointName = \"\";\n this.checks = {};\n this.endpoint = {};\n this.probes = [];\n this.selectedFootprint = [];\n this.org = null;\n this.quotas = {};\n\n this.ignoreChanges = false;\n\n var promises = [];\n this.reset();\n if (\"endpoint\" in $location.search()) {\n promises.push(this.getEndpoint($location.search().endpoint));\n promises.push(this.getQuotas());\n } else {\n // make sure we have sufficient quota.\n promises.push(this.checkQuota());\n this.endpoint = {name: \"\"};\n }\n\n promises.push(this.getProbes());\n promises.push(this.getOrgDetails());\n\n $q.all(promises).then(() => {\n this.pageReady = true;\n $timeout(function() {\n $anchorScroll();\n }, 0, false);\n }, function(err) {\n alertSrv.set(\"endpoint config init failed\", err, 'error', 10000);\n });\n\n if ($location.search().check) {\n switch($location.search().check) {\n case \"ping\":\n this.showPing = true;\n break;\n case \"dns\":\n this.showDNS = true;\n break;\n case \"http\":\n this.showHTTP = true;\n break;\n case \"https\":\n this.showHTTPS = true;\n break;\n }\n }\n\n $window.onbeforeunload = function() {\n if (self.ignoreChanges) { return; }\n if (self.changesPending()) {\n return \"There are unsaved changes to this dashboard\";\n }\n };\n\n $scope.$on('$locationChangeStart', function(event, next) {\n if ((!self.ignoreChanges) && (self.changesPending())) {\n event.preventDefault();\n var baseLen = $location.absUrl().length - $location.url().length;\n console.log(\"next: \", next);\n console.log(\"baseLen: \", baseLen);\n var nextUrl = next.substring(baseLen);\n console.log(\"nexUrl: \", nextUrl);\n var modalScope = $scope.$new();\n modalScope.ignore = function() {\n self.ignoreChanges = true;\n $location.url(nextUrl);\n return;\n };\n\n modalScope.save = function() {\n self.savePending(nextUrl);\n };\n\n $rootScope.appEvent('show-modal', {\n src: 'public/app/partials/unsaved-changes.html',\n modalClass: 'confirm-modal',\n scope: modalScope,\n });\n }\n });\n }\n\n getEndpoint(idString) {\n var id = parseInt(idString);\n return this.backendSrv.get('api/plugin-proxy/raintank-worldping-app/api/v2/endpoints/'+id).then(resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to get endpoint.\", resp.meta.message, 'error', 10000);\n return this.$q.reject(resp.meta.message);\n }\n this.endpoint = resp.body;\n this.newEndpointName = this.endpoint.name;\n _.forEach(resp.body.checks, check => {\n this.checks[check.type] = _.cloneDeep(check);\n });\n var definedChecks = _.keys(this.checks);\n if (definedChecks.length < 4) {\n if (_.indexOf(definedChecks, \"http\") === -1) {\n this.checks[\"http\"] = defaultCheck(\"http\");\n }\n if (_.indexOf(definedChecks, \"https\") === -1) {\n this.checks[\"https\"] = defaultCheck(\"https\");\n }\n if (_.indexOf(definedChecks, \"ping\") === -1) {\n this.checks[\"ping\"] = defaultCheck(\"ping\");\n }\n if (_.indexOf(definedChecks, \"dns\") === -1) {\n this.checks[\"dns\"] = defaultCheck(\"dns\");\n }\n }\n });\n }\n\n getQuotas() {\n return this.backendSrv.get('api/plugin-proxy/raintank-worldping-app/api/v2/quotas').then(resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to get quotas.\", resp.meta.message, 'error', 10000);\n return this.$q.reject(resp.meta.message);\n }\n _.forEach(resp.body, q => {\n this.quotas[q.target] = q;\n });\n return this.quotas;\n });\n }\n\n checkQuota() {\n return this.getQuotas().then(quotas => {\n if (quotas.endpoint) {\n const q = quotas.endpoint;\n this.insufficientQuota = q.limit > 0 && q.used >= q.limit;\n }\n if (this.insufficientQuota) {\n return this.$q.reject(\"Endpoint quota reached.\");\n }\n return true;\n });\n }\n\n getProbes() {\n return this.backendSrv.get('api/plugin-proxy/raintank-worldping-app/api/v2/probes').then(resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to get getProbes.\", resp.meta.message, 'error', 10000);\n return this.$q.reject(resp.meta.message);\n }\n this.probes = resp.body;\n _.forEach(this.probes, probe => {\n _.forEach(probe.tags, t => {\n if (!(t in this.probesByTag)) {\n this.probesByTag[t] = [];\n }\n this.probesByTag[t].push(probe);\n });\n });\n });\n }\n\n getOrgDetails() {\n return this.backendSrv.get('api/plugin-proxy/raintank-worldping-app/api/grafana-net/profile/org').then(\n resp => {\n this.org = resp;\n },\n resp => {\n this.alertSrv.set(\"failed to get Org Details\", resp.statusText, 'error', 10000);\n }\n );\n }\n\n probeCount(check) {\n if (!check) {\n return 0;\n }\n return this.getProbesForCheck(check).length;\n }\n\n getProbesForCheck(check) {\n return check.route.config.ids || [];\n }\n\n totalChecks(check) {\n if (check === undefined) {\n return _.reduce(this.checks, (total, value) => {\n if (!value.enabled) {\n return total;\n }\n\n return total + this.totalChecks(value);\n }, 0);\n }\n\n var probeCount = this.probeCount(check);\n if (probeCount < 1 || check.frequency < 1) {\n return 0;\n }\n\n return (30.4375 * 24 * (3600/check.frequency) * probeCount / 1000000);\n }\n\n formatSize(size) {\n if (size > 1024 * 1024) {\n return (size / 1024 / 1024).toFixed(2) + ' MB';\n }\n if (size > 1024) {\n return (size / 1024).toFixed(2) + ' KB';\n }\n return size;\n }\n\n currentlyTrial() {\n if (!this.org) {\n return false;\n }\n\n if (this.org.wpPlan === 'trial') {\n return true;\n }\n\n return false;\n }\n\n requiresUpgrade() {\n if (!this.org) {\n return true;\n }\n\n if (this.org.wpPlan !== '' && this.org.wpPlan !== 'free' && this.org.wpPlan !== 'trial') {\n return false;\n }\n\n if (this.org.checksPerMonth / 1000000 + this.totalChecks() > 1) {\n return true;\n }\n\n return false;\n }\n\n reset() {\n this.discovered = false;\n this.discoveryInProgress = false;\n this.discoveryError = false;\n this.showConfig = false;\n this.showCreating = false;\n this.endpoint = {};\n this.checks = {};\n }\n\n cancel() {\n this.reset();\n this.ignoreChanges = true;\n this.$window.history.back();\n }\n\n remove(endpoint) {\n return this.backendSrv.delete('api/plugin-proxy/raintank-worldping-app/api/v2/endpoints/' + endpoint.id).then(resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to delete endpoint.\", resp.meta.message, 'error', 10000);\n return this.$q.reject(resp.meta.message);\n }\n this.$location.path('plugins/raintank-worldping-app/page/endpoints');\n });\n }\n\n updateEndpoint() {\n this.endpoint.name = this.newEndpointName;\n this.saveEndpoint();\n }\n\n tagsUpdated() {\n this.saveEndpoint();\n }\n\n savePending(nextUrl) {\n _.forEach(this.checks, check => {\n if (!check.id && check.enabled) {\n //add the check\n this.endpoint.checks.push(check);\n return;\n }\n for (var i=0; i < this.endpoint.checks.length; i++) {\n if (this.endpoint.checks[i].id === check.id) {\n this.endpoint.checks[i] = _.cloneDeep(check);\n }\n }\n });\n return this.saveEndpoint().then(() => {\n this.ignoreChanges = true;\n if (nextUrl) {\n this.$location.url(nextUrl);\n } else {\n this.$location.path(\"plugins/raintank-worldping-app/page/endpoints\");\n }\n });\n }\n\n saveEndpoint() {\n return this.backendSrv.put('api/plugin-proxy/raintank-worldping-app/api/v2/endpoints', this.endpoint).then(resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to update endpoint.\", resp.meta.message, 'error', 10000);\n return this.$q.reject(resp.meta.message);\n }\n this.endpoint = resp.body;\n });\n }\n\n updateCheck(check) {\n if (check.enabled) {\n var numProbes = this.probeCount(check);\n if (numProbes < check.healthSettings.num_collector) {\n check.healthSettings.num_collectors = numProbes;\n }\n if (check.type === \"http\" || check.type === \"https\") {\n if (['PUT', 'POST', 'DELETE', 'PATCH'].indexOf(check.settings.method) < 0) {\n check.settings.body = \"\";\n }\n }\n }\n var found = false;\n for (var i=0; i < this.endpoint.checks.length; i++) {\n if (this.endpoint.checks[i].type === check.type) {\n this.endpoint.checks[i] = _.cloneDeep(check);\n found = true;\n break;\n }\n }\n if (!found) {\n this.endpoint.checks.push(check);\n }\n return this.saveEndpoint().then(() => {\n this.alertSrv.set(check.type + \" check updated.\", \"\", \"success\", 2000);\n _.forEach(this.endpoint.checks, c => {\n if (c.type === check.type) {\n this.checks[check.type] = _.cloneDeep(c);\n }\n });\n });\n }\n\n skipDiscovery() {\n this.discoveryInProgress = false;\n this.showConfig = true;\n this.discoveryError = false;\n }\n\n discover(endpoint) {\n if (!endpoint.name){\n return;\n }\n this.discoveryInProgress = true;\n this.discoveryError = false;\n return this.backendSrv.get('api/plugin-proxy/raintank-worldping-app/api/v2/endpoints/discover', endpoint).then(\n resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to update endpoint.\", resp.meta.message, 'error', 10000);\n this.discoveryError = \"Failed to discover endpoint.\";\n return this.$q.reject(resp.meta.message);\n }\n this.endpoint = resp.body;\n _.forEach(this.endpoint.checks, check => {\n this.checks[check.type] = _.cloneDeep(check);\n });\n var definedChecks = _.keys(this.checks);\n if (definedChecks.length < 4) {\n if (_.indexOf(definedChecks, \"http\") === -1) {\n this.checks[\"http\"] = defaultCheck(\"http\");\n }\n if (_.indexOf(definedChecks, \"https\") === -1) {\n this.checks[\"https\"] = defaultCheck(\"https\");\n }\n if (_.indexOf(definedChecks, \"ping\") === -1) {\n this.checks[\"ping\"] =defaultCheck(\"ping\");\n }\n if (_.indexOf(definedChecks, \"dns\") === -1) {\n this.checks[\"dns\"] = defaultCheck(\"dns\");\n }\n }\n this.showConfig = true;\n this.discovered = true;\n },\n () => {\n this.discoveryError = \"Failed to discover endpoint.\";\n }\n ).finally(() => {\n this.discoveryInProgress = false;\n });\n }\n\n addEndpoint() {\n var self = this;\n var delay = 120;\n var newChecks = [];\n _.forEach(this.checks, check => {\n if (check.enabled) {\n if (check.frequency < delay) {\n delay = check.frequency;\n }\n var numProbes = this.probeCount(check);\n if (numProbes < 3) {\n check.healthSettings.num_collectors = numProbes;\n }\n newChecks.push(check);\n }\n });\n this.endpoint.checks = newChecks;\n return this.backendSrv.post('api/plugin-proxy/raintank-worldping-app/api/v2/endpoints', this.endpoint).then(resp => {\n if (resp.meta.code !== 200) {\n this.alertSrv.set(\"failed to add endpoint.\", resp.meta.message, 'error', 10000);\n return this.$q.reject(resp.meta.message);\n }\n this.endpoint.id = resp.body.id;\n this.endpoint.slug = resp.body.slug;\n this.ignoreChanges = true;\n this.alertSrv.set(\"endpoint added\", '', 'success', 3000);\n this.showCreating = true;\n this.endpointReadyDelay = delay;\n this.endpointReady = false;\n this.$timeout(function() {\n self.endpointReady = true;\n }, delay * 1000);\n });\n }\n\n changesPending() {\n var changes = false;\n var seenCheckTypes = {};\n\n //check if any existing checks have changed\n _.forEach(this.endpoint.checks, check => {\n seenCheckTypes[check.type] = true;\n if (!angular.equals(check, this.checks[check.type])) {\n changes = true;\n }\n });\n\n //check if any new checks added.\n _.forEach(this.checks, check => {\n if (!(check.type in seenCheckTypes) && (\"frequency\" in check) && check.enabled) {\n changes = true;\n }\n });\n\n return changes;\n }\n\n gotoDashboard(endpoint, type) {\n if (!type) {\n type = 'summary';\n }\n var search = {\n \"var-collector\": \"All\",\n \"var-endpoint\": this.endpoint.slug\n };\n switch(type) {\n case \"summary\":\n this.$location.path(\"/dashboard/db/worldping-endpoint-summary\").search(search);\n break;\n case \"ping\":\n this.$location.path(\"/dashboard/db/worldping-endpoint-ping\").search(search);\n break;\n case \"dns\":\n this.$location.path(\"/dashboard/db/worldping-endpoint-dns\").search(search);\n break;\n case \"http\":\n search['var-protocol'] = \"http\";\n this.$location.path(\"/dashboard/db/worldping-endpoint-web\").search(search);\n break;\n case \"https\":\n search['var-protocol'] = \"https\";\n this.$location.path(\"/dashboard/db/worldping-endpoint-web\").search(search);\n break;\n default:\n this.$location.path(\"/dashboard/db/worldping-endpoint-summary\").search(search);\n break;\n }\n }\n\n initialEndpointChecksFootprint(footprint) {\n _.forEach(this.endpoint.checks, check => {\n check.route = footprint.route;\n this.checks[check.type].route = footprint.route;\n });\n }\n\n replaceAllEndpointChecksFootprint(footprint) {\n _.forEach(this.endpoint.checks, check => {\n check.route = footprint.route;\n });\n return this.saveEndpoint().then(() => {\n this.alertSrv.set(\"All checks updated.\", \"\", \"success\", 2000);\n _.forEach(this.endpoint.checks, check => {\n this.checks[check.type] = _.cloneDeep(check);\n });\n });\n }\n\n appendAllEndpointChecksFootprint(footprint) {\n _.forEach(this.endpoint.checks, check => {\n _.forEach(footprint.route.config.ids, id => {\n if (check.route.config.ids.indexOf(id) === -1){\n check.route.config.ids.push(id);\n }\n });\n });\n return this.saveEndpoint().then(() => {\n this.alertSrv.set(\"All checks updated.\", \"\", \"success\", 2000);\n _.forEach(this.endpoint.checks, check => {\n this.checks[check.type] = _.cloneDeep(check);\n });\n });\n }\n}\n\nEndpointConfigCtrl.templateUrl = 'public/plugins/raintank-worldping-app/components/endpoint/partials/endpoint_config.html';\n\nexport {EndpointConfigCtrl};\n"]} \ No newline at end of file diff --git a/dist/components/endpoint/endpoint_details.js b/dist/components/endpoint/endpoint_details.js index 9103d70..5d57c4c 100644 --- a/dist/components/endpoint/endpoint_details.js +++ b/dist/components/endpoint/endpoint_details.js @@ -19,7 +19,7 @@ System.register(["lodash"], function (_export, _context) { _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; _createClass = function () { diff --git a/dist/components/endpoint/endpoint_list.js b/dist/components/endpoint/endpoint_list.js index c7093db..b5f0fd4 100644 --- a/dist/components/endpoint/endpoint_list.js +++ b/dist/components/endpoint/endpoint_list.js @@ -21,7 +21,7 @@ System.register(['lodash', 'jquery'], function (_export, _context) { _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; _createClass = function () { diff --git a/dist/components/endpoint/partials/endpoint_config.html b/dist/components/endpoint/partials/endpoint_config.html index af6f2e1..413afe8 100644 --- a/dist/components/endpoint/partials/endpoint_config.html +++ b/dist/components/endpoint/partials/endpoint_config.html @@ -49,6 +49,14 @@
At the selected frequency, we'll send a burst of 10 ICMP echo ("ping") packets to the hostname.
@@ -103,7 +108,7 @@