stash
This commit is contained in:
parent
21cb4018a3
commit
06f7c515ef
4 changed files with 237 additions and 83 deletions
|
|
@ -78,7 +78,8 @@
|
|||
<tr v-for="request in requests" :key="request.befriender">
|
||||
<td>{{ request.befriender }}</td>
|
||||
<td class="d-none d-md-table-cell">
|
||||
{{ request.befriender_public_key.slice(0,32) }}...</td>
|
||||
{{ request.befriender_public_key.slice(0, 32) }}...
|
||||
</td>
|
||||
<td class="table-action">
|
||||
<button class="btn btn-sm btn-success" @click="tryAcceptFriend(request)">
|
||||
<b-icon-check></b-icon-check>
|
||||
|
|
@ -128,11 +129,11 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['getFriends', "getFriendServer", "requestFriend", "acceptFriend", "fetchFriendRequests", "declineFriend"]),
|
||||
...mapActions(['fetchFriends', "lookupServer", "requestFriend", "acceptFriend", "fetchFriendRequests", "declineFriend"]),
|
||||
fetchContent() {
|
||||
this.getFriends().then((friends) => {
|
||||
this.fetchFriends().then((friends) => {
|
||||
friends.map((friend) => {
|
||||
this.getFriendServer(friend).then((server) => {
|
||||
this.lookupServer(friend).then((server) => {
|
||||
this.friends[friend.username] = {...friend, server: server}
|
||||
})
|
||||
})
|
||||
|
|
@ -151,21 +152,24 @@ export default {
|
|||
this.newfriend = ""
|
||||
this.fetchContent()
|
||||
}
|
||||
}).catch(() => {})
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
tryAcceptFriend(request) {
|
||||
this.acceptFriend({id: request.id, secret: request.secret, befriender: request.befriender}).then((ok) => {
|
||||
if (ok) {
|
||||
this.fetchContent()
|
||||
}
|
||||
}).catch(() => {})
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
tryRejectFriend(friend) {
|
||||
this.declineFriend({username: friend}).then((ok) => {
|
||||
if (ok) {
|
||||
this.fetchContent()
|
||||
}
|
||||
}).catch(() => {})
|
||||
}).catch(() => {
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
</table>
|
||||
</div>
|
||||
<div class="card">
|
||||
<button class="btn" @click="getInventoryItems">Refresh</button>
|
||||
<button class="btn" @click="fetchInventoryItems">Refresh</button>
|
||||
<router-link to="/inventory/new" class="btn btn-primary">Add</router-link>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -67,25 +67,10 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["apiFederatedGet", "getFriends", "getFriendServer"]),
|
||||
...mapMutations(["setInventoryItems"]),
|
||||
async getInventoryItems() {
|
||||
try {
|
||||
const servers = await this.getFriends().then(friends => friends.map(friend => this.getFriendServer({username: friend})))
|
||||
const urls = servers.map(server => server.then(s => {
|
||||
return {host: s, target: "/api/inventory_items/"}
|
||||
}))
|
||||
urls.map(url => url.then(u => this.apiFederatedGet(u).then(items => {
|
||||
this.setInventoryItems({url: u.domain, items})
|
||||
}).catch(e => {
|
||||
}))) // TODO: handle error
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
...mapActions(["fetchInventoryItems"]),
|
||||
},
|
||||
async mounted() {
|
||||
await this.getInventoryItems()
|
||||
await this.fetchInventoryItems()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue