Skip to content

Commit 37a00ac

Browse files
committed
#6 display worker logs
1 parent 844b45b commit 37a00ac

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

backend/openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,8 @@ components:
646646
type: array
647647
items:
648648
$ref: '#/components/schemas/AnvilJob'
649+
logs:
650+
type: string
649651
SuccessResponse:
650652
type: object
651653
properties:

backend/src/controller/AnvilWorker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export enum AnvilWorkerStatus {
1313
export class AnvilWorker {
1414
public readonly id: string;
1515
public readonly name: string;
16+
public logs: string;
1617
public status: AnvilWorkerStatus;
1718
private timer: NodeJS.Timeout;
1819
private commands: AnvilCommand[];
@@ -25,6 +26,7 @@ export class AnvilWorker {
2526
this.status = AnvilWorkerStatus.IDLE;
2627
this.commands = [];
2728
this.jobs = [];
29+
this.logs = "";
2830
this.keepAlive();
2931
}
3032

@@ -49,7 +51,8 @@ export class AnvilWorker {
4951
id: this.id,
5052
name: this.name,
5153
status: this.status.toString(),
52-
jobs: this.jobs.map(j => j.apiObject())
54+
jobs: this.jobs.map(j => j.apiObject()),
55+
logs: this.logs
5356
}
5457
}
5558

backend/src/endpoints/WorkerEndpoint.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export namespace WorkerEndpoint {
3737
return next(new BadRequest("id not valid"));
3838
}
3939
worker.keepAlive();
40+
if (req.body.logs && req.body.logs.trim().length > 0) {
41+
worker.logs += req.body.logs;
42+
}
4043
res.json(worker.fetchCommand(status));
4144
}
4245

backend/src/lib/data_types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export interface IAnvilWorker {
103103
name: string,
104104
id: string,
105105
status: string,
106-
jobs: IAnvilJob[]
106+
jobs: IAnvilJob[],
107+
logs: string
107108
}
108109

109110
export interface IAnvilJob {

frontend/src/views/ControllerView.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
<span v-else>
5959
No Jobs running.
6060
</span>
61+
<br>
62+
<code v-if="worker.logs">
63+
{{ worker.logs }}
64+
</code>
6165
</main>
6266
<footer class="buttons">
6367
<span v-if="worker.status == 'WORKING'" :aria-busy="true"></span>
@@ -160,4 +164,11 @@ article {
160164
--table-row-stripped-background-color: rgb(227, 227, 227);
161165
background-color: rgb(227, 227, 227);
162166
}
167+
168+
code {
169+
white-space: pre-line;
170+
max-height: 10rem;
171+
width: 100%;
172+
overflow-x: scroll;
173+
}
163174
</style>

0 commit comments

Comments
 (0)