stash
This commit is contained in:
parent
b5d079c9d9
commit
c8fdfbb09a
5 changed files with 97 additions and 5 deletions
55
frontend/src/components/AuthenticatedImage.vue
Normal file
55
frontend/src/components/AuthenticatedImage.vue
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<!--img src=""-->
|
||||||
|
data:{{ image_data }}<br>
|
||||||
|
owner:{{ owner }}<br>
|
||||||
|
src:{{ src }}<br>
|
||||||
|
servers:{{ servers }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
img {
|
||||||
|
width: 190px;
|
||||||
|
height: 107px;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {mapActions, mapGetters} from "vuex";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "AuthenticatedImage",
|
||||||
|
props: {
|
||||||
|
src: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
owner: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
image_data: "",
|
||||||
|
servers: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(["signAuth"])
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions(["getFriendServers"])
|
||||||
|
},
|
||||||
|
async mounted() {
|
||||||
|
try {
|
||||||
|
this.servers = await this.getFriendServers({username: this.owner});
|
||||||
|
this.image_data = await this.servers.get(this.signAuth, this.src);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -1,7 +1,8 @@
|
||||||
class NeighborsCache {
|
class NeighborsCache {
|
||||||
constructor() {
|
constructor() {
|
||||||
//this._max_age = 1000 * 60 * 60; // 1 hour
|
//this._max_age = 1000 * 60 * 60; // 1 hour
|
||||||
this._max_age = 1000 * 60 * 5; // 5 minutes
|
//this._max_age = 1000 * 60 * 5; // 5 minutes
|
||||||
|
this._max_age = 1000 * 15; // 15 seconds
|
||||||
this._cache = JSON.parse(localStorage.getItem('neighbor-cache')) || {};
|
this._cache = JSON.parse(localStorage.getItem('neighbor-cache')) || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {createStore} from 'vuex';
|
||||||
import router from '@/router';
|
import router from '@/router';
|
||||||
import FallBackResolver from "@/dns";
|
import FallBackResolver from "@/dns";
|
||||||
import NeighborsCache from "@/neigbors";
|
import NeighborsCache from "@/neigbors";
|
||||||
import {createSignAuth, createTokenAuth, createNullAuth, ServerSet, ServerSetUnion} from "@/federation";
|
import {createNullAuth, createSignAuth, createTokenAuth, ServerSet, ServerSetUnion} from "@/federation";
|
||||||
|
|
||||||
|
|
||||||
export default createStore({
|
export default createStore({
|
||||||
|
@ -262,6 +262,10 @@ export default createStore({
|
||||||
state.last_load.files = Date.now()
|
state.last_load.files = Date.now()
|
||||||
return data
|
return data
|
||||||
},
|
},
|
||||||
|
async fetchFilesByItem({state, commit, dispatch, getters}, {id}) {
|
||||||
|
const servers = await dispatch('getHomeServers')
|
||||||
|
return await servers.get(getters.signAuth, '/api/item_files/' + id + '/')
|
||||||
|
},
|
||||||
async pushFile({state, dispatch, getters}, {item_id, file}) {
|
async pushFile({state, dispatch, getters}, {item_id, file}) {
|
||||||
const servers = await dispatch('getHomeServers')
|
const servers = await dispatch('getHomeServers')
|
||||||
const data = await servers.post(getters.signAuth, '/api/item_files/' + item_id + '/', file)
|
const data = await servers.post(getters.signAuth, '/api/item_files/' + item_id + '/', file)
|
||||||
|
|
|
@ -32,6 +32,19 @@
|
||||||
<input type="text" class="form-control" id="image" name="image"
|
<input type="text" class="form-control" id="image" name="image"
|
||||||
placeholder="Enter image" v-model="item.image">
|
placeholder="Enter image" v-model="item.image">
|
||||||
</div-->
|
</div-->
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="image" class="form-label">Image</label>
|
||||||
|
<div>
|
||||||
|
<img v-for="file in files" :key="file.id" :alt="file.name"
|
||||||
|
:src="'https://toolshed.j3d1.de'+file.name" class="img-thumbnail border-info">
|
||||||
|
<!-- TODO replace dirty hack with proper solution -->
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<authenticated-image v-for="file in files" :key="file.id" :src="file.name"
|
||||||
|
:owner="file.owner"></authenticated-image>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- actions -->
|
<!-- actions -->
|
||||||
|
@ -59,14 +72,21 @@ import BaseLayout from "@/components/BaseLayout.vue";
|
||||||
import TagField from "@/components/TagField.vue";
|
import TagField from "@/components/TagField.vue";
|
||||||
import PropertyField from "@/components/PropertyField.vue";
|
import PropertyField from "@/components/PropertyField.vue";
|
||||||
import {mapActions, mapGetters} from "vuex";
|
import {mapActions, mapGetters} from "vuex";
|
||||||
|
import AuthenticatedImage from "@/components/AuthenticatedImage.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "InventoryDetail",
|
name: "InventoryDetail",
|
||||||
components: {
|
components: {
|
||||||
|
AuthenticatedImage,
|
||||||
PropertyField, TagField,
|
PropertyField, TagField,
|
||||||
BaseLayout,
|
BaseLayout,
|
||||||
...BIcons
|
...BIcons
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
files: []
|
||||||
|
}
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -80,14 +100,26 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(["fetchInventoryItems", "deleteInventoryItem"])
|
...mapActions(["fetchInventoryItems", "deleteInventoryItem", "fetchFilesByItem"]),
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
await this.fetchInventoryItems()
|
await this.fetchInventoryItems()
|
||||||
|
console.log(this.id, typeof this.id)
|
||||||
|
const files = await this.fetchFilesByItem({id: this.id})
|
||||||
|
this.files = files.map(file => {
|
||||||
|
return {
|
||||||
|
...file,
|
||||||
|
owner: this.item.owner
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
img {
|
||||||
|
width: 190px;
|
||||||
|
height: 107px;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
|
@ -23,7 +23,7 @@ export default defineConfig({
|
||||||
'Content-Security-Policy': 'default-src \'self\';'
|
'Content-Security-Policy': 'default-src \'self\';'
|
||||||
+ ' script-src \'self\' \'wasm-unsafe-eval\';'
|
+ ' script-src \'self\' \'wasm-unsafe-eval\';'
|
||||||
+ ' style-src \'self\' \'unsafe-inline\';'
|
+ ' style-src \'self\' \'unsafe-inline\';'
|
||||||
+ ' img-src \'self\' data:; '
|
+ ' img-src \'self\' * data:; '
|
||||||
+ ' connect-src * data:', // TODO: change * to https://* for production
|
+ ' connect-src * data:', // TODO: change * to https://* for production
|
||||||
},
|
},
|
||||||
/*https: {
|
/*https: {
|
||||||
|
|
Loading…
Reference in a new issue