mirror of
https://github.com/kaythomas0/noisedash.git
synced 2025-11-12 03:16:20 +00:00
Add initial implementation for loading proflies
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
const express = require('express')
|
const express = require('express')
|
||||||
const session = require('express-session')
|
const session = require('express-session')
|
||||||
const FileStore = require('session-file-store')(session);
|
const FileStore = require('session-file-store')(session)
|
||||||
const cors = require('cors')
|
const cors = require('cors')
|
||||||
const passport = require('passport')
|
const passport = require('passport')
|
||||||
const path = require('path')
|
|
||||||
const cookieParser = require('cookie-parser')
|
const cookieParser = require('cookie-parser')
|
||||||
const config = require('config')
|
const config = require('config')
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ app.use(cors(corsOptions))
|
|||||||
|
|
||||||
const fileStoreOptions = {
|
const fileStoreOptions = {
|
||||||
path: config.get('Server.sessionFileStorePath')
|
path: config.get('Server.sessionFileStorePath')
|
||||||
};
|
}
|
||||||
|
|
||||||
require('./boot/db')()
|
require('./boot/db')()
|
||||||
require('./boot/auth')()
|
require('./boot/auth')()
|
||||||
|
|||||||
@@ -73,11 +73,76 @@ router.get('/profiles', function (req, res, next) {
|
|||||||
rows.forEach((row) => {
|
rows.forEach((row) => {
|
||||||
profiles.push(row.name)
|
profiles.push(row.name)
|
||||||
console.log(row.name)
|
console.log(row.name)
|
||||||
});
|
})
|
||||||
|
|
||||||
console.log('PROFILES: ')
|
console.log('PROFILES: ')
|
||||||
res.json({ profiles: profiles })
|
res.json({ profiles: profiles })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.get('/profiles/:profileId', function (req, res, next) {
|
||||||
|
if (!req.user) {
|
||||||
|
return res.sendStatus(401)
|
||||||
|
}
|
||||||
|
|
||||||
|
const profile = {
|
||||||
|
name: null,
|
||||||
|
isTimerEnabled: null,
|
||||||
|
duration: null,
|
||||||
|
volume: null,
|
||||||
|
noiseColor: null,
|
||||||
|
isFilterEnabled: null,
|
||||||
|
filterType: null,
|
||||||
|
isLFOFilterCutoffEnabled: null,
|
||||||
|
lfoFilterCutoffFrequency: null,
|
||||||
|
lfoFilterCutoffLow: null,
|
||||||
|
lfoFilterCutoffHigh: null,
|
||||||
|
isTremoloEnabled: null,
|
||||||
|
tremoloFrequency: null,
|
||||||
|
tremoloDepth: null
|
||||||
|
}
|
||||||
|
|
||||||
|
db.get(`SELECT
|
||||||
|
name,
|
||||||
|
timer_enabled as isTimerEnabled,
|
||||||
|
duration,
|
||||||
|
volume,
|
||||||
|
noise_color as noiseColor,
|
||||||
|
filter_enabled as isFilterEnabled,
|
||||||
|
filter_type as filterType,
|
||||||
|
filter_cutoff as filterCutoff,
|
||||||
|
lfo_filter_cutoff_enabled as isLFOFilterCutoffEnabled,
|
||||||
|
lfo_filter_cutoff_frequency as lfoFilterCutoffFrequency,
|
||||||
|
lfo_filter_cutoff_low as lfoFilterCutoffLow,
|
||||||
|
lfo_filter_cutoff_high as lfoFilterCutoffHigh,
|
||||||
|
tremolo_enabled as isTremoloEnabled,
|
||||||
|
tremolo_frequency as tremoloFrequency,
|
||||||
|
tremolo_depth as tremoloDepth
|
||||||
|
FROM profiles WHERE id = ?`, [req.params.profileId], (err, row) => {
|
||||||
|
if (err) {
|
||||||
|
console.log('Error getting profile')
|
||||||
|
console.log(err)
|
||||||
|
return res.sendStatus(500)
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.name = row.name
|
||||||
|
profile.isTimerEnabled = row.isTimerEnabled
|
||||||
|
profile.duration = row.duration
|
||||||
|
profile.volume = row.volume
|
||||||
|
profile.noiseColor = row.noiseColor
|
||||||
|
profile.isFilterEnabled = row.isFilterEnabled
|
||||||
|
profile.filterType = row.filterType
|
||||||
|
profile.isLFOFilterCutoffEnabled = row.isLFOFilterCutoffEnabled
|
||||||
|
profile.lfoFilterCutoffFrequency = row.lfoFilterCutoffFrequency
|
||||||
|
profile.lfoFilterCutoffLow = row.lfoFilterCutoffLow
|
||||||
|
profile.lfoFilterCutoffHigh = row.lfoFilterCutoffHigh
|
||||||
|
profile.isTremoloEnabled = row.isTremoloEnabled
|
||||||
|
profile.tremoloFrequency = row.tremoloFrequency
|
||||||
|
profile.tremoloDepth = row.tremoloDepth
|
||||||
|
|
||||||
|
console.log('PROFILES: ')
|
||||||
|
res.json({ profile: profile })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|||||||
@@ -21,14 +21,23 @@
|
|||||||
Profiles
|
Profiles
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
<v-row justify="center">
|
||||||
<v-select
|
<v-select
|
||||||
v-model="selectedProfile"
|
v-model="selectedProfile"
|
||||||
:items="profileItems"
|
:items="profileItems"
|
||||||
label="Profiles"
|
label="Profiles"
|
||||||
class="mx-3"
|
class="mx-3"
|
||||||
@click="loadProfiles"
|
@click="populateProfileItems"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<v-btn
|
||||||
|
class="mx-3 mb-5"
|
||||||
|
@click="loadProfile"
|
||||||
|
>
|
||||||
|
Load Profile
|
||||||
|
</v-btn>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
<v-dialog
|
<v-dialog
|
||||||
v-model="profileDialog"
|
v-model="profileDialog"
|
||||||
max-width="600px"
|
max-width="600px"
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ export default {
|
|||||||
this.noise.connect(this.filter)
|
this.noise.connect(this.filter)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loadProfiles () {
|
populateProfileItems () {
|
||||||
this.$http.get('https://localhost:3000/profiles')
|
this.$http.get('https://localhost:3000/profiles')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
@@ -170,6 +170,17 @@ export default {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.profileDialog = false
|
this.profileDialog = false
|
||||||
|
},
|
||||||
|
loadProfile () {
|
||||||
|
this.$http.get('https://localhost:3000/profiles/'.concat(this.profileItems.indexOf(this.selectedProfile) + 1))
|
||||||
|
.then(response => {
|
||||||
|
if (response.status === 200) {
|
||||||
|
console.log(response.data.profile)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
console.error(error.response)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user