dashboard-reddit.html 8.47 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
11
12
<link rel="import" href="/bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="/bower_components/yasgui-polymer/yasgui.html">
<link rel = "import" href = "/bower_components/iron-pages/iron-pages.html">

13

14

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
15

16

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

militarpancho's avatar
militarpancho committed
19
20
21

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

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

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

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

        ids:{
177
178
          type: Array
           
179
180
181
182
        },
        data:{
          type: Object
        },
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
183
184
185
186
        client: {
          type: Object,
          notify: true,
          observer: '_clientChanged'              
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
        },
        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
205
        console.log("ready");
206
207
      },

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

</dom-module>