{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/shared-analytics/pulls/comments/77484056","id":77484056,"diff_hunk":"@@ -0,0 +1,142 @@\n+var href = parent.window.location.href,\n+    hrefLastSegment = href.substr(href.lastIndexOf('/') + 1),\n+    resolveURI = parent.ues.global.dashboard.id == hrefLastSegment ? '../' : '../../';\n+\n+var TOPIC = \"range-selected\";\n+$(function() {\n+    var dateLabel = $('#reportrange .btn-label');\n+    //if there are url elemements present, use them. Otherwis use last hour\n+    var timeFrom = moment().subtract(29, 'days');\n+    var timeTo = moment();\n+    var message = {};\n+\n+    var qs = gadgetUtil.getQueryString();\n+    if (qs.timeFrom != null) {\n+        timeFrom = qs.timeFrom;\n+    }\n+    if (qs.timeTo != null) {\n+        timeTo = qs.timeTo;\n+    }\n+    var count = 0;\n+    console.log(\"TimeFrom: \" + timeFrom + \" TimeTo: \" + timeTo);\n+\n+    //make the selected time range highlighted\n+    var timeUnit = qs.timeUnit;\n+\n+    if (timeUnit != null) {\n+        $(\"#btnLast\" + timeUnit).addClass(\"active\");\n+    } else {\n+        $(\"#btnLastMonth\").addClass(\"active\");\n+    }\n+\n+    cb(moment().subtract(29, 'days'), moment());\n+\n+    function cb(start, end) {\n+        dateLabel.html(start.format('MMMM D, YYYY hh:mm A') + ' - ' + end.format('MMMM D, YYYY hh:mm A'));\n+        if (count != 0) {\n+            message = {\n+                timeFrom: new Date(start).getTime(),\n+                timeTo: new Date(end).getTime(),\n+                timeUnit: \"Custom\"\n+            };\n+            gadgets.Hub.publish(TOPIC, message);\n+        }\n+        count++;\n+        if (message.timeUnit && (message.timeUnit == 'Custom')) {\n+            $(\"#date-select button\").removeClass(\"active\");\n+            $(\"#reportrange #btnCustomRange\").addClass(\"active\");\n+        }\n+    }\n+\n+    $('#btnCustomRange').daterangepicker({\n+        \"timePicker\": true,\n+        \"autoApply\": true,\n+        \"alwaysShowCalendars\": true,\n+        \"opens\": \"left\"\n+    }, cb);\n+\n+    $(\"#btnLastHour\").click(function() {\n+        dateLabel.html(moment().subtract(1, 'hours').format('MMMM D, YYYY hh:mm A') + ' - ' + moment().format('MMMM D, YYYY hh:mm A'));\n+        $(\"#date-select button\").removeClass(\"active\");\n+        $(this).addClass(\"active\");\n+        message = {\n+            timeFrom: new Date(moment().subtract(1, 'hours')).getTime(),\n+            timeTo: new Date(moment()).getTime(),\n+            timeUnit: \"Hour\"\n+        };\n+        gadgets.Hub.publish(TOPIC, message);\n+    });\n+\n+    $(\"#btnLastDay\").click(function() {\n+        dateLabel.html(moment().subtract(1, 'day').format('MMMM D, YYYY hh:mm A') + ' - ' + moment().format('MMMM D, YYYY hh:mm A'));\n+        $(\"#date-select button\").removeClass(\"active\");\n+        $(this).addClass(\"active\");\n+        message = {\n+            timeFrom: new Date(moment().subtract(1, 'day')).getTime(),\n+            timeTo: new Date(moment()).getTime(),\n+            timeUnit: \"Day\"\n+        };\n+        gadgets.Hub.publish(TOPIC, message);\n+    });\n+\n+    $(\"#btnLastMonth\").click(function() {\n+        dateLabel.html(moment().subtract(29, 'days').format('MMMM D, YYYY hh:mm A') + ' - ' + moment().format('MMMM D, YYYY hh:mm A'));\n+        $(\"#date-select button\").removeClass(\"active\");\n+        $(this).addClass(\"active\");\n+        message = {\n+            timeFrom: new Date(moment().subtract(29, 'days')).getTime(),\n+            timeTo: new Date(moment()).getTime(),\n+            timeUnit: \"Month\"\n+        };\n+        gadgets.Hub.publish(TOPIC, message);\n+    });\n+\n+    $(\"#btnLastYear\").click(function() {\n+        dateLabel.html(moment().subtract(1, 'year').format('MMMM D, YYYY hh:mm A') + ' - ' + moment().format('MMMM D, YYYY hh:mm A'));\n+        $(\"#date-select button\").removeClass(\"active\");\n+        $(this).addClass(\"active\");\n+        message = {\n+            timeFrom: new Date(moment().subtract(1, 'year')).getTime(),\n+            timeTo: new Date(moment()).getTime(),\n+            timeUnit: \"Year\"\n+        };\n+        gadgets.Hub.publish(TOPIC, message);\n+    });\n+\n+});\n+\n+gadgets.HubSettings.onConnect = function() {\n+    gadgets.Hub.subscribe(\"chart-zoomed\", function(topic, data, subscriberData) {\n+        onChartZoomed(data);\n+    });\n+};\n+\n+function onChartZoomed(data) {\n+    console.log(data); \n+    message = {\n+        timeFrom: data.timeFrom,\n+        timeTo: data.timeTo,\n+        timeUnit: \"Custom\"\n+    };\n+    gadgets.Hub.publish(TOPIC, message);\n+    var dateLabel = $('#reportrange .btn-label');\n+    var start = data.timeFrom;\n+    var end = data.timeTo;\n+    // dateLabel.html(start.format('MMMM D, YYYY hh:mm A') + ' - ' + end.format('MMMM D, YYYY hh:mm A'));\n+    if (data.timeUnit && (data.timeUnit == 'Custom')) {\n+        $(\"#date-select button\").removeClass(\"active\");\n+        $(\"#reportrange #btnCustomRange\").addClass(\"active\");\n+    }\n+};\n+\n+$(window).load(function() {\n+    var datePicker = $('.daterangepicker'),\n+        parentWindow = window.parent.document,\n+        thisParentWrapper = $('#' + gadgets.rpc.RPC_ID, parentWindow).closest('.gadget-body');\n+\n+    $('head', parentWindow).append('<link rel=\"stylesheet\" type=\"text/css\" href=\"' + resolveURI + 'store/carbon.super/gadget/Date_Range_Picker/css/daterangepicker.css\" />');\n+    $('body', parentWindow).append('<script src=\"' + resolveURI + 'store/carbon.super/gadget/Date_Range_Picker/js/daterangepicker.js\" type=\"text/javascript\"></script>');","path":"log-analyzer/features/org.wso2.carbon.la.apim.feature/src/main/resources/gadgets/Date_Range_Picker/js/main.js","position":138,"original_position":138,"commit_id":"0d87ec1f52d75a33ee56d1ae17f6a5b7dfc03e7e","original_commit_id":"0d87ec1f52d75a33ee56d1ae17f6a5b7dfc03e7e","user":{"login":"sinthuja","id":7677649,"avatar_url":"https://avatars.githubusercontent.com/u/7677649?v=3","gravatar_id":"","url":"https://api.github.com/users/sinthuja","html_url":"https://github.com/sinthuja","followers_url":"https://api.github.com/users/sinthuja/followers","following_url":"https://api.github.com/users/sinthuja/following{/other_user}","gists_url":"https://api.github.com/users/sinthuja/gists{/gist_id}","starred_url":"https://api.github.com/users/sinthuja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinthuja/subscriptions","organizations_url":"https://api.github.com/users/sinthuja/orgs","repos_url":"https://api.github.com/users/sinthuja/repos","events_url":"https://api.github.com/users/sinthuja/events{/privacy}","received_events_url":"https://api.github.com/users/sinthuja/received_events","type":"User","site_admin":false},"body":"Why are you accessing the parent from the gadget? Why the date picker is needed to be included in the parent?","created_at":"2016-09-05T08:13:34Z","updated_at":"2016-09-05T08:13:34Z","html_url":"https://github.com/wso2/shared-analytics/pull/5#discussion_r77484056","pull_request_url":"https://api.github.com/repos/wso2/shared-analytics/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/wso2/shared-analytics/pulls/comments/77484056"},"html":{"href":"https://github.com/wso2/shared-analytics/pull/5#discussion_r77484056"},"pull_request":{"href":"https://api.github.com/repos/wso2/shared-analytics/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/shared-analytics/pulls/5","id":65870261,"html_url":"https://github.com/wso2/shared-analytics/pull/5","diff_url":"https://github.com/wso2/shared-analytics/pull/5.diff","patch_url":"https://github.com/wso2/shared-analytics/pull/5.patch","issue_url":"https://api.github.com/repos/wso2/shared-analytics/issues/5","number":5,"state":"closed","locked":false,"title":"Loganalyzer gadgets for APIM","user":{"login":"ksdperera","id":5366557,"avatar_url":"https://avatars.githubusercontent.com/u/5366557?v=3","gravatar_id":"","url":"https://api.github.com/users/ksdperera","html_url":"https://github.com/ksdperera","followers_url":"https://api.github.com/users/ksdperera/followers","following_url":"https://api.github.com/users/ksdperera/following{/other_user}","gists_url":"https://api.github.com/users/ksdperera/gists{/gist_id}","starred_url":"https://api.github.com/users/ksdperera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ksdperera/subscriptions","organizations_url":"https://api.github.com/users/ksdperera/orgs","repos_url":"https://api.github.com/users/ksdperera/repos","events_url":"https://api.github.com/users/ksdperera/events{/privacy}","received_events_url":"https://api.github.com/users/ksdperera/received_events","type":"User","site_admin":false},"body":"Adding loganalyzer dashboard gadgets for APIM ","created_at":"2016-04-09T04:11:03Z","updated_at":"2016-09-05T08:13:34Z","closed_at":"2016-04-09T04:13:10Z","merged_at":"2016-04-09T04:13:10Z","merge_commit_sha":"11175b491c90f96602330e790ac0c38848a8bc8d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/wso2/shared-analytics/pulls/5/commits","review_comments_url":"https://api.github.com/repos/wso2/shared-analytics/pulls/5/comments","review_comment_url":"https://api.github.com/repos/wso2/shared-analytics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/shared-analytics/issues/5/comments","statuses_url":"https://api.github.com/repos/wso2/shared-analytics/statuses/0d87ec1f52d75a33ee56d1ae17f6a5b7dfc03e7e","head":{"label":"ksdperera:loganalyzerGadgets","ref":"loganalyzerGadgets","sha":"0d87ec1f52d75a33ee56d1ae17f6a5b7dfc03e7e","user":{"login":"ksdperera","id":5366557,"avatar_url":"https://avatars.githubusercontent.com/u/5366557?v=3","gravatar_id":"","url":"https://api.github.com/users/ksdperera","html_url":"https://github.com/ksdperera","followers_url":"https://api.github.com/users/ksdperera/followers","following_url":"https://api.github.com/users/ksdperera/following{/other_user}","gists_url":"https://api.github.com/users/ksdperera/gists{/gist_id}","starred_url":"https://api.github.com/users/ksdperera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ksdperera/subscriptions","organizations_url":"https://api.github.com/users/ksdperera/orgs","repos_url":"https://api.github.com/users/ksdperera/repos","events_url":"https://api.github.com/users/ksdperera/events{/privacy}","received_events_url":"https://api.github.com/users/ksdperera/received_events","type":"User","site_admin":false},"repo":null},"base":{"label":"wso2:master","ref":"master","sha":"493979068c57ce82b00e51b754614037d6f0581a","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":55576120,"name":"shared-analytics","full_name":"wso2/shared-analytics","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/shared-analytics","description":"","fork":false,"url":"https://api.github.com/repos/wso2/shared-analytics","forks_url":"https://api.github.com/repos/wso2/shared-analytics/forks","keys_url":"https://api.github.com/repos/wso2/shared-analytics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/shared-analytics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/shared-analytics/teams","hooks_url":"https://api.github.com/repos/wso2/shared-analytics/hooks","issue_events_url":"https://api.github.com/repos/wso2/shared-analytics/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/shared-analytics/events","assignees_url":"https://api.github.com/repos/wso2/shared-analytics/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/shared-analytics/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/shared-analytics/tags","blobs_url":"https://api.github.com/repos/wso2/shared-analytics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/shared-analytics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/shared-analytics/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/shared-analytics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/shared-analytics/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/shared-analytics/languages","stargazers_url":"https://api.github.com/repos/wso2/shared-analytics/stargazers","contributors_url":"https://api.github.com/repos/wso2/shared-analytics/contributors","subscribers_url":"https://api.github.com/repos/wso2/shared-analytics/subscribers","subscription_url":"https://api.github.com/repos/wso2/shared-analytics/subscription","commits_url":"https://api.github.com/repos/wso2/shared-analytics/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/shared-analytics/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/shared-analytics/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/shared-analytics/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/shared-analytics/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/shared-analytics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/shared-analytics/merges","archive_url":"https://api.github.com/repos/wso2/shared-analytics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/shared-analytics/downloads","issues_url":"https://api.github.com/repos/wso2/shared-analytics/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/shared-analytics/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/shared-analytics/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/shared-analytics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/shared-analytics/labels{/name}","releases_url":"https://api.github.com/repos/wso2/shared-analytics/releases{/id}","deployments_url":"https://api.github.com/repos/wso2/shared-analytics/deployments","created_at":"2016-04-06T04:36:55Z","updated_at":"2016-05-11T09:08:47Z","pushed_at":"2016-09-05T06:41:48Z","git_url":"git://github.com/wso2/shared-analytics.git","ssh_url":"git@github.com:wso2/shared-analytics.git","clone_url":"https://github.com/wso2/shared-analytics.git","svn_url":"https://github.com/wso2/shared-analytics","homepage":null,"size":3558,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":2,"forks":16,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/shared-analytics/pulls/5"},"html":{"href":"https://github.com/wso2/shared-analytics/pull/5"},"issue":{"href":"https://api.github.com/repos/wso2/shared-analytics/issues/5"},"comments":{"href":"https://api.github.com/repos/wso2/shared-analytics/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/shared-analytics/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/shared-analytics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/shared-analytics/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/shared-analytics/statuses/0d87ec1f52d75a33ee56d1ae17f6a5b7dfc03e7e"}}}}
{"actor":{"display_login":"sinthuja"}}