mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-14 12:18:01 +00:00
Add accent color picker
This commit is contained in:
@@ -59,7 +59,7 @@ module.exports = function () {
|
|||||||
} else {
|
} else {
|
||||||
const userVersion = row.user_version
|
const userVersion = row.user_version
|
||||||
|
|
||||||
if (userVersion === 0) {
|
if (userVersion < 1) {
|
||||||
db.run('ALTER TABLE samples ADD COLUMN fade_in REAL DEFAULT 0')
|
db.run('ALTER TABLE samples ADD COLUMN fade_in REAL DEFAULT 0')
|
||||||
db.run('ALTER TABLE samples ADD COLUMN loop_points_enabled INTEGER DEFAULT 0')
|
db.run('ALTER TABLE samples ADD COLUMN loop_points_enabled INTEGER DEFAULT 0')
|
||||||
db.run('ALTER TABLE samples ADD COLUMN loop_start REAL DEFAULT 0')
|
db.run('ALTER TABLE samples ADD COLUMN loop_start REAL DEFAULT 0')
|
||||||
@@ -67,6 +67,12 @@ module.exports = function () {
|
|||||||
|
|
||||||
db.run('PRAGMA user_version = 1')
|
db.run('PRAGMA user_version = 1')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (userVersion < 2) {
|
||||||
|
db.run('ALTER TABLE users ADD COLUMN preferences TEXT DEFAULT "{}"')
|
||||||
|
|
||||||
|
db.run('PRAGMA user_version = 2')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ router.get('/users/current', (req, res) => {
|
|||||||
return res.sendStatus(401)
|
return res.sendStatus(401)
|
||||||
}
|
}
|
||||||
|
|
||||||
db.get('SELECT is_admin as isAdmin, dark_mode as darkMode, can_upload as canUpload, * FROM users WHERE id = ?', [req.user.id], (err, row) => {
|
db.get(`SELECT
|
||||||
|
is_admin as isAdmin,
|
||||||
|
dark_mode as darkMode,
|
||||||
|
can_upload as canUpload,
|
||||||
|
* FROM users WHERE id = ?`, [req.user.id], (err, row) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
return res.sendStatus(500)
|
return res.sendStatus(500)
|
||||||
@@ -24,6 +28,7 @@ router.get('/users/current', (req, res) => {
|
|||||||
user.isAdmin = row.isAdmin === 1
|
user.isAdmin = row.isAdmin === 1
|
||||||
user.darkMode = row.darkMode === 1
|
user.darkMode = row.darkMode === 1
|
||||||
user.canUpload = row.canUpload === 1
|
user.canUpload = row.canUpload === 1
|
||||||
|
user.preferences = JSON.parse(row.preferences)
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json({ user: user })
|
res.json({ user: user })
|
||||||
@@ -287,4 +292,23 @@ router.delete('/users/:userId', (req, res) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.patch('/users/preferences', (req, res) => {
|
||||||
|
if (!req.user) {
|
||||||
|
return res.sendStatus(401)
|
||||||
|
}
|
||||||
|
|
||||||
|
const preferences = JSON.stringify(req.body.preferences)
|
||||||
|
|
||||||
|
db.serialize(() => {
|
||||||
|
db.run('UPDATE users SET preferences = ? WHERE id = ?', [preferences, req.user.id], (err) => {
|
||||||
|
if (err) {
|
||||||
|
logger.error(err)
|
||||||
|
return res.sendStatus(500)
|
||||||
|
} else {
|
||||||
|
return res.sendStatus(200)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
|
<h2 class="headline font-weight-bold mb-3">
|
||||||
|
User Management
|
||||||
|
</h2>
|
||||||
|
|
||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
<v-row>
|
<v-row>
|
||||||
ID: {{ currentUser.id }}
|
ID: {{ currentUser.id }}
|
||||||
@@ -26,7 +30,7 @@
|
|||||||
>
|
>
|
||||||
<template #activator="{ on, attrs }">
|
<template #activator="{ on, attrs }">
|
||||||
<v-btn
|
<v-btn
|
||||||
class="my-3"
|
class="mt-5 mb-10"
|
||||||
v-bind="attrs"
|
v-bind="attrs"
|
||||||
v-on="on"
|
v-on="on"
|
||||||
@click="resetChangePasswordForm"
|
@click="resetChangePasswordForm"
|
||||||
@@ -77,12 +81,35 @@
|
|||||||
</v-form>
|
</v-form>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
|
<h2 class="headline font-weight-bold mb-3">
|
||||||
|
Preferences
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<h3 class="font-weight-bold">
|
||||||
|
Dark Mode
|
||||||
|
</h3>
|
||||||
|
|
||||||
<v-switch
|
<v-switch
|
||||||
v-model="$vuetify.theme.dark"
|
v-model="$vuetify.theme.dark"
|
||||||
label="Dark Mode"
|
:label="`${$vuetify.theme.dark ? 'On' : 'Off'}`"
|
||||||
@change="toggleDarkMode"
|
@change="toggleDarkMode"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<h3 class="mb-5 font-weight-bold">
|
||||||
|
Accent Color
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<v-color-picker
|
||||||
|
v-model="accentColor"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<v-btn
|
||||||
|
class="mt-5"
|
||||||
|
@click="updateAccentColor"
|
||||||
|
>
|
||||||
|
Apply
|
||||||
|
</v-btn>
|
||||||
|
|
||||||
<v-snackbar
|
<v-snackbar
|
||||||
v-model="snackbar"
|
v-model="snackbar"
|
||||||
timeout="3000"
|
timeout="3000"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
dense
|
dense
|
||||||
>
|
>
|
||||||
<v-app-bar-nav-icon
|
<v-app-bar-nav-icon
|
||||||
@click="getCurrentUser"
|
@click="checkForAdmin"
|
||||||
/>
|
/>
|
||||||
</v-app-bar>
|
</v-app-bar>
|
||||||
<v-navigation-drawer
|
<v-navigation-drawer
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export default {
|
|||||||
changePasswordDialog: false,
|
changePasswordDialog: false,
|
||||||
isPasswordValid: false,
|
isPasswordValid: false,
|
||||||
password: '',
|
password: '',
|
||||||
|
accentColor: '#607d8b',
|
||||||
snackbar: false,
|
snackbar: false,
|
||||||
snackbarText: '',
|
snackbarText: '',
|
||||||
rules: {
|
rules: {
|
||||||
@@ -21,6 +22,7 @@ export default {
|
|||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
this.currentUser = response.data.user
|
this.currentUser = response.data.user
|
||||||
|
this.accentColor = this.currentUser.preferences.accentColor
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -45,6 +47,14 @@ export default {
|
|||||||
this.$http.patch('/users/dark-mode', {
|
this.$http.patch('/users/dark-mode', {
|
||||||
darkMode: this.$vuetify.theme.dark
|
darkMode: this.$vuetify.theme.dark
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
updateAccentColor () {
|
||||||
|
const preferences = { accentColor: this.accentColor }
|
||||||
|
this.$http.patch('/users/preferences', {
|
||||||
|
preferences: preferences
|
||||||
|
})
|
||||||
|
this.$vuetify.theme.themes.dark.primary = this.accentColor
|
||||||
|
this.$vuetify.theme.themes.light.primary = this.accentColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ export default {
|
|||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
loggedIn: false
|
loggedIn: false
|
||||||
}),
|
}),
|
||||||
|
created () {
|
||||||
|
this.getUserPreferences()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
home () {
|
home () {
|
||||||
this.$router.push('/')
|
this.$router.push('/')
|
||||||
@@ -24,7 +27,7 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getCurrentUser () {
|
checkForAdmin () {
|
||||||
this.loggedIn = false
|
this.loggedIn = false
|
||||||
this.drawyer = true
|
this.drawyer = true
|
||||||
this.$http.get('/users/current')
|
this.$http.get('/users/current')
|
||||||
@@ -32,12 +35,21 @@ export default {
|
|||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
this.loggedIn = true
|
this.loggedIn = true
|
||||||
this.isAdmin = response.data.user.isAdmin
|
this.isAdmin = response.data.user.isAdmin
|
||||||
this.$vuetify.theme.dark = response.data.user.darkMode
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.isAdmin = false
|
this.isAdmin = false
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
getUserPreferences () {
|
||||||
|
this.$http.get('/users/current')
|
||||||
|
.then(response => {
|
||||||
|
if (response.status === 200) {
|
||||||
|
const preferences = response.data.user.preferences
|
||||||
|
this.$vuetify.theme.themes.dark.primary = preferences.accentColor
|
||||||
|
this.$vuetify.theme.themes.light.primary = preferences.accentColor
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -489,6 +489,9 @@ export default {
|
|||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
this.canUpload = response.data.user.canUpload
|
this.canUpload = response.data.user.canUpload
|
||||||
this.$vuetify.theme.dark = response.data.user.darkMode
|
this.$vuetify.theme.dark = response.data.user.darkMode
|
||||||
|
const preferences = response.data.user.preferences
|
||||||
|
this.$vuetify.theme.themes.dark.primary = preferences.accentColor
|
||||||
|
this.$vuetify.theme.themes.light.primary = preferences.accentColor
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuetify from 'vuetify/lib/framework'
|
import Vuetify from 'vuetify/lib'
|
||||||
|
|
||||||
import colors from 'vuetify/lib/util/colors'
|
import colors from 'vuetify/lib/util/colors'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user