Browse Source

Add axios

Added axios and displaying the active devices to the side panel
main
Haris Razis 4 years ago
parent
commit
0fbd837515
No known key found for this signature in database GPG Key ID: 86A4D290ED03FAB4
  1. 21
      web/package-lock.json
  2. 1
      web/package.json
  3. 20
      web/src/components/Hero.vue
  4. 53
      web/src/components/Panel.vue

21
web/package-lock.json

@ -9,6 +9,7 @@
"version": "0.1.0",
"dependencies": {
"@influxdata/influxdb-client": "^1.8.0",
"axios": "^0.21.0",
"bulma": "^0.9.1",
"vue": "^3.0.0",
"vue-class-component": "^8.0.0-0"
@ -1677,6 +1678,14 @@
"integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==",
"dev": true
},
"node_modules/axios": {
"version": "0.21.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz",
"integrity": "sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==",
"dependencies": {
"follow-redirects": "^1.10.0"
}
},
"node_modules/babel-code-frame": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
@ -5254,7 +5263,6 @@
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz",
"integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==",
"dev": true,
"funding": [
{
"type": "individual",
@ -15855,6 +15863,14 @@
"integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==",
"dev": true
},
"axios": {
"version": "0.21.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz",
"integrity": "sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==",
"requires": {
"follow-redirects": "^1.10.0"
}
},
"babel-code-frame": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
@ -18773,8 +18789,7 @@
"follow-redirects": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz",
"integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==",
"dev": true
"integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA=="
},
"for-in": {
"version": "1.0.2",

1
web/package.json

@ -9,6 +9,7 @@
},
"dependencies": {
"@influxdata/influxdb-client": "^1.8.0",
"axios": "^0.21.0",
"bulma": "^0.9.1",
"vue": "^3.0.0",
"vue-class-component": "^8.0.0-0"

20
web/src/components/Hero.vue

@ -5,25 +5,7 @@
<h1 class="title">
Welcome to the admin panel for anchiale
</h1>
<h2 class="subtitle mt-3">
<div class="field is-grouped">
<p class="control">
<button class="button is-primary is-inverted">
Get clients
</button>
</p>
<p class="control">
<button class="button">
Cancel
</button>
</p>
<p class="control">
<button class="button is-danger">
Delete post
</button>
</p>
</div>
</h2>
<h2 class="subtitle mt-3"></h2>
</div>
</div>
</section>

53
web/src/components/Panel.vue

@ -3,12 +3,34 @@
<p class="panel-heading">
Devices
</p>
<a class="panel-block is-active">
<span class="panel-icon">
<i class="fab fa-raspberry-pi" />
</span>
bulma
</a>
<div class="panel-block">
<div class="field is-grouped">
<p class="control">
<button class="button is-success is-outlined " v-on:click="getClient">
Get clients
</button>
</p>
<p class="control">
<button class="button">
Cancel
</button>
</p>
</div>
</div>
<div v-if="hasClients">
<a class="panel-block " v-for="(client, index) in clients" :key="index">
<span class="panel-icon">
<i class="fab fa-raspberry-pi" />
</span>
{{ client }}
</a>
</div>
<div v-else>
<span class="panel-block">No clients yet!</span>
</div>
<div v-if="error">
<span class="panel-block">{{ error }}</span>
</div>
<div class="panel-block">
<button class="button is-link is-outlined is-fullwidth">
Reset all filters
@ -19,6 +41,23 @@
<script lang="ts">
import { Vue } from 'vue-class-component';
import axios from 'axios';
export default class Panel extends Vue {
private error = '';
private hasClients = false;
private clients: Array<string> = [];
export default class Panel extends Vue {}
getClient() {
axios
.get('http://localhost:3000/devices')
.then((response) => {
this.hasClients = true;
this.clients = response.data;
})
.catch((error) => {
this.error = error.message;
});
}
}
</script>

Loading…
Cancel
Save