Add ability to hide saltutil.find_jobs jobs

This commit is contained in:
Adam Goldsmith 2019-12-30 14:12:27 -05:00
parent 3b3603cd6f
commit c87322a36f
2 changed files with 25 additions and 3 deletions

View File

@ -1,11 +1,20 @@
<template>
<div>
<label>
Show Raw Events JSON <input type="checkbox" v-model="showRawEvents"
/></label>
<label>
Hide
<code>saltutil.find_job</code>
jobs <input type="checkbox" v-model="hideFindJob"
/></label>
<Job
v-for="(jobEvents, jid) in jobs"
:key="jid"
:jid="jid"
:showRawEvents="showRawEvents"
:events="jobEvents"
:showRawEvents="showRawEvents"
:hideFindJob="hideFindJob"
></Job>
</div>
</template>
@ -26,6 +35,7 @@ export default class App extends Vue {
events: salt.SaltEvent[] = [];
jobs: { [key: string]: salt.JobEvent[] } = {};
showRawEvents: boolean = false;
hideFindJob: boolean = true;
mounted(): void {
fetch(BASE_URL + 'login', {

View File

@ -1,5 +1,5 @@
<template>
<div class="job">
<div class="job" v-show="!hidden">
<h3>
<span v-if="startEvent">
{{ startEvent.data.fun }}
@ -48,6 +48,7 @@ export default class Job extends Vue {
@Prop(Number) readonly jid: salt.JobID;
@Prop(Boolean) readonly showRawEvents: boolean;
@Prop() readonly events: salt.JobEvent[];
@Prop(String) readonly hideFindJob: string;
isJobEventType<T extends salt.JobEvent['splitTag'][3]>(
event: salt.JobEvent,
@ -59,7 +60,7 @@ export default class Job extends Vue {
return event.splitTag[3] === type;
}
get startEvent(): salt.JobNewEvent {
get startEvent(): salt.JobNewEvent | undefined {
return this.events.find((event): event is salt.JobNewEvent =>
this.isJobEventType(event, 'new')
);
@ -79,6 +80,17 @@ export default class Job extends Vue {
}, {});
}
get hidden(): boolean {
return (
this.hideFindJob &&
this.events.find(
event =>
!this.isJobEventType(event, 'prog') &&
event.data.fun === 'saltutil.find_job'
) !== undefined
);
}
event_name(event: salt.JobEvent) {
if (this.isJobEventType(event, 'prog')) {
return `${this.event_symbol(event)} Progress: ${