stash
This commit is contained in:
parent
0434961829
commit
4b11264dfe
3 changed files with 18 additions and 13 deletions
|
@ -23,17 +23,21 @@ export default {
|
||||||
servers: []
|
servers: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: mapActions(['fetchImage']),
|
methods: {
|
||||||
async mounted() {
|
...mapActions(['fetchImage']),
|
||||||
try {
|
loadImage() {
|
||||||
const response = await this.fetchImage(this.src);
|
this.fetchImage(this.src).then((response) => {
|
||||||
const mime_type = response.headers.get("content-type");
|
const mime_type = response.headers.get("content-type");
|
||||||
const base64 = btoa(new Uint8Array(await response.arrayBuffer())
|
response.arrayBuffer().then((buf) => {
|
||||||
.reduce((data, byte) => data + String.fromCharCode(byte), ""));
|
const base64 = btoa(new Uint8Array(buf)
|
||||||
this.image_data = "data:" + mime_type + ";base64," + base64;
|
.reduce((data, byte) => data + String.fromCharCode(byte), ""));
|
||||||
} catch (e) {
|
this.image_data = "data:" + mime_type + ";base64," + base64;
|
||||||
console.log(e);
|
});
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.loadImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -208,14 +208,15 @@ const store = new Vuex.Store({
|
||||||
await dispatch('loadTickets');
|
await dispatch('loadTickets');
|
||||||
},
|
},
|
||||||
async fetchImage({state}, url) {
|
async fetchImage({state}, url) {
|
||||||
return await fetch(url, {headers: {'Authorization': `Token ${state.token}`}}).then(r => r.blob());
|
return await fetch(url, {headers: {'Authorization': `Token ${state.token}`}});
|
||||||
},
|
},
|
||||||
async loadEvents({commit}) {
|
async loadEvents({commit}) {
|
||||||
const {data} = await axios.get('/2/events/');
|
const {data} = await axios.get('/2/events/');
|
||||||
commit('replaceEvents', data);
|
commit('replaceEvents', data);
|
||||||
},
|
},
|
||||||
changeEvent({dispatch, getters}, eventName) {
|
changeEvent({dispatch, getters, commit}, eventName) {
|
||||||
router.push({path: `/${eventName.slug}/${getters.getActiveView}/`});
|
router.push({path: `/${eventName.slug}/${getters.getActiveView}/`});
|
||||||
|
commit('replaceLoadedItems', []);
|
||||||
dispatch('loadEventItems');
|
dispatch('loadEventItems');
|
||||||
},
|
},
|
||||||
changeView({getters}, link) {
|
changeView({getters}, link) {
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
v-slot="{ item }"
|
v-slot="{ item }"
|
||||||
@itemActivated="openLightboxModalWith($event)"
|
@itemActivated="openLightboxModalWith($event)"
|
||||||
>
|
>
|
||||||
<AuthenticatedImage
|
<AuthenticatedImage v-if="item.file"
|
||||||
:src="`/media/2/256/${item.file}/`"
|
:src="`/media/2/256/${item.file}/`"
|
||||||
class="card-img-top img-fluid"
|
class="card-img-top img-fluid"
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue