Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
sefarad
tweet-chart
Commits
9564ae46
Commit
9564ae46
authored
Jun 02, 2017
by
Alberto Pascual
Browse files
updated to use without elasticsearch
parent
bcdae15b
Changes
3
Hide whitespace changes
Inline
Side-by-side
bower.json
View file @
9564ae46
...
...
@@ -3,6 +3,7 @@
"authors"
:
[
"gsi-upm"
],
"version"
:
"1.0.1"
,
"description"
:
"This web component displays text field information from elasticsearch"
,
"main"
:
"tweet-chart.html"
,
"keywords"
:
[
...
...
tweet-chart.css
View file @
9564ae46
...
...
@@ -32,6 +32,7 @@ paper-icon-button.green:hover {
margin
:
10px
;
padding
:
10px
;
border-radius
:
5px
;
}
.positive
{
...
...
tweet-chart.html
View file @
9564ae46
...
...
@@ -19,7 +19,7 @@
<span>
{{title}}
</span>
</div>
<template
is=
"dom-repeat"
items=
"{{data}}"
as=
"tweet"
>
<div
class
$="{{
checkSentiment
(
tweet.sentiment
)}}"
>
<div
class
$="{{
checkSentiment
(
tweet.sentiment
)}}
same-height
"
>
<img
src=
{{checkSource(tweet.name)}}
style=
"width: 60px"
></br>
<span
class=
"text"
>
{{tweet.text}}
</span></br>
<span
style=
"font-weight: bold"
>
{{tweet.name}}
</span></br>
...
...
@@ -78,6 +78,11 @@
value
:
function
()
{
return
[];
}
},
datos
:{
type
:
Object
,
observer
:
'
_dataChanged
'
},
field
:
{
type
:
String
},
...
...
@@ -98,105 +103,18 @@
}
},
observers
:
[
'
_filtersChange(filters.*)
'
],
ready
:
function
()
{
this
.
field
?
this
.
queryDefault
()
:
undefined
},
queryDefault
:
function
()
{
var
client
=
new
$
.
es
.
Client
({
hosts
:
this
.
host
});
_dataChanged
:
function
()
{
var
that
=
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
;
var
results
=
[]
hits
.
forEach
(
function
(
entry
)
{
var
hits
=
this
.
datos
.
hits
.
hits
;
var
results
=
[]
hits
.
forEach
(
function
(
entry
)
{
results
.
push
(
entry
.
_source
);
});
that
.
data
=
results
});
},
queryChange
:
function
(
value
)
{
var
client
=
new
$
.
es
.
Client
({
hosts
:
this
.
host
});
var
that
=
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
;
var
results
=
[]
hits
.
forEach
(
function
(
entry
)
{
results
.
push
(
entry
.
_source
);
});
that
.
data
=
results
});
},
/** Fired when a search is made.
*
* @event query-change
* @param {Object} detail
* @param {Object} detail.query The search string.
*/
_queryChanged
:
function
()
{
this
.
query
?
this
.
queryChange
(
this
.
query
)
:
this
.
queryDefault
();
},
_filtersChange
:
function
()
{
if
(
filtered
){
var
client
=
new
$
.
es
.
Client
({
hosts
:
this
.
host
});
var
that
=
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
;
var
results
=
[]
hits
.
forEach
(
function
(
entry
)
{
results
.
push
(
entry
.
_source
);
});
that
.
data
=
results
});
}
that
.
data
=
results
},
checkSentiment
:
function
(
sentiment
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment