|
1 | 1 | import Component from '@ember/component';
|
2 | 2 | import { computed } from '@ember/object';
|
| 3 | +import { jsonToTable } from '../../../util/json-to-table'; |
| 4 | + |
| 5 | +export default Component.extend({ |
3 | 6 |
|
4 |
| -export default class SubmissionResult extends Component { |
5 | 7 | didRender() {
|
6 |
| - this.element.scrollIntoView({ behavior: "smooth", block: "end" }) |
7 |
| - } |
| 8 | + this._super(...arguments); |
| 9 | + this.element.scrollIntoView({ behavior: "smooth", block: "end" }); |
| 10 | + }, |
8 | 11 |
|
9 |
| - @computed('judgeResult') |
10 |
| - get isRunning() { |
11 |
| - return !this.judgeResult |
12 |
| - } |
| 12 | + isRunning: computed('judgeResult', function() { |
| 13 | + return !this.get('judgeResult'); |
| 14 | + }), |
13 | 15 |
|
14 |
| - @computed('judgeResult') |
15 |
| - get isErrored() { |
16 |
| - return !!this.judgeResult.stderr |
17 |
| - } |
| 16 | + isErrored: computed('judgeResult', function() { |
| 17 | + return !!this.get('judgeResult')?.stderr; |
| 18 | + }), |
18 | 19 |
|
19 |
| - @computed('judgeResult') |
20 |
| - get isSubmission() { |
21 |
| - return !!(this.judgeResult.testcases) |
22 |
| - } |
| 20 | + isSubmission: computed('judgeResult', function() { |
| 21 | + return !!this.get('judgeResult')?.testcases; |
| 22 | + }), |
23 | 23 |
|
24 |
| - @computed('isErrored') |
25 |
| - get errorPayload() { |
26 |
| - if (this.isErrored) { |
27 |
| - return window.atob(this.judgeResult.stderr || this.judgeResult.stdout) |
| 24 | + errorPayload: computed('isErrored', function() { |
| 25 | + if (this.get('isErrored')) { |
| 26 | + return window.atob(this.get('judgeResult')?.stderr || this.get('judgeResult')?.stdout); |
28 | 27 | }
|
29 |
| - } |
| 28 | + }), |
| 29 | + |
| 30 | + output: computed('isSubmission', function() { |
| 31 | + if (!this.get('isSubmission')) { |
| 32 | + const output = window.atob(this.get('judgeResult')?.stdout); |
30 | 33 |
|
31 |
| - @computed('isSubmission') |
32 |
| - get output() { |
33 |
| - if (!this.isSubmission) { |
34 |
| - return window.atob(this.judgeResult.stdout) |
| 34 | + return output; |
35 | 35 | }
|
36 |
| - } |
| 36 | + }), |
37 | 37 |
|
38 |
| - @computed('isSubmission') |
39 |
| - get testcasesPayload() { |
40 |
| - if (this.isSubmission) { |
41 |
| - return this.judgeResult.testcases |
| 38 | + testcasesPayload: computed('isSubmission', function() { |
| 39 | + if (this.get('isSubmission')) { |
| 40 | + return this.get('judgeResult')?.testcases; |
42 | 41 | }
|
| 42 | + }), |
| 43 | + |
| 44 | + jsonToTable(data) { |
| 45 | + const table = jsonToTable(data); |
| 46 | + return table; |
43 | 47 | }
|
44 |
| -} |
| 48 | +}); |
0 commit comments