2018-06-03 07:15:10 +01:00
|
|
|
<template>
|
2018-09-12 05:25:02 +01:00
|
|
|
<div class="nav flex">
|
|
|
|
<div class="logo flex-1">
|
2018-06-03 07:15:10 +01:00
|
|
|
<router-link :to="{ name: 'dashboard' }">
|
|
|
|
Pterodactyl
|
|
|
|
</router-link>
|
|
|
|
</div>
|
2018-09-12 05:25:02 +01:00
|
|
|
<div class="search-box flex-none" v-if="$route.name !== 'dashboard'">
|
|
|
|
<input type="text" class="search-input" id="searchInput" placeholder="Search..."
|
2018-09-12 05:32:01 +01:00
|
|
|
:class="{ 'has-search-results': (servers.length > 0 || loadingResults) && searchActive }"
|
2018-09-12 05:25:02 +01:00
|
|
|
v-on:focus="searchActive = true"
|
|
|
|
v-on:blur="searchActive = false"
|
|
|
|
v-on:input="search"
|
|
|
|
v-model="searchTerm"
|
|
|
|
/>
|
2018-09-12 05:32:01 +01:00
|
|
|
<div class="search-results select-none" :class="{ 'hidden': (servers.length === 0 && !loadingResults) || !searchActive }">
|
|
|
|
<div v-if="loadingResults">
|
|
|
|
<a href="#">
|
|
|
|
<div class="flex items-center">
|
|
|
|
<div class="flex-1">
|
|
|
|
<span class="text-sm text-grey-darker">Loading...</span>
|
|
|
|
</div>
|
|
|
|
<div class="flex-none">
|
|
|
|
<span class="spinner spinner-relative"></span>
|
|
|
|
</div>
|
2018-09-12 05:25:02 +01:00
|
|
|
</div>
|
2018-09-12 05:32:01 +01:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
|
|
|
<router-link
|
|
|
|
v-for="server in servers"
|
|
|
|
:key="server.identifier"
|
|
|
|
:to="{ name: 'server', params: { id: server.identifier } }"
|
|
|
|
>
|
|
|
|
<div class="flex items-center">
|
|
|
|
<div class="flex-1">
|
|
|
|
<span class="font-bold text-grey-darkest">{{ server.name }}</span><br />
|
|
|
|
<span class="font-light text-grey-dark text-sm" v-if="server.description.length > 0">{{ server.description }}</span>
|
|
|
|
</div>
|
|
|
|
<div class="flex-none">
|
|
|
|
<span class="pillbox bg-indigo">{{ server.node }}</span>
|
|
|
|
</div>
|
2018-09-12 05:25:02 +01:00
|
|
|
</div>
|
2018-09-12 05:32:01 +01:00
|
|
|
</router-link>
|
|
|
|
</div>
|
2018-09-12 05:25:02 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="menu flex-none">
|
2018-06-03 07:15:10 +01:00
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<router-link :to="{ name: 'dashboard' }">
|
2018-06-17 01:05:06 +01:00
|
|
|
<server-icon aria-label="Server dashboard" class="h-4"/>
|
2018-06-03 07:15:10 +01:00
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<router-link :to="{ name: 'account' }">
|
2018-06-17 01:05:06 +01:00
|
|
|
<user-icon aria-label="Profile management" class="h-4"/>
|
2018-06-03 07:15:10 +01:00
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a :href="this.route('admin.index')">
|
2018-06-17 01:05:06 +01:00
|
|
|
<settings-icon aria-label="Administrative controls" class="h-4"/>
|
2018-06-03 07:15:10 +01:00
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
2018-06-16 22:30:20 +01:00
|
|
|
<a :href="this.route('auth.logout')" v-on:click.prevent="doLogout">
|
2018-06-17 01:05:06 +01:00
|
|
|
<log-out-icon aria-label="Sign out" class="h-4"/>
|
2018-06-03 07:15:10 +01:00
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-09-12 05:25:02 +01:00
|
|
|
import debounce from 'lodash/debounce';
|
|
|
|
import { mapState } from 'vuex';
|
2018-06-03 07:15:10 +01:00
|
|
|
import { LogOutIcon, ServerIcon, SettingsIcon, UserIcon } from 'vue-feather-icons'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'navigation',
|
2018-06-16 22:30:20 +01:00
|
|
|
components: { LogOutIcon, ServerIcon, SettingsIcon, UserIcon },
|
2018-09-12 05:25:02 +01:00
|
|
|
|
|
|
|
data: function () {
|
|
|
|
return {
|
2018-09-12 05:32:01 +01:00
|
|
|
loadingResults: false,
|
2018-09-12 05:25:02 +01:00
|
|
|
searchActive: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
...mapState('dashboard', ['servers']),
|
|
|
|
searchTerm: {
|
|
|
|
get: function () {
|
|
|
|
return this.$store.getters['dashboard/getSearchTerm'];
|
|
|
|
},
|
|
|
|
set: function (value) {
|
|
|
|
this.$store.dispatch('dashboard/setSearchTerm', value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-06-16 22:30:20 +01:00
|
|
|
methods: {
|
2018-09-12 05:25:02 +01:00
|
|
|
search: debounce(function () {
|
|
|
|
if (this.searchTerm.length > 3) {
|
2018-09-12 05:32:01 +01:00
|
|
|
this.loadingResults = true;
|
2018-09-12 05:25:02 +01:00
|
|
|
this.gatherSearchResults(this.searchTerm);
|
|
|
|
}
|
|
|
|
}, 500),
|
|
|
|
|
|
|
|
gatherSearchResults: function () {
|
|
|
|
this.$store.dispatch('dashboard/loadServers')
|
|
|
|
.then(() => {
|
|
|
|
if (this.servers.length === 0) {
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.error(err);
|
|
|
|
const response = err.response;
|
|
|
|
if (response.data && isObject(response.data.errors)) {
|
|
|
|
response.data.errors.forEach(error => {
|
|
|
|
this.error(error.detail);
|
|
|
|
});
|
|
|
|
}
|
2018-09-12 05:32:01 +01:00
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
this.loadingResults = false;
|
2018-09-12 05:25:02 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-06-16 22:30:20 +01:00
|
|
|
doLogout: function () {
|
|
|
|
this.$store.commit('auth/logout');
|
|
|
|
return window.location = this.route('auth.logout');
|
|
|
|
},
|
|
|
|
}
|
2018-06-03 07:15:10 +01:00
|
|
|
};
|
|
|
|
</script>
|