Show task details for selected task

The task details are updated at real-time via SocketIO updates.
This commit is contained in:
Sybren A. Stüvel 2022-05-03 13:05:10 +02:00
parent 18891dda91
commit 73b122be84
4 changed files with 108 additions and 17 deletions

View File

@ -9,10 +9,11 @@
</div> </div>
<div class="col-2"> <div class="col-2">
<job-details :jobData="jobs.activeJob" /> <job-details :jobData="jobs.activeJob" />
<tasks-table ref="tasksTable" :jobID="jobs.activeJobID" @selectedTaskChange="onSelectedTaskChanged" /> <tasks-table v-if="jobs.activeJobID" ref="tasksTable" :jobID="jobs.activeJobID"
@selectedTaskChange="onSelectedTaskChanged" />
</div> </div>
<div class="col-3"> <div class="col-3">
<task-details /> <task-details :taskData="tasks.activeTask" />
</div> </div>
<footer> <footer>
<span class='notifications' v-if="notifs.last">{{ notifs.last.msg }}</span> <span class='notifications' v-if="notifs.last">{{ notifs.last.msg }}</span>
@ -84,13 +85,14 @@ export default {
return; return;
} }
console.log("selected task changed:", taskSummary); console.log("selected task changed:", taskSummary);
// const jobsAPI = new API.JobsApi(apiClient); const jobsAPI = new API.JobsApi(apiClient);
// jobsAPI.fetchTask(taskSummary.id) jobsAPI.fetchTask(taskSummary.id)
// .then((task) => { .then((task) => {
// this.tasks.setSelectedTask(task); this.tasks.setSelectedTask(task);
// // Forward the full task to Tabulator, so that that gets updated too. // Forward the full task to Tabulator, so that that gets updated too.
// this.$refs.tasksTable.processTaskUpdate(task); if (this.$refs.tasksTable)
// }); this.$refs.tasksTable.processTaskUpdate(task);
});
}, },
sendMessage(message) { sendMessage(message) {
@ -131,11 +133,13 @@ export default {
*/ */
onSioTaskUpdate(taskUpdate) { onSioTaskUpdate(taskUpdate) {
if (!this.$refs.tasksTable) { if (!this.$refs.tasksTable) {
console.warn("App: this.$refs.tasksTable is", this.$refs.tasksTable);
return; return;
} }
this.$refs.tasksTable.processTaskUpdate(taskUpdate); this.$refs.tasksTable.processTaskUpdate(taskUpdate);
if (this.tasks.activeTaskID == taskUpdate.id) {
this.onSelectedTaskChanged(taskUpdate);
}
}, },
onChatMessage(message) { onChatMessage(message) {
@ -152,6 +156,7 @@ export default {
onSIODisconnected(reason) { onSIODisconnected(reason) {
this.flamencoName = DEFAULT_FLAMENCO_NAME; this.flamencoName = DEFAULT_FLAMENCO_NAME;
this.flamencoVersion = DEFAULT_FLAMENCO_VERSION; this.flamencoVersion = DEFAULT_FLAMENCO_VERSION;
this.jobs.deselectAllJobs();
}, },
fetchManagerInfo() { fetchManagerInfo() {
const metaAPI = new API.MetaApi(apiClient); const metaAPI = new API.MetaApi(apiClient);

View File

@ -152,7 +152,9 @@ export default {
jobTypeSettings[setting.key] = setting; jobTypeSettings[setting.key] = setting;
this.jobTypeSettings = jobTypeSettings; this.jobTypeSettings = jobTypeSettings;
this._setJobSettings(this.jobData.settings); if (this.jobData) {
this._setJobSettings(this.jobData.settings);
}
}, },
_setJobSettings(newJobSettings) { _setJobSettings(newJobSettings) {

View File

@ -1,23 +1,107 @@
<template> <template>
<div class="task-details"> <h2 class="column-title">Task Details</h2>
<h2 class="column-title">Task Details</h2> <div v-if="hasTaskData" class="task-details">
<table class="details">
<tr class="field-id">
<th>ID</th>
<td>{{ taskData.id }}</td>
</tr>
<tr class="field-name">
<th>Name</th>
<td>{{ taskData.name }}</td>
</tr>
<tr class="field-status">
<th>Status</th>
<td>{{ taskData.status }}</td>
</tr>
<tr class="field-type">
<th>Type</th>
<td>{{ taskData.type }}</td>
</tr>
<tr class="field-priority">
<th>Prio</th>
<td>{{ taskData.priority }}</td>
</tr>
<tr class="field-created">
<th>Created</th>
<td>{{ datetime.relativeTime(taskData.created) }}</td>
</tr>
<tr class="field-updated">
<th>Updated</th>
<td>{{ datetime.relativeTime(taskData.updated) }}</td>
</tr>
</table>
<h3 class="sub-title">Commands</h3>
<table class="commands">
<tr v-for="cmd in taskData.commands" :class="`field-${cmd.name}`">
<th>{{ cmd.name }}</th>
<td>{{ cmd.parameters }}</td>
</tr>
</table>
</div>
<div v-else class="no-task-selected">
<p>No task selected, pick one from the list on the left.</p>
</div> </div>
</template> </template>
<script lang="js"> <script lang="js">
import * as datetime from "@/datetime";
import * as API from '@/manager-api';
import { apiClient } from '@/stores/api-query-count';
function objectEmpty(o) {
if (!o) return true;
return Object.entries(o).length == 0;
}
export default { export default {
data: () => { props: [
"taskData", // Task data to show.
],
data() {
return { return {
datetime: datetime, // So that the template can access it.
jobsApi: new API.JobsApi(apiClient),
}; };
}, },
mounted() { mounted() {
// Allow testing from the JS console: // Allow testing from the JS console:
window.taskDetailsVue = this; window.taskDetailsVue = this;
}, },
methods: { computed: {
} hasTaskData() {
return !!this.taskData && !!this.taskData.id;
},
},
}; };
</script> </script>
<style scoped> <style scoped>
.task-details {
font-size: smaller;
font-family: 'Noto Mono', monospace;
}
tr:hover {
background-color: #333333;
}
tr.field-id td {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
th {
font-weight: bold;
text-align: right;
vertical-align: top;
}
</style> </style>

View File

@ -86,7 +86,7 @@ export default {
console.log("socketIO reconnected after", attemptNumber, "attempts"); console.log("socketIO reconnected after", attemptNumber, "attempts");
// Resubscribe to whatever we want to be subscribed to: // Resubscribe to whatever we want to be subscribed to:
if (this.subscribedJob) this._updateJobSubscription("subscribe", newJob); if (this.subscribedJob) this._updateJobSubscription("subscribe", this.subscribedJob);
this.$emit("sioReconnected", attemptNumber); this.$emit("sioReconnected", attemptNumber);
}); });