Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: polymer_1.0.4/bower_components/google-analytics/google-analytics-dashboard.html

Issue 1205703007: Add polymer 1.0 to npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Renamed folder to 1.0.4 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <link rel="import" href="../polymer/polymer.html">
2 <link rel="import" href="../google-signin/google-signin-aware.html">
3 <!--
4 Element for grouping Google Analytics elements together.
5
6 `<google-analytics-chart>` elements inside a `<google-analytics-dashboard>`
7 element will automatically update as control elements (e.g.
8 `<google-analytics-view-selector>` or `<google-analytics-date-selector>`)
9 update query parameters.
10
11 ##### Example
12
13 <google-analytics-dashboard>
14
15 <google-analytics-view-selector></google-analytics-view-selector>
16 <google-analytics-date-selector></google-analytics-date-selector>
17
18 <google-analytics-chart
19 metrics="ga:sessions"
20 dimensions="ga:country"
21 sort="-ga:sessions"
22 maxResults="5"
23 chartType="column">
24 </google-analytics-chart>
25
26 </google-analytics-dashboard>
27
28 -->
29
30
31 <dom-module id="google-analytics-dashboard">
32 <template>
33 <google-signin-aware
34 on-google-signin-aware-success="_signedIn"
35 on-google-signin-aware-signed-out="_signedOut"></google-signin-aware>
36 <content id="content"></content>
37 </template>
38 </dom-module>
39 <script>
40
41 (function() {
42 'use strict';
43
44 Polymer({
45
46 is: 'google-analytics-dashboard',
47
48 properties: {
49 /**
50 * The `query` attribute represents the internal query object of this
51 * dashboard. It is updated when control elements fire the
52 * `analytics-dashboard-control-change` event and pass along query data.
53 */
54 query: {
55 type: Object,
56 value: function() { return {}; }
57 },
58
59 /**
60 * True if user has been authorized
61 */
62 authorized: {
63 type: Boolean,
64 value: false,
65 reflectToAttribute: true
66 }
67
68 },
69
70 listeners: {
71 'analytics-dashboard-control-change': 'queryUpdated'
72 },
73
74 ready: function() {
75 this.updateChildren();
76 },
77
78 /**
79 * The `queryUpdated` method is the callback for whenever the
80 * `analytics-dashboard-control-change` event is fired. It updates the
81 * query attribute, which is then sent to child charts.
82 *
83 * @method queryUpdated
84 * @param {CustomEvent} event - The event with the query data.
85 */
86 queryUpdated: function(event) {
87 // Update `this.query` with the passed event data.
88 Object.keys(event.detail).forEach(function(key) {
89 this.query[key] = event.detail[key];
90 }.bind(this))
91
92 this.updateChildren();
93 },
94
95 /**
96 * The `updateChildren` method updates each of this dashboards
97 * `<google-analytics-chart>` element with its current query value.
98 *
99 * @method updateChildren
100 */
101 updateChildren: function() {
102 if (!this.authorized) {
103 return;
104 }
105 var charts = Polymer.dom(this).querySelectorAll('google-analytics-chart' );
106 for (var i = 0, chart; chart = charts[i]; i++) {
107 Object.keys(this.query).forEach(function(key) {
108 chart[key] = this.query[key];
109 }.bind(this));
110 }
111 },
112
113 _signedIn: function() {
114 this.authorized = true;
115 this.updateChildren();
116 },
117
118 _signedOut: function() {
119 this.authorized = false;
120 }
121
122 });
123
124 })();
125
126 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698