{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/kibana/pulls/comments/50902376","id":50902376,"diff_hunk":"@@ -0,0 +1,150 @@\n+var modules = require('ui/modules');\n+var template = require('plugins/kibana/settings/sections/indices/directives/pattern_review_step.html');\n+var _ = require('lodash');\n+var editFieldTypeHTML = require('plugins/kibana/settings/sections/indices/partials/_edit_field_type.html');\n+\n+var testData = {\n+  message: '11/24/2015 ip=1.1.1.1 bytes=1234',\n+  clientip: '1.1.1.1',\n+  bytes: 1234,\n+  geoip: {\n+    lat: 37.3894,\n+    lon: 122.0819\n+  },\n+  location: {\n+    lat: 37.3894,\n+    lon: 122.0819\n+  },\n+  '@timestamp': '2015-11-24T00:00:00.000Z',\n+  otherdate: '2015-11-24T00:00:00.000Z',\n+  codes: [1, 2, 3, 4]\n+};\n+\n+var testPipeline = [\n+  {\n+    grok: {\n+      match_field: 'message',\n+      match_pattern: 'foo'\n+    }\n+  },\n+  {\n+    geoip: {\n+      source_field: 'ip'\n+    }\n+  },\n+  {\n+    geoip: {\n+      source_field: 'ip',\n+      target_field: 'location'\n+    }\n+  },\n+  {\n+    date: {\n+      match_field: 'initialDate',\n+      match_formats: ['dd/MM/yyyy hh:mm:ss']\n+    }\n+  },\n+  {\n+    date: {\n+      match_field: 'initialDate',\n+      match_formats: ['dd/MM/yyyy hh:mm:ss'],\n+      target_field: 'otherdate'\n+    }\n+  }\n+];\n+\n+function pickDefaultTimeFieldName(dateFields) {\n+  if (_.isEmpty(dateFields)) {\n+    return undefined;\n+  }\n+\n+  let fieldName = dateFields[0];\n+  if (_.includes(dateFields, '@timestamp')) {\n+    fieldName = '@timestamp';\n+  }\n+\n+  return fieldName;\n+}\n+\n+modules.get('apps/settings')\n+  .directive('patternReviewStep', function () {\n+    return {\n+      template: template,\n+      scope: {\n+        sampleDocs: '=',\n+        indexPattern: '=',\n+        pipeline: '='\n+      },\n+      controller: function ($scope, Private) {\n+        $scope.sampleDocs = testData;\n+        $scope.pipeline = testPipeline;\n+\n+        if (_.isUndefined($scope.indexPattern)) {\n+          $scope.indexPattern = {};\n+        }\n+\n+        const knownFieldTypes = {};\n+        $scope.dateFields = [];\n+        $scope.pipeline.forEach(function (processor) {\n+          if (processor.geoip) {\n+            let field = processor.geoip.target_field || 'geoip';\n+            knownFieldTypes[field] = 'geo_point';\n+          }\n+          if (processor.date) {\n+            let field = processor.date.target_field || '@timestamp';\n+            knownFieldTypes[field] = 'date';\n+            $scope.dateFields.push(field);\n+          }\n+        });\n+\n+        _.defaults($scope.indexPattern, {\n+          id: 'filebeat-*',\n+          title: 'filebeat-*',\n+          timeFieldName: pickDefaultTimeFieldName($scope.dateFields),\n+          fields: _.map($scope.sampleDocs, (value, key) => {\n+            let type = knownFieldTypes[key] || typeof value;\n+            if (type === 'object' && _.isArray(value) && !_.isEmpty(value)) {\n+              type = typeof value[0];\n+            }\n+            return {name: key, type: type};","path":"src/plugins/kibana/public/settings/sections/indices/directives/pattern_review_step.js","position":109,"original_position":109,"commit_id":"3f02157be36e6344cf230cf438a3a9853dd46836","original_commit_id":"3f02157be36e6344cf230cf438a3a9853dd46836","user":{"login":"michaelcheng429","id":2475562,"avatar_url":"https://avatars.githubusercontent.com/u/2475562?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelcheng429","html_url":"https://github.com/michaelcheng429","followers_url":"https://api.github.com/users/michaelcheng429/followers","following_url":"https://api.github.com/users/michaelcheng429/following{/other_user}","gists_url":"https://api.github.com/users/michaelcheng429/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelcheng429/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelcheng429/subscriptions","organizations_url":"https://api.github.com/users/michaelcheng429/orgs","repos_url":"https://api.github.com/users/michaelcheng429/repos","events_url":"https://api.github.com/users/michaelcheng429/events{/privacy}","received_events_url":"https://api.github.com/users/michaelcheng429/received_events","type":"User","site_admin":false},"body":"Does the team use ES6 shorthand?\r\n\r\n```javascript\r\nreturn {type, name: key};\r\n```","created_at":"2016-01-26T21:25:29Z","updated_at":"2016-01-26T21:25:29Z","html_url":"https://github.com/elastic/kibana/pull/5892#discussion_r50902376","pull_request_url":"https://api.github.com/repos/elastic/kibana/pulls/5892","_links":{"self":{"href":"https://api.github.com/repos/elastic/kibana/pulls/comments/50902376"},"html":{"href":"https://github.com/elastic/kibana/pull/5892#discussion_r50902376"},"pull_request":{"href":"https://api.github.com/repos/elastic/kibana/pulls/5892"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/kibana/pulls/5892","id":55837365,"html_url":"https://github.com/elastic/kibana/pull/5892","diff_url":"https://github.com/elastic/kibana/pull/5892.diff","patch_url":"https://github.com/elastic/kibana/pull/5892.patch","issue_url":"https://api.github.com/repos/elastic/kibana/issues/5892","number":5892,"state":"open","locked":false,"title":"Ingest UI Pattern Review Screen","user":{"login":"Bargs","id":6239176,"avatar_url":"https://avatars.githubusercontent.com/u/6239176?v=3","gravatar_id":"","url":"https://api.github.com/users/Bargs","html_url":"https://github.com/Bargs","followers_url":"https://api.github.com/users/Bargs/followers","following_url":"https://api.github.com/users/Bargs/following{/other_user}","gists_url":"https://api.github.com/users/Bargs/gists{/gist_id}","starred_url":"https://api.github.com/users/Bargs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bargs/subscriptions","organizations_url":"https://api.github.com/users/Bargs/orgs","repos_url":"https://api.github.com/users/Bargs/repos","events_url":"https://api.github.com/users/Bargs/events{/privacy}","received_events_url":"https://api.github.com/users/Bargs/received_events","type":"User","site_admin":false},"body":"Requires #5790. When reviewing this pull, you can ignore the changes from that PR which have been merged in.\r\n\r\nImplements the pattern review step from #5974. Takes the pipeline and example docs from the previous step and creates an simple index pattern with a title, time_field_name (if a date field is present), and fields with auto detected types. The user can configure the index pattern we've generated. The result of the step is an index pattern object that can be sent to the new ingest API #5199 once the user clicks save (to be implemented in a coming PR).","created_at":"2016-01-13T00:12:20Z","updated_at":"2016-01-26T21:25:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"88be43d986d74f87b3a6ce82a587c6ed42062c3c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/kibana/pulls/5892/commits","review_comments_url":"https://api.github.com/repos/elastic/kibana/pulls/5892/comments","review_comment_url":"https://api.github.com/repos/elastic/kibana/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/kibana/issues/5892/comments","statuses_url":"https://api.github.com/repos/elastic/kibana/statuses/3f02157be36e6344cf230cf438a3a9853dd46836","head":{"label":"Bargs:ingest/patternReview","ref":"ingest/patternReview","sha":"3f02157be36e6344cf230cf438a3a9853dd46836","user":{"login":"Bargs","id":6239176,"avatar_url":"https://avatars.githubusercontent.com/u/6239176?v=3","gravatar_id":"","url":"https://api.github.com/users/Bargs","html_url":"https://github.com/Bargs","followers_url":"https://api.github.com/users/Bargs/followers","following_url":"https://api.github.com/users/Bargs/following{/other_user}","gists_url":"https://api.github.com/users/Bargs/gists{/gist_id}","starred_url":"https://api.github.com/users/Bargs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bargs/subscriptions","organizations_url":"https://api.github.com/users/Bargs/orgs","repos_url":"https://api.github.com/users/Bargs/repos","events_url":"https://api.github.com/users/Bargs/events{/privacy}","received_events_url":"https://api.github.com/users/Bargs/received_events","type":"User","site_admin":false},"repo":{"id":42202308,"name":"kibana","full_name":"Bargs/kibana","owner":{"login":"Bargs","id":6239176,"avatar_url":"https://avatars.githubusercontent.com/u/6239176?v=3","gravatar_id":"","url":"https://api.github.com/users/Bargs","html_url":"https://github.com/Bargs","followers_url":"https://api.github.com/users/Bargs/followers","following_url":"https://api.github.com/users/Bargs/following{/other_user}","gists_url":"https://api.github.com/users/Bargs/gists{/gist_id}","starred_url":"https://api.github.com/users/Bargs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bargs/subscriptions","organizations_url":"https://api.github.com/users/Bargs/orgs","repos_url":"https://api.github.com/users/Bargs/repos","events_url":"https://api.github.com/users/Bargs/events{/privacy}","received_events_url":"https://api.github.com/users/Bargs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Bargs/kibana","description":"Kibana","fork":true,"url":"https://api.github.com/repos/Bargs/kibana","forks_url":"https://api.github.com/repos/Bargs/kibana/forks","keys_url":"https://api.github.com/repos/Bargs/kibana/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Bargs/kibana/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Bargs/kibana/teams","hooks_url":"https://api.github.com/repos/Bargs/kibana/hooks","issue_events_url":"https://api.github.com/repos/Bargs/kibana/issues/events{/number}","events_url":"https://api.github.com/repos/Bargs/kibana/events","assignees_url":"https://api.github.com/repos/Bargs/kibana/assignees{/user}","branches_url":"https://api.github.com/repos/Bargs/kibana/branches{/branch}","tags_url":"https://api.github.com/repos/Bargs/kibana/tags","blobs_url":"https://api.github.com/repos/Bargs/kibana/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Bargs/kibana/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Bargs/kibana/git/refs{/sha}","trees_url":"https://api.github.com/repos/Bargs/kibana/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Bargs/kibana/statuses/{sha}","languages_url":"https://api.github.com/repos/Bargs/kibana/languages","stargazers_url":"https://api.github.com/repos/Bargs/kibana/stargazers","contributors_url":"https://api.github.com/repos/Bargs/kibana/contributors","subscribers_url":"https://api.github.com/repos/Bargs/kibana/subscribers","subscription_url":"https://api.github.com/repos/Bargs/kibana/subscription","commits_url":"https://api.github.com/repos/Bargs/kibana/commits{/sha}","git_commits_url":"https://api.github.com/repos/Bargs/kibana/git/commits{/sha}","comments_url":"https://api.github.com/repos/Bargs/kibana/comments{/number}","issue_comment_url":"https://api.github.com/repos/Bargs/kibana/issues/comments{/number}","contents_url":"https://api.github.com/repos/Bargs/kibana/contents/{+path}","compare_url":"https://api.github.com/repos/Bargs/kibana/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Bargs/kibana/merges","archive_url":"https://api.github.com/repos/Bargs/kibana/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Bargs/kibana/downloads","issues_url":"https://api.github.com/repos/Bargs/kibana/issues{/number}","pulls_url":"https://api.github.com/repos/Bargs/kibana/pulls{/number}","milestones_url":"https://api.github.com/repos/Bargs/kibana/milestones{/number}","notifications_url":"https://api.github.com/repos/Bargs/kibana/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Bargs/kibana/labels{/name}","releases_url":"https://api.github.com/repos/Bargs/kibana/releases{/id}","deployments_url":"https://api.github.com/repos/Bargs/kibana/deployments","created_at":"2015-09-09T20:17:45Z","updated_at":"2016-01-26T15:29:23Z","pushed_at":"2016-01-26T15:29:07Z","git_url":"git://github.com/Bargs/kibana.git","ssh_url":"git@github.com:Bargs/kibana.git","clone_url":"https://github.com/Bargs/kibana.git","svn_url":"https://github.com/Bargs/kibana","homepage":"https://www.elastic.co/products/kibana","size":85392,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"elastic:feature/ingest","ref":"feature/ingest","sha":"d262deaba267ad4e45019b99ff34e11871f7b8e7","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":7833168,"name":"kibana","full_name":"elastic/kibana","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/kibana","description":"Kibana","fork":false,"url":"https://api.github.com/repos/elastic/kibana","forks_url":"https://api.github.com/repos/elastic/kibana/forks","keys_url":"https://api.github.com/repos/elastic/kibana/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/kibana/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/kibana/teams","hooks_url":"https://api.github.com/repos/elastic/kibana/hooks","issue_events_url":"https://api.github.com/repos/elastic/kibana/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/kibana/events","assignees_url":"https://api.github.com/repos/elastic/kibana/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/kibana/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/kibana/tags","blobs_url":"https://api.github.com/repos/elastic/kibana/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/kibana/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/kibana/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/kibana/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/kibana/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/kibana/languages","stargazers_url":"https://api.github.com/repos/elastic/kibana/stargazers","contributors_url":"https://api.github.com/repos/elastic/kibana/contributors","subscribers_url":"https://api.github.com/repos/elastic/kibana/subscribers","subscription_url":"https://api.github.com/repos/elastic/kibana/subscription","commits_url":"https://api.github.com/repos/elastic/kibana/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/kibana/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/kibana/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/kibana/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/kibana/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/kibana/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/kibana/merges","archive_url":"https://api.github.com/repos/elastic/kibana/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/kibana/downloads","issues_url":"https://api.github.com/repos/elastic/kibana/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/kibana/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/kibana/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/kibana/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/kibana/labels{/name}","releases_url":"https://api.github.com/repos/elastic/kibana/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/kibana/deployments","created_at":"2013-01-26T04:00:59Z","updated_at":"2016-01-26T14:40:01Z","pushed_at":"2016-01-26T20:52:46Z","git_url":"git://github.com/elastic/kibana.git","ssh_url":"git@github.com:elastic/kibana.git","clone_url":"https://github.com/elastic/kibana.git","svn_url":"https://github.com/elastic/kibana","homepage":"https://www.elastic.co/products/kibana","size":98687,"stargazers_count":4748,"watchers_count":4748,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1772,"mirror_url":null,"open_issues_count":796,"forks":1772,"open_issues":796,"watchers":4748,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/kibana/pulls/5892"},"html":{"href":"https://github.com/elastic/kibana/pull/5892"},"issue":{"href":"https://api.github.com/repos/elastic/kibana/issues/5892"},"comments":{"href":"https://api.github.com/repos/elastic/kibana/issues/5892/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/kibana/pulls/5892/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/kibana/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/kibana/pulls/5892/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/kibana/statuses/3f02157be36e6344cf230cf438a3a9853dd46836"}}}}