mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +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:
parent
8bcce4d5cc
commit
2349791676
@ -678,6 +678,11 @@ bool Laminar::tryStartRun(std::shared_ptr<Run> run, int queueIndex) {
|
||||
.fetch<uint>([&](uint etc){
|
||||
j.set("etc", time(nullptr) + etc);
|
||||
});
|
||||
j.startArray("tags");
|
||||
for(const str& t: jobTags[run->name]) {
|
||||
j.String(t.c_str());
|
||||
}
|
||||
j.EndArray();
|
||||
j.EndObject();
|
||||
const char* msg = j.str();
|
||||
for(LaminarClient* c : clients) {
|
||||
@ -779,6 +784,11 @@ void Laminar::runFinished(Run * r) {
|
||||
.set("started", r->startedAt)
|
||||
.set("result", to_string(r->result))
|
||||
.set("reason", r->reason());
|
||||
j.startArray("tags");
|
||||
for(const str& t: jobTags[r->name]) {
|
||||
j.String(t.c_str());
|
||||
}
|
||||
j.EndArray();
|
||||
j.startArray("artifacts");
|
||||
populateArtifacts(j, r->name, r->build);
|
||||
j.EndArray();
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
},
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
Loading…
Reference in New Issue
Block a user