| <template> |
| <div> |
| <div v-if="jobStatusInfos[0][1].length > 0" style="margin-top: -6px" |
| class="text-primary cancel-pending-btn me-2" @click="cancelAll()"> |
| Cancel All |
| </div> |
| |
| |
| |
| |
| |
| <span v-for="(tableData, idx) of allTableData" :key="idx"> |
| <span v-if="isTableVisible(idx)"> |
| <div v-if="tableData && tableData.rows.length > 0"> |
| <Table :tableData="tableData" :caption="jobStatusInfos[idx][0]" @cancelJob="cancelJob" |
| :noFixedTable="true" initialSortColumnName="Start" initialSortOrder="desc" |
| :downloadFilenameBase="jobStatusInfos[idx][0]"></Table> |
| </div> |
| <div v-else> |
| <div class="table-title">{{ jobStatusInfos[idx][0] }}</div> |
| <p style="font-size: 14px">(Queue empty)</p> |
| </div> |
| </span> |
| </span> |
| </div> |
| </template> |
| |
| <script lang="ts"> |
| |
| |
| import Table from "@/UI/Components/Table/Table.vue"; |
| import { |
| ICellValue, |
| ITableData, |
| CellValue, |
| IHeader, |
| } from "@/UI/Components/Table/Types"; |
| import { Options, Vue } from "vue-class-component"; |
| import { cancelInQueueStore, getQueueStore } from "./QueueStore"; |
| import { IJobStatusInfo, JobStatus } from "./QueueTypes"; |
| import { formatTimestamp } from "@/Core/Utils/TimeUtils"; |
| |
| const headers: [IHeader[], IHeader[]] = [ |
| [ |
| { text: "", width: 25, sortable: false }, |
| { text: "Job ID", note: "Job ID (type:id)" }, |
| { text: "Procs", note: "Number of Processors", width: 80 }, |
| { text: "Progress", note: "Progress" }, |
| { text: "Start", note: "Job Start Time" }, |
| ], |
| [ |
| { text: "Job ID", note: "Job ID (type:id)" }, |
| { text: "Procs", note: "Number of Processors", width: 80 }, |
| { text: "Status", note: "Job Status" }, |
| { text: "Start", note: "Job Start Time" }, |
| { text: "End", note: "Job End Time" }, |
| ], |
| ]; |
| |
| |
| |
| |
| @Options({ |
| components: { |
| Table, |
| }, |
| }) |
| export default class JobManager extends Vue { |
| jobStatusInfos: any[] = [ |
| ["Running Jobs", [] as IJobStatusInfo[]], |
| ["Completed Jobs", [] as IJobStatusInfo[]], |
| ]; |
| |
| |
| |
| |
| |
| |
| get allTableData(): ITableData[] { |
| return [this.jobStatusesToTableData(0), this.jobStatusesToTableData(1)]; |
| } |
| |
| |
| |
| |
| |
| |
| |
| isTableVisible(tableIdx: number): boolean { |
| |
| const secondTableDataCount = this.jobStatusInfos[1][1].length; |
| |
| |
| return tableIdx === 0 || secondTableDataCount > 0; |
| } |
| |
| |
| |
| |
| |
| |
| |
| jobStatusesToTableData(tableIdx: number): ITableData { |
| const jobStatuses = this.jobStatusInfos[tableIdx][1]; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| let rows = jobStatuses |
| .map((r: any) => { |
| return { |
| "": { |
| val: "", |
| iconClasses: ["far", "fa-rectangle-xmark"], |
| iconClickEmitName: "cancelJob", |
| iconShowFilterFunc: (row: { |
| [key: string]: CellValue; |
| }): boolean => { |
| if (row.Status === undefined) { |
| |
| |
| |
| |
| |
| return true; |
| } |
| |
| const status = (row.Status as ICellValue) |
| .val as JobStatus; |
| |
| |
| return status === JobStatus.Running; |
| }, |
| } as ICellValue, |
| "Job ID": r.id, |
| Procs: r.numProcessors?.toString() as string, |
| Status: r.status.toString(), |
| Progress: (100 * r.progress).toFixed(1) + "%", |
| Start: { sortVal: r.startTime, val: formatTimestamp(r.startTime) }, |
| End: { sortVal: r.endTime, val: formatTimestamp(r.endTime) }, |
| }; |
| }); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| return { |
| headers: headers[tableIdx], |
| rows: rows, |
| } as ITableData; |
| } |
| |
| |
| |
| |
| cancelAll() { |
| |
| for (const jobStatusInfo of this.jobStatusInfos[0][1]) { |
| cancelInQueueStore(jobStatusInfo.id); |
| } |
| } |
| |
| |
| |
| |
| |
| |
| cancelJob(row: { [key: string]: CellValue }) { |
| |
| const id = (row["Job ID"] as ICellValue).val as string; |
| |
| cancelInQueueStore(id); |
| } |
| |
| |
| |
| |
| mounted() { |
| |
| setInterval(() => { |
| const queueStore = getQueueStore(); |
| this.jobStatusInfos[0][1] = queueStore.running; |
| this.jobStatusInfos[1][1] = queueStore.done; |
| }, 1000); |
| } |
| } |
| </script> |
| |
| <style scoped lang="scss"> |
| .cancel-pending-btn { |
| position: absolute; |
| right: 0; |
| top: 18px; |
| font-weight: 400; |
| cursor: pointer !important; |
| } |
| </style> |
| |