|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <el-card class="item" v-if="alive"> |
| 4 | + <AjaxTable |
| 5 | + :ajax_url="ajax_url" |
| 6 | + :columns="columns" |
| 7 | + :limit="limit" |
| 8 | + :total="data_count" |
| 9 | + :process="process" |
| 10 | + :default_sort="{prop: 'id', order: 'descending'}" |
| 11 | + pagination_class="status-list-pagination" |
| 12 | + /> |
| 13 | + </el-card> |
| 14 | + </div> |
| 15 | +</template> |
| 16 | + |
| 17 | +<script> |
| 18 | +import sfconfig from './../../sfconfig'; |
| 19 | +import apiurl from './../../apiurl'; |
| 20 | +import AjaxTable from './../lib/AjaxTable.vue'; |
| 21 | +import ProblemTitleLink from './../problem/ProblemTitleLink.vue'; |
| 22 | +import UserNameLink from './../user/UserNameLink.vue'; |
| 23 | +
|
| 24 | +export default { |
| 25 | + name: 'StatusList', |
| 26 | + data() { |
| 27 | + return { |
| 28 | + alive: true, |
| 29 | + ajax_url: apiurl('/status/list'), |
| 30 | + limit: 30, |
| 31 | + columns: [{ |
| 32 | + name: 'id', |
| 33 | + label: 'Run ID', |
| 34 | + width: '120', |
| 35 | + align: 'center', |
| 36 | + sortable: true |
| 37 | + }, { |
| 38 | + name: 'problem', |
| 39 | + label: 'Problem', |
| 40 | + align: 'center', |
| 41 | + sortable: false |
| 42 | + }, { |
| 43 | + name: 'state', |
| 44 | + label: 'Status', |
| 45 | + align: 'center', |
| 46 | + sortable: false |
| 47 | + }, { |
| 48 | + name: 'score', |
| 49 | + label: 'Score', |
| 50 | + width: '120', |
| 51 | + align: 'center', |
| 52 | + sortable: true |
| 53 | + }, { |
| 54 | + name: 'time', |
| 55 | + label: 'Time', |
| 56 | + width: '120', |
| 57 | + align: 'center', |
| 58 | + sortable: false |
| 59 | + }, { |
| 60 | + name: 'memory', |
| 61 | + label: 'Memory', |
| 62 | + width: '120', |
| 63 | + align: 'center', |
| 64 | + sortable: false |
| 65 | + }, { |
| 66 | + name: 'lang', |
| 67 | + label: 'Language', |
| 68 | + width: '120', |
| 69 | + align: 'center', |
| 70 | + sortable: false |
| 71 | + }, { |
| 72 | + name: 'owner', |
| 73 | + label: 'Author', |
| 74 | + width: '120', |
| 75 | + align: 'center', |
| 76 | + sortable: false |
| 77 | + }], |
| 78 | + data_count: 10 |
| 79 | + }; |
| 80 | + }, |
| 81 | + methods: { |
| 82 | + get_list_length() { |
| 83 | + this.$axios |
| 84 | + .get(apiurl('/status/list/count')) |
| 85 | + .then(response => { |
| 86 | + let data = response.data; |
| 87 | + this.data_count = data.res; |
| 88 | + }) |
| 89 | + .catch(err => { |
| 90 | + this.$SegmentMessage.error(this, '[Status List] Get List Length Failed'); |
| 91 | + console.log(err); |
| 92 | + }); |
| 93 | + }, |
| 94 | + process(x) { |
| 95 | + let color = ''; |
| 96 | + if (x.score === 100) { |
| 97 | + color += 'color-success'; |
| 98 | + } else if (x.score < 100 && x.score > 0) { |
| 99 | + color += 'color-warning'; |
| 100 | + } else if(x.score == 0) { |
| 101 | + color += 'color-danger'; |
| 102 | + } else { |
| 103 | + color += 'color-regular-text'; |
| 104 | + } |
| 105 | + x.problem = (<ProblemTitleLink pid={x.problem}></ProblemTitleLink>); |
| 106 | + x.score = (<div class={color + ' text-extra-bold'}>{x.score >= 0 ? x.score : '-'}</div>); |
| 107 | + x.lang = sfconfig.langTable[x.lang].label; |
| 108 | + let stateTable = sfconfig.stateTable.filter(id => { |
| 109 | + return id.value === String(x.state); |
| 110 | + })[0]; |
| 111 | + x.state = (<div style={'color: ' + stateTable.color + ';'}>{stateTable.label}</div>); |
| 112 | + x.time = x.time + ' ms'; |
| 113 | + x.memory = x.memory + ' KB'; |
| 114 | + x.owner = (<UserNameLink userid={x.owner}></UserNameLink>); |
| 115 | + return x; |
| 116 | + }, |
| 117 | + }, |
| 118 | + components: { |
| 119 | + AjaxTable |
| 120 | + }, |
| 121 | + mounted() { |
| 122 | + this.get_list_length(); |
| 123 | + } |
| 124 | +}; |
| 125 | +</script> |
| 126 | + |
| 127 | +<style scoped> |
| 128 | +.item { |
| 129 | + margin-top: 20px; |
| 130 | +} |
| 131 | +</style> |
| 132 | + |
0 commit comments