Skip to content

Commit bf453fb

Browse files
committed
basic stuff
0 parents  commit bf453fb

16 files changed

+14427
-0
lines changed

.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
# local env files
6+
.env.local
7+
.env.*.local
8+
9+
# Log files
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
14+
# Editor directories and files
15+
.idea
16+
.vscode
17+
*.suo
18+
*.ntvs*
19+
*.njsproj
20+
*.sln
21+
*.sw*

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# admin
2+
3+
## Project setup
4+
```
5+
npm install
6+
```
7+
8+
### Compiles and hot-reloads for development
9+
```
10+
npm run serve
11+
```
12+
13+
### Compiles and minifies for production
14+
```
15+
npm run build
16+
```
17+
18+
### Run your tests
19+
```
20+
npm run test
21+
```
22+
23+
### Lints and fixes files
24+
```
25+
npm run lint
26+
```

babel.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/app'
4+
]
5+
}

package-lock.json

+13,783
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "admin",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"serve": "vue-cli-service serve",
7+
"build": "vue-cli-service build",
8+
"lint": "vue-cli-service lint"
9+
},
10+
"dependencies": {
11+
"axios": "^0.18.0",
12+
"bootstrap-vue": "^2.0.0-rc.11",
13+
"vue": "^2.5.17",
14+
"vue-good-table": "^2.14.6",
15+
"vue-router": "^3.0.1",
16+
"vue-stash": "^2.0.1-beta"
17+
},
18+
"devDependencies": {
19+
"@vue/cli-plugin-babel": "^3.0.4",
20+
"@vue/cli-plugin-eslint": "^3.0.4",
21+
"@vue/cli-service": "^3.0.4",
22+
"@vue/eslint-config-standard": "^3.0.4",
23+
"node-sass": "^4.9.0",
24+
"sass-loader": "^7.0.1",
25+
"tachyons": "^4.11.1",
26+
"vue-template-compiler": "^2.5.17"
27+
},
28+
"eslintConfig": {
29+
"root": true,
30+
"env": {
31+
"node": true
32+
},
33+
"extends": [
34+
"plugin:vue/essential",
35+
"@vue/standard"
36+
],
37+
"rules": {},
38+
"parserOptions": {
39+
"parser": "babel-eslint"
40+
}
41+
},
42+
"postcss": {
43+
"plugins": {
44+
"autoprefixer": {}
45+
}
46+
},
47+
"browserslist": [
48+
"> 1%",
49+
"last 2 versions",
50+
"not ie <= 8"
51+
]
52+
}

public/favicon.ico

1.12 KB
Binary file not shown.

public/index.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
8+
<title>admin</title>
9+
</head>
10+
<body>
11+
<noscript>
12+
<strong>We're sorry but admin doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
13+
</noscript>
14+
<div id="app"></div>
15+
<!-- built files will be auto injected -->
16+
</body>
17+
</html>

src/App.vue

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<div>
3+
<b-navbar variant="info" type="dark" toggleable="md">
4+
<router-link to="/"><b-navbar-brand>CTF Admin</b-navbar-brand></router-link>
5+
6+
<b-navbar-nav>
7+
<b-nav-item><router-link to="/users">Users</router-link></b-nav-item>
8+
<b-nav-item><router-link to="/teams">Teams</router-link></b-nav-item>
9+
<b-nav-item><router-link to="/challenges">Challenges</router-link></b-nav-item>
10+
</b-navbar-nav>
11+
12+
<b-navbar-nav class="ml-auto">
13+
<b-nav-item>Competitions</b-nav-item>
14+
<b-nav-item-dropdown :text="$store.competition ? $store.competition.name : ''" right>
15+
<b-dropdown-item @click="updateCompetition(competition); $refs.view.load()" v-for="(competition, index) in $store.competitions" :key="index">{{ competition.name }}</b-dropdown-item>
16+
</b-nav-item-dropdown>
17+
<b-nav-item>Log Out</b-nav-item>
18+
</b-navbar-nav>
19+
</b-navbar>
20+
<router-view class="m-4" ref="view"></router-view>
21+
</div>
22+
</template>
23+
24+
<style lang="scss">
25+
@import '../node_modules/bootstrap/dist/css/bootstrap.css';
26+
@import '../node_modules/bootstrap-vue/dist/bootstrap-vue.css';
27+
@import '../node_modules/vue-good-table/dist/vue-good-table.css';
28+
29+
a, a:hover {
30+
color: inherit;
31+
text-decoration: inherit;
32+
}
33+
</style>

src/config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
API_URL: process.env.VUE_APP_API_URL || '/api'
3+
}

src/main.js

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import Vue from 'vue'
2+
import App from './App.vue'
3+
import router from './router'
4+
import BootstrapVue from 'bootstrap-vue'
5+
import VueStash from 'vue-stash'
6+
import axios from 'axios'
7+
import config from './config'
8+
9+
Vue.use(VueStash)
10+
11+
Vue.mixin({
12+
methods: {
13+
markdown (text) {
14+
return marked(text)
15+
},
16+
post (route, data, competition) {
17+
return axios.post(config.API_URL + (competition === false ? '' : ('/competitions/' + this.$store.competition.id)) + route, data, { headers: { Authorization: 'Token ' + localStorage['token'] } })
18+
},
19+
get (route, competition) {
20+
return axios.get(config.API_URL + (competition === false ? '' : ('/competitions/' + this.$store.competition.id)) + route, { headers: { Authorization: 'Token ' + localStorage['token'] } })
21+
},
22+
patch (route, data, competition) {
23+
return axios.patch(config.API_URL + (competition === false ? '' : ('/competitions/' + this.$store.competition.id)) + route, data, { headers: { Authorization: 'Token ' + localStorage['token'] } })
24+
},
25+
put (route, data, competition) {
26+
return axios.put(config.API_URL + (competition === false ? '' : ('/competitions/' + this.$store.competition.id)) + route, data, { headers: { Authorization: 'Token ' + localStorage['token'] } })
27+
},
28+
deleteRequest (route, competition) {
29+
return axios.delete(config.API_URL + (competition === false ? '' : ('/competitions/' + this.$store.competition.id)) + route, { headers: { Authorization: 'Token ' + localStorage['token'] } })
30+
},
31+
logout () {
32+
localStorage.removeItem('token')
33+
this.reload()
34+
this.alert('Success!', 'You have been logged out.', 'success')
35+
},
36+
updateCompetition (competition) {
37+
this.$store.competition = competition
38+
localStorage.competition = competition.id
39+
this.reload().then(function () { this.routerKey++ }.bind(this))
40+
},
41+
reload () {
42+
var emptyUser = {
43+
id: null,
44+
username: null,
45+
eligible: null,
46+
created: null,
47+
team: {
48+
id: null,
49+
name: null,
50+
members: [],
51+
eligible: null,
52+
affiliation: null,
53+
created: null,
54+
score: null,
55+
solves: []
56+
}
57+
}
58+
return this.get('/competitions', false).then(function (res) {
59+
this.$store.competitions = res.data
60+
}.bind(this)).then(() => this.get('/self', false)).then(function (res) {
61+
this.$store.user = res.data.user
62+
this.$store.competition = localStorage.competition && this.$store.competitions.filter(c => c.id === parseInt(localStorage.competition))[0] ? this.$store.competitions.filter(c => c.id === parseInt(localStorage.competition))[0] : this.$store.competitions[0]
63+
this.$store.competitionLoaded = true
64+
this.$store.loaded = true
65+
}.bind(this))
66+
}
67+
}
68+
})
69+
70+
71+
Vue.use(BootstrapVue);
72+
73+
Vue.config.productionTip = false
74+
75+
new Vue({
76+
router,
77+
components: { App },
78+
template: '<App/>',
79+
data: {
80+
store: {
81+
user: {
82+
id: null,
83+
username: null,
84+
eligible: null,
85+
created: null,
86+
team: {
87+
id: null,
88+
name: null,
89+
members: [],
90+
eligible: null,
91+
affiliation: null,
92+
created: null,
93+
score: null,
94+
solves: []
95+
},
96+
theme: '',
97+
},
98+
competition: null,
99+
competitions: [],
100+
loaded: false,
101+
competitionLoaded: false,
102+
alerts: []
103+
},
104+
refreshKey: 1
105+
},
106+
mounted () {
107+
this.reload()
108+
},
109+
render: h => h(App)
110+
}).$mount('#app')

src/router.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import Vue from 'vue'
2+
import Router from 'vue-router'
3+
import Home from './views/Home.vue'
4+
import Login from './views/Login.vue'
5+
import Users from './views/Users.vue'
6+
import Teams from './views/Teams.vue'
7+
import Challenges from './views/Challenges.vue'
8+
9+
Vue.use(Router)
10+
11+
export default new Router({
12+
mode: 'history',
13+
base: process.env.BASE_URL,
14+
routes: [
15+
{
16+
path: '/',
17+
name: 'home',
18+
component: Home
19+
},
20+
{
21+
path: '/login',
22+
name: 'login',
23+
component: Login
24+
},
25+
{
26+
path: '/users',
27+
name: 'users',
28+
component: Users
29+
},
30+
{
31+
path: '/teams',
32+
name: 'teams',
33+
component: Teams
34+
},
35+
{
36+
path: '/challenges',
37+
name: 'challenges',
38+
component: Challenges
39+
}
40+
]
41+
})

0 commit comments

Comments
 (0)