Skip to content

Commit 2178aed

Browse files
authored
Merge pull request #12 from flant/fix_get_snapshot_list
Получаем список снапшотов с verbose=false
2 parents 40ab157 + d8a6436 commit 2178aed

File tree

3 files changed

+30
-29
lines changed

3 files changed

+30
-29
lines changed

front/index.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ <h1 class="my-4">Snapshots list
6767
<li class="nav-item">
6868
<a class="nav-link" href="#" id="get_repo_sort_name" data-otype="name" data-odir="asc">Sort by Name</a>
6969
</li>
70-
<li class="nav-item">
70+
<!--li class="nav-item">
7171
<a class="nav-link" href="#" id="get_repo_sort_time" data-otype="time" data-odir="asc">Sort by Time</a>
72-
</li>
73-
</ul>
72+
</li-->
73+
</ul>
7474

7575
<div class="d-flex align-items-center invisible" id="loading"><strong>Loading...</strong><div class="spinner-border ml-auto" role="status" aria-hidden="true"></div></div>
7676
<ul class="list-unstyled mb-0 overflow-auto" style="max-height: 800px;" id="snapshotlist"> </ul>
7777

78-
</div>
78+
</div>
7979

8080
<!-- Sidebar Widgets Column -->
8181
<div class="col-md-4">
@@ -87,7 +87,7 @@ <h5 class="card-header">Restored indices</h5>
8787
</div>
8888
<div class="card-footer bg-warning">
8989
<small class="text-monospace">Attention! The <strong>extracted_*</strong> indices will be deleted 48 hours after they were created.</small>
90-
</div>
90+
</div>
9191
</div>
9292
</div><!-- /.row -->
9393
</div><!-- /.container -->
@@ -282,14 +282,14 @@ <h5 class="modal-title" id="exampleModalLabel">X-tract indices from snapshot</h5
282282

283283
$('#selectedsnap').html("from <strong>"+reponame+"</strong>");
284284

285-
$("#get_repo_sort_time").attr("data-id", reponame);
285+
#$("#get_repo_sort_time").attr("data-id", reponame);
286286
$("#get_repo_sort_name").attr("data-id", reponame);
287287

288288
var post = {
289289
"action": "get_snapshots",
290290
"values" : {
291291
"repo": reponame,
292-
"otype": "time",
292+
"otype": "name",
293293
"odir": "desc"
294294
}
295295
};
@@ -306,11 +306,11 @@ <h5 class="modal-title" id="exampleModalLabel">X-tract indices from snapshot</h5
306306
dlicon = '<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-download" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/><path fill-rule="evenodd" d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"/></svg>';
307307

308308
for(var k in data) {
309-
snapshot = data[k].id;
310-
uniqid = data[k].start_epoch;
311-
status = data[k].status;
312-
date = new Date(data[k].start_epoch * 1000);
313-
hdate = date.toLocaleString("ru-RU", {timeZoneName: "short"});
309+
snapshot = data[k].name;
310+
#uniqid = data[k].start_epoch;
311+
status = data[k].state;
312+
#date = new Date(data[k].start_epoch * 1000);
313+
#hdate = date.toLocaleString("ru-RU", {timeZoneName: "short"});
314314
restore_button = "";
315315

316316
if (status == "SUCCESS") {
@@ -321,7 +321,7 @@ <h5 class="modal-title" id="exampleModalLabel">X-tract indices from snapshot</h5
321321
restore_button = "";
322322
}
323323

324-
str += "<li><h5 class='font-weight-bold list-group-item list-group-item-action' title='"+status+"'>"+icon+" <strong>" + snapshot + "</strong> created at " + hdate + restore_button +"</h5></li>";
324+
str += "<li><h5 class='font-weight-bold list-group-item list-group-item-action' title='"+status+"'>"+icon+" <strong>" + snapshot + "</strong> " + restore_button +"</h5></li>";
325325
}
326326

327327
$("#loading").addClass('invisible');

modules/router/router.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,9 @@ type Cluster struct {
137137
}
138138

139139
type snapList []struct {
140-
Id string `json:"id,omitempty"`
141-
Status string `json:"status,omitempty"`
142-
End_epoch string `json:"end_epoch,omitempty"`
143-
Start_epoch string `json:"start_epoch,omitempty"`
140+
Name string `json:"name,omitempty"`
141+
Uuid string `json:"uuid,omitempty"`
142+
State string `json:"state,omitempty"`
144143
}
145144

146145
type scrollResponse struct {
@@ -349,7 +348,7 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
349348
return
350349
}
351350

352-
response, err := rt.doGet(rt.conf.Snapshot.Host+"_cat/snapshots/"+request.Values.Repo+"?format=json", "Snapshot")
351+
response, err := rt.doGet(rt.conf.Snapshot.Host+"_snapshot/"+request.Values.Repo+"/*?verbose=false&format=json", "Snapshot")
353352
if err != nil {
354353
http.Error(w, err.Error(), http.StatusInternalServerError)
355354
log.Println(remoteIP, "\t", r.Method, "\t", r.URL.Path, "\t", request.Action, "\t", http.StatusInternalServerError, "\t", err.Error())
@@ -367,9 +366,9 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
367366
if !rt.conf.Snapshot.Include {
368367
j := 0
369368
for _, n := range snap_list {
370-
matched, err := regexp.MatchString(`^[\.]\S+`, n.Id)
369+
matched, err := regexp.MatchString(`^[\.]\S+`, n.Name)
371370
if err != nil {
372-
log.Println("Regex error for ", n.Id)
371+
log.Println("Regex error for ", n.Name)
373372
}
374373
if !matched {
375374
snap_list[j] = n
@@ -380,7 +379,7 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
380379
snap_list = snap_list[:j]
381380

382381
}
383-
if request.Values.OrderType == "time" {
382+
/*if request.Values.OrderType == "time" {
384383
385384
if request.Values.OrderDir == "asc" {
386385
sort.Slice(snap_list[:], func(i, j int) bool {
@@ -392,16 +391,17 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
392391
})
393392
}
394393
395-
} else if request.Values.OrderType == "name" {
394+
} else */
395+
if request.Values.OrderType == "name" {
396396

397397
if request.Values.OrderDir == "asc" {
398398
sort.Slice(snap_list[:], func(i, j int) bool {
399-
return snap_list[i].Id < snap_list[j].Id
399+
return snap_list[i].Name < snap_list[j].Name
400400
})
401401

402402
} else {
403403
sort.Slice(snap_list[:], func(i, j int) bool {
404-
return snap_list[i].Id > snap_list[j].Id
404+
return snap_list[i].Name > snap_list[j].Name
405405
})
406406
}
407407

@@ -414,7 +414,7 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
414414

415415
case "get_snapshots_sorted":
416416
{
417-
if request.Values.OrderType == "time" {
417+
/*if request.Values.OrderType == "time" {
418418
419419
if request.Values.OrderDir == "asc" {
420420
sort.Slice(rt.sl[:], func(i, j int) bool {
@@ -426,16 +426,17 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
426426
})
427427
}
428428
429-
} else if request.Values.OrderType == "name" {
429+
} else */
430+
if request.Values.OrderType == "name" {
430431

431432
if request.Values.OrderDir == "asc" {
432433
sort.Slice(rt.sl[:], func(i, j int) bool {
433-
return rt.sl[i].Id < rt.sl[j].Id
434+
return rt.sl[i].Name < rt.sl[j].Name
434435
})
435436

436437
} else {
437438
sort.Slice(rt.sl[:], func(i, j int) bool {
438-
return rt.sl[i].Id > rt.sl[j].Id
439+
return rt.sl[i].Name > rt.sl[j].Name
439440
})
440441
}
441442

modules/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313

1414
package version
1515

16-
var Version = "extractor/v0.2.22"
16+
var Version = "extractor/v0.2.23"

0 commit comments

Comments
 (0)