This commit is contained in:
j3d1 2023-05-31 22:44:22 +02:00
parent d288c70e6a
commit 5c073c3049
4 changed files with 39 additions and 15 deletions

View file

@ -1,12 +1,11 @@
<template> <template>
<li class="nav-item dropdown"> <li class="nav-item dropdown">
<a class="nav-icon dropdown-toggle" href="#" id="messagesDropdown" data-toggle="dropdown"> <a class="nav-icon dropdown-toggle" href="#" id="messagesDropdown" @click.prevent="toggleDropdown">
<div class="position-relative"> <div class="position-relative">
<b-icon-chat-left class="bi-valign-middle"></b-icon-chat-left> <b-icon-chat-left class="bi-valign-middle"></b-icon-chat-left>
</div> </div>
</a> </a>
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right py-0" <div :class="['dropdown-menu','dropdown-menu-right', 'dropdown-menu-lg','py-0', {'show': show_dropdown}]">
aria-labelledby="messagesDropdown">
<div class="dropdown-menu-header"> <div class="dropdown-menu-header">
<div class="position-relative"> <div class="position-relative">
4 New Messages 4 New Messages
@ -95,10 +94,20 @@ export default {
default: () => [] default: () => []
} }
}, },
data() {
return {
show_dropdown: false
}
},
computed: { computed: {
top_messages() { top_messages() {
return this.messages.slice(0, 4); return this.messages.slice(0, 4);
} }
},
methods: {
toggleDropdown() {
this.show_dropdown = !this.show_dropdown;
}
} }
} }
</script> </script>

View file

@ -1,6 +1,6 @@
<template> <template>
<li class="nav-item dropdown"> <li class="nav-item dropdown">
<a class="nav-icon dropdown-toggle" href="#" id="alertsDropdown" data-toggle="dropdown"> <a class="nav-icon dropdown-toggle" href="#" id="alertsDropdown" @click.prevent="toggleDropdown">
<div class="position-relative"> <div class="position-relative">
<b-icon-bell class="bi-valign-middle"></b-icon-bell> <b-icon-bell class="bi-valign-middle"></b-icon-bell>
<span :class="['indicator', notificationsColor(top_notifications)]">{{ <span :class="['indicator', notificationsColor(top_notifications)]">{{
@ -8,8 +8,7 @@
}}</span> }}</span>
</div> </div>
</a> </a>
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right py-0" <div :class="['dropdown-menu','dropdown-menu-right', 'dropdown-menu-lg','py-0', {'show': show_dropdown}]">
aria-labelledby="alertsDropdown">
<div class="dropdown-menu-header"> <div class="dropdown-menu-header">
{{ top_notifications.length }} New Notifications {{ top_notifications.length }} New Notifications
</div> </div>
@ -61,6 +60,11 @@ export default {
default: () => [] default: () => []
} }
}, },
data() {
return {
show_dropdown: false
}
},
computed: { computed: {
top_notifications() { top_notifications() {
return this.notifications.sort((a, b) => { return this.notifications.sort((a, b) => {
@ -84,6 +88,9 @@ export default {
return 'bg-warning'; return 'bg-warning';
} }
return 'bg-primary'; return 'bg-primary';
},
toggleDropdown() {
this.show_dropdown = !this.show_dropdown
} }
}, },
async mounted() { async mounted() {

View file

@ -7,7 +7,7 @@
</a> </a>
<a class="nav-link dropdown-toggle d-none d-sm-inline-block" href="#" <a class="nav-link dropdown-toggle d-none d-sm-inline-block" href="#"
data-toggle="dropdown"> @click.prevent="toggleDropdown">
<img src="/assets/img/avatars/avatar.png" class="avatar img-fluid rounded mr-1" <img src="/assets/img/avatars/avatar.png" class="avatar img-fluid rounded mr-1"
alt="Charles Hall"/> alt="Charles Hall"/>
<span class="text-dark"> <span class="text-dark">
@ -15,7 +15,7 @@
</span> </span>
</a> </a>
<div class="dropdown-menu dropdown-menu-right"> <div :class="['dropdown-menu','dropdown-menu-right', {'show': show_dropdown}]">
<router-link to="/profile" class="dropdown-item"> <router-link to="/profile" class="dropdown-item">
<b-icon-person class="bi-valign-middle mr-1"></b-icon-person> <b-icon-person class="bi-valign-middle mr-1"></b-icon-person>
Profile Profile
@ -40,8 +40,16 @@ export default {
components: { components: {
...BIcons ...BIcons
}, },
data() {
return {
show_dropdown: false
}
},
methods: { methods: {
...mapMutations(['logout']) ...mapMutations(['logout']),
toggleDropdown() {
this.show_dropdown = !this.show_dropdown
}
}, },
computed: { computed: {
username() { username() {

View file

@ -143,18 +143,18 @@ export default createStore({
commit('setHomeServers', promise) commit('setHomeServers', promise)
return promise return promise
}, },
async getAllFriendsServers({state, dispatch, commit}) { async getAllKnownServers({state, dispatch, commit}) {
const friends = await dispatch('fetchFriends') const friends = await dispatch('fetchFriends')
if (state.all_friends_servers) if (state.all_friends_servers)
return state.all_friends_servers return state.all_friends_servers
const promise = (async () => { const promise = (async () => {
const servers = new ServerSetUnion([]) const servers = new ServerSetUnion([])
const home = await dispatch('getHomeServers')
servers.add(home)
for (const friend of friends) { for (const friend of friends) {
const s = await dispatch('lookupServer', {username: friend.username}) const s = await dispatch('lookupServer', {username: friend.username})
servers.add(new ServerSet(s, state.unreachable_neighbors)) servers.add(new ServerSet(s, state.unreachable_neighbors))
} }
const home = await dispatch('getHomeServers')
servers.add(home)
return servers return servers
})() })()
commit('setAllFriendsServers', promise) commit('setAllFriendsServers', promise)
@ -170,7 +170,7 @@ export default createStore({
return items return items
}, },
async searchInventories({state, dispatch, getters}, {query}) { async searchInventories({state, dispatch, getters}, {query}) {
const servers = await dispatch('getAllFriendsServers') const servers = await dispatch('getAllKnownServers')
return await servers.get(getters.signAuth, '/api/inventory/search/?q=' + query) return await servers.get(getters.signAuth, '/api/inventory/search/?q=' + query)
}, },
async createInventoryItem({state, dispatch, getters}, item) { async createInventoryItem({state, dispatch, getters}, item) {
@ -190,7 +190,7 @@ export default createStore({
return ret return ret
}, },
async fetchSearchResults({state, dispatch, getters}, {query}) { async fetchSearchResults({state, dispatch, getters}, {query}) {
const servers = await dispatch('getAllFriendsServers') const servers = await dispatch('getAllKnownServers')
return await servers.get(getters.signAuth, '/api/search/?query=' + query) return await servers.get(getters.signAuth, '/api/search/?query=' + query)
}, },
async fetchFriends({commit, dispatch, getters, state}) { async fetchFriends({commit, dispatch, getters, state}) {