|
@ -7,34 +7,41 @@ |
|
|
<div class="field is-grouped"> |
|
|
<div class="field is-grouped"> |
|
|
<p class="control"> |
|
|
<p class="control"> |
|
|
<button class="button is-success is-outlined " v-on:click="getClient"> |
|
|
<button class="button is-success is-outlined " v-on:click="getClient"> |
|
|
Get clients |
|
|
Fetch clients |
|
|
</button> |
|
|
</button> |
|
|
</p> |
|
|
</p> |
|
|
<p class="control"> |
|
|
<p class="control"> |
|
|
<button class="button"> |
|
|
<button class="button is-outlined" v-on:click="clearClient"> |
|
|
Cancel |
|
|
Clear |
|
|
|
|
|
</button> |
|
|
|
|
|
</p> |
|
|
|
|
|
<p class="control"> |
|
|
|
|
|
<button class="button is-danger is-outlined" v-on:click="resetSocket"> |
|
|
|
|
|
Close server socket |
|
|
</button> |
|
|
</button> |
|
|
</p> |
|
|
</p> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div v-if="hasClients"> |
|
|
<div v-if="hasClients"> |
|
|
<a class="panel-block " v-for="(client, index) in clients" :key="index"> |
|
|
<div class="mx-4 py-2" v-for="(client, index) in clients" :key="index"> |
|
|
<span class="panel-icon"> |
|
|
<nav class="level"> |
|
|
<i class="fab fa-raspberry-pi" /> |
|
|
<div class="level-left"> |
|
|
</span> |
|
|
<span class="icon is-medium"> |
|
|
{{ client }} |
|
|
<i class="fab fa-raspberry-pi" /> |
|
|
</a> |
|
|
</span> |
|
|
</div> |
|
|
_id: {{ client }} |
|
|
<div v-else> |
|
|
</div> |
|
|
<span class="panel-block">No clients yet!</span> |
|
|
<div class="level-right"> |
|
|
|
|
|
<a class="delete" v-on:Click="deleteClient(index)"></a> |
|
|
|
|
|
</div> |
|
|
|
|
|
</nav> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div v-if="error"> |
|
|
<div v-else-if="error"> |
|
|
<span class="panel-block">{{ error }}</span> |
|
|
<span class="panel-block">{{ error }}</span> |
|
|
</div> |
|
|
</div> |
|
|
<div class="panel-block"> |
|
|
<div v-else> |
|
|
<button class="button is-link is-outlined is-fullwidth"> |
|
|
<span class="panel-block">No clients yet, try fetching!</span> |
|
|
Reset all filters |
|
|
|
|
|
</button> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</nav> |
|
|
</nav> |
|
|
</template> |
|
|
</template> |
|
@ -50,7 +57,7 @@ export default class Panel extends Vue { |
|
|
|
|
|
|
|
|
getClient() { |
|
|
getClient() { |
|
|
axios |
|
|
axios |
|
|
.get('http://localhost:3000/devices') |
|
|
.get(`${process.env.VUE_APP_SERVER_URL}/devices`) |
|
|
.then((response) => { |
|
|
.then((response) => { |
|
|
this.hasClients = true; |
|
|
this.hasClients = true; |
|
|
this.clients = response.data; |
|
|
this.clients = response.data; |
|
@ -59,5 +66,37 @@ export default class Panel extends Vue { |
|
|
this.error = error.message; |
|
|
this.error = error.message; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
clearClient() { |
|
|
|
|
|
this.hasClients = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
deleteClient(key: number) { |
|
|
|
|
|
axios |
|
|
|
|
|
.post(`${process.env.VUE_APP_SERVER_URL}/devices`, { |
|
|
|
|
|
device: this.clients[key], |
|
|
|
|
|
}) |
|
|
|
|
|
.then((res) => { |
|
|
|
|
|
if (res.data === 'done') { |
|
|
|
|
|
this.getClient(); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((error) => { |
|
|
|
|
|
console.log(error); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
resetSocket() { |
|
|
|
|
|
axios |
|
|
|
|
|
.post(`${process.env.VUE_APP_SERVER_URL}/socket`, { |
|
|
|
|
|
action: 'close', |
|
|
|
|
|
}) |
|
|
|
|
|
.then((res) => { |
|
|
|
|
|
this.hasClients = false; |
|
|
|
|
|
}) |
|
|
|
|
|
.catch((error) => { |
|
|
|
|
|
console.log(error); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|