Move everything to models and services #17

Merged
konrad merged 82 commits from refactor/models into master 2019-03-02 10:25:10 +00:00
Showing only changes of commit 8d8f0ced42 - Show all commits

View File

@ -27,14 +27,16 @@
<script>
import auth from '../../auth'
import router from '../../router'
import {HTTP} from '../../http-common'
import message from '../../message'
import NamespaceModel from "../../models/namespace";
import NamespaceService from "../../services/namespace";
export default {
name: "NewNamespace",
data() {
return {
namespace: {title: ''},
namespace: NamespaceModel,
namespaceService: NamespaceService,
error: '',
loading: false
}
@ -46,32 +48,24 @@
}
},
created() {
this.namespace = new NamespaceModel()
this.namespaceService = new NamespaceService()
this.$parent.setFullPage();
},
methods: {
newNamespace() {
const cancel = message.setLoading(this)
HTTP.put(`namespaces`, this.namespace, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
this.namespaceService.create(this.namespace)
.then(() => {
this.$parent.loadNamespaces()
this.handleSuccess({message: 'The namespace was successfully created.'})
cancel()
message.success({message: 'The namespace was successfully created.'}, this)
router.push({name: 'home'})
})
.catch(e => {
cancel()
this.handleError(e)
message.error(e, this)
})
},
back() {
router.go(-1)
},
handleError(e) {
message.error(e, this)
},
handleSuccess(e) {
message.success(e, this)
}
}
}