Skip to content

Commit 12f7272

Browse files
author
Boris
committed
Фильтр по полям, логирование поисковых запросов
1 parent bd7818b commit 12f7272

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

Diff for: front/assets/js/app-search.js

+29-15
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ var mapping = [];
44
var fmapping = {};
55
var filter_operation = ["is", "is_not", "exists", "does_not_exists"]
66
var filters_set = {}
7-
dateS.setMinutes(dateS.getMinutes() - 195)
8-
dateE.setMinutes(dateE.getMinutes() - 180)
7+
//dateS.setMinutes(dateS.getMinutes() - 195)
8+
dateS.setMinutes(dateS.getMinutes() - 15)
9+
//dateE.setMinutes(dateE.getMinutes() - 180)
10+
//dateE.setMinutes(dateE.getMinutes() - 180)
911
$.datetimepicker.setLocale('ru');
10-
$('#datetimepicker_start').datetimepicker({timepicker: true, format:'Y-m-d H:i:s', step: 15, value:dateS});
12+
$('#datetimepicker_start').datetimepicker({timepicker: true, format:'Y-m-d H:i:s', step: 15, value:dateS.toISOString()});
1113
$('#datetimepicker_end').datetimepicker({
1214
timepicker: true,
1315
format:'Y-m-d H:i:s',
1416
step: 15,
15-
value:dateE,
17+
value:dateE.toISOString(),
1618
onShow:function( ct ){
1719
this.setOptions({
1820
minDate:$('#datetimepicker_start').val()?$('#datetimepicker_start').val():false
@@ -22,6 +24,22 @@ $('#datetimepicker_end').datetimepicker({
2224
//var getnodes = setInterval(NodeStatus, 5000);
2325
//var getindices = setInterval(IndexList, 3000);
2426

27+
28+
function cyrb53(str, seed = 0){
29+
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
30+
for(let i = 0, ch; i < str.length; i++) {
31+
ch = str.charCodeAt(i);
32+
h1 = Math.imul(h1 ^ ch, 2654435761);
33+
h2 = Math.imul(h2 ^ ch, 1597334677);
34+
}
35+
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
36+
h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
37+
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
38+
h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
39+
40+
return 4294967296 * (2097151 & h2) + (h1 >>> 0);
41+
}
42+
2543
function bytesToSize(bytes) {
2644
var sizes = ['b', 'kb', 'mb', 'gb', 'tb'];
2745
if (bytes == 0) return '0 byte';
@@ -103,29 +121,25 @@ $('#igs').on('change', function(e) {
103121
$('#mapping_filter').val('');
104122
str += "<ul class='list-group'>"
105123
for (var k in data) {
106-
// <li class="list-group-item" style="">
107-
// <input type="checkbox" name="fields" id="mappingkubernetes.namespace_labels.extended-monitoring_deckhouse_io/enabled" data-type="text" value="kubernetes.namespace_labels.extended-monitoring_deckhouse_io/enabled" >
108-
// &nbsp;<label for="mappingkubernetes.namespace_labels.extended-monitoring_deckhouse_io/enabled" style="word-wrap: break-word !important;word-break: break-word;">kubernetes.namespace_labels.extended-monitoring_deckhouse_io/enabled&nbsp;&nbsp;(text)</label>
109-
// </li>
110-
str += "<li class='list-group-item' style='word-wrap: break-word !important; word-break: break-word;display: flex;align-items: flex-start;'><input type='checkbox' name='fields' id='mapping_"+k+"' data-type='" + data[k] + "' value='" + k + "' style='margin-top: 6px;'>&nbsp;<label for='mapping_"+k+"'>"+ k + "&nbsp;&nbsp;(" + data[k] + ")" +"</label></li>";
124+
str += "<li class='list-group-item' style='word-wrap: break-word !important; word-break: break-word;display: flex;align-items: flex-start;' id='m_"+cyrb53(k)+"'><input type='checkbox' name='fields' id='mapping_"+k+"' data-type='" + data[k] + "' value='" + k + "' style='margin-top: 6px;'>&nbsp;<label for='mapping_"+k+"'>"+ k + "&nbsp;&nbsp;(" + data[k] + ")" +"</label></li>";
111125
mapping.push(k);
112126
}
113127
fmapping = data;
114128
str += "</ul>"
115129
$("#fields").html(str);
130+
event.preventDefault();
116131
}
117132
});
118133
});
119134

120135
$('#mapping_filter').on('keypress', function(e) {
121-
var str="";
122-
str += "<ul class='list-group'>"
123136
for (var k in fmapping) {
124-
if (k.includes(e.target.value))
125-
str += "<li class='list-group-item' style='word-wrap: break-word !important; word-break: break-word;display: flex;align-items: flex-start;'><input type='checkbox' name='fields' id='mapping_"+k+"' data-type='" + fmapping[k] + "' value='" + k + "' style='margin-top: 6px;'>&nbsp;<label for='mapping_"+k+"'>"+ k + "</label></li>";
137+
if (k.includes(e.target.value)) {
138+
$('#m_'+cyrb53(k)).show();
139+
} else {
140+
$('#m_'+cyrb53(k)).hide();
141+
}
126142
}
127-
str += "</ul>"
128-
$("#fields").html(str);
129143
});
130144

131145
$('#modal_add_filter').on('shown.bs.modal',function(e){

Diff for: modules/router/methods.go

-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ func (rt *Router) getIndexGroups(cluster string) ([]indexGroup, error) {
236236
return nil, err
237237
}
238238
err = json.Unmarshal(response, &igs)
239-
fmt.Printf("%v\n", igs)
240239
if err != nil {
241240
return nil, err
242241
}
@@ -246,7 +245,6 @@ func (rt *Router) getIndexGroups(cluster string) ([]indexGroup, error) {
246245
igresp = append(igresp, n)
247246
}
248247
unique := removeDuplicates(igresp)
249-
fmt.Printf("%v\n", unique)
250248
return unique, nil
251249

252250
}

Diff for: modules/router/router.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,8 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
684684
query = fmt.Sprintf(`"query": { "bool": { "must": [ %s ],"filter": [ %s %s ], "should": [],"must_not": [ %s ] }}`, xql, tf, filters, must_not)
685685

686686
full_query = fmt.Sprintf(`{"size": 500, %s, %s, %s, %s }`, sort, use_source, fields, query)
687-
fmt.Println(full_query)
688687
if request.Search.Count {
688+
log.Println("action: Count", "\tquery: ", "{"+query+"}")
689689
_ = json.Unmarshal([]byte("{"+query+"}"), &req)
690690
cresponse, err := rt.doPost(host+request.Search.Index+"/_count", req, "Search")
691691
if err != nil {
@@ -695,6 +695,7 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
695695
}
696696
w.Write(cresponse)
697697
} else {
698+
log.Println("action: Search", "\tquery: ", full_query)
698699
_ = json.Unmarshal([]byte(full_query), &req)
699700
sresponse, err := rt.doPost(host+request.Search.Index+"/_search", req, "Search")
700701
if err != nil {

Diff for: modules/version/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313

1414
package version
1515

16-
var Version = "extractor/v0.2.15"
16+
var Version = "extractor/v0.2.16"

0 commit comments

Comments
 (0)