2018-05-27 06:17:02 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div class="server-search animate fadein">
|
|
|
|
<input type="text" placeholder="search for servers..."
|
|
|
|
@input="onChange"
|
|
|
|
v-model="search"
|
|
|
|
ref="search"
|
|
|
|
/>
|
|
|
|
</div>
|
2018-05-28 22:04:41 +00:00
|
|
|
<transition-group class="w-full m-auto mt-4 animate fadein sm:flex flex-wrap content-start"><div class="server-box" :key="index" v-for="(server, index) in servers.models">
|
2018-05-28 20:23:40 +00:00
|
|
|
<router-link :to="{ name: 'server', params: { id: server.identifier }}" class="content">
|
2018-05-27 06:17:02 +00:00
|
|
|
<div class="float-right">
|
2018-05-28 18:34:24 +00:00
|
|
|
<div class="indicator"></div>
|
2018-05-27 06:17:02 +00:00
|
|
|
</div>
|
|
|
|
<div class="mb-4">
|
2018-05-28 18:34:24 +00:00
|
|
|
<div class="text-black font-bold text-xl">
|
|
|
|
{{ server.name }}
|
|
|
|
</div>
|
2018-05-27 06:17:02 +00:00
|
|
|
</div>
|
|
|
|
<div class="mb-0 flex">
|
|
|
|
<div class="usage">
|
|
|
|
<div class="indicator-title">CPU</div>
|
|
|
|
</div>
|
2018-05-27 22:37:03 +00:00
|
|
|
<div class="mb-4">
|
|
|
|
<div class="text-black font-bold text-xl">{{ server.name }}</div>
|
2018-05-27 06:17:02 +00:00
|
|
|
</div>
|
2018-05-27 22:37:03 +00:00
|
|
|
<div class="mb-0 flex">
|
|
|
|
<div class="usage">
|
|
|
|
<div class="indicator-title">CPU</div>
|
|
|
|
</div>
|
|
|
|
<div class="usage">
|
|
|
|
<div class="indicator-title">Memory</div>
|
|
|
|
</div>
|
2018-05-27 06:17:02 +00:00
|
|
|
</div>
|
2018-05-27 22:37:03 +00:00
|
|
|
<div class="mb-4 flex text-center">
|
|
|
|
<div class="inline-block border border-grey-lighter border-l-0 p-4 flex-1">
|
|
|
|
<span class="font-bold text-xl">---</span>
|
|
|
|
<span class="font-light text-sm">%</span>
|
|
|
|
</div>
|
|
|
|
<div class="inline-block border border-grey-lighter border-l-0 border-r-0 p-4 flex-1">
|
|
|
|
<span class="font-bold text-xl">---</span>
|
|
|
|
<span class="font-light text-sm">Mb</span>
|
|
|
|
</div>
|
2018-05-27 06:17:02 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="flex items-center">
|
|
|
|
<div class="text-sm">
|
2018-05-28 21:11:23 +00:00
|
|
|
<p class="text-grey">{{ server.node }}</p>
|
2018-05-27 06:17:02 +00:00
|
|
|
<p class="text-grey-dark">{{ server.allocation.ip }}:{{ server.allocation.port }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-05-28 18:34:24 +00:00
|
|
|
</router-link>
|
2018-05-27 06:17:02 +00:00
|
|
|
</div>
|
|
|
|
</transition-group>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-05-28 21:11:23 +00:00
|
|
|
import { ServerCollection } from '../../models/server';
|
2018-05-27 06:17:02 +00:00
|
|
|
import _ from 'lodash';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'dashboard',
|
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
search: '',
|
2018-05-28 21:11:23 +00:00
|
|
|
servers: new ServerCollection,
|
2018-05-27 06:17:02 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted: function () {
|
|
|
|
this.loadServers();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
/**
|
|
|
|
* Load the user's servers and render them onto the dashboard.
|
|
|
|
*
|
|
|
|
* @param {string} query
|
|
|
|
*/
|
|
|
|
loadServers: function (query = '') {
|
2018-05-28 20:23:40 +00:00
|
|
|
window.axios.get(this.route('api.client.index'), {
|
2018-05-27 06:17:02 +00:00
|
|
|
params: { query },
|
|
|
|
})
|
2018-05-28 21:11:23 +00:00
|
|
|
.then(response => {
|
|
|
|
this.servers = new ServerCollection;
|
|
|
|
response.data.data.forEach(obj => {
|
|
|
|
this.servers.add(obj.attributes);
|
2018-05-28 20:23:40 +00:00
|
|
|
});
|
2018-05-27 06:17:02 +00:00
|
|
|
})
|
2018-05-28 21:11:23 +00:00
|
|
|
.catch(error => {
|
2018-05-27 06:17:02 +00:00
|
|
|
console.error(error);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle a search for servers but only call the search function every 500ms
|
|
|
|
* at the fastest.
|
|
|
|
*/
|
|
|
|
onChange: _.debounce(function () {
|
|
|
|
this.loadServers(this.$data.search);
|
|
|
|
}, 500),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|