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

resolves #47: jobs don't refresh on jobs page

The computed list of filtered jobs wasn't updated when a notification
was received from the server. Switch to using a method rather than a
computed property to fix this. Also add tags to jobs reported in
job_started and job_completed notifications
This commit is contained in:
Oliver Giles
2018-08-24 13:10:00 +03:00
parent 8bcce4d5cc
commit 2349791676
3 changed files with 29 additions and 20 deletions

View File

@@ -165,7 +165,7 @@
<li v-for="t in tags" :class="{'active':t==tag}"><a href v-on:click.prevent="tag = t">{{t}}</a></li>
</ul>
<table class="table table-striped" id="joblist">
<tr v-for="job in filteredJobs">
<tr v-for="job in filteredJobs()">
<td><router-link :to="'/jobs/'+job.name">{{job.name}}</router-link></td>
<td class="text-center"><span v-html="runIcon(job.result)"></span> <router-link :to="'/jobs/'+job.name+'/'+job.number">#{{job.number}}</router-link></td>
<td class="text-center">{{formatDate(job.started)}}</td>

View File

@@ -304,24 +304,6 @@ const Jobs = function() {
template: '#jobs',
mixins: [WebsocketHandler, Utils, ProgressUpdater],
data: function() { return state; },
computed: {
filteredJobs() {
var ret = this.jobs;
var tag = this.tag;
if (tag) {
ret = ret.filter(function(job) {
return job.tags.indexOf(tag) >= 0;
});
}
var search = this.search;
if (search) {
ret = ret.filter(function(job) {
return job.name.indexOf(search) > -1;
});
}
return ret;
}
},
methods: {
status: function(msg) {
state.jobs = msg.jobs;
@@ -347,6 +329,7 @@ const Jobs = function() {
},
job_started: function(data) {
var updAt = null;
// jobsRunning must be maintained for ProgressUpdater
for (var i in state.jobsRunning) {
if (state.jobsRunning[i].name === data.name) {
updAt = i;
@@ -389,7 +372,23 @@ const Jobs = function() {
break;
}
}
}
},
filteredJobs: function() {
var ret = state.jobs;
var tag = state.tag;
if (tag) {
ret = ret.filter(function(job) {
return job.tags.indexOf(tag) >= 0;
});
}
var search = this.search;
if (search) {
ret = ret.filter(function(job) {
return job.name.indexOf(search) > -1;
});
}
return ret;
},
}
};
}();