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

resolves #38: implement pagination for the job page

This commit is contained in:
Oliver Giles
2018-06-01 14:51:34 +03:00
parent d1ca6392a4
commit a0f586581d
5 changed files with 41 additions and 9 deletions

View File

@@ -189,6 +189,11 @@
<td class="text-center hidden-xs">{{job.reason}}</td>
</tr>
</table>
<ul class="pagination pull-right">
<li><button class="btn btn-default" v-on:click="page_prev" :disabled="page==0">&laquo;</button></li>
<li>Page {{page+1}} of {{pages}}</li>
<li><button class="btn btn-default" v-on:click="page_next" :disabled="page==pages-1">&raquo;</button></li>
</ul>
</div></div>
</div>
</div></template>

View File

@@ -21,8 +21,10 @@ const WebsocketHandler = function() {
// "status" is the first message the websocket always delivers.
// Use this to confirm the navigation. The component is not
// created until next() is called, so creating a reference
// for other message types must be deferred
if (msg.type === 'status') {
// for other message types must be deferred. Also check that
// the reference is not already created, this allows a subsequent
// status message to be handled as an update.
if (msg.type === 'status' && !this.comp) {
next(comp => {
// Set up bidirectional reference
// 1. needed to reference the component for other msg types
@@ -394,6 +396,8 @@ var Job = function() {
lastSuccess: null,
lastFailed: null,
nQueued: 0,
pages: 0,
page: 0
};
return Vue.extend({
template: '#job',
@@ -408,6 +412,7 @@ var Job = function() {
state.lastSuccess = msg.lastSuccess;
state.lastFailed = msg.lastFailed;
state.nQueued = msg.nQueued;
state.pages = msg.pages;
var chtBt = new Chart(document.getElementById("chartBt").getContext("2d")).Bar({
labels: msg.recent.map(function(e) {
@@ -454,6 +459,12 @@ var Job = function() {
break;
}
}
},
page_next: function() {
this.ws.send(JSON.stringify({page:++state.page}));
},
page_prev: function() {
this.ws.send(JSON.stringify({page:--state.page}));
}
}
});