dashboard-reddit.html 8.54 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">
8
<link rel="import" href="./elements/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
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

  <style is="custom-style">
    @import url("../../styles/app-theme.html");
  </style>
  <link rel="import" type="css" href="dashboard-tourpedia.css">

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

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

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

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

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

</dom-module>