Skip to content

Commit

Permalink
problem添加快捷编辑;
Browse files Browse the repository at this point in the history
修复development mode问题
  • Loading branch information
zema1 committed Nov 17, 2017
1 parent 9a72d11 commit 6b238b3
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 34 deletions.
4 changes: 4 additions & 0 deletions build/webpack.dll.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const webpack = require('webpack');
const path = require('path');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const config = require('../config')

const vendors = [
'vue/dist/vue.esm.js',
Expand All @@ -23,6 +24,9 @@ module.exports = {
library: '[name]_dll',
},
plugins: [
new webpack.DefinePlugin({
'process.env': config.build.env
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /zh-cn/),
new UglifyJSPlugin({
Expand Down
4 changes: 4 additions & 0 deletions deploy/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ http {

proxy_pass http://oj-backend:8080;
}
location /admin {
root /OJ_FE/dist/admin;
try_files $uri $uri/ /index.html;
}
location / {
root /OJ_FE/dist;
try_files $uri $uri/ /index.html;
Expand Down
12 changes: 0 additions & 12 deletions src/pages/admin/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@
</script>

<style lang="less">
[class^="el-icon-fa"], [class*=" el-icon-fa"] {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome !important;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
@import url("../../../node_modules/font-awesome/less/font-awesome");
@fa-css-prefix: el-icon-fa;
body {
margin: 0;
padding: 0;
Expand Down
1 change: 1 addition & 0 deletions src/pages/admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Panel from './components/Panel.vue'
import IconBtn from './components/btn/IconBtn.vue'
import Save from './components/btn/Save.vue'
import Cancel from './components/btn/Cancel.vue'
import './style.less'

// register global utility filters.
Object.keys(filters).forEach(key => {
Expand Down
11 changes: 11 additions & 0 deletions src/pages/admin/style.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[class^="el-icon-fa"], [class*=" el-icon-fa"] {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome !important;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

@import url("../../../node_modules/font-awesome/less/font-awesome");
@fa-css-prefix: el-icon-fa;
48 changes: 34 additions & 14 deletions src/pages/admin/views/problem/ProblemList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
element-loading-text="loading"
ref="table"
:data="problemList"
@cell-dblclick="handleDblclick"
style="width: 100%">
<el-table-column
width="100"
Expand All @@ -21,12 +22,19 @@
</el-table-column>
<el-table-column
width="150"
prop="_id"
label="Display ID">
<template slot-scope="{row}">
<span v-show="!row.isEditing">{{row._id}}</span>
<el-input v-show="row.isEditing" v-model="row._id" @keyup.enter.native="handleInlineEdit(row)"></el-input>
</template>
</el-table-column>
<el-table-column
prop="title"
label="Title">
<template slot-scope="{row}">
<span v-show="!row.isEditing">{{row.title}}</span>
<el-input v-show="row.isEditing" v-model="row.title" @keyup.enter.native="handleInlineEdit(row)"></el-input>
</template>
</el-table-column>
<el-table-column
prop="created_by.username"
Expand All @@ -48,7 +56,7 @@
<el-switch v-model="scope.row.visible"
on-text=""
off-text=""
@change="handleVisibleSwitch(scope.row)">
@change="handleInlineEdit(scope.row)">
</el-switch>
</template>
</el-table-column>
Expand Down Expand Up @@ -106,6 +114,9 @@
this.getProblemList(this.currentPage)
},
methods: {
handleDblclick (row) {
row.isEditing = true
},
goEdit (problemId) {
if (this.routeName === 'problem-list') {
this.$router.push({name: 'edit-problem', params: {problemId}})
Expand All @@ -131,6 +142,9 @@
api[funcName]((page - 1) * this.pageSize, this.pageSize, this.keyword, this.contestId).then(res => {
this.loading = false
this.total = res.data.data.total
for (let problem of res.data.data.results) {
problem.isEditing = false
}
this.problemList = res.data.data.results
}, res => {
this.loading = false
Expand All @@ -142,18 +156,24 @@
}, () => {
})
},
handleVisibleSwitch (row) {
let data = Object.assign({}, row)
let funcName = ''
if (this.contestId) {
data.contest_id = this.contestId
funcName = 'editContestProblem'
} else {
funcName = 'editProblem'
}
api[funcName](data).then(res => {
this.currentChange(this.currentPage)
}).catch()
handleInlineEdit (row) {
this.$confirm('Sure to update the problem?', '', {
type: 'warning'
}).then(() => {
let data = Object.assign({}, row)
let funcName = ''
if (this.contestId) {
data.contest_id = this.contestId
funcName = 'editContestProblem'
} else {
funcName = 'editProblem'
}
api[funcName](data).then(res => {
this.getProblemList(this.currentPage)
}).catch()
}).catch(() => {
this.getProblemList(this.currentPage)
})
},
downloadTestCase (problemID) {
let url = '/admin/test_case?problem_id=' + problemID
Expand Down
6 changes: 3 additions & 3 deletions src/pages/oj/views/problem/chartData.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const pieColorMap = {
'AC': {color: '#19be6b'},
'WA': {color: '#ed3f14'},
'TLE': {color: '#495060'},
'MLE': {color: '#80848f'},
'TLE': {color: '#ff9300'},
'MLE': {color: '#f7de00'},
'RE': {color: '#ff6104'},
'CE': {color: '#ff9900'},
'CE': {color: '#80848f'},
'PAC': {color: '#2d8cf0'}
}

Expand Down
9 changes: 6 additions & 3 deletions src/pages/oj/views/submission/SubmissionDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Alert :type="status.type" showIcon>
<span class="title">{{status.statusName}}</span>
<div slot="desc" class="content">
<template v-if="submission.result == -2">
<template v-if="isCE">
<pre>{{submission.statistic_info.err_info}}</pre>
</template>
<template v-else>
Expand All @@ -18,7 +18,7 @@
</Col>

<!--后台返info就显示出来, 权限控制放后台 -->
<Col v-if="submission.info && submission.result != -2" :span="20">
<Col v-if="submission.info && !isCE" :span="20">
<Alert type="warning">
<div class="admin-info-content">
<Icon type="information-circled" color="#f90"></Icon>
Expand Down Expand Up @@ -117,7 +117,7 @@
getSubmission () {
api.getSubmission(this.$route.params.id).then(res => {
let data = res.data.data
if (data.info && !data.info.data[0].score) {
if (data.info && data.info.data && !data.info.data[0].score) {
this.columns.splice(this.columns.length - 1, 1)
}
this.submission = data
Expand All @@ -139,6 +139,9 @@
statusName: JUDGE_STATUS[this.submission.result].name,
color: JUDGE_STATUS[this.submission.result].color
}
},
isCE () {
return this.submission.result === -2
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/pages/oj/views/submission/SubmissionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@
this.contestID = this.$route.params.contestID
let query = this.$route.query
this.problemID = query.problemID
this.myself = query.myself === '1'
this.result = query.result || ''
this.formFilter.myself = query.myself === '1'
this.formFilter.result = query.result || ''
this.formFilter.username = query.username || ''
this.page = parseInt(query.page) || 1
this.routeName = this.$route.name
this.getSubmissions()
Expand Down

0 comments on commit 6b238b3

Please sign in to comment.