Show task log tail in the web interface
This commit is contained in:
parent
2cf6e2e528
commit
ae0f4a7ca4
@ -1,10 +1,11 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted } from 'vue'
|
import { onMounted, watch } from 'vue'
|
||||||
import { TabulatorFull as Tabulator } from 'tabulator-tables';
|
import { TabulatorFull as Tabulator } from 'tabulator-tables';
|
||||||
import { useTaskLog } from '@/stores/tasklog'
|
import { useTaskLog } from '@/stores/tasklog'
|
||||||
import * as datetime from "@/datetime";
|
import { useTasks } from '@/stores/tasks'
|
||||||
|
|
||||||
const taskLog = useTaskLog();
|
const taskLog = useTaskLog();
|
||||||
|
const tasks = useTasks();
|
||||||
|
|
||||||
const tabOptions = {
|
const tabOptions = {
|
||||||
columns: [
|
columns: [
|
||||||
@ -30,8 +31,14 @@ onMounted(() => {
|
|||||||
tabulator = new Tabulator('#task_log_list', tabOptions);
|
tabulator = new Tabulator('#task_log_list', tabOptions);
|
||||||
tabulator.on("tableBuilt", _scrollToBottom);
|
tabulator.on("tableBuilt", _scrollToBottom);
|
||||||
tabulator.on("tableBuilt", _subscribeToPinia);
|
tabulator.on("tableBuilt", _subscribeToPinia);
|
||||||
|
console.log("Task log list: mounted on task ID", tasks.activeTaskID);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tasks.$subscribe((_, state) => {
|
||||||
|
console.log("Task log list: new task ID", state.activeTaskID);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
function _scrollToBottom() {
|
function _scrollToBottom() {
|
||||||
if (taskLog.empty) return;
|
if (taskLog.empty) return;
|
||||||
tabulator.scrollToRow(taskLog.lastID, "bottom", false);
|
tabulator.scrollToRow(taskLog.lastID, "bottom", false);
|
||||||
|
@ -82,7 +82,6 @@ export default {
|
|||||||
this._fetchJob(newJobID);
|
this._fetchJob(newJobID);
|
||||||
},
|
},
|
||||||
taskID(newTaskID, oldTaskID) {
|
taskID(newTaskID, oldTaskID) {
|
||||||
this.taskLog.clear();
|
|
||||||
this._fetchTask(newTaskID);
|
this._fetchTask(newTaskID);
|
||||||
},
|
},
|
||||||
showFooterPopup(shown) {
|
showFooterPopup(shown) {
|
||||||
@ -199,6 +198,8 @@ export default {
|
|||||||
* @param {string} taskID task ID, can be empty string for "no task".
|
* @param {string} taskID task ID, can be empty string for "no task".
|
||||||
*/
|
*/
|
||||||
_fetchTask(taskID) {
|
_fetchTask(taskID) {
|
||||||
|
this._fetchTaskLogTail(taskID);
|
||||||
|
|
||||||
if (!taskID) {
|
if (!taskID) {
|
||||||
this.tasks.deselectAllTasks();
|
this.tasks.deselectAllTasks();
|
||||||
return;
|
return;
|
||||||
@ -214,6 +215,27 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch task log tail.
|
||||||
|
*
|
||||||
|
* TODO: Only do this when the footer pop-over is visible and set to the
|
||||||
|
* "Task Log" tab. Otherwise the logs won't be shown anyway.
|
||||||
|
*
|
||||||
|
* @param {string} taskID task ID.
|
||||||
|
*/
|
||||||
|
_fetchTaskLogTail(taskID) {
|
||||||
|
this.taskLog.clear();
|
||||||
|
if (!taskID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const jobsAPI = new API.JobsApi(apiClient);
|
||||||
|
return jobsAPI.fetchTaskLogTail(taskID)
|
||||||
|
.then((logTail) => {
|
||||||
|
this.taskLog.addChunk(logTail);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
onChatMessage(message) {
|
onChatMessage(message) {
|
||||||
console.log("chat message received:", message);
|
console.log("chat message received:", message);
|
||||||
this.messages.push(`${message.text}`);
|
this.messages.push(`${message.text}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user