dashboard-reddit.html 8.28 KB
Newer Older
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
1
2
3
4
5
6
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../material-search/material-search.html">
<link rel="import" href="../paper-material/paper-material.html">
<link rel="import" href="../google-chart-elasticsearch/google-chart.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../number-chart/number-chart.html">
7
8
9
10
<link rel="import" href="./elements/comment-chart/comment-chart.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../yasgui-polymer/yasgui.html">

11

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

13

militarpancho's avatar
militarpancho committed
14
<dom-module id="dashboard-reddit">
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

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

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

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

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

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

</dom-module>