Skip to content

Commit 0624c17

Browse files
authored
Merge pull request #93 from segment-oj/add-status-list-fisher
Add status list
2 parents 8c954fd + bcf6391 commit 0624c17

File tree

9 files changed

+307
-5
lines changed

9 files changed

+307
-5
lines changed

src/assets/css/basic.css

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,24 @@ h3::before {
194194
.problem-list-pagination {
195195
border: 1px solid #ebeef5;
196196
background: #ffffff;
197-
margin-left: -20px;
197+
margin-left: -21px;
198198
padding: 10px;
199199
height: 36px;
200200
max-width: 100vw;
201-
width: 827px;
201+
width: 828px;
202+
text-align: center;
203+
bottom: 0;
204+
position: fixed;
205+
}
206+
207+
.status-list-pagination {
208+
border: 1px solid #ebeef5;
209+
background: #ffffff;
210+
margin-left: -21px;
211+
padding: 10px;
212+
height: 36px;
213+
max-width: 100vw;
214+
width: 1118px;
202215
text-align: center;
203216
bottom: 0;
204217
position: fixed;

src/assets/css/theme.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
}
88

99
.color-warning {
10-
color: #e6a23c;
10+
color: rgb(247, 186, 42);
1111
}
1212

1313
.color-info {

src/components/page/navbar.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
<i class="el-icon-s-order" />
2323
<div class="lable"> Problem List</div>
2424
</el-menu-item>
25+
<el-menu-item index="/status/list" class="webkit-box">
26+
<i class="el-icon-s-marketing" />
27+
<div class="lable"> Status List</div>
28+
</el-menu-item>
2529
<el-submenu index="1">
2630
<template slot="title">
2731
<i class="el-icon-s-help" />
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<template>
2+
<div>
3+
<router-link :to="( '/problem/' + String(this.pid))" class="color-regular-text text-normal">{{this.title}} </router-link>
4+
</div>
5+
</template>
6+
7+
<script>
8+
import apiurl from './../../apiurl';
9+
10+
export default {
11+
name: 'ProblemTitleLink',
12+
props: {
13+
pid: {
14+
type: Number,
15+
required: true
16+
}
17+
},
18+
data() {
19+
return {
20+
title: new String()
21+
};
22+
},
23+
methods: {
24+
loadproblem(id) {
25+
this.$axios
26+
.get(apiurl('/problem/' + String(id)))
27+
.then(res => {
28+
this.title = '#' + String(id) + '. ' + res.data.res.title;
29+
})
30+
.catch(() => {
31+
this.title = '#' + String(id);
32+
});
33+
}
34+
},
35+
mounted() {
36+
this.title = '#' + this.pid;
37+
this.loadproblem(this.pid);
38+
}
39+
};
40+
</script>

src/components/problem/list.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export default {
118118
},
119119
},
120120
methods: {
121-
get_list_lenth() {
121+
get_list_length() {
122122
this.$axios
123123
.get(apiurl('/problem/list/count'))
124124
.then(response => {
@@ -159,6 +159,7 @@ export default {
159159
} else {
160160
color += 'color-regular-text';
161161
}
162+
x.pid = (<div class={color}>{x.pid}</div>);
162163
if (!x.enabled) {
163164
x.title = (
164165
<div>
@@ -182,7 +183,7 @@ export default {
182183
CreateProblem
183184
},
184185
mounted() {
185-
this.get_list_lenth();
186+
this.get_list_length();
186187
this.get_column();
187188
}
188189
};

src/components/status/list.vue

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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+

src/components/user/UserNameLink.vue

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<template>
2+
<div>
3+
<router-link :to="( '/account/' + String(this.userid))" class="color-regular-text text-normal">{{this.username}} </router-link>
4+
</div>
5+
</template>
6+
7+
<script>
8+
import apiurl from './../../apiurl';
9+
10+
export default {
11+
name: 'UserNameLink',
12+
props: {
13+
userid: {
14+
type: Number,
15+
required: true
16+
}
17+
},
18+
data() {
19+
return {
20+
username: new String()
21+
};
22+
},
23+
methods: {
24+
loadusername(id) {
25+
this.$axios
26+
.get(apiurl('/account/' + String(id)))
27+
.then(res => {
28+
this.username = res.data.res.username;
29+
})
30+
.catch(() => {
31+
this.username = id;
32+
});
33+
}
34+
},
35+
mounted() {
36+
this.username = this.userid;
37+
this.loadusername(this.userid);
38+
}
39+
};
40+
</script>

src/router.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ let router = new Router({
2828
}, {
2929
path: '/problem/:id/submit',
3030
component: () => import('./components/problem/submit.vue')
31+
}, {
32+
path: '/status/list',
33+
component: () => import('./components/status/list.vue')
3134
}, {
3235
path: '/app/editor',
3336
component: () => import('./components/app/editor.vue')

src/sfconfig.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,74 @@ export default {
178178
value: '4',
179179
theme: 'zenburn'
180180
}],
181+
stateTable: [{
182+
value: '0',
183+
label: 'Waiting',
184+
color: '#909399'
185+
}, {
186+
value: '1',
187+
label: 'Compiling',
188+
color: '#f7ba2a'
189+
}, {
190+
value: '2',
191+
label: 'Judging',
192+
color: '#409eff'
193+
}, {
194+
value: '3',
195+
label: 'Waiting',
196+
color: '#909399'
197+
}, {
198+
value: '10',
199+
label: 'Accepted',
200+
color: '#67C23A'
201+
}, {
202+
value: '11',
203+
label: 'Partly Correct',
204+
color: '#F7BA2A'
205+
}, {
206+
value: '12',
207+
label: 'Time Limit Exceed',
208+
color: '#F7BA2A'
209+
}, {
210+
value: '13',
211+
label: 'Memory Limit Exceeded',
212+
color: '#324057'
213+
}, {
214+
value: '14',
215+
label: 'Runtime Error',
216+
color: '#324057'
217+
}, {
218+
value: '15',
219+
label: 'Wrong Answer',
220+
color: '#F56C6C'
221+
}, {
222+
value: '16',
223+
label: 'Unknown Error',
224+
color: '#324057'
225+
}, {
226+
value: '17',
227+
label: 'Compile Error',
228+
color: '#F7BA2A'
229+
}, {
230+
value: '18',
231+
label: 'Output Limit Exceeded',
232+
color: '#F56C6C'
233+
}, {
234+
value: '20',
235+
label: 'System Error',
236+
color: '#FF4949'
237+
}, {
238+
value: '21',
239+
label: 'Judger Configure Error',
240+
color: '#FF4949'
241+
}, {
242+
value: '22',
243+
label: 'Judger Resources Limit Exceeded',
244+
color: '#FF4949'
245+
}, {
246+
value: '23',
247+
label: 'Unsupported Language',
248+
color: '#FF4949'
249+
}],
181250
captchaKeyMax: 2000000000
182251
};

0 commit comments

Comments
 (0)