2017-07-08 16:51:47 +00:00
|
|
|
<template>
|
|
|
|
<div class="dashboard">
|
|
|
|
<h1>Global Settings</h1>
|
|
|
|
|
|
|
|
<ul>
|
2017-07-08 19:39:49 +00:00
|
|
|
<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>
|
2017-07-08 16:51:47 +00:00
|
|
|
</ul>
|
|
|
|
|
2017-07-08 19:27:26 +00:00
|
|
|
<form @submit="saveCommands">
|
2017-07-08 17:13:19 +00:00
|
|
|
<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>
|
2017-07-08 19:27:26 +00:00
|
|
|
<textarea v-model.trim="beforeSave"></textarea>
|
2017-07-08 17:13:19 +00:00
|
|
|
|
|
|
|
<h3>After Save</h3>
|
2017-07-08 19:27:26 +00:00
|
|
|
<textarea v-model.trim="afterSave"></textarea>
|
2017-07-08 17:13:19 +00:00
|
|
|
|
2017-07-08 16:51:47 +00:00
|
|
|
<p><input type="submit" value="Save"></p>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapState, mapMutations } from 'vuex'
|
2017-07-08 19:27:26 +00:00
|
|
|
import api from '@/utils/api'
|
2017-07-08 16:51:47 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'settings',
|
|
|
|
data: function () {
|
|
|
|
return {
|
2017-07-08 17:13:19 +00:00
|
|
|
beforeSave: '',
|
|
|
|
afterSave: ''
|
2017-07-08 16:51:47 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState([ 'user' ])
|
|
|
|
},
|
2017-07-08 17:13:19 +00:00
|
|
|
created () {
|
2017-07-08 19:27:26 +00:00
|
|
|
api.getCommands()
|
|
|
|
.then(commands => {
|
|
|
|
this.beforeSave = commands['before_save'].join('\n')
|
|
|
|
this.afterSave = commands['after_save'].join('\n')
|
|
|
|
})
|
|
|
|
.catch(error => { this.showError(error) })
|
2017-07-08 17:13:19 +00:00
|
|
|
},
|
2017-07-08 16:51:47 +00:00
|
|
|
methods: {
|
2017-07-08 19:27:26 +00:00
|
|
|
...mapMutations([ 'showSuccess', 'showError' ]),
|
|
|
|
saveCommands (event) {
|
2017-07-08 17:13:19 +00:00
|
|
|
event.preventDefault()
|
2017-07-08 19:27:26 +00:00
|
|
|
|
|
|
|
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) })
|
2017-07-08 17:13:19 +00:00
|
|
|
}
|
2017-07-08 16:51:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|