Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions front/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ <h1 class="my-4">Snapshots list
<li class="nav-item">
<a class="nav-link" href="#" id="get_repo_sort_name" data-otype="name" data-odir="asc">Sort by Name</a>
</li>
<li class="nav-item">
<!--li class="nav-item">
<a class="nav-link" href="#" id="get_repo_sort_time" data-otype="time" data-odir="asc">Sort by Time</a>
</li>
</ul>
</li-->
</ul>

<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>
<ul class="list-unstyled mb-0 overflow-auto" style="max-height: 800px;" id="snapshotlist"> </ul>

</div>
</div>

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

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

$("#get_repo_sort_time").attr("data-id", reponame);
#$("#get_repo_sort_time").attr("data-id", reponame);
$("#get_repo_sort_name").attr("data-id", reponame);

var post = {
"action": "get_snapshots",
"values" : {
"repo": reponame,
"otype": "time",
"otype": "name",
"odir": "desc"
}
};
Expand All @@ -306,11 +306,11 @@ <h5 class="modal-title" id="exampleModalLabel">X-tract indices from snapshot</h5
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>';

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

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

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>";
str += "<li><h5 class='font-weight-bold list-group-item list-group-item-action' title='"+status+"'>"+icon+" <strong>" + snapshot + "</strong> " + restore_button +"</h5></li>";
}

$("#loading").addClass('invisible');
Expand Down
31 changes: 16 additions & 15 deletions modules/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ type Cluster struct {
}

type snapList []struct {
Id string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
End_epoch string `json:"end_epoch,omitempty"`
Start_epoch string `json:"start_epoch,omitempty"`
Name string `json:"name,omitempty"`
Uuid string `json:"uuid,omitempty"`
State string `json:"state,omitempty"`
}

type scrollResponse struct {
Expand Down Expand Up @@ -349,7 +348,7 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
return
}

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

}
if request.Values.OrderType == "time" {
/*if request.Values.OrderType == "time" {

if request.Values.OrderDir == "asc" {
sort.Slice(snap_list[:], func(i, j int) bool {
Expand All @@ -392,16 +391,17 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
})
}

} else if request.Values.OrderType == "name" {
} else */
if request.Values.OrderType == "name" {

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

} else {
sort.Slice(snap_list[:], func(i, j int) bool {
return snap_list[i].Id > snap_list[j].Id
return snap_list[i].Name > snap_list[j].Name
})
}

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

case "get_snapshots_sorted":
{
if request.Values.OrderType == "time" {
/*if request.Values.OrderType == "time" {

if request.Values.OrderDir == "asc" {
sort.Slice(rt.sl[:], func(i, j int) bool {
Expand All @@ -426,16 +426,17 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
})
}

} else if request.Values.OrderType == "name" {
} else */
if request.Values.OrderType == "name" {

if request.Values.OrderDir == "asc" {
sort.Slice(rt.sl[:], func(i, j int) bool {
return rt.sl[i].Id < rt.sl[j].Id
return rt.sl[i].Name < rt.sl[j].Name
})

} else {
sort.Slice(rt.sl[:], func(i, j int) bool {
return rt.sl[i].Id > rt.sl[j].Id
return rt.sl[i].Name > rt.sl[j].Name
})
}

Expand Down
2 changes: 1 addition & 1 deletion modules/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@

package version

var Version = "extractor/v0.2.22"
var Version = "extractor/v0.2.23"