mirror of
https://github.com/ohwgiles/laminar.git
synced 2026-03-02 03:40:21 +00:00
Replace nodes/tags with contexts
The nodes/tags system has not been particularly successful, it's not as intuitive as it could be, and in an attempt to be a single feature to address many use cases, ends up addressing none of them particularly well. This commit replaces nodes and tags with contexts. Each job may define which context(s) the job may be associated with. Laminar will only pop the job off the waiting queue when it can be assigned to a context. A context defines an integer number of executors, which represents how many runs can be simultaneously assigned to it. A context may provide extra environment variables. Essentially, a context replaces a node, and tags are gone. You just assign jobs to contexts directly, and you can use a glob expression. This should be more intuitive. For grouping jobs in the WebUI, a separate mechanism called "groups" is provided.
This commit is contained in:
@@ -207,8 +207,8 @@
|
||||
<input class="form-control" id="jobFilter" v-model="search" placeholder="Filter...">
|
||||
</div>
|
||||
<ul class="nav nav-tabs">
|
||||
<li :class="{'active':tag==null}"><a href v-on:click.prevent="tag = null">All Jobs</a></li>
|
||||
<li v-for="t in tags" :class="{'active':t==tag}"><a href v-on:click.prevent="tag = t">{{t}}</a></li>
|
||||
<li v-show="ungrouped.length" :class="{'active':group==null}"><a href v-on:click.prevent="group = null">Ungrouped Jobs</a></li>
|
||||
<li v-for="g in Object.keys(groups)" :class="{'active':g==group}"><a href v-on:click.prevent="group = g">{{g}}</a></li>
|
||||
</ul>
|
||||
<table class="table table-striped" id="joblist">
|
||||
<tr v-for="job in filteredJobs()">
|
||||
|
||||
@@ -415,8 +415,9 @@ const Jobs = function() {
|
||||
var state = {
|
||||
jobs: [],
|
||||
search: '',
|
||||
tags: [],
|
||||
tag: null
|
||||
groups: {},
|
||||
group: null,
|
||||
ungrouped: []
|
||||
};
|
||||
return {
|
||||
template: '#jobs',
|
||||
@@ -437,13 +438,10 @@ const Jobs = function() {
|
||||
state.jobs.sort(function(a, b){return a.name < b.name ? -1 : a.name > b.name ? 1 : 0;});
|
||||
}
|
||||
}
|
||||
var tags = {};
|
||||
for (var i in state.jobs) {
|
||||
for (var j in state.jobs[i].tags) {
|
||||
tags[state.jobs[i].tags[j]] = true;
|
||||
}
|
||||
}
|
||||
state.tags = Object.keys(tags);
|
||||
state.groups = {};
|
||||
Object.keys(msg.groups).map(k => state.groups[k] = new RegExp(msg.groups[k]));
|
||||
state.ungrouped = state.jobs.filter(j => !Object.values(state.groups).some(r => r.test(j.name))).map(j => j.name);
|
||||
state.group = state.ungrouped.length ? null : Object.keys(state.groups)[0];
|
||||
},
|
||||
job_started: function(data) {
|
||||
var updAt = null;
|
||||
@@ -470,6 +468,8 @@ const Jobs = function() {
|
||||
// first execution of new job. TODO insert without resort
|
||||
state.jobs.unshift(data);
|
||||
state.jobs.sort(function(a, b){return a.name < b.name ? -1 : a.name > b.name ? 1 : 0;});
|
||||
if(!Object.values(state.groups).some(r => r.test(data.name)))
|
||||
state.ungrouped.push(data.name);
|
||||
} else {
|
||||
state.jobs[updAt] = data;
|
||||
}
|
||||
@@ -492,19 +492,13 @@ const Jobs = function() {
|
||||
}
|
||||
},
|
||||
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;
|
||||
});
|
||||
}
|
||||
let ret = [];
|
||||
if (state.group)
|
||||
ret = state.jobs.filter(job => state.groups[state.group].test(job.name));
|
||||
else
|
||||
ret = state.jobs.filter(job => state.ungrouped.includes(job.name));
|
||||
if (this.search)
|
||||
ret = ret.filter(job => job.name.indexOf(this.search) > -1);
|
||||
return ret;
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user