dashboard-reddit.html 8.51 KB
Newer Older
militarpancho's avatar
militarpancho committed
1
2
3
4
5
6
7
<link rel="import" href="/bower_components/polymer/polymer.html">
<link rel="import" href="/bower_components/material-search/material-search.html">
<link rel="import" href="/bower_components/paper-material/paper-material.html">
<link rel="import" href="/bower_components/google-chart-elasticsearch/google-chart.html">
<link rel="import" href="/bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="/bower_components/paper-tabs/paper-tab.html">
<link rel="import" href="/bower_components/number-chart/number-chart.html">
militarpancho's avatar
militarpancho committed
8
<link rel="import" href="/bower_components/comment-chart/comment-chart.html">
militarpancho's avatar
militarpancho committed
9
10
<link rel="import" href="/bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="/bower_components/yasgui-polymer/yasgui.html">
11
12
13
<link rel="import" href="/bower_components/iron-pages/iron-pages.html">
<link rel="import" href="/bower_components/paper-item/paper-item.html">
<link rel="import" href="/bower_components/paper-menu/paper-menu.html">
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
14

15

militarpancho's avatar
militarpancho committed
16
<dom-module id="dashboard-reddit">
17

militarpancho's avatar
militarpancho committed
18
19
20

  <link rel="import" type="css" href="dashboard-tourpedia.css" type="css">
  <link rel="import" href="/styles/app-theme.html" type="css">
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

  <template>
    <iron-ajax auto
        url="queries.json"
        handle-as="json"
        last-response="{{queries}}"></iron-ajax>

    <paper-tabs selected="{{selected}}">
      <paper-tab>Dashboard</paper-tab>
      <paper-tab>Sparql Editor</paper-tab>
    </paper-tabs>

    <iron-pages selected="{{selected}}">
      <div>
        <material-search search-value="{{query}}"></material-search>
        <br>
        <div style="width: 100%; display: inline-block">
militarpancho's avatar
militarpancho committed
38
          <div style="width: 32%; margin-right: 2%; float: left">
39
40
41
42
43
44
            <number-chart 
              icon="info"
              stylebg="bg-red"
              data="{{data}}">
            </number-chart>
          </div>
militarpancho's avatar
militarpancho committed
45
          <div style="width: 32%; margin-right: 2%; float: left">
46
47
            <number-chart 
              data="{{data}}"
48
              object="BlogPosting"
militarpancho's avatar
militarpancho committed
49
              aggKey="type"
50
              title="BlogPosting"
militarpancho's avatar
militarpancho committed
51
              icon="icons:receipt"
52
53
54
              stylebg="bg-yellow">
            </number-chart>
          </div>
militarpancho's avatar
militarpancho committed
55
           <div style="width: 32%; float: left"> 
militarpancho's avatar
militarpancho committed
56
57
             <number-chart  
               data="{{data}}" 
58
59
               object="Comment"
			         aggKey="type"
militarpancho's avatar
militarpancho committed
60
61
62
63
64
65
66
67
               title="Comments" 
               icon="maps:rate-review"
               aggkey="location"
               stylebg="bg-green"> 
             </number-chart>
           </div>
         </div>

68
69
70
        <div style="width: 100%; display: inline-block">
          <div class="chart_container" style="right: 0; float: right">
            <google-chart
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
71
              data="{{data}}"
72
              field="articlesection"
73
74
75
76
              id='pie-chart4'
              extra-id='pie-chart4'
              type='pie'
              filters="{{filters}}"
militarpancho's avatar
militarpancho committed
77
              icon='icons:list'
78
              param='{{param}}'
79
80
              options='{"title": "Article Sections"}'
              cols='[{"label": "articlesection", "type": "string"},{"label": "Count", "type": "number"}]'
81
            </google-chart>
militarpancho's avatar
militarpancho committed
82
		  </div>
83
84
          <div class="chart_container" style="left: 0; float: left">
            <google-chart
85
              field="type"
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
86
87
88
89
              data="{{data}}"             
              id='pie-chart3'
              extra-id='pie-chart3'
              type='pie'
90
              filters="{{filters}}"
militarpancho's avatar
militarpancho committed
91
              icon='icons:reorder'
92
93
              options='{"title": "Publication Type"}'
              cols='[{"label": "type", "type": "string"},{"label": "Count", "type": "number"}]'
94
95
96
            </google-chart>
          </div>
        </div>
militarpancho's avatar
militarpancho committed
97
		 <div style="width: 100%"> 
militarpancho's avatar
militarpancho committed
98
          <div class="chart_container" style="left: 0; float: left">
militarpancho's avatar
militarpancho committed
99
100
101
102
103
104
            <google-chart
              field="sentiment"
              data="{{data}}"             
              id='pie-chart5'
              extra-id='pie-chart5'
              type='pie'
militarpancho's avatar
militarpancho committed
105
              filters="{{filters}}"
militarpancho's avatar
militarpancho committed
106
107
108
              icon='social:mood'
              options='{"title": "Sentiments"}'
              cols='[{"label": "Sentiment", "type": "string"},{"label": "Count", "type": "number"}]'
militarpancho's avatar
militarpancho committed
109
            </google-chart>
militarpancho's avatar
militarpancho committed
110
111
112
		   </div> 
          <div class="chart_container" style="left: 0; float: right">
            <google-chart
113
              field="emotion"
militarpancho's avatar
militarpancho committed
114
115
116
117
              data="{{data}}"             
              id='pie-chart5'
              extra-id='pie-chart5'
              type='pie'
militarpancho's avatar
militarpancho committed
118
              filters="{{filters}}"
militarpancho's avatar
militarpancho committed
119
120
121
              icon='social:sentiment-very-dissatisfied'
              options='{"title": "Emotions"}'
              cols='[{"label": "Sentiment", "type": "string"},{"label": "Count", "type": "number"}]'
militarpancho's avatar
militarpancho committed
122
            </google-chart>
militarpancho's avatar
militarpancho committed
123
		   </div>
124
  
militarpancho's avatar
militarpancho committed
125
		   <div style="clear: both"></div>
militarpancho's avatar
militarpancho committed
126
        </div>
militarpancho's avatar
militarpancho committed
127
        <div>
128
          <div class="chart_container" style="left: 0; float: left; width: 100%">
129
130
            <news-chart 
				      datos = "{{data}}"
131
132
			        filters="{{filters}}"
              icon='social:people'>
133
            </news-chart>
militarpancho's avatar
militarpancho committed
134
          </div>
militarpancho's avatar
militarpancho committed
135
136
          <!--<div class="chart_container" style="left: 0; float: right">
           <google-chart
137
138
			  data = {{data}}
			  field="subreddit"
militarpancho's avatar
militarpancho committed
139
140
141
142
143
144
145
146
              id='column-chart1'
              extra-id='column-chart1'
              type='column'
              filters="{{filters}}"
              icon='maps:local-play'
              param='{{param}}'
              optionsbi='{"legend": "none"}'
              options='{"title": "Subreddits sentiment count"}'
147
			  cols='[{"label": "Subreddits", "type": "string"},{"label": "Count", "type": "number"}]'>
militarpancho's avatar
militarpancho committed
148
            </google-chart>
149
		  </div>-->
150
151
152
153
		  </div>
    </div>
    <div>
        <yasgui-ui
154
            endpoint="http://homer.gsi:13030/gsicrawler/query"
155
156
157
            queries="{{queries}}">
        </yasgui-ui>
    </div>
158
159
    </iron-pages>
  </template>
160
   
161
162

  <script>
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
163
  var ready = false;
164
    Polymer({
militarpancho's avatar
militarpancho committed
165
      is: 'dashboard-reddit',
166
167
168
169
170
171
172
      properties: {
        selected: {
          type: Number,
          value: 0
        }, 

        ids:{
173
174
          type: Array
           
175
176
177
178
        },
        data:{
          type: Object
        },
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
179
180
181
182
        client: {
          type: Object,
          notify: true,
          observer: '_clientChanged'              
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
        },
        fields: {
          type: Array,
          value: function() { return []; }
        },

        filters: {
          type: Array,
          notify: true,
          value: function() { return []; }
        }
      },
    
      observers: [
      '_filtersChange(filters.*)'
      ],

      ready: function(){
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
201
        console.log("ready");
202
203
      },

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
204
205
206
207
      _clientChanged: function() {
        console.log("ClientChanged");
        ready = true;
        this._query();
208
209
      },
      _filtersChange: function() {
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
210
211
212
        this._query();
       },
       _query: function() {
213
        console.log("_filtersChangedash")
214
        var that = this;
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
215
216
217
        console.log("Ready?: ", ready);
        if(ready){
          this.client.search({
218
          // undocumented params are appended to the query string
219
          index: "gsicrawler",
220
221
222
223
224
225
226
227
          body: {
            size: 10,
            query: {
              bool: {
                must: this.filters,
              }
            },
            aggs: {
militarpancho's avatar
militarpancho committed
228
229
             type: {
               terms: {
230
                 field: "@type.keyword",
militarpancho's avatar
militarpancho committed
231
232
233
234
235
                 order: {
                   _count: "desc"
                 }
               }
             },
236
             articlesection: {
militarpancho's avatar
militarpancho committed
237
               terms: {
238
                 field: "articleSection.keyword",
militarpancho's avatar
militarpancho committed
239
240
                 order: {
                   _count: "desc"
241
                 }
militarpancho's avatar
militarpancho committed
242
               }
militarpancho's avatar
militarpancho committed
243
             },
244
245
246
247
248
249
             about: {
               terms: {
                 field: "about.keyword",
                 order: {
                   _count: "desc"
                 } 
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
250
               }
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
             },
    			 sentiment: {
    			   terms: {
    				 field: "sentiments.marl:hasPolarity.keyword",
    				 order: {
    				   _count: "desc"
    			     }
    			   }
    		     },
     			emotion: {
     		      terms: {
     			    field: "emotions.onyx:hasEmotion.onyx:hasEmotionCategory.keyword",
     				 order: {
     				   _count: "desc"
                     }      
                   }
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
267
268
 			}
 		   }
269
		  }	
270
          }).then(function (resp) {
271
272
273
274
            var myids = []
            resp.hits.hits.forEach(function(entry){myids.push(entry._id)})
            that.ids = myids;
            //console.log(that.ids)
275
            that.data = resp;
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
276
            console.log(that.data);
277
            
278
279
280
281
282
283
284
            });
        }
      }
    });
  </script>

</dom-module>