2019-12-21 23:23:44 +01:00
|
|
|
<template>
|
2020-01-06 17:00:56 +01:00
|
|
|
<div class="section">
|
|
|
|
<div class="columns is-mobile is-centered">
|
|
|
|
<div class="column is-two-thirds-tablet is-half-desktop is-one-third-widescreen is-one-quarter-fullhd">
|
|
|
|
<h1 class="title">New account</h1>
|
|
|
|
<form @submit.prevent="createAccount">
|
|
|
|
<div class="field">
|
|
|
|
<div class="file is-dark is-boxed">
|
|
|
|
<label class="file-label">
|
|
|
|
<input class="file-input" type="file" accept="image/*" v-on:change="uploadQrcode" ref="qrcodeInput">
|
|
|
|
<span class="file-cta">
|
|
|
|
<span class="file-icon">
|
|
|
|
<font-awesome-icon :icon="['fas', 'qrcode']" size="lg" />
|
|
|
|
</span>
|
|
|
|
<span class="file-label">Upload a qrcode</span>
|
|
|
|
</span>
|
|
|
|
</label>
|
2020-01-02 00:09:19 +01:00
|
|
|
</div>
|
2019-12-21 23:23:44 +01:00
|
|
|
</div>
|
2020-01-06 17:00:56 +01:00
|
|
|
<div class="field">
|
|
|
|
<label class="label">Service</label>
|
|
|
|
<div class="control">
|
2020-01-06 21:45:14 +01:00
|
|
|
<input class="input" type="text" placeholder="Service" v-model="twofaccount.service" required autofocus />
|
2020-01-06 17:00:56 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
2020-01-06 21:45:14 +01:00
|
|
|
<label class="label">Account</label>
|
2020-01-06 17:00:56 +01:00
|
|
|
<div class="control">
|
2020-01-06 21:45:14 +01:00
|
|
|
<input class="input" type="text" placeholder="Email" v-model="twofaccount.account" />
|
2020-01-06 17:00:56 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="label">Uri</label>
|
|
|
|
<div class="control">
|
|
|
|
<input class="input" type="text" placeholder="Uri" v-model="twofaccount.uri" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label class="label">Icon</label>
|
|
|
|
<div class="file is-dark">
|
|
|
|
<label class="file-label">
|
|
|
|
<input class="file-input" type="file" accept="image/*" v-on:change="uploadIcon" ref="iconInput">
|
|
|
|
<span class="file-cta">
|
|
|
|
<span class="file-icon">
|
|
|
|
<font-awesome-icon :icon="['fas', 'image']" />
|
|
|
|
</span>
|
|
|
|
<span class="file-label">Choose an image…</span>
|
|
|
|
</span>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<div class="control">
|
|
|
|
<input class="input" type="text" placeholder="Icon" v-model="twofaccount.icon" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control">
|
2020-01-07 15:46:48 +01:00
|
|
|
<router-link :to="{ name: 'accounts', params: { InitialEditMode: true } }" class="button is-light">Cancel</router-link>
|
2020-01-06 17:00:56 +01:00
|
|
|
</div>
|
|
|
|
<div class="control">
|
|
|
|
<button type="submit" class="button is-link">Create</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
2019-12-21 23:23:44 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2020-01-05 23:21:28 +01:00
|
|
|
twofaccount: {
|
2020-01-06 21:45:14 +01:00
|
|
|
'service' : '',
|
|
|
|
'account' : '',
|
2020-01-05 23:21:28 +01:00
|
|
|
'uri' : '',
|
|
|
|
'icon' : ''
|
|
|
|
}
|
2019-12-21 23:23:44 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
|
|
createAccount: function() {
|
|
|
|
let token = localStorage.getItem('jwt')
|
|
|
|
|
|
|
|
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
|
|
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
|
|
|
|
|
|
|
axios.post('/api/twofaccounts', this.twofaccount).then(response => {
|
2020-01-07 15:46:48 +01:00
|
|
|
this.$router.push({name: 'accounts', params: { InitialEditMode: true }});
|
2019-12-21 23:23:44 +01:00
|
|
|
})
|
2020-01-03 17:25:56 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
uploadQrcode(event) {
|
|
|
|
|
|
|
|
let token = localStorage.getItem('jwt')
|
|
|
|
|
|
|
|
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
|
|
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
|
|
|
|
2020-01-05 23:21:28 +01:00
|
|
|
let files = this.$refs.qrcodeInput.files
|
2020-01-03 17:25:56 +01:00
|
|
|
|
|
|
|
if (!files.length) {
|
|
|
|
console.log('no files');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
console.log(files.length + ' file(s) found');
|
|
|
|
}
|
|
|
|
|
|
|
|
let imgdata = new FormData();
|
|
|
|
|
|
|
|
imgdata.append('qrcode', files[0]);
|
|
|
|
|
|
|
|
let config = {
|
|
|
|
header : {
|
|
|
|
'Content-Type' : 'multipart/form-data',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
axios.post('/api/qrcode/decode', imgdata, config).then(response => {
|
|
|
|
console.log('image upload response > ', response);
|
|
|
|
this.twofaccount = response.data;
|
|
|
|
}
|
|
|
|
)
|
2020-01-05 23:21:28 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
uploadIcon(event) {
|
|
|
|
|
|
|
|
let token = localStorage.getItem('jwt')
|
|
|
|
|
|
|
|
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
|
|
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
|
|
|
|
|
|
|
let files = this.$refs.iconInput.files
|
|
|
|
|
|
|
|
if (!files.length) {
|
|
|
|
console.log('no files');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
console.log(files.length + ' file(s) found');
|
|
|
|
}
|
|
|
|
|
|
|
|
let imgdata = new FormData();
|
|
|
|
|
|
|
|
imgdata.append('icon', files[0]);
|
|
|
|
|
|
|
|
let config = {
|
|
|
|
header : {
|
|
|
|
'Content-Type' : 'multipart/form-data',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
axios.post('/api/icon/upload', imgdata, config).then(response => {
|
|
|
|
console.log('icon path > ', response);
|
|
|
|
this.twofaccount.icon = response.data;
|
|
|
|
}
|
|
|
|
)
|
2019-12-21 23:23:44 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|