feat: add axios and first request

This commit is contained in:
Michel Roux 2024-11-03 18:54:42 +01:00
parent 5aafe1dade
commit 19782c0a10
8 changed files with 231 additions and 29 deletions

View File

@ -1,42 +1,21 @@
<template>
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item" href="/">
<span class="icon-text">
<span class="icon">
<i class="fa fa-paper-plane"></i>
</span>
<span>Pilotwings</span>
</span>
</a>
</div>
<div class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item" :href="`${$api}/docs`">
<span class="icon-text">
<span class="icon">
<i class="fa fa-book"></i>
</span>
<span>API Documentation</span>
</span>
</a>
</div>
</div>
</nav>
<Navbar />
<section class="section">
<div class="container">
<Breadcrumb />
<RouterView />
</div>
</section>
</template>
<script lang="ts">
import Breadcrumb from './components/Breadcrumb.vue'
import Navbar from './components/Navbar.vue'
import { RouterView } from 'vue-router'
export default {
name: 'App',
components: {
Breadcrumb,
Navbar,
RouterView,
},
}

View File

@ -0,0 +1,22 @@
<template>
<nav class="breadcrumb" aria-label="breadcrumbs">
<ul>
<li class="is-active">
<router-link to="/">
<span class="icon-text">
<span class="icon">
<i class="fa fa-home"></i>
</span>
<span>Home</span>
</span>
</router-link>
</li>
</ul>
</nav>
</template>
<script lang="ts">
export default {
name: 'Breadcrumb',
}
</script>

View File

@ -0,0 +1,17 @@
<template>
<div :class="loading ? 'skeleton-block' : ''">
<slot />
</div>
</template>
<script lang="ts">
export default {
name: 'Loading',
props: {
loading: {
type: Boolean,
default: true,
},
},
}
</script>

View File

@ -0,0 +1,19 @@
<template>
<article :class="`message is-${type}`">
<div class="message-body">
<slot />
</div>
</article>
</template>
<script lang="ts">
export default {
name: 'Message',
props: {
type: {
type: String,
required: true,
},
},
}
</script>

View File

@ -0,0 +1,32 @@
<template>
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item" href="/">
<span class="icon-text">
<span class="icon">
<i class="fa fa-paper-plane"></i>
</span>
<span>Pilotwings</span>
</span>
</a>
</div>
<div class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item" :href="`${$api}/docs`">
<span class="icon-text">
<span class="icon">
<i class="fa fa-book"></i>
</span>
<span>API Documentation</span>
</span>
</a>
</div>
</div>
</nav>
</template>
<script lang="ts">
export default {
name: 'Navbar',
}
</script>

View File

@ -1,9 +1,41 @@
<template>
<main>{{ 'oui' }}</main>
<Loading class="container" :loading="loading">
<Message v-if="error" type="danger">Error loading containers</Message>
<ul v-if="!loading && !error">
<li v-for="container in containers" :key="container.name">
{{ container.name }}
</li>
</ul>
</Loading>
</template>
<script lang="ts">
import Loading from '@/components/Loading.vue'
import Message from '@/components/Message.vue'
import axios from 'axios'
export default {
name: 'Containers',
components: {
Loading,
Message,
},
data() {
return {
containers: [],
error: false,
loading: true,
}
},
async mounted() {
try {
this.containers = await axios.get(`${this.$api}/api/containers`)
} catch (error) {
console.error(error)
this.error = true
} finally {
this.loading = false
}
},
}
</script>

100
package-lock.json generated
View File

@ -8,6 +8,7 @@
"name": "frontend",
"version": "0.0.0",
"dependencies": {
"axios": "^1.7.7",
"bulma": "^1.0.2",
"font-awesome": "^4.7.0",
"vue": "^3.5.12",
@ -1515,6 +1516,23 @@
"dev": true,
"license": "Python-2.0"
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
"license": "MIT"
},
"node_modules/axios": {
"version": "1.7.7",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz",
"integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@ -1605,6 +1623,18 @@
"dev": true,
"license": "MIT"
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"license": "MIT",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@ -1678,6 +1708,15 @@
"dev": true,
"license": "MIT"
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"license": "MIT",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/entities": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
@ -2168,6 +2207,26 @@
"dev": true,
"license": "ISC"
},
"node_modules/follow-redirects": {
"version": "1.15.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"license": "MIT",
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/font-awesome": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/font-awesome/-/font-awesome-4.7.0.tgz",
@ -2177,6 +2236,20 @@
"node": ">=0.10.3"
}
},
"node_modules/form-data": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz",
"integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==",
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@ -2443,6 +2516,27 @@
"node": ">=8.6"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/minimatch": {
"version": "9.0.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
@ -2701,6 +2795,12 @@
"node": ">=6.0.0"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
"license": "MIT"
},
"node_modules/punycode": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",

View File

@ -11,6 +11,7 @@
"lint": "eslint . --fix"
},
"dependencies": {
"axios": "^1.7.7",
"bulma": "^1.0.2",
"font-awesome": "^4.7.0",
"vue": "^3.5.12",