mirror of https://github.com/velour/catbase.git
126 lines
4.0 KiB
HTML
126 lines
4.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<!-- Load required Bootstrap and BootstrapVue CSS -->
|
|
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css"/>
|
|
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@^2/dist/bootstrap-vue.min.css"/>
|
|
|
|
<!-- Load polyfills to support older browsers -->
|
|
<script src="//polyfill.io/v3/polyfill.min.js?features=es2015%2CMutationObserver"></script>
|
|
|
|
<!-- Load Vue followed by BootstrapVue -->
|
|
<script src="//unpkg.com/vue@^2/dist/vue.min.js"></script>
|
|
<script src="//unpkg.com/bootstrap-vue@^2/dist/bootstrap-vue.min.js"></script>
|
|
<script src="//unpkg.com/axios/dist/axios.min.js"></script>
|
|
<meta charset="UTF-8">
|
|
<title>Memes</title>
|
|
</head>
|
|
<body>
|
|
|
|
<div id="app">
|
|
<b-navbar>
|
|
<b-navbar-brand>Emojys</b-navbar-brand>
|
|
<b-navbar-nav>
|
|
<b-nav-item v-for="item in nav" :href="item.url" :active="item.name === 'Meme'" :key="item.key">{{ item.name
|
|
}}
|
|
</b-nav-item>
|
|
</b-navbar-nav>
|
|
</b-navbar>
|
|
|
|
<b-navbar>
|
|
<b-navbar-nav>
|
|
<b-nav-item href="/emojy/stats">Stats</b-nav-item>
|
|
<b-nav-item href="/emojy/list">List</b-nav-item>
|
|
<b-nav-item active href="/emojy/new">Upload</b-nav-item>
|
|
</b-navbar-nav>
|
|
</b-navbar>
|
|
|
|
<div
|
|
style="background-color:red;"
|
|
variant="error"
|
|
v-if="err != ''"
|
|
@click="err = ''">
|
|
{{ err }}
|
|
</div>
|
|
|
|
<div class="container">
|
|
<label>Passphrase</label>
|
|
<b-input v-model="password"></b-input>
|
|
<label>File
|
|
<input type="file" @change="handleFileUpload( $event )"/>
|
|
</label>
|
|
<br>
|
|
<button @click="submitFile()">Submit</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
var app = new Vue({
|
|
el: '#app',
|
|
data: function () {
|
|
return {
|
|
err: '',
|
|
view: '',
|
|
nav: [],
|
|
results: [],
|
|
fileList: {},
|
|
image: null,
|
|
password: ''
|
|
}
|
|
},
|
|
watch: {
|
|
view(newView, oldView) {
|
|
this.err = '';
|
|
}
|
|
},
|
|
mounted() {
|
|
axios.get('/nav')
|
|
.then(resp => {
|
|
this.nav = resp.data;
|
|
})
|
|
.catch(err => console.log(err))
|
|
this.refresh();
|
|
},
|
|
methods: {
|
|
refresh: function () {
|
|
axios.get('/emojy/all')
|
|
.then(resp => {
|
|
this.results = resp.data
|
|
this.err = ''
|
|
})
|
|
.catch(err => (this.err = err))
|
|
axios.get('/emojy/allFiles')
|
|
.then(resp => {
|
|
this.fileList = resp.data
|
|
this.err = ''
|
|
})
|
|
.catch(err => (this.err = err))
|
|
},
|
|
handleFileUpload(evt) {
|
|
this.file = evt.target.files[0];
|
|
console.log("added file data: " + this.file);
|
|
},
|
|
submitFile() {
|
|
let formData = new FormData();
|
|
formData.append('file', this.file);
|
|
formData.append('password', this.password)
|
|
console.log('trying to make/save form data: ' + formData)
|
|
axios.post('/emojy/upload',
|
|
formData,
|
|
{
|
|
headers: {'Content-Type': 'multipart/form-data'}
|
|
})
|
|
.then(() => {
|
|
console.log('SUCCESS!!');
|
|
window.location.href = '/emojy/list';
|
|
})
|
|
.catch(e => {
|
|
console.log('FAILURE!!' + e);
|
|
this.err = 'Could not upload file.';
|
|
});
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
</body>
|
|
</html> |