1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-03-02 03:40:21 +00:00

resolves #40: implement frontend sorting

This feature allows runs to be sorted by result, number, start time
or duration, in ascending or descending order, on the Job page. Request
is processed server-side so that the correct page division can be done.
Currently running jobs are not sorted.
This commit is contained in:
Oliver Giles
2018-08-24 12:15:40 +03:00
parent a81492e5bc
commit 8bcce4d5cc
5 changed files with 93 additions and 18 deletions

View File

@@ -402,7 +402,7 @@ var Job = function() {
lastFailed: null,
nQueued: 0,
pages: 0,
page: 0
sort: {}
};
return Vue.extend({
template: '#job',
@@ -418,7 +418,7 @@ var Job = function() {
state.lastFailed = msg.lastFailed;
state.nQueued = msg.nQueued;
state.pages = msg.pages;
state.page = msg.page;
state.sort = msg.sort;
var chtBt = new Chart(document.getElementById("chartBt"), {
type: 'bar',
@@ -467,10 +467,21 @@ var Job = function() {
}
},
page_next: function() {
this.ws.send(JSON.stringify({page:++state.page}));
state.sort.page++;
this.ws.send(JSON.stringify(state.sort));
},
page_prev: function() {
this.ws.send(JSON.stringify({page:--state.page}));
state.sort.page--;
this.ws.send(JSON.stringify(state.sort));
},
do_sort: function(field) {
if(state.sort.field == field) {
state.sort.order = state.sort.order == 'asc' ? 'dsc' : 'asc';
} else {
state.sort.order = 'dsc';
state.sort.field = field;
}
this.ws.send(JSON.stringify(state.sort));
}
}
});