{"action":"created","comment":{"url":"https://api.github.com/repos/prometheus/promdash/pulls/comments/28203342","id":28203342,"diff_hunk":"@@ -60,6 +60,22 @@ angular.module(\"Prometheus.services\").factory(\"SharedGraphBehavior\", [\"$http\", \"\n       }\n     }\n \n+    function addVarsFromServerInterpolations(servers) {\n+      var singleInterpolation = /{{\\s?(\\w+)\\s?}}/g;\n+      for (var i = 0; i < servers.length; i++) {\n+        while (match = singleInterpolation.exec(servers[i].url)) {\n+          var_name = match[1]\n+          if (!(var_name in $scope.globalConfig.vars)) {\n+            console.log(\"Found \" + var_name + \" in \" + servers[i].url)\n+            $scope.globalConfig.vars[var_name] = ''  // no default value\n+          }\n+        }\n+      }\n+    }\n+\n+    $scope.servers = servers;","path":"app/assets/javascripts/angular/resources/shared_graph_behavior.js","position":17,"original_position":17,"commit_id":"33786ba1b24e377bd83d130b278fb988e9faffe1","original_commit_id":"33786ba1b24e377bd83d130b278fb988e9faffe1","user":{"login":"mwitkow-io","id":9655971,"avatar_url":"https://avatars.githubusercontent.com/u/9655971?v=3","gravatar_id":"","url":"https://api.github.com/users/mwitkow-io","html_url":"https://github.com/mwitkow-io","followers_url":"https://api.github.com/users/mwitkow-io/followers","following_url":"https://api.github.com/users/mwitkow-io/following{/other_user}","gists_url":"https://api.github.com/users/mwitkow-io/gists{/gist_id}","starred_url":"https://api.github.com/users/mwitkow-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwitkow-io/subscriptions","organizations_url":"https://api.github.com/users/mwitkow-io/orgs","repos_url":"https://api.github.com/users/mwitkow-io/repos","events_url":"https://api.github.com/users/mwitkow-io/events{/privacy}","received_events_url":"https://api.github.com/users/mwitkow-io/received_events","type":"User","site_admin":false},"body":"@stuartnelson3, I have no idea where `servers` comes from. It's neither from `$scope` nor directly injected. Is this some magical global variable?","created_at":"2015-04-12T13:15:33Z","updated_at":"2015-04-12T13:15:33Z","html_url":"https://github.com/prometheus/promdash/pull/372#discussion_r28203342","pull_request_url":"https://api.github.com/repos/prometheus/promdash/pulls/372","_links":{"self":{"href":"https://api.github.com/repos/prometheus/promdash/pulls/comments/28203342"},"html":{"href":"https://github.com/prometheus/promdash/pull/372#discussion_r28203342"},"pull_request":{"href":"https://api.github.com/repos/prometheus/promdash/pulls/372"}}},"pull_request":{"url":"https://api.github.com/repos/prometheus/promdash/pulls/372","id":33119667,"html_url":"https://github.com/prometheus/promdash/pull/372","diff_url":"https://github.com/prometheus/promdash/pull/372.diff","patch_url":"https://github.com/prometheus/promdash/pull/372.patch","issue_url":"https://api.github.com/repos/prometheus/promdash/issues/372","number":372,"state":"open","locked":false,"title":"Vars Interpolation in Servers","user":{"login":"mwitkow-io","id":9655971,"avatar_url":"https://avatars.githubusercontent.com/u/9655971?v=3","gravatar_id":"","url":"https://api.github.com/users/mwitkow-io","html_url":"https://github.com/mwitkow-io","followers_url":"https://api.github.com/users/mwitkow-io/followers","following_url":"https://api.github.com/users/mwitkow-io/following{/other_user}","gists_url":"https://api.github.com/users/mwitkow-io/gists{/gist_id}","starred_url":"https://api.github.com/users/mwitkow-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwitkow-io/subscriptions","organizations_url":"https://api.github.com/users/mwitkow-io/orgs","repos_url":"https://api.github.com/users/mwitkow-io/repos","events_url":"https://api.github.com/users/mwitkow-io/events{/privacy}","received_events_url":"https://api.github.com/users/mwitkow-io/received_events","type":"User","site_admin":false},"body":"So this is a first pass on https://github.com/prometheus/promdash/issues/180. I'm quite foreign to AngularJS and Ruby, so I'm not sure if this is the right approach.\r\n\r\nEverything seems to work:\r\n * specifying `{{my_var}}` in a server URL will make it be interpolated from template `scope.vars`\r\n * if template vars already don't specify the variable, it will be extracted out of server definitions and added with an empty value\r\n\r\nThere is one problem now:\r\nListing and viewing servers that contain interpolation variables causes them to be ignored in HTML. Editing in HTML and viewing in JSON works, and the data is in the DB. I presume (wild guess here) the problem may be that AngularJS interprets `{{my_var}}` as a directive and tries to bind it, and it defaults to empty. I don't know how to work around it though. Is there a way to make AngularJS ignore directives in a given node?","created_at":"2015-04-12T13:11:50Z","updated_at":"2015-04-12T13:15:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c99cd00b290073f9912f6410a744f8eef18214f7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/prometheus/promdash/pulls/372/commits","review_comments_url":"https://api.github.com/repos/prometheus/promdash/pulls/372/comments","review_comment_url":"https://api.github.com/repos/prometheus/promdash/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prometheus/promdash/issues/372/comments","statuses_url":"https://api.github.com/repos/prometheus/promdash/statuses/33786ba1b24e377bd83d130b278fb988e9faffe1","head":{"label":"mwitkow-io:feature/interpolation_in_servers","ref":"feature/interpolation_in_servers","sha":"33786ba1b24e377bd83d130b278fb988e9faffe1","user":{"login":"mwitkow-io","id":9655971,"avatar_url":"https://avatars.githubusercontent.com/u/9655971?v=3","gravatar_id":"","url":"https://api.github.com/users/mwitkow-io","html_url":"https://github.com/mwitkow-io","followers_url":"https://api.github.com/users/mwitkow-io/followers","following_url":"https://api.github.com/users/mwitkow-io/following{/other_user}","gists_url":"https://api.github.com/users/mwitkow-io/gists{/gist_id}","starred_url":"https://api.github.com/users/mwitkow-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwitkow-io/subscriptions","organizations_url":"https://api.github.com/users/mwitkow-io/orgs","repos_url":"https://api.github.com/users/mwitkow-io/repos","events_url":"https://api.github.com/users/mwitkow-io/events{/privacy}","received_events_url":"https://api.github.com/users/mwitkow-io/received_events","type":"User","site_admin":false},"repo":{"id":33791151,"name":"promdash","full_name":"mwitkow-io/promdash","owner":{"login":"mwitkow-io","id":9655971,"avatar_url":"https://avatars.githubusercontent.com/u/9655971?v=3","gravatar_id":"","url":"https://api.github.com/users/mwitkow-io","html_url":"https://github.com/mwitkow-io","followers_url":"https://api.github.com/users/mwitkow-io/followers","following_url":"https://api.github.com/users/mwitkow-io/following{/other_user}","gists_url":"https://api.github.com/users/mwitkow-io/gists{/gist_id}","starred_url":"https://api.github.com/users/mwitkow-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwitkow-io/subscriptions","organizations_url":"https://api.github.com/users/mwitkow-io/orgs","repos_url":"https://api.github.com/users/mwitkow-io/repos","events_url":"https://api.github.com/users/mwitkow-io/events{/privacy}","received_events_url":"https://api.github.com/users/mwitkow-io/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mwitkow-io/promdash","description":"Prometheus Dashboard Builder","fork":true,"url":"https://api.github.com/repos/mwitkow-io/promdash","forks_url":"https://api.github.com/repos/mwitkow-io/promdash/forks","keys_url":"https://api.github.com/repos/mwitkow-io/promdash/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mwitkow-io/promdash/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mwitkow-io/promdash/teams","hooks_url":"https://api.github.com/repos/mwitkow-io/promdash/hooks","issue_events_url":"https://api.github.com/repos/mwitkow-io/promdash/issues/events{/number}","events_url":"https://api.github.com/repos/mwitkow-io/promdash/events","assignees_url":"https://api.github.com/repos/mwitkow-io/promdash/assignees{/user}","branches_url":"https://api.github.com/repos/mwitkow-io/promdash/branches{/branch}","tags_url":"https://api.github.com/repos/mwitkow-io/promdash/tags","blobs_url":"https://api.github.com/repos/mwitkow-io/promdash/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mwitkow-io/promdash/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mwitkow-io/promdash/git/refs{/sha}","trees_url":"https://api.github.com/repos/mwitkow-io/promdash/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mwitkow-io/promdash/statuses/{sha}","languages_url":"https://api.github.com/repos/mwitkow-io/promdash/languages","stargazers_url":"https://api.github.com/repos/mwitkow-io/promdash/stargazers","contributors_url":"https://api.github.com/repos/mwitkow-io/promdash/contributors","subscribers_url":"https://api.github.com/repos/mwitkow-io/promdash/subscribers","subscription_url":"https://api.github.com/repos/mwitkow-io/promdash/subscription","commits_url":"https://api.github.com/repos/mwitkow-io/promdash/commits{/sha}","git_commits_url":"https://api.github.com/repos/mwitkow-io/promdash/git/commits{/sha}","comments_url":"https://api.github.com/repos/mwitkow-io/promdash/comments{/number}","issue_comment_url":"https://api.github.com/repos/mwitkow-io/promdash/issues/comments{/number}","contents_url":"https://api.github.com/repos/mwitkow-io/promdash/contents/{+path}","compare_url":"https://api.github.com/repos/mwitkow-io/promdash/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mwitkow-io/promdash/merges","archive_url":"https://api.github.com/repos/mwitkow-io/promdash/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mwitkow-io/promdash/downloads","issues_url":"https://api.github.com/repos/mwitkow-io/promdash/issues{/number}","pulls_url":"https://api.github.com/repos/mwitkow-io/promdash/pulls{/number}","milestones_url":"https://api.github.com/repos/mwitkow-io/promdash/milestones{/number}","notifications_url":"https://api.github.com/repos/mwitkow-io/promdash/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mwitkow-io/promdash/labels{/name}","releases_url":"https://api.github.com/repos/mwitkow-io/promdash/releases{/id}","created_at":"2015-04-11T20:28:38Z","updated_at":"2015-04-11T20:28:39Z","pushed_at":"2015-04-12T13:07:22Z","git_url":"git://github.com/mwitkow-io/promdash.git","ssh_url":"git@github.com:mwitkow-io/promdash.git","clone_url":"https://github.com/mwitkow-io/promdash.git","svn_url":"https://github.com/mwitkow-io/promdash","homepage":"http://prometheus.io/","size":5994,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"prometheus:master","ref":"master","sha":"d065f7abc4c9e78ba75611207b566e9b23d17f72","user":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"repo":{"id":13788490,"name":"promdash","full_name":"prometheus/promdash","owner":{"login":"prometheus","id":3380462,"avatar_url":"https://avatars.githubusercontent.com/u/3380462?v=3","gravatar_id":"","url":"https://api.github.com/users/prometheus","html_url":"https://github.com/prometheus","followers_url":"https://api.github.com/users/prometheus/followers","following_url":"https://api.github.com/users/prometheus/following{/other_user}","gists_url":"https://api.github.com/users/prometheus/gists{/gist_id}","starred_url":"https://api.github.com/users/prometheus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prometheus/subscriptions","organizations_url":"https://api.github.com/users/prometheus/orgs","repos_url":"https://api.github.com/users/prometheus/repos","events_url":"https://api.github.com/users/prometheus/events{/privacy}","received_events_url":"https://api.github.com/users/prometheus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prometheus/promdash","description":"Prometheus Dashboard Builder","fork":false,"url":"https://api.github.com/repos/prometheus/promdash","forks_url":"https://api.github.com/repos/prometheus/promdash/forks","keys_url":"https://api.github.com/repos/prometheus/promdash/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prometheus/promdash/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prometheus/promdash/teams","hooks_url":"https://api.github.com/repos/prometheus/promdash/hooks","issue_events_url":"https://api.github.com/repos/prometheus/promdash/issues/events{/number}","events_url":"https://api.github.com/repos/prometheus/promdash/events","assignees_url":"https://api.github.com/repos/prometheus/promdash/assignees{/user}","branches_url":"https://api.github.com/repos/prometheus/promdash/branches{/branch}","tags_url":"https://api.github.com/repos/prometheus/promdash/tags","blobs_url":"https://api.github.com/repos/prometheus/promdash/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prometheus/promdash/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prometheus/promdash/git/refs{/sha}","trees_url":"https://api.github.com/repos/prometheus/promdash/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prometheus/promdash/statuses/{sha}","languages_url":"https://api.github.com/repos/prometheus/promdash/languages","stargazers_url":"https://api.github.com/repos/prometheus/promdash/stargazers","contributors_url":"https://api.github.com/repos/prometheus/promdash/contributors","subscribers_url":"https://api.github.com/repos/prometheus/promdash/subscribers","subscription_url":"https://api.github.com/repos/prometheus/promdash/subscription","commits_url":"https://api.github.com/repos/prometheus/promdash/commits{/sha}","git_commits_url":"https://api.github.com/repos/prometheus/promdash/git/commits{/sha}","comments_url":"https://api.github.com/repos/prometheus/promdash/comments{/number}","issue_comment_url":"https://api.github.com/repos/prometheus/promdash/issues/comments{/number}","contents_url":"https://api.github.com/repos/prometheus/promdash/contents/{+path}","compare_url":"https://api.github.com/repos/prometheus/promdash/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prometheus/promdash/merges","archive_url":"https://api.github.com/repos/prometheus/promdash/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prometheus/promdash/downloads","issues_url":"https://api.github.com/repos/prometheus/promdash/issues{/number}","pulls_url":"https://api.github.com/repos/prometheus/promdash/pulls{/number}","milestones_url":"https://api.github.com/repos/prometheus/promdash/milestones{/number}","notifications_url":"https://api.github.com/repos/prometheus/promdash/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prometheus/promdash/labels{/name}","releases_url":"https://api.github.com/repos/prometheus/promdash/releases{/id}","created_at":"2013-10-22T23:15:38Z","updated_at":"2015-04-10T23:19:55Z","pushed_at":"2015-04-12T13:11:50Z","git_url":"git://github.com/prometheus/promdash.git","ssh_url":"git@github.com:prometheus/promdash.git","clone_url":"https://github.com/prometheus/promdash.git","svn_url":"https://github.com/prometheus/promdash","homepage":"http://prometheus.io/","size":5994,"stargazers_count":98,"watchers_count":98,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":62,"forks":16,"open_issues":62,"watchers":98,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prometheus/promdash/pulls/372"},"html":{"href":"https://github.com/prometheus/promdash/pull/372"},"issue":{"href":"https://api.github.com/repos/prometheus/promdash/issues/372"},"comments":{"href":"https://api.github.com/repos/prometheus/promdash/issues/372/comments"},"review_comments":{"href":"https://api.github.com/repos/prometheus/promdash/pulls/372/comments"},"review_comment":{"href":"https://api.github.com/repos/prometheus/promdash/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prometheus/promdash/pulls/372/commits"},"statuses":{"href":"https://api.github.com/repos/prometheus/promdash/statuses/33786ba1b24e377bd83d130b278fb988e9faffe1"}}}}