Add New Apps via gui

This commit is contained in:
Kekskurse 2019-07-23 18:22:58 +02:00
parent f4848dbb6b
commit 8e79961d4d
3 changed files with 42 additions and 7 deletions

View file

@ -3,7 +3,7 @@ import axios from 'axios'
export default() => {
return axios.create({
baseURL: `http://127.0.0.1:8000/api/`,
baseURL: `https://api.account.keks.cloud/api/`,
//baseURL: `https://api.account.keks.cloud/api/`,
withCredentials: false,
headers: {
'Accept': 'application/json',

View file

@ -29,6 +29,6 @@ export default {
return Api().get('/v1/app/'+id+'/user')
},
newApp(name, description, url) {
return Api().post('/v1/app/', {name: name, description: description, url: url});
return Api().post('/v1/app', {name: name, description: description, url: url});
}
}

View file

@ -10,7 +10,8 @@
type="text"
v-model="name"
error=true
error-messages="ja"
:error=nameErrorFlag
:error-messages=nameError
></v-text-field>
<v-text-field
label="Description"
@ -18,14 +19,16 @@
type="text"
v-model="description"
error=true
error-messages="ja"
:error=descriptionErrorFlag
:error-messages=descriptionError
></v-text-field>
<v-text-field
label="URL"
value=""
type="text"
v-model="url"
error-messages=""
:error-messages=urlError
:error=urlErrorFlag
></v-text-field>
</v-flex>
</v-layout>
@ -50,13 +53,45 @@
data () {
return {
name: '',
nameError: null,
nameErrorFlag: false,
description: '',
url: ''
descriptionError: '',
descriptionErrorFlag: false,
url: '',
urlError: '',
urlErrorFlag: false
}
},
methods: {
createApp: function () {
AppService.newApp()
this.nameErrorFlag = false;
this.nameError = null;
this.descriptionErrorFlag = false;
this.descriptionError = null;
this.urlErrorFlag = false;
this.urlError = null;
AppService.newApp(this.name, this.description, this.url).then((res) => {
this.$router.push({name: 'appDetails', params: {id: res.data.data.id}});
}).catch((error) => {
if(error.response.status == 422){
if(error.response.data.data.name != undefined) {
this.nameErrorFlag = true;
this.nameError = error.response.data.data.name[0]
}
if(error.response.data.data.description != undefined) {
this.descriptionErrorFlag = true;
this.descriptionError = error.response.data.data.description[0]
}
if(error.response.data.data.url != undefined) {
this.urlErrorFlag = true;
this.urlError = error.response.data.data.url[0]
}
console.log(error.response.data.data);
} else {
alert(error.response.data.msg);
}
});
}
},
mounted: function() {