New namespace now uses model/service
All checks were successful
the build was successful

This commit is contained in:
konrad 2019-02-24 12:40:19 +01:00
parent fa673b86f3
commit 8d8f0ced42
Signed by: konrad
GPG Key ID: F40E70337AB24C9B

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)
}
}
}