Use the client API to load servers on the listing page

This commit is contained in:
Dane Everitt 2018-05-28 13:23:40 -07:00
parent ad69193ac0
commit 6e5c365018
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
8 changed files with 98 additions and 9 deletions

View file

@ -9,7 +9,7 @@
</div>
<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">
<router-link :to="{ name: 'server', params: { id: server.uuidShort }}" class="content">
<router-link :to="{ name: 'server', params: { id: server.identifier }}" class="content">
<div class="float-right">
<div class="indicator"></div>
</div>
@ -49,6 +49,7 @@
</template>
<script>
import Server from '../../models/server';
import _ from 'lodash';
export default {
@ -73,11 +74,14 @@
loadServers: function (query = '') {
const self = this;
window.axios.get(this.route('dashboard.servers'), {
window.axios.get(this.route('api.client.index'), {
params: { query },
})
.then(function (response) {
self.servers = response.data;
self.servers = [];
response.data.data.forEach(function (obj) {
self.servers.push(new Server().fill(obj.attributes))
});
})
.catch(function (error) {
console.error(error);