Files
wolk/assets/src/components/GlobalSettings.vue
Henrique Dias efd1fdc1f4 Add links to global settings
Former-commit-id: 26b67fd4474f97fc8bd1ed0911826531f7b544e2 [formerly 7d17796dab54ac1ea0a8ae1b65ac8c19ba5a3653] [formerly b4bf430cd662e6942a410a33c8d9fb2ca7d9766a [formerly 05884fd12d426cbedfc3f73679e390ce7c35035d]]
Former-commit-id: 4cbf2a84a1ee32983dda4b930121f48bfb60fc3b [formerly ba148130d397dbab9b1b73520c4560a0bc6e4f1f]
Former-commit-id: 45e0b0e0b92411fde9874d4136a4212f915b8baf
2017-07-08 20:39:49 +01:00

72 lines
2.0 KiB
Vue

<template>
<div class="dashboard">
<h1>Global Settings</h1>
<ul>
<li><router-link to="/settings/profile">Go to Profile Settings</router-link></li>
<li><router-link to="/users">Go to User Management</router-link></li>
</ul>
<form @submit="saveCommands">
<h2>Commands</h2>
<p class="small">Here you can set commands that are executed in the named events. You write one command
per line. If the event is related to files, such as before and after saving, the environment variable
<code>file</code> will be available with the path of the file.</p>
<h3>Before Save</h3>
<textarea v-model.trim="beforeSave"></textarea>
<h3>After Save</h3>
<textarea v-model.trim="afterSave"></textarea>
<p><input type="submit" value="Save"></p>
</form>
</div>
</template>
<script>
import { mapState, mapMutations } from 'vuex'
import api from '@/utils/api'
export default {
name: 'settings',
data: function () {
return {
beforeSave: '',
afterSave: ''
}
},
computed: {
...mapState([ 'user' ])
},
created () {
api.getCommands()
.then(commands => {
this.beforeSave = commands['before_save'].join('\n')
this.afterSave = commands['after_save'].join('\n')
})
.catch(error => { this.showError(error) })
},
methods: {
...mapMutations([ 'showSuccess', 'showError' ]),
saveCommands (event) {
event.preventDefault()
let commands = {
'before_save': this.beforeSave.split('\n'),
'after_save': this.afterSave.split('\n')
}
if (commands['before_save'].length === 1 && commands['before_save'][0] === '') commands['before_save'] = []
if (commands['after_save'].length === 1 && commands['after_save'][0] === '') commands['after_save'] = []
api.updateCommands(commands)
.then(() => { this.showSuccess('Commands updated!') })
.catch(error => { this.showError(error) })
}
}
}
</script>