Commit ef6ba69f authored by Cage, Gregory's avatar Cage, Gregory
Browse files

Update UI to load stderr

parent 69258037
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ export default {
            mouseMoved: false,
            expanded: false,
            lastHeight: 0,
            lastHeightErr: 0,
        };
    },
    computed: {
@@ -58,12 +59,21 @@ export default {
        // If the user is at the bottom of the code div, auto scroll for them.
        try {
            var codeDiv = document.querySelector("#stdout").querySelector(".code");
            if (codeDiv.scrollTop >= this.lastHeight - 3000) {
            if (codeDiv.scrollTop >= this.lastHeight - 300) {
                codeDiv.scrollTop = codeDiv.scrollHeight;
            }
            this.lastHeight = codeDiv.scrollHeight;
        } catch(exception) {
            console.log("Code div is not present");
            console.log("Code (stdout) div is not present");
        }
        try {
            var codeDivErr = document.querySelector("#stderr").querySelector(".code");
            if (codeDivErr.scrollTop >= this.lastHeightErr - 300) {
                codeDivErr.scrollTop = codeDivErr.scrollHeight;
            }
            this.lastHeightErr = codeDivErr.scrollHeight;
        } catch(exception) {
            console.log("Code div (stderr) is not present");
        }
    },
    methods: {
+4 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ describe("JobInformation/JobInformation.vue", () => {
    beforeEach(() => {
        axiosMock = new MockAdapter(axios);
        axiosMock.onGet(new RegExp(`api/configuration/decode/*`)).reply(200, { decoded_id: 123 });
        axiosMock.onGet("/api/jobs/test_id?full=True&stdout_position=0&stdout_length=50000").reply(200, jobResponse);
        axiosMock.onGet("/api/jobs/test_id?full=True&stdout_position=0&stdout_length=50000&stderr_position=0&stderr_length=50000").reply(200, jobResponse);
    });

    afterEach(() => {
@@ -48,6 +48,9 @@ describe("JobInformation/JobInformation.vue", () => {
            stdout_position: STDOUT_POSITION,
            stdout_length: STDOUT_LENGTH,
            stdout_text: STDOUT_TEXT,
            stderr_position: STDOUT_POSITION,
            stderr_length: STDOUT_LENGTH,
            stderr_text: STDOUT_TEXT,
        };
        wrapper = mount(JobInformation, {
            propsData,
+9 −15
Original line number Diff line number Diff line
<template>
    <div>
        <job-details-provider auto-refresh :jobId="job_id" :stdout_position=stdout_position :stdout_length=stdout_length @update:result="updateJob" />
        <job-details-provider auto-refresh :jobId="job_id" :stdout_position=stdout_position :stdout_length=stdout_length :stderr_position=stderr_position :stderr_length=stderr_length @update:result="updateJob"/>
        <h2 class="h-md">Job Information</h2>
        <table id="job-information" class="tabletip info_data_table">
            <tbody>
@@ -42,7 +42,7 @@
                </tr>
                <code-row v-if="job" id="command-line" :code-label="'Command Line'" :code-item="job.command_line" />
                <code-row v-if="job" id="stdout" :code-label="'Tool Standard Output'" :code-item="stdout_text" />
                <code-row v-if="job" id="stderr" :code-label="'Tool Standard Error'" :code-item="job.tool_stderr" />
                <code-row v-if="job" id="stderr" :code-label="'Tool Standard Error'" :code-item="stderr_text" />
                <code-row
                    v-if="job && job.traceback"
                    id="traceback"
@@ -110,6 +110,9 @@ export default {
            stdout_position: 0,
            stdout_length: 50000,
            stdout_text: "",
            stderr_position: 0,
            stderr_length: 50000,
            stderr_text: "",
        };
    },
    computed: {
@@ -122,19 +125,6 @@ export default {
            return this.job && !JOB_STATES_MODEL.NON_TERMINAL_STATES.includes(this.job.state);
        },
    },
    updated() {
        try {
            const stdout_block = document.querySelector("#stdout").querySelector(".code");
            // if user is scrolled above the bottom of the code element, then no need to update the stdout
            if (stdout_block.scrollTop <= stdout_block.scrollHeight - 3000) {
                this.stdout_length = 0;
            } else {
                this.stdout_length = 50000;
            }
        } catch(exception) {
            console.log(exception);
        }
    },
    methods: {
        getAppRoot() {
            return getAppRoot();
@@ -146,6 +136,10 @@ export default {
                this.stdout_text += job.tool_stdout;
                this.stdout_position += job.tool_stdout.length;
            }
            if (job.tool_stderr != null) {
                this.stderr_text += job.tool_stderr;
                this.stderr_position += job.tool_stderr.length;
            }
        },
    },
};
+2 −2
Original line number Diff line number Diff line
@@ -5,8 +5,8 @@ import { rethrowSimple } from "utils/simple-error";
import { stateIsTerminal } from "./utils";
import { cleanPaginationParameters } from "./utils";

async function jobDetails({ jobId, stdout_position = 0, stdout_length = 0 }) {
    const url = `${getAppRoot()}api/jobs/${jobId}?full=True&stdout_position=${stdout_position}&stdout_length=${stdout_length}`;
async function jobDetails({ jobId, stdout_position = 0, stdout_length = 0, stderr_position = 0, stderr_length = 0 }) {
    const url = `${getAppRoot()}api/jobs/${jobId}?full=True&stdout_position=${stdout_position}&stdout_length=${stdout_length}&stderr_position=${stderr_position}&stderr_length=${stderr_length}`;
    try {
        const { data } = await axios.get(url);
        return data;