mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-11 19:06:20 +00:00
@@ -1,11 +0,0 @@
|
||||
[*.{js,jsx,ts,tsx,vue}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.{js,jsx,ts,tsx,vue}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
21
.eslintrc.js
21
.eslintrc.js
@@ -1,21 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
|
||||
env: {
|
||||
node: true
|
||||
},
|
||||
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020
|
||||
},
|
||||
|
||||
rules: {
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
|
||||
},
|
||||
|
||||
extends: [
|
||||
'plugin:vue/essential',
|
||||
'@vue/standard'
|
||||
]
|
||||
}
|
||||
7811
package-lock.json
generated
7811
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
170
package.json
170
package.json
@@ -1,86 +1,86 @@
|
||||
{
|
||||
"name": "noisedash",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "Self-hosted web ambient noise generator",
|
||||
"author": "KevinThomas0 <me@kevinthomas.dev>",
|
||||
"scripts": {
|
||||
"build": "node build/build.js",
|
||||
"lint": "vue-cli-service lint",
|
||||
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
|
||||
"server": "node server/app",
|
||||
"start": "npm run dev",
|
||||
"test": "npm run unit",
|
||||
"unit": "jest --config test/unit/jest.conf.js --coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"bcrypt": "^5.0.1",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"sqlite3": "^5.0.2",
|
||||
"vue": "^2.5.2",
|
||||
"vue-router": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-eslint": "^4.5.13",
|
||||
"@vue/eslint-config-standard": "^5.1.2",
|
||||
"autoprefixer": "^7.1.2",
|
||||
"babel-core": "^6.22.1",
|
||||
"babel-eslint": "^8.2.1",
|
||||
"babel-helper-vue-jsx-merge-props": "^2.0.3",
|
||||
"babel-jest": "^21.0.2",
|
||||
"babel-loader": "^7.1.1",
|
||||
"babel-plugin-dynamic-import-node": "^1.2.0",
|
||||
"babel-plugin-syntax-jsx": "^6.18.0",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
|
||||
"babel-plugin-transform-runtime": "^6.22.0",
|
||||
"babel-plugin-transform-vue-jsx": "^3.5.0",
|
||||
"babel-preset-env": "^1.3.2",
|
||||
"babel-preset-stage-2": "^6.22.0",
|
||||
"chalk": "^2.0.1",
|
||||
"copy-webpack-plugin": "^4.0.1",
|
||||
"css-loader": "^0.28.0",
|
||||
"eslint": "^6.7.2",
|
||||
"eslint-friendly-formatter": "^4.0.1",
|
||||
"eslint-plugin-import": "^2.20.2",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"eslint-plugin-vue": "^6.2.2",
|
||||
"extract-text-webpack-plugin": "^3.0.0",
|
||||
"file-loader": "^1.1.4",
|
||||
"friendly-errors-webpack-plugin": "^1.6.1",
|
||||
"html-webpack-plugin": "^2.30.1",
|
||||
"jest": "^22.0.4",
|
||||
"jest-serializer-vue": "^0.3.0",
|
||||
"node-notifier": "^5.1.2",
|
||||
"optimize-css-assets-webpack-plugin": "^3.2.0",
|
||||
"ora": "^1.2.0",
|
||||
"portfinder": "^1.0.13",
|
||||
"postcss-import": "^11.0.0",
|
||||
"postcss-loader": "^2.0.8",
|
||||
"postcss-url": "^7.2.1",
|
||||
"rimraf": "^2.6.0",
|
||||
"semver": "^5.3.0",
|
||||
"shelljs": "^0.7.6",
|
||||
"uglifyjs-webpack-plugin": "^1.1.1",
|
||||
"url-loader": "^0.5.8",
|
||||
"vue-jest": "^1.0.2",
|
||||
"vue-loader": "^13.3.0",
|
||||
"vue-style-loader": "^3.0.1",
|
||||
"vue-template-compiler": "^2.5.2",
|
||||
"webpack": "^3.6.0",
|
||||
"webpack-bundle-analyzer": "^2.9.0",
|
||||
"webpack-dev-server": "^2.9.1",
|
||||
"webpack-merge": "^4.1.0"
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"not ie <= 8"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 6.0.0",
|
||||
"npm": ">= 3.0.0"
|
||||
}
|
||||
}
|
||||
"name": "noisedash",
|
||||
"version": "1.0.0",
|
||||
"description": "Self-hosted web ambient noise generator",
|
||||
"author": "KevinThomas0 <me@kevinthomas.dev>",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
|
||||
"start": "npm run dev",
|
||||
"unit": "jest --config test/unit/jest.conf.js --coverage",
|
||||
"test": "npm run unit",
|
||||
"lint": "eslint --ext .js,.vue src test/unit",
|
||||
"server": "node server/app",
|
||||
"build": "node build/build.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.21.1",
|
||||
"bcrypt": "^5.0.1",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"sqlite3": "^5.0.2",
|
||||
"vue": "^2.5.2",
|
||||
"vue-router": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^7.1.2",
|
||||
"babel-core": "^6.22.1",
|
||||
"babel-eslint": "^8.2.1",
|
||||
"babel-helper-vue-jsx-merge-props": "^2.0.3",
|
||||
"babel-jest": "^21.0.2",
|
||||
"babel-loader": "^7.1.1",
|
||||
"babel-plugin-dynamic-import-node": "^1.2.0",
|
||||
"babel-plugin-syntax-jsx": "^6.18.0",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
|
||||
"babel-plugin-transform-runtime": "^6.22.0",
|
||||
"babel-plugin-transform-vue-jsx": "^3.5.0",
|
||||
"babel-preset-env": "^1.3.2",
|
||||
"babel-preset-stage-2": "^6.22.0",
|
||||
"chalk": "^2.0.1",
|
||||
"copy-webpack-plugin": "^4.0.1",
|
||||
"css-loader": "^0.28.0",
|
||||
"eslint": "^4.15.0",
|
||||
"eslint-config-standard": "^10.2.1",
|
||||
"eslint-friendly-formatter": "^3.0.0",
|
||||
"eslint-loader": "^1.7.1",
|
||||
"eslint-plugin-import": "^2.7.0",
|
||||
"eslint-plugin-node": "^5.2.0",
|
||||
"eslint-plugin-promise": "^3.4.0",
|
||||
"eslint-plugin-standard": "^3.0.1",
|
||||
"eslint-plugin-vue": "^4.0.0",
|
||||
"extract-text-webpack-plugin": "^3.0.0",
|
||||
"file-loader": "^1.1.4",
|
||||
"friendly-errors-webpack-plugin": "^1.6.1",
|
||||
"html-webpack-plugin": "^2.30.1",
|
||||
"jest": "^22.0.4",
|
||||
"jest-serializer-vue": "^0.3.0",
|
||||
"node-notifier": "^5.1.2",
|
||||
"optimize-css-assets-webpack-plugin": "^3.2.0",
|
||||
"ora": "^1.2.0",
|
||||
"portfinder": "^1.0.13",
|
||||
"postcss-import": "^11.0.0",
|
||||
"postcss-loader": "^2.0.8",
|
||||
"postcss-url": "^7.2.1",
|
||||
"rimraf": "^2.6.0",
|
||||
"semver": "^5.3.0",
|
||||
"shelljs": "^0.7.6",
|
||||
"uglifyjs-webpack-plugin": "^1.1.1",
|
||||
"url-loader": "^0.5.8",
|
||||
"vue-jest": "^1.0.2",
|
||||
"vue-loader": "^13.3.0",
|
||||
"vue-style-loader": "^3.0.1",
|
||||
"vue-template-compiler": "^2.5.2",
|
||||
"webpack": "^3.6.0",
|
||||
"webpack-bundle-analyzer": "^2.9.0",
|
||||
"webpack-dev-server": "^2.9.1",
|
||||
"webpack-merge": "^4.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0",
|
||||
"npm": ">= 3.0.0"
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"not ie <= 8"
|
||||
]
|
||||
}
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
msg: 'The superheros'
|
||||
}
|
||||
}
|
||||
}
|
||||
msg: "The superheros",
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
h1,
|
||||
@@ -30,4 +30,4 @@ li {
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
msg: 'Hello World!'
|
||||
}
|
||||
}
|
||||
}
|
||||
msg: "Hello World!",
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
<style scoped>
|
||||
|
||||
@@ -21,44 +21,44 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
email: '',
|
||||
password: ''
|
||||
}
|
||||
email: "",
|
||||
password: "",
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleSubmit (e) {
|
||||
e.preventDefault()
|
||||
handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
if (this.password.length > 0) {
|
||||
this.$http
|
||||
.post('http://localhost:3000/login', {
|
||||
.post("http://localhost:3000/login", {
|
||||
email: this.email,
|
||||
password: this.password
|
||||
password: this.password,
|
||||
})
|
||||
.then((response) => {
|
||||
const isAdmin = response.data.user.isAdmin
|
||||
localStorage.setItem('user', JSON.stringify(response.data.user))
|
||||
localStorage.setItem('jwt', response.data.token)
|
||||
let is_admin = response.data.user.is_admin;
|
||||
localStorage.setItem("user", JSON.stringify(response.data.user));
|
||||
localStorage.setItem("jwt", response.data.token);
|
||||
|
||||
if (localStorage.getItem('jwt') != null) {
|
||||
this.$emit('loggedIn')
|
||||
if (localStorage.getItem("jwt") != null) {
|
||||
this.$emit("loggedIn");
|
||||
if (this.$route.params.nextUrl != null) {
|
||||
this.$router.push(this.$route.params.nextUrl)
|
||||
this.$router.push(this.$route.params.nextUrl);
|
||||
} else {
|
||||
if (isAdmin === 1) {
|
||||
this.$router.push('admin')
|
||||
if (is_admin == 1) {
|
||||
this.$router.push("admin");
|
||||
} else {
|
||||
this.$router.push('dashboard')
|
||||
this.$router.push("dashboard");
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error(error.response)
|
||||
})
|
||||
console.error(error.response);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<label for="password-confirm">Is this an administrator account?</label>
|
||||
<div>
|
||||
<select v-model="isAdmin">
|
||||
<select v-model="is_admin">
|
||||
<option value="1">Yes</option>
|
||||
<option value="0">No</option>
|
||||
</select>
|
||||
@@ -44,58 +44,57 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: ['nextUrl'],
|
||||
data () {
|
||||
props: ["nextUrl"],
|
||||
data() {
|
||||
return {
|
||||
name: '',
|
||||
email: '',
|
||||
password: '',
|
||||
password_confirmation: '',
|
||||
isAdmin: null
|
||||
}
|
||||
name: "",
|
||||
email: "",
|
||||
password: "",
|
||||
password_confirmation: "",
|
||||
is_admin: null,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleSubmit (e) {
|
||||
e.preventDefault()
|
||||
handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (
|
||||
this.password === this.password_confirmation &&
|
||||
this.password.length > 0
|
||||
) {
|
||||
let url = 'http://localhost:3000/register'
|
||||
if (this.isAdmin != null || this.isAdmin === 1) {
|
||||
url = 'http://localhost:3000/register-admin'
|
||||
}
|
||||
let url = "http://localhost:3000/register";
|
||||
if (this.is_admin != null || this.is_admin == 1)
|
||||
url = "http://localhost:3000/register-admin";
|
||||
this.$http
|
||||
.post(url, {
|
||||
name: this.name,
|
||||
email: this.email,
|
||||
password: this.password,
|
||||
isAdmin: this.isAdmin
|
||||
is_admin: this.is_admin,
|
||||
})
|
||||
.then((response) => {
|
||||
localStorage.setItem('user', JSON.stringify(response.data.user))
|
||||
localStorage.setItem('jwt', response.data.token)
|
||||
localStorage.setItem("user", JSON.stringify(response.data.user));
|
||||
localStorage.setItem("jwt", response.data.token);
|
||||
|
||||
if (localStorage.getItem('jwt') != null) {
|
||||
this.$emit('loggedIn')
|
||||
if (localStorage.getItem("jwt") != null) {
|
||||
this.$emit("loggedIn");
|
||||
if (this.$route.params.nextUrl != null) {
|
||||
this.$router.push(this.$route.params.nextUrl)
|
||||
this.$router.push(this.$route.params.nextUrl);
|
||||
} else {
|
||||
this.$router.push('/')
|
||||
this.$router.push("/");
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
})
|
||||
console.error(error);
|
||||
});
|
||||
} else {
|
||||
this.password = ''
|
||||
this.passwordConfirm = ''
|
||||
this.password = "";
|
||||
this.passwordConfirm = "";
|
||||
|
||||
return alert('Passwords do not match')
|
||||
return alert("Passwords do not match");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
msg: 'The commoners'
|
||||
}
|
||||
}
|
||||
}
|
||||
msg: "The commoners",
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
@@ -32,4 +32,4 @@ li {
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
10
src/main.js
10
src/main.js
@@ -5,14 +5,14 @@ import App from './App'
|
||||
import router from './router'
|
||||
import Axios from 'axios'
|
||||
|
||||
Vue.prototype.$http = Axios
|
||||
Vue.prototype.$http = Axios;
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
/* eslint-disable no-new */
|
||||
new Vue({
|
||||
el: '#app',
|
||||
router,
|
||||
components: { App },
|
||||
template: '<App/>'
|
||||
el: '#app',
|
||||
router,
|
||||
components: { App },
|
||||
template: '<App/>'
|
||||
})
|
||||
|
||||
@@ -8,78 +8,80 @@ import Admin from '@/components/Admin'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
const router = new Router({
|
||||
mode: 'history',
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'HelloWorld',
|
||||
component: HelloWorld
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
component: Login,
|
||||
meta: {
|
||||
guest: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/register',
|
||||
name: 'register',
|
||||
component: Register,
|
||||
meta: {
|
||||
guest: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/dashboard',
|
||||
name: 'userboard',
|
||||
component: UserBoard,
|
||||
meta: {
|
||||
requiresAuth: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/admin',
|
||||
name: 'admin',
|
||||
component: Admin,
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
isAdmin: true
|
||||
}
|
||||
}
|
||||
]
|
||||
let router = new Router({
|
||||
mode: 'history',
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'HelloWorld',
|
||||
component: HelloWorld
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
component: Login,
|
||||
meta: {
|
||||
guest: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/register',
|
||||
name: 'register',
|
||||
component: Register,
|
||||
meta: {
|
||||
guest: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/dashboard',
|
||||
name: 'userboard',
|
||||
component: UserBoard,
|
||||
meta: {
|
||||
requiresAuth: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/admin',
|
||||
name: 'admin',
|
||||
component: Admin,
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
is_admin: true
|
||||
}
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.matched.some(record => record.meta.requiresAuth)) {
|
||||
if (localStorage.getItem('jwt') == null) {
|
||||
next({
|
||||
path: '/login',
|
||||
params: { nextUrl: to.fullPath }
|
||||
})
|
||||
} else {
|
||||
const user = JSON.parse(localStorage.getItem('user'))
|
||||
if (to.matched.some(record => record.meta.isAdmin)) {
|
||||
if (user.isAdmin === 1) {
|
||||
next()
|
||||
if (to.matched.some(record => record.meta.requiresAuth)) {
|
||||
if (localStorage.getItem('jwt') == null) {
|
||||
next({
|
||||
path: '/login',
|
||||
params: { nextUrl: to.fullPath }
|
||||
})
|
||||
} else {
|
||||
next({ name: 'userboard' })
|
||||
let user = JSON.parse(localStorage.getItem('user'))
|
||||
if (to.matched.some(record => record.meta.is_admin)) {
|
||||
if (user.is_admin == 1) {
|
||||
next()
|
||||
}
|
||||
else {
|
||||
next({ name: 'userboard' })
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}
|
||||
} else if (to.matched.some(record => record.meta.guest)) {
|
||||
if (localStorage.getItem('jwt') == null) {
|
||||
next()
|
||||
}
|
||||
else {
|
||||
next({ name: 'userboard' })
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}
|
||||
} else if (to.matched.some(record => record.meta.guest)) {
|
||||
if (localStorage.getItem('jwt') == null) {
|
||||
next()
|
||||
} else {
|
||||
next({ name: 'userboard' })
|
||||
next()
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user