|
| 1 | +<!-- |
| 2 | +Copyright (C) NIWA & British Crown (Met Office) & Contributors. |
| 3 | +
|
| 4 | +This program is free software: you can redistribute it and/or modify |
| 5 | +it under the terms of the GNU General Public License as published by |
| 6 | +the Free Software Foundation, either version 3 of the License, or |
| 7 | +(at your option) any later version. |
| 8 | +
|
| 9 | +This program is distributed in the hope that it will be useful, |
| 10 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +GNU General Public License for more details. |
| 13 | +
|
| 14 | +You should have received a copy of the GNU General Public License |
| 15 | +along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | +--> |
| 17 | + |
| 18 | +<template> |
| 19 | + <v-row |
| 20 | + no-gutters |
| 21 | + class="flex-grow-1 position-relative" |
| 22 | + > |
| 23 | + <v-col |
| 24 | + cols="12" |
| 25 | + class="mh-100 position-relative" |
| 26 | + > |
| 27 | + <v-container |
| 28 | + fluid |
| 29 | + class="pa-0" |
| 30 | + > |
| 31 | + <v-data-table |
| 32 | + :headers="shownHeaders" |
| 33 | + :items="tasks" |
| 34 | + :sort-by.sync="sortBy" |
| 35 | + dense |
| 36 | + :footer-props="{ |
| 37 | + itemsPerPageOptions: [10, 20, 50, 100, 200, -1], |
| 38 | + showFirstLastPage: true |
| 39 | + }" |
| 40 | + :options="{ itemsPerPage: 50 }" |
| 41 | + > |
| 42 | + <!-- Use custom format for values in columns that have a specified formatter: --> |
| 43 | + <!-- Used to make durations human readable --> |
| 44 | + <!-- Durations of 0 will be undefined unless allowZeros is true --> |
| 45 | + <template |
| 46 | + v-for="header in shownHeaders.filter(header => header.hasOwnProperty('formatter'))" |
| 47 | + v-slot:[`item.${header.value}`]="{ value }" |
| 48 | + > |
| 49 | + {{ header.formatter(value, header.allowZeros) }} |
| 50 | + </template> |
| 51 | + </v-data-table> |
| 52 | + </v-container> |
| 53 | + </v-col> |
| 54 | + </v-row> |
| 55 | +</template> |
| 56 | + |
| 57 | +<script> |
| 58 | +import { formatDuration } from '@/utils/tasks' |
| 59 | +
|
| 60 | +export default { |
| 61 | + name: 'AnalysisTableComponent', |
| 62 | +
|
| 63 | + props: { |
| 64 | + tasks: { |
| 65 | + type: Array, |
| 66 | + required: true |
| 67 | + }, |
| 68 | + timingOption: { |
| 69 | + type: String, |
| 70 | + required: true |
| 71 | + } |
| 72 | + }, |
| 73 | +
|
| 74 | + data () { |
| 75 | + return { |
| 76 | + sortBy: 'name', |
| 77 | + headers: [ |
| 78 | + { |
| 79 | + text: 'Task', |
| 80 | + value: 'name' |
| 81 | + }, |
| 82 | + { |
| 83 | + text: 'Platform', |
| 84 | + value: 'platform' |
| 85 | + }, |
| 86 | + { |
| 87 | + text: 'Count', |
| 88 | + value: 'count' |
| 89 | + } |
| 90 | + ] |
| 91 | + } |
| 92 | + }, |
| 93 | +
|
| 94 | + computed: { |
| 95 | + shownHeaders () { |
| 96 | + let times |
| 97 | + if (this.timingOption === 'totalTimes') { |
| 98 | + times = 'Total' |
| 99 | + } else if (this.timingOption === 'runTimes') { |
| 100 | + times = 'Run' |
| 101 | + } else if (this.timingOption === 'queueTimes') { |
| 102 | + times = 'Queue' |
| 103 | + } else { |
| 104 | + return this.headers |
| 105 | + } |
| 106 | + const timingHeaders = [ |
| 107 | + { |
| 108 | + text: `Mean T-${times}`, |
| 109 | + value: `mean${times}Time`, |
| 110 | + formatter: formatDuration, |
| 111 | + allowZeros: false |
| 112 | + }, |
| 113 | + { |
| 114 | + text: `Std Dev T-${times}`, |
| 115 | + value: `stdDev${times}Time`, |
| 116 | + formatter: formatDuration, |
| 117 | + allowZeros: true |
| 118 | + }, |
| 119 | + { |
| 120 | + text: `Min T-${times}`, |
| 121 | + value: `min${times}Time`, |
| 122 | + formatter: formatDuration, |
| 123 | + allowZeros: false |
| 124 | + }, |
| 125 | + { |
| 126 | + text: `Q1 T-${times}`, |
| 127 | + value: `${times.toLowerCase()}Quartiles[0]`, |
| 128 | + formatter: formatDuration, |
| 129 | + allowZeros: false |
| 130 | + }, |
| 131 | + { |
| 132 | + text: `Median T-${times}`, |
| 133 | + value: `${times.toLowerCase()}Quartiles[1]`, |
| 134 | + formatter: formatDuration, |
| 135 | + allowZeros: false |
| 136 | + }, |
| 137 | + { |
| 138 | + text: `Q3 T-${times}`, |
| 139 | + value: `${times.toLowerCase()}Quartiles[2]`, |
| 140 | + formatter: formatDuration, |
| 141 | + allowZeros: false |
| 142 | + }, |
| 143 | + { |
| 144 | + text: `Max T-${times}`, |
| 145 | + value: `max${times}Time`, |
| 146 | + formatter: formatDuration, |
| 147 | + allowZeros: false |
| 148 | + } |
| 149 | + ] |
| 150 | + return this.headers.concat(timingHeaders) |
| 151 | + } |
| 152 | + } |
| 153 | +} |
| 154 | +</script> |
0 commit comments