koel/resources/assets/js/stores/setting.js

29 lines
517 B
JavaScript
Raw Normal View History

2016-11-26 03:25:35 +00:00
import { http } from '../services'
2016-12-01 10:54:28 +00:00
import { alerts } from '../utils'
2016-11-26 03:25:35 +00:00
import stub from '../stubs/settings'
2015-12-13 04:42:28 +00:00
2016-06-25 10:15:57 +00:00
export const settingStore = {
2016-06-25 16:05:24 +00:00
stub,
2016-03-13 17:00:32 +00:00
2016-06-25 16:05:24 +00:00
state: {
2016-11-26 03:25:35 +00:00
settings: []
2016-06-25 16:05:24 +00:00
},
2016-03-13 17:00:32 +00:00
2016-11-26 03:25:35 +00:00
init (settings) {
this.state.settings = settings
2016-06-25 16:05:24 +00:00
},
2015-12-13 04:42:28 +00:00
2016-11-26 03:25:35 +00:00
get all () {
return this.state.settings
2016-06-25 16:05:24 +00:00
},
2015-12-13 04:42:28 +00:00
2016-11-26 03:25:35 +00:00
update () {
2016-06-27 06:11:35 +00:00
return new Promise((resolve, reject) => {
2017-01-12 16:50:00 +00:00
http.post('settings', this.all, ({ data }) => {
2016-12-01 10:54:28 +00:00
alerts.success('Settings saved.')
2017-01-12 16:50:00 +00:00
resolve(data)
2016-12-20 15:44:47 +00:00
}, error => reject(error))
2016-11-26 03:25:35 +00:00
})
}
}