Commit 7b78d263 authored by Assunta DeSanto's avatar Assunta DeSanto
Browse files

connecting states in JobStateSummary to actually matched states in states.js;...

connecting states in JobStateSummary to actually matched states in states.js; using isTerminal from JobStateSummary to determine if progress bar should be shown
parent 988cf44a
Loading
Loading
Loading
Loading
+19 −30
Original line number Diff line number Diff line
@@ -3,15 +3,27 @@ at components/JobStates/CollectionJobStates but it relies on the backbone data
model, so probably has to go eventually.-->
<template>
    <div class="collection-progress">
        <b-progress v-if="maxJobs != okJobs + errorJobs" :max="maxJobs">
            <b-progress-bar v-if="errorJobs" :value="errorJobs" variant="danger" v-b-tooltip.hover="errorJobs" />
            <b-progress-bar v-if="okJobs" :value="okJobs" variant="success" v-b-tooltip.hover="okJobs" />
            <b-progress-bar v-if="runningJobs" :value="runningJobs" variant="warning" v-b-tooltip.hover="runningJobs" />
        <b-progress v-if="!summary.isTerminal" :max="summary.jobCount">
            <b-progress-bar
                v-if="waitingJobs"
                :value="waitingJobs"
                v-if="summary.errorCount"
                :value="summary.errorCount"
                variant="danger"
                v-b-tooltip.hover="summary.errorCount" />
            <b-progress-bar
                v-if="summary.okCount"
                :value="summary.okCount"
                variant="success"
                v-b-tooltip.hover="summary.okCount" />
            <b-progress-bar
                v-if="summary.runningCount"
                :value="summary.runningCount"
                variant="warning"
                v-b-tooltip.hover="summary.runningCount" />
            <b-progress-bar
                v-if="summary.waitingCount"
                :value="summary.waitingCount"
                variant="secondary"
                v-b-tooltip.hover="waitingJobs" />
                v-b-tooltip.hover="summary.waitingCount" />
        </b-progress>
    </div>
</template>
@@ -22,28 +34,5 @@ export default {
    props: {
        summary: { type: JobStateSummary, required: true },
    },
    computed: {
        maxJobs() {
            return this.summary.get("all_jobs");
        },
        okJobs() {
            return this.summary.get("ok");
        },
        runningJobs() {
            return this.summary.get("running");
        },
        errorJobs() {
            const failed = this.summary.get("failed") || 0;
            const error = this.summary.get("error") || 0;
            const discarded = this.summary.get("discarded") || 0;
            return failed + error + discarded;
        },
        waitingJobs() {
            const queued = this.summary.get("queued") || 0;
            const waiting = this.summary.get("waiting") || 0;
            const paused = this.summary.get("paused") || 0;
            return queued + waiting + paused;
        },
    },
};
</script>
+20 −12
Original line number Diff line number Diff line
@@ -6,8 +6,8 @@
 */
import { STATES } from "../model/states";

const NON_TERMINAL_STATES = [STATES.NEW, STATES.WAITING, STATES.QUEUED, STATES.RUNNING];
const ERROR_STATES = [STATES.ERROR, STATES.DISCARDED];
const NON_TERMINAL_STATES = ["new", "waiting", "queued", "running"];
const ERROR_STATES = ["error", "discarded"];

export class JobStateSummary extends Map {
    constructor(dsc = {}) {
@@ -28,18 +28,18 @@ export class JobStateSummary extends Map {
    get state() {
        if (this.jobCount) {
            if (this.isErrored) {
                return STATES.ERROR;
                return STATES.error;
            }
            if (this.isRunning) {
                return STATES.RUNNING;
                return STATES.running;
            }
            if (this.isNew) {
                return STATES.LOADING;
                return STATES.loading;
            }
            if (this.isTerminal) {
                return STATES.OK;
                return STATES.ok;
            }
            return STATES.QUEUED;
            return STATES.queued;
        }
        return this.populated_state;
    }
@@ -47,11 +47,11 @@ export class JobStateSummary extends Map {
    // Flags

    get isNew() {
        return !this.populated_state || this.populated_state == STATES.NEW;
        return !this.populated_state || this.populated_state == STATES.new;
    }

    get isErrored() {
        return this.populated_state == STATES.ERROR || this.anyHasJobs(...ERROR_STATES);
        return this.populated_state == STATES.error || this.anyHasJobs(...ERROR_STATES);
    }

    get isTerminal() {
@@ -62,20 +62,28 @@ export class JobStateSummary extends Map {
    }

    get isRunning() {
        return this.hasJobs(STATES.RUNNING);
        return this.hasJobs(STATES.running);
    }

    // Counts

    get okCount() {
        return this.get("ok");
    }

    get jobCount() {
        return this.get("all_jobs");
    }

    get errorCount() {
        return this.get(STATES.ERROR);
        return (this.get("error") || 0) + (this.get("failed") || 0) + (this.get("discarded") || 0);
    }

    get runningCount() {
        return this.get(STATES.RUNNING);
        return this.get("running");
    }

    get waitingCount() {
        return (this.get("queued") || 0) + (this.get("waiting") || 0) + (this.get("paused") || 0);
    }
}