Skip to content

Commit 021ce85

Browse files
committed
Migrate to Vue.js
1 parent 16957e9 commit 021ce85

20 files changed

+266
-89
lines changed

Diff for: .browserslistrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
> 1%
2+
last 2 versions

Diff for: .eslintrc.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true
5+
},
6+
extends: ["plugin:vue/essential", "@vue/prettier"],
7+
rules: {
8+
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
9+
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off"
10+
},
11+
parserOptions: {
12+
parser: "babel-eslint"
13+
}
14+
};

Diff for: .gitignore

+10-1
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,13 @@ typings/
7979

8080
# Config files
8181
credential.js
82-
secret.js
82+
secret.js
83+
84+
# Node modules
85+
node_modules/
86+
87+
# Build Files
88+
dist/
89+
90+
# Config files
91+
.prettierrc.js

Diff for: babel.config.js

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

Diff for: config/credentials.js

-3
This file was deleted.

Diff for: controller/details.js

Whitespace-only changes.

Diff for: jobs/everyweek.js

-10
This file was deleted.

Diff for: models/user.js

-25
This file was deleted.

Diff for: package.json

+27-23
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
{
22
"name": "codebadge",
3-
"version": "1.0.0",
4-
"description": "Community sustainer",
5-
"main": "server.js",
3+
"version": "0.1.0",
4+
"private": true,
65
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1",
8-
"start": "node server.js"
6+
"serve": "vue-cli-service serve",
7+
"build": "vue-cli-service build",
8+
"lint": "vue-cli-service lint"
99
},
10-
"repository": {
11-
"type": "git",
12-
"url": "git+https://github.com/TG1999/Codebadge.git"
13-
},
14-
"keywords": [
15-
"community",
16-
"badge"
17-
],
18-
"author": "TG",
19-
"license": "MIT",
20-
"bugs": {
21-
"url": "https://github.com/TG1999/Codebadge/issues"
22-
},
23-
"homepage": "https://github.com/TG1999/Codebadge#readme",
2410
"dependencies": {
25-
"express": "^4.16.4",
26-
"mongoose": "^5.4.22",
27-
"node-schedule": "^1.3.2",
28-
"request": "^2.88.0"
11+
"axios": "^0.18.0",
12+
"core-js": "^2.6.5",
13+
"vue": "^2.6.10",
14+
"vue-router": "^3.0.3",
15+
"vuetify": "^1.5.5",
16+
"vuex": "^3.0.1"
17+
},
18+
"devDependencies": {
19+
"@vue/cli-plugin-babel": "^3.7.0",
20+
"@vue/cli-plugin-eslint": "^3.7.0",
21+
"@vue/cli-service": "^3.7.0",
22+
"@vue/eslint-config-prettier": "^4.0.1",
23+
"babel-eslint": "^10.0.1",
24+
"eslint": "^5.16.0",
25+
"eslint-plugin-vue": "^5.0.0",
26+
"node-sass": "^4.9.0",
27+
"sass-loader": "^7.1.0",
28+
"stylus": "^0.54.5",
29+
"stylus-loader": "^3.0.1",
30+
"vue-cli-plugin-vuetify": "^0.5.0",
31+
"vue-template-compiler": "^2.5.21",
32+
"vuetify-loader": "^1.0.5"
2933
}
3034
}

Diff for: postcss.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
plugins: {
3+
autoprefixer: {}
4+
}
5+
};

Diff for: public/favicon.ico

4.19 KB
Binary file not shown.

Diff for: public/index.html

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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>codebadge</title>
9+
<link
10+
rel="stylesheet"
11+
href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"
12+
/>
13+
<link
14+
rel="stylesheet"
15+
href="https://fonts.googleapis.com/css?family=Material+Icons"
16+
/>
17+
<link
18+
rel="stylesheet"
19+
href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
20+
integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay"
21+
crossorigin="anonymous"
22+
/>
23+
</head>
24+
<body>
25+
<noscript>
26+
<strong
27+
>We're sorry but codebadge doesn't work properly without JavaScript
28+
enabled. Please enable it to continue.</strong
29+
>
30+
</noscript>
31+
<div id="app"></div>
32+
<!-- built files will be auto injected -->
33+
</body>
34+
</html>

Diff for: routes/index.js

-6
This file was deleted.

Diff for: server.js

-21
This file was deleted.

Diff for: src/App.vue

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<template>
2+
<v-app>
3+
<v-toolbar color="white" app>
4+
<v-toolbar-title class="headline text-uppercase">
5+
<span>Codebadge</span>
6+
<span class="font-weight-light text-none">&nbsp;(Production Stage)</span>
7+
</v-toolbar-title>
8+
</v-toolbar>
9+
10+
<v-content class="content">
11+
<router-view></router-view>
12+
</v-content>
13+
</v-app>
14+
</template>
15+
16+
<script>
17+
export default {
18+
name: 'App',
19+
components: {},
20+
data() {
21+
return {
22+
//
23+
};
24+
}
25+
};
26+
</script>
27+
28+
<style lang="scss" >
29+
.content {
30+
background-color: white;
31+
}
32+
</style>

Diff for: src/main.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Vue from 'vue';
2+
import './plugins/vuetify';
3+
import App from './App.vue';
4+
import router from './router';
5+
import store from './store';
6+
7+
Vue.config.productionTip = false;
8+
9+
new Vue({
10+
router,
11+
store,
12+
render: h => h(App)
13+
}).$mount('#app');

Diff for: src/plugins/vuetify.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Vue from 'vue';
2+
import Vuetify from 'vuetify/lib';
3+
import 'vuetify/src/stylus/app.styl';
4+
5+
Vue.use(Vuetify, {
6+
iconfont: 'md'
7+
});

Diff for: src/router.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import Vue from 'vue';
2+
import Router from 'vue-router';
3+
import AuthView from './views/AuthView';
4+
import HomeView from './views/HomeView';
5+
import OrgView from './views/OrgView';
6+
import AuthService from './services/authService';
7+
8+
Vue.use(Router);
9+
10+
const authService = new AuthService();
11+
12+
export default new Router({
13+
routes: [
14+
{
15+
path: '',
16+
redirect: 'auth'
17+
},
18+
{
19+
path: '/auth',
20+
name: 'authView',
21+
component: AuthView
22+
},
23+
{
24+
path: '/home',
25+
name: 'homeView',
26+
component: HomeView,
27+
beforeEnter: (to, from, next) => {
28+
next(authService.isLoggedIn());
29+
}
30+
},
31+
{
32+
path: '/org/:name',
33+
name: 'orgView',
34+
component: OrgView,
35+
beforeEnter: (to, from, next) => {
36+
next(authService.isLoggedIn());
37+
}
38+
}
39+
]
40+
});

Diff for: src/store.js

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import Vue from 'vue';
2+
import Vuex from 'vuex';
3+
import axios from 'axios';
4+
import AxiosHelper from './config/AxiosHelper';
5+
import AuthService from './services/authService';
6+
7+
Vue.use(Vuex);
8+
9+
const authService = new AuthService();
10+
11+
export default new Vuex.Store({
12+
state: {
13+
user: [],
14+
userOrgs: []
15+
},
16+
mutations: {
17+
SET_USER(state, user) {
18+
state.user = user;
19+
},
20+
SET_USER_ORGS(state, userOrgs) {
21+
state.userOrgs = userOrgs;
22+
}
23+
},
24+
actions: {
25+
loadUser(context) {
26+
axios
27+
.get(`${AxiosHelper.baseUrl}/user`, {
28+
headers: {
29+
Authorization: `token ${authService.getToken()}`
30+
}
31+
})
32+
.then(res => context.commit('SET_USER', res.data))
33+
.catch(err => console.log(err));
34+
},
35+
loadUserOrgs(context) {
36+
axios
37+
.get(`${AxiosHelper.baseUrl}/user/orgs`, {
38+
headers: {
39+
Authorization: `token ${authService.getToken()}`
40+
}
41+
})
42+
.then(res => context.commit('SET_USER_ORGS', res.data))
43+
.catch(err => console.log(err));
44+
}
45+
},
46+
getters: {
47+
//UserDetails.vue
48+
userData: state => {
49+
let userData = {
50+
username: state.user.name,
51+
githubName: state.user.login,
52+
dp: state.user.avatar_url
53+
};
54+
55+
return userData;
56+
},
57+
58+
//OrgList.vue
59+
orgsData: state => {
60+
let orgsData = [];
61+
state.userOrgs.forEach(org => {
62+
orgsData.push({
63+
name: org.login,
64+
avatar: org.avatar_url
65+
});
66+
});
67+
68+
return orgsData;
69+
},
70+
71+
//Org.vue
72+
getOrgByName: state => name => {
73+
return state.userOrgs.find(org => (org.login = name));
74+
}
75+
}
76+
});

Diff for: vue.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
publicPath: process.env.NODE_ENV === 'production' ? '/Codebadge/' : '/'
3+
};

0 commit comments

Comments
 (0)