|
1 | 1 | <template>
|
2 | 2 | <div>
|
3 | 3 | <h1>Runners Overview</h1>
|
| 4 | + <div> |
| 5 | + <p>Search for runner: <input type="text" v-model="searchRunner" placeholder="runner name" /></p> |
| 6 | + <p><input type="checkbox" v-model.lazy="searchOnlyOnline" id="online"/><label for="online">Show only online runners</label></p> |
| 7 | + </div> |
4 | 8 | <table>
|
5 | 9 | <thead>
|
6 | 10 | <tr>
|
|
19 | 23 | <template v-for="runner in sortedRunners" :key="runner.runnerId">
|
20 | 24 | <tr>
|
21 | 25 | <td>{{ getStatusIcon(runner.isOnline)}} <a target="_blank" title="Show monitoring" :href="'https://grafana.ethquokkaops.io/d/rYdddlPWk/node-exporter-full?orgId=1&var-DS_PROMETHEUS=default&var-job=integrations%2Fnode_exporter&var-node='+ runner.hostname +':9090'">📈</a> {{ runner.hostname }}</td>
|
22 |
| - <td v-if="runner.jobId">🚀 Job assigned</td> |
23 |
| - <td v-else>🔎 No job assigned</td> |
| 26 | + <td>{{ getRunnerJobState(runner)}}</td> |
24 | 27 | <td><a :href="'https://github.com/' + runner.owner" target="_blank">{{ runner.owner }}</a></td>
|
25 | 28 | <td>{{ runner.size }}</td>
|
26 | 29 | <td><code>{{ runner.iPv4 }}</code></td>
|
@@ -99,23 +102,47 @@ export default {
|
99 | 102 | return {
|
100 | 103 | runners: [],
|
101 | 104 | visibleRunners: [],
|
102 |
| - jobs: [] |
| 105 | + jobs: [], |
| 106 | + searchRunner: "", |
| 107 | + searchOnlyOnline: false |
103 | 108 | };
|
104 | 109 | },
|
105 | 110 | mounted() {
|
106 | 111 | this.fetchRunners();
|
107 |
| - setInterval(this.fetchRunners, 2000); |
| 112 | + setInterval(this.fetchRunners, 10000); |
108 | 113 | },
|
109 | 114 | computed: {
|
110 | 115 | sortedRunners() {
|
111 |
| - return this.runners.map(runner => ({ |
| 116 | + console.log("Triggered compute") |
| 117 | + return this.runners |
| 118 | + .filter(runner => { |
| 119 | + if(this.searchOnlyOnline === true) { |
| 120 | + return runner.isOnline && runner.hostname.includes(this.searchRunner) |
| 121 | + } else { |
| 122 | + return runner.hostname.includes(this.searchRunner) |
| 123 | + } |
| 124 | + }) |
| 125 | + .map(runner => ({ |
112 | 126 | ...runner,
|
113 | 127 | lifecycle: runner.lifecycle.slice().sort((a, b) => new Date(a.eventTimeUtc) - new Date(b.eventTimeUtc)),
|
114 | 128 | job: this.jobs.find(j => j.runnerId === runner.runnerId)
|
115 | 129 | }));
|
116 | 130 | }
|
117 | 131 | },
|
118 | 132 | methods: {
|
| 133 | + getRunnerJobState(runner) { |
| 134 | + if(runner.jobId) { |
| 135 | + if(runner.job) { |
| 136 | + return this.getJobState(runner.job.db.state); |
| 137 | + } |
| 138 | + else { |
| 139 | + return "welp" |
| 140 | + } |
| 141 | + } |
| 142 | + else { |
| 143 | + return "🔎 No job assigned"; |
| 144 | + } |
| 145 | + }, |
119 | 146 | getCommitUrl(sha, repo) {
|
120 | 147 | return "https://github.com/" + repo + "/commit/" + sha
|
121 | 148 | },
|
@@ -144,62 +171,64 @@ export default {
|
144 | 171 | getJobState(statusCode) {
|
145 | 172 | const JobState = {
|
146 | 173 | 0: "Unknown",
|
147 |
| - 1: "Queued", |
148 |
| - 2: "In Progress", |
149 |
| - 3: "Completed" |
| 174 | + 1: "⏸️ Queued", |
| 175 | + 2: "▶️ In Progress", |
| 176 | + 3: "✅ Completed" |
150 | 177 | };
|
151 | 178 | if (Object.prototype.hasOwnProperty.call(JobState, statusCode)) {
|
152 | 179 | return JobState[statusCode];
|
153 | 180 | }
|
154 | 181 | return "Unknown"; // Default case if status code is not found
|
155 | 182 |
|
156 | 183 | },
|
157 |
| - fetchRunners() { |
158 |
| - axios.get(process.env.VUE_APP_API_URL + '/api/get-runners') |
159 |
| - .then(response => { |
160 |
| - this.runners = response.data; |
161 |
| - for(var od of this.visibleRunners) { |
162 |
| - let r = this.runners.find(x => x.runnerId === od) |
163 |
| - this.fetchJob(r.jobId, od) |
164 |
| - } |
| 184 | + async fetchRunners() { |
| 185 | + let runnerResp = await axios.get(process.env.VUE_APP_API_URL + '/api/get-runners'); |
| 186 | + this.runners = runnerResp.data; |
| 187 | +
|
| 188 | + // Fetch job infos |
| 189 | + for(var r of this.runners) { |
| 190 | + if(r.jobId) { |
| 191 | + let loadGh = this.visibleRunners.includes(r.runnerId) |
| 192 | + await this.fetchJob(r.jobId, r.runnerId, loadGh) |
| 193 | + } |
| 194 | + } |
165 | 195 |
|
166 |
| - }) |
167 |
| - .catch(error => { |
168 |
| - console.error('There was an error fetching the runners:', error); |
169 |
| - }); |
170 | 196 | },
|
171 |
| - fetchJob(jobid,runnerid) { |
| 197 | + async fetchJob(jobid,runnerid, withGithub) { |
172 | 198 | if(!jobid) { return }
|
173 |
| - axios.get(process.env.VUE_APP_API_URL + '/api/get-job/'+jobid) |
174 |
| - .then(response => { |
175 |
| - const index = this.jobs.findIndex(job => job.runnerId === runnerid); |
| 199 | + let jobDb = await axios.get(process.env.VUE_APP_API_URL + '/api/get-job/'+jobid); |
176 | 200 |
|
177 |
| - if (index !== -1) { |
178 |
| - this.jobs.splice(index, 1); |
179 |
| - } |
| 201 | + const index = this.jobs.findIndex(job => job.runnerId === runnerid); |
| 202 | +
|
| 203 | + if (index !== -1) { |
| 204 | + this.jobs.splice(index, 1); |
| 205 | + } |
180 | 206 |
|
181 |
| - this.jobs.push({ |
182 |
| - runnerId: runnerid, |
183 |
| - db: response.data, |
184 |
| - gh: {} |
185 |
| - }) |
186 |
| - axios.get(response.data.jobUrl).then(resp => { |
187 |
| - let j = this.jobs.find(j => j.runnerId === runnerid); |
188 |
| - j['gh'] = resp.data; |
189 |
| - }) |
| 207 | + this.jobs.push({ |
| 208 | + runnerId: runnerid, |
| 209 | + db: jobDb.data, |
| 210 | + gh: {} |
| 211 | + }) |
| 212 | +
|
| 213 | + if(withGithub) { |
| 214 | + try { |
| 215 | + let resp = await axios.get(jobDb.data.jobUrl); |
| 216 | + let j = this.jobs.find(j => j.runnerId === runnerid); |
| 217 | + j['gh'] = resp.data; |
| 218 | + } |
| 219 | + catch { |
| 220 | + console.log("unable to query github") |
| 221 | + } |
| 222 | + } |
190 | 223 |
|
191 |
| - }) |
192 |
| - .catch(error => { |
193 |
| - console.error('There was an error fetching the runners:', error); |
194 |
| - }); |
195 | 224 |
|
196 | 225 | },
|
197 | 226 | toggleDetails(id,jobid) {
|
198 | 227 | const index = this.visibleRunners.indexOf(id);
|
199 | 228 | if (index > -1) {
|
200 | 229 | this.visibleRunners.splice(index, 1);
|
201 | 230 | } else {
|
202 |
| - this.fetchJob(jobid,id) |
| 231 | + this.fetchJob(jobid,id,true) |
203 | 232 | this.visibleRunners.push(id);
|
204 | 233 | }
|
205 | 234 | }
|
|
0 commit comments