2015-12-13 04:42:28 +00:00
|
|
|
|
<template>
|
2016-06-25 16:05:24 +00:00
|
|
|
|
<section id="settingsWrapper">
|
|
|
|
|
<h1 class="heading">
|
|
|
|
|
<span>Settings</span>
|
|
|
|
|
</h1>
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
2016-08-13 10:43:25 +00:00
|
|
|
|
<form @submit.prevent="confirmThenSave" class="main-scroll-wrap">
|
2016-06-25 16:05:24 +00:00
|
|
|
|
<div class="form-row">
|
|
|
|
|
<label for="inputSettingsPath">Media Path</label>
|
|
|
|
|
<p class="help">
|
|
|
|
|
The <em>absolute</em> path to the server directory containing your media.
|
|
|
|
|
Koel will scan this directory for songs and extract any available information.<br>
|
|
|
|
|
Scanning may take a while, especially if you have a lot of songs, so be patient.
|
|
|
|
|
</p>
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
<input type="text" v-model="state.settings.media_path" id="inputSettingsPath">
|
|
|
|
|
</div>
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
<div class="form-row">
|
|
|
|
|
<button type="submit">Scan</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</section>
|
2015-12-13 04:42:28 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2016-11-26 03:25:35 +00:00
|
|
|
|
import { settingStore, sharedStore } from '../../../stores'
|
2016-12-01 10:54:28 +00:00
|
|
|
|
import { parseValidationError, forceReloadWindow, showOverlay, hideOverlay, alerts } from '../../../utils'
|
2016-11-26 03:25:35 +00:00
|
|
|
|
import router from '../../../router'
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
export default {
|
2016-11-26 03:25:35 +00:00
|
|
|
|
data () {
|
2016-06-25 16:05:24 +00:00
|
|
|
|
return {
|
|
|
|
|
state: settingStore.state,
|
2016-11-26 03:25:35 +00:00
|
|
|
|
sharedState: sharedStore.state
|
|
|
|
|
}
|
2016-06-25 16:05:24 +00:00
|
|
|
|
},
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
2016-08-13 10:43:25 +00:00
|
|
|
|
computed: {
|
|
|
|
|
/**
|
|
|
|
|
* Determine if we should warn the user upon saving.
|
2016-09-23 10:03:33 +00:00
|
|
|
|
*
|
2016-08-13 10:43:25 +00:00
|
|
|
|
* @return {boolean}
|
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
|
shouldWarn () {
|
2016-08-13 10:43:25 +00:00
|
|
|
|
// Warn the user if the media path is not empty and about to change.
|
|
|
|
|
return this.sharedState.originalMediaPath &&
|
2016-11-26 03:25:35 +00:00
|
|
|
|
this.sharedState.originalMediaPath !== this.state.settings.media_path.trim()
|
|
|
|
|
}
|
2016-08-11 02:55:54 +00:00
|
|
|
|
},
|
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
methods: {
|
2016-11-26 03:25:35 +00:00
|
|
|
|
confirmThenSave () {
|
2016-08-13 10:43:25 +00:00
|
|
|
|
if (this.shouldWarn) {
|
2016-12-01 10:54:28 +00:00
|
|
|
|
alerts.confirm('Warning: Changing the media path will essentially remove all existing data – songs, artists, \
|
|
|
|
|
albums, favorites, everything – and empty your playlists! Sure you want to proceed?', this.save)
|
2016-08-13 10:43:25 +00:00
|
|
|
|
} else {
|
2016-11-26 03:25:35 +00:00
|
|
|
|
this.save()
|
2016-08-13 10:43:25 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
/**
|
|
|
|
|
* Save the settings.
|
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
|
save () {
|
|
|
|
|
showOverlay()
|
2016-08-13 10:43:25 +00:00
|
|
|
|
|
|
|
|
|
settingStore.update().then(() => {
|
|
|
|
|
// Make sure we're back to home first.
|
2016-11-26 03:25:35 +00:00
|
|
|
|
router.go('home')
|
|
|
|
|
forceReloadWindow()
|
2016-08-13 10:43:25 +00:00
|
|
|
|
}).catch(r => {
|
2016-11-26 03:25:35 +00:00
|
|
|
|
let msg = 'Unknown error.'
|
2016-08-13 10:43:25 +00:00
|
|
|
|
|
|
|
|
|
if (r.status === 422) {
|
2016-11-26 03:25:35 +00:00
|
|
|
|
msg = parseValidationError(r.responseJSON)[0]
|
2016-08-13 10:43:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
|
hideOverlay()
|
2016-12-01 10:54:28 +00:00
|
|
|
|
alerts.error(msg)
|
2016-11-26 03:25:35 +00:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="sass">
|
2016-06-25 16:05:24 +00:00
|
|
|
|
@import "../../../../sass/partials/_vars.scss";
|
|
|
|
|
@import "../../../../sass/partials/_mixins.scss";
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
#settingsWrapper {
|
|
|
|
|
input[type="text"] {
|
|
|
|
|
width: 384px;
|
|
|
|
|
margin-top: 12px;
|
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
|
@media only screen and (max-width : 667px) {
|
|
|
|
|
input[type="text"] {
|
|
|
|
|
width: 100%;
|
2015-12-13 04:42:28 +00:00
|
|
|
|
}
|
2016-06-25 16:05:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
|
</style>
|