-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
117 lines (105 loc) · 3.61 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html>
<head>
<title>Ember ACS Search</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<style>
body { margin: 1em;}
.photo_small {
width: 48px;
height: 48px;
background-size: cover;
background-position: center;
}
table { border: 1px solid #ccc; margin-top: 1em;}
th, td {padding: .3em; border-bottom: 1px solid #ccc;}
</style>
</head>
<body>
<!-- Default application template name -->
<script type="text/x-handlebars" id="application">
<h1>Ember ACS Search</h1>
{{outlet}}
</script>
<!-- Default index-page template name -->
<script type="text/x-handlebars" id="index">
{{input valueBinding="searchQuery" placeholder="Search..."}}
<button {{action "searchAcs"}}>Search</button>
<table>
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Title</th>
<th>Department</th>
</tr>
</thead>
{{#each person in persons}}
<tr>
<td><div style="background-image: url(http://cv.altran.se/media/{{unbound person.image}})" class="photo_small"></div></td>
<td>{{person.name}}</td>
<td>{{person.title}}</td>
<td>{{person.department}}</td>
</tr>
{{else}}
<tr><td colspan="4">
{{#if searchQuery}}
No people found for search "{{searchQuery}}".
{{else}}
Type above to start searching!
{{/if}}
</td></tr>
{{/each}}
</table>
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.4.0/ember.prod.js"></script>
<script>
var ACS = Ember.Application.create({});
// IndexController is automatically bound
ACS.IndexController = Ember.Controller.extend({
searchAcs: function () {
var searchQuery = this.get("searchQuery");
var persons = [];
if (searchQuery == '') {
this.set("persons", []);
} else {
$.ajax({
type:"get",
url: 'https://cv.altran.se/solr/collection1/select',
dataType: 'jsonp',
jsonp: 'json.wrf',
context: this,
data: {
'q':searchQuery,
'wt':'json',
'rows':10,
'fl': 'rendered',
'facet': 'true',
'facet.field': [
'location_exact',
'department_exact',
'years_of_experience_exact'
]
},
traditional: true
}).done(function( data ) {
var docs = data.response.docs;
var persons = [];
if( docs.length>0 ) {
for( var i=0; i<docs.length; i++ ) {
var person = JSON.parse( docs[i].rendered );
person.image = person.image.replace(/(.jpg|.png)/gi,'_scale_110x110.jpg');
persons.push( person );
}
}
// update the content
this.set("persons", persons);
});
}
}.observes('searchQuery')
});
</script>
</body>
</html>