2022-05-30 20:34:42 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<!-- Load required Bootstrap and BootstrapVue CSS -->
|
2022-06-08 20:57:24 +00:00
|
|
|
<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"/>
|
2022-05-30 20:34:42 +00:00
|
|
|
|
|
|
|
<!-- 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="https://unpkg.com/vue-router@^2"></script>
|
|
|
|
<script src="https://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>
|
2022-06-08 20:57:24 +00:00
|
|
|
<b-nav-item v-for="item in nav" :href="item.url" :active="item.name === 'Meme'" :key="item.key">{{ item.name
|
|
|
|
}}
|
|
|
|
</b-nav-item>
|
2022-05-30 20:34:42 +00:00
|
|
|
</b-navbar-nav>
|
|
|
|
</b-navbar>
|
2022-06-08 20:57:24 +00:00
|
|
|
|
|
|
|
<b-navbar>
|
|
|
|
<b-navbar-nav>
|
|
|
|
<b-nav-item :active="view == 'stats'" @click="view = 'stats'">Stats</b-nav-item>
|
|
|
|
<b-nav-item :active="view == 'list'" @click="view = 'list'">List</b-nav-item>
|
|
|
|
<b-nav-item :active="view == 'upload'" @click="view = 'upload'">Upload</b-nav-item>
|
|
|
|
</b-navbar-nav>
|
|
|
|
</b-navbar>
|
|
|
|
|
|
|
|
<div
|
|
|
|
style="background-color:red;"
|
2022-05-30 20:34:42 +00:00
|
|
|
variant="error"
|
2022-06-08 20:57:24 +00:00
|
|
|
v-if="err != ''"
|
|
|
|
@click="err = ''">
|
2022-05-30 20:34:42 +00:00
|
|
|
{{ err }}
|
2022-06-08 20:57:24 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="container" v-if="view == 'upload'">
|
|
|
|
<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>
|
2022-05-30 20:34:42 +00:00
|
|
|
|
2022-06-08 20:57:24 +00:00
|
|
|
<ul v-if="view == 'stats'">
|
2022-06-06 14:20:50 +00:00
|
|
|
<li v-for="(category, name) in results" key="name">
|
|
|
|
{{name}}:
|
|
|
|
<ul>
|
|
|
|
<li v-for="emojy in category" key="emojy">
|
|
|
|
{{emojy.count}} -
|
2022-06-06 14:47:11 +00:00
|
|
|
<span v-if="name != 'emoji'">
|
|
|
|
<span v-if="emojy.onServer">✅</span>
|
|
|
|
<span v-else>❎</span>
|
|
|
|
-
|
|
|
|
</span>
|
2022-06-08 20:57:24 +00:00
|
|
|
<img v-if="emojy.url" :src="emojy.url" :alt="emojy.name" class="img-thumbnail"
|
|
|
|
style="max-width: 64px; max-height: 64px"/>
|
2022-06-06 14:20:50 +00:00
|
|
|
<span v-else>{{emojy.emojy}}</span>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
2022-05-30 20:34:42 +00:00
|
|
|
</ul>
|
2022-06-08 20:57:24 +00:00
|
|
|
|
|
|
|
<ul v-if="view == 'list'">
|
|
|
|
<li v-for="(path, name) in fileList" key="name">
|
|
|
|
{{name}}:
|
|
|
|
<img :src="path" :alt="name" class="img-thumbnail" style="max-width: 64px; max-height: 64px"/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2022-05-30 20:34:42 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
var router = new VueRouter({
|
|
|
|
mode: 'history',
|
|
|
|
routes: []
|
|
|
|
});
|
|
|
|
var app = new Vue({
|
|
|
|
el: '#app',
|
|
|
|
router,
|
2022-06-08 20:57:24 +00:00
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
err: '',
|
|
|
|
view: '',
|
|
|
|
nav: [],
|
|
|
|
results: [],
|
|
|
|
fileList: {},
|
|
|
|
image: null,
|
|
|
|
password: ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
view(newView, oldView) {
|
|
|
|
this.err = '';
|
|
|
|
}
|
2022-05-30 20:34:42 +00:00
|
|
|
},
|
|
|
|
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))
|
2022-06-08 20:57:24 +00:00
|
|
|
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!!');
|
|
|
|
this.view = 'list';
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
console.log('FAILURE!!' + e);
|
|
|
|
this.err = 'Could not upload file.';
|
|
|
|
});
|
2022-05-30 20:34:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|