Add sample edit feature

This commit is contained in:
Kevin Thomas
2022-04-13 22:50:15 -07:00
parent 37dc916dcc
commit 0916ff314e
5 changed files with 40 additions and 18 deletions

View File

@@ -61,7 +61,6 @@ module.exports = function () {
if (userVersion === 0) {
db.run('ALTER TABLE samples ADD COLUMN fade_in REAL DEFAULT 0')
db.run('ALTER TABLE samples ADD COLUMN fade_out REAL 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_end REAL DEFAULT 0')

View File

@@ -351,7 +351,9 @@ router.get('/profiles/:profileId', (req, res) => {
sampleQueryArgs.push(row.sample)
})
db.all(`SELECT samples.id, name, profiles_samples.volume
db.all(`SELECT samples.id, name, profiles_samples.volume,
fade_in as fadeIn, loop_points_enabled as loopPointsEnabled,
loop_start as loopStart, loop_end as loopEnd
FROM samples
INNER JOIN profiles_samples
ON profiles_samples.sample = samples.id
@@ -371,6 +373,10 @@ router.get('/profiles/:profileId', (req, res) => {
sample.id = row.id
sample.name = row.name
sample.volume = row.volume
sample.fadeIn = row.fadeIn
sample.loopPointsEnabled = row.loopPointsEnabled === 1
sample.loopStart = row.loopStart
sample.loopEnd = row.loopEnd
samples.push(sample)
})

View File

@@ -158,16 +158,13 @@ router.put('/samples/:sampleId', (req, res) => {
})
db.run(`UPDATE samples SET
name = ?,
fade_in = ?,
fade_out = ?,
loop_points_enabled = ?,
loop_start = ?,
loop_end = ?,
loop_end = ?
WHERE id = ?`, [
req.body.name,
req.body.fadeIn,
req.body.loopPointsEnabled,
req.body.loopPointsEnabled ? 1 : 0,
req.body.loopStart,
req.body.loopEnd,
req.params.sampleId