-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
172 lines (147 loc) · 4.38 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>ThinkPad search</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/bootstrap-vue.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bootstrap-vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.9.3/umd/popper.min.js"></script>
<script src="https://cdn.rawgit.com/itemsapi/itemsjs/master/dist/itemsjs.js"></script>
<script src="data.js"></script>
<style>ul { list-style-type: none; }</style>
</head>
<body translate="no">
<div id="el">
<div class="container" style="margin-top: 50px;">
<h1>List of {{ searchResult.data.items.length }} ThinkPads</h1>
<div class="row">
<div class="col-md-2 col-xs-2">
<div v-for="facet in searchResult.data.aggregations">
<h5 style="margin-bottom: 5px;"><strong style="color: #337ab7;">{{ facet.title }}</strong></h5>
<ul class="browse-list list-unstyled long-list" style="margin-bottom: 0;">
<li v-for="bucket in facet.buckets">
<div class="checkbox block" style="margin-top: 0; margin-bottom: 0;">
<label>
<input class="checkbox" type="checkbox" v-model="filters[facet.name]" v-bind:value="bucket.key">
{{ bucket.key }} ({{ bucket.doc_count }})
</label>
</div>
</li>
</ul>
</div>
</div>
<div class="col-md-10 col-xs-10">
<div class="breadcrumbs"></div>
<div class="clearfix"></div>
<ul>
<li v-for="(item, index) in searchResult.data.items">
{{ item.name }}
<!--
<b-button :v-b-toggle="'collapse-' + index" variant="primary">{{ item.name }}</b-button>
<b-collapse :id="'collapse-' + index" class="mt-2">
<b-card>
<p class="card-text">{{ item.machine_code }}</p>
</b-card>
</b-collapse>
-->
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="clearfix" style="margin-bottom: 100px;"></div>
</div>
</div>
</div>
<script id="rendered-js" >
var configuration = {
searchableFields: [],
sortings: {
name_asc: {
field: "name",
order: "asc" } },
aggregations: {
memory_slots: {
title: "Memory slots",
conjunction: false,
},
max_memory: {
title: "Max memory",
conjunction: false,
},
soldered_memory: {
title: "Max soldered memory",
conjunction: false,
},
memory_type: {
title: "Memory type",
},
cpu_manufacturer: {
title: "CPU Manufacturer",
},
tb: {
title: "USB4 / Thunderbolt",
conjunction: false,
},
m2_count: {
title: "Number of M.2 slots",
conjunction: false,
},
m2_size: {
title: "M.2 physical size",
},
}
}
Object.keys(configuration.aggregations).forEach(function (key) {
config = configuration.aggregations[key];
config.sort = 'key';
config.chosen_filters_on_top = false;
config.hide_zero_doc_count = true;
})
itemsjs = itemsjs(rows, configuration);
var vm = new Vue({
el: "#el",
data: function () {
// making it more generic
var filters = {};
Object.keys(configuration.aggregations).map(function (v) {
filters[v] = [];
});
// adding pagination variables
var page = this.page || 1;
var per_page = this.per_page || 12;
return {
query: "",
// initializing filters with empty arrays
filters: filters,
// setting pagination variables
page: 1,
per_page: 300 };
},
methods: {
reset: function () {
var filters = {};
Object.keys(configuration.aggregations).map(function (v) {
filters[v] = [];
});
this.filters = filters;
this.page = 1;
this.query = "";
},
toggeleDiv: function() {
this.display_div = !this.display_div;
}
},
computed: {
searchResult: function () {
var result = itemsjs.search({
query: this.query,
page: this.page,
per_page: 300,
filters: this.filters });
return result;
} } });
</script>
</body>
</html>