Commit 015fbfda authored by Alberto Pascual's avatar Alberto Pascual
Browse files

no more elasticsearch needed for this component

parent ff5962e2
......@@ -111,11 +111,11 @@ subject to an additional IP rights grant found at https://polymer.github.io/PATE
return "http://tour-pedia.org/api/getReviewsByPlaceId?placeId=" + id
},
completed: function(){
console.log("iron-ajax completed")
//console.log("iron-ajax completed")
this.$.ajax.generateRequest();
},
finished: function(){
console.log("iron-ajax review completed")
//console.log("iron-ajax review completed")
},
checkplace: function(id){
if (id == this.places.id){
......
......@@ -3,6 +3,7 @@
"authors": [
"gsi-upm"
],
"version":"1.0.1",
"description": "Web component to visualize reviews from Tourpedia",
"main": "reviews-table.html",
"keywords": [
......
......@@ -35,9 +35,9 @@ subject to an additional IP rights grant found at https://polymer.github.io/PATE
</tr>
</table>
<iron-pages id="pages" selected="0">
<template is="dom-repeat" items="{{ids}}" as="id">
<!--<template is="dom-repeat" items="{{ids}}" as="id">
<ajax-review id="{{id}}"></ajax-review>
</template>
</template>-->
</iron-pages>
</table>
<div style="text-align:center; margin: 0 auto">
......@@ -66,7 +66,10 @@ subject to an additional IP rights grant found at https://polymer.github.io/PATE
type: String,
value: "1"
},
data: {
type: Object,
observer: '_mydataChanged'
},
ids:{
type: Array,
value: ["481","482","32512","32420","91963","96677","160677","131425","322429","322612"]
......@@ -104,6 +107,29 @@ subject to an additional IP rights grant found at https://polymer.github.io/PATE
ready: function() {
},
_mydataChanged: function() {
//console.log("in _dataChanged")
//console.log(this.data)
//console.log(this.$$('#pages'))
//console.log(this.$$('ajax-review'))
if(this.$$('ajax-review') != null){
console.log("elimino anteriores")
var nodes = Polymer.dom(this.$$('#pages')).childNodes
//console.log(Polymer.dom(this.$$('#pages')).childNodes)
for(var j = 0; j < nodes.length; j++){
//console.log(nodes[j])
Polymer.dom(this.$$('#pages')).removeChild(nodes[j])
}
}
for (var i=0; i < this.data.length; i++){
var customElement = document.createElement("ajax-review");
customElement.setAttribute("id", this.data[i]);
Polymer.dom(this.$$('#pages')).appendChild(customElement);
}
//console.log(this.data)
},
checkSource: function(source) {
if(source == "Foursquare")
return "https://playfoursquare.s3.amazonaws.com/press/2014/foursquare-logomark.png"
......@@ -146,96 +172,8 @@ subject to an additional IP rights grant found at https://polymer.github.io/PATE
getIdURL: function(index) {
return "http://tour-pedia.org/api/getReviewsByPlaceId?placeId="+this.ids[index]
},
_queryChanged: function() {
this.query ? this.queryChange(this.query) : this.queryDefault();
},
queryChange: function(value) {
var client = new $.es.Client({
hosts: this.host
});
var id = this.extraId;
var doc = this;
client.search({
// undocumented params are appended to the query string
index: this.index,
type: this.subindex,
body: {
size: 10,
query: {
multi_match:{
query: this.query,
fields: this.fields
}
}
}
}).then(function (resp) {
var hits = resp.hits.hits;
doc.ids = [];
hits.forEach(function(entry) {
doc.push('ids',entry._id)
});
});
},
queryDefault: function() {
var client = new $.es.Client({
hosts: this.host
});
var id = this.extraId;
var doc = this;
client.search({
// undocumented params are appended to the query string
index: this.index,
type: this.subindex,
body: {
size: 10,
query: {
match_all: {}
}
}
}).then(function (resp) {
var hits = resp.hits.hits;
doc.ids = [];
hits.forEach(function(entry) {
doc.push('ids',entry._id)
});
});
},
_filtersChange: function() {
if(filtered){
var client = new $.es.Client({
hosts: this.host
});
var id = this.extraId;
var doc = this;
client.search({
// undocumented params are appended to the query string
index: this.index,
type: this.subindex,
body: {
size: 10,
query: {
bool: {
must: this.filters,
}
}
}
}).then(function (resp) {
var hits = resp.hits.hits;
doc.ids = [];
hits.forEach(function(entry) {
doc.push('ids',entry._id)
});
});
}
}
});
</script>
</dom-module>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment