Skip to content
Snippets Groups Projects
Commit 92ca1527 authored by Pierre-Jean CHANCELLIER's avatar Pierre-Jean CHANCELLIER
Browse files

Gestion des erreurs et intégration d'Appolo

parent c6de4197
No related branches found
No related tags found
No related merge requests found
<template> <template>
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary" :disabled="isWaiting">
<span v-if="isWaiting"> <span v-if="isWaiting">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
Chargement... Chargement...
......
...@@ -19,13 +19,12 @@ export default { ...@@ -19,13 +19,12 @@ export default {
data() { data() {
return { return {
menus : [ menus : [
{title: 'Un menu', {title: 'Développement',
items : [ items : [
{path: '/explore',title: 'Explorer la toile de confiance'}, {path: '/explore',title: 'Explorer la toile de confiance'},
{path: '/test',title: 'Test'}, {path: '/appolo',title: 'Appolo'}
{path: '/coucou',title: 'Coucou'}
]}, ]},
{title: 'Un autre menu', {title: 'Pages',
items : [ items : [
{path: '/hoho',title: 'Hoho'}, {path: '/hoho',title: 'Hoho'},
{path: '/hihi',title: 'Hihi'}, {path: '/hihi',title: 'Hihi'},
......
...@@ -13,6 +13,8 @@ export default { ...@@ -13,6 +13,8 @@ export default {
WWZ_REQUEST_DETAILS(hint) { return `{idSearch(with:{hint:\\"${hint}\\"}){ids{pubkey,uid,status}}}` }, WWZ_REQUEST_DETAILS(hint) { return `{idSearch(with:{hint:\\"${hint}\\"}){ids{pubkey,uid,status}}}` },
}, },
async fetch() { async fetch() {
this.isWaiting = true
this.retour = await fetch(this.WWZ_URL, { this.retour = await fetch(this.WWZ_URL, {
method: 'POST', method: 'POST',
headers: { headers: {
...@@ -20,17 +22,16 @@ export default { ...@@ -20,17 +22,16 @@ export default {
}, },
body: '{"query":"' + this.query + '"}' body: '{"query":"' + this.query + '"}'
}).then((res) => { }).then((res) => {
// console.log(this.query) this.isWaiting = false
return res.json() return res.json()
}).catch((error) => {
this.isWaiting = false
return {errors: error}
}) })
}, },
watch: { watch: {
query : function() { query : function() {
this.isWaiting = true
this.$fetch() this.$fetch()
},
retour : function() {
this.isWaiting = false
} }
} }
} }
\ No newline at end of file
...@@ -39,15 +39,24 @@ export default { ...@@ -39,15 +39,24 @@ export default {
modules: [ modules: [
// https://go.nuxtjs.dev/pwa // https://go.nuxtjs.dev/pwa
'@nuxtjs/pwa', '@nuxtjs/pwa',
'@nuxtjs/apollo',
], ],
// PWA module configuration: https://go.nuxtjs.dev/pwa // PWA module configuration: https://go.nuxtjs.dev/pwa
pwa: { pwa: {
manifest: { manifest: {
lang: 'en' lang: 'fr'
} }
}, },
apollo: {
clientConfigs: {
default: {
httpEndpoint: 'https://wwgql.coinduf.eu',
},
},
},
// Build Configuration: https://go.nuxtjs.dev/config-build // Build Configuration: https://go.nuxtjs.dev/config-build
build: { build: {
} }
......
This diff is collapsed.
...@@ -9,9 +9,11 @@ ...@@ -9,9 +9,11 @@
"generate": "nuxt generate" "generate": "nuxt generate"
}, },
"dependencies": { "dependencies": {
"@nuxtjs/apollo": "^4.0.1-rc.5",
"@nuxtjs/pwa": "^3.3.5", "@nuxtjs/pwa": "^3.3.5",
"bootstrap": "^4.6.0", "bootstrap": "^4.6.0",
"core-js": "^3.15.1", "core-js": "^3.15.1",
"graphql-tag": "^2.12.6",
"nuxt": "^2.15.7" "nuxt": "^2.15.7"
}, },
"devDependencies": { "devDependencies": {
......
<template>
<main class="content">
<h2 class="display-2 text-center mb-5">Test Appolo</h2>
<div class="row">
<div class="col-6 m-auto text-center">
Hello Appolo
<ApolloQuery :query="query">
<!-- The result will automatically updated -->
<template slot-scope="{ result: { data, loading } }">
<!-- Some content -->
<div v-if="loading">Loading...</div>
<p v-else>
{{ data }}
</p>
</template>
</ApolloQuery>
</div>
</div>
</main>
</template>
<script>
import gql from 'graphql-tag'
export default {
data() {
return {
// Fil d'ariane
breadcrumb: [
{
text: 'Accueil',
to: '/'
},
{
text: 'Appolo',
active: true
}
],
query: gql`{version}`
}
},
methods: {
// Fonctions locales
},
mounted () {
// Mise à jour du fil d'ariane au chargement
$nuxt.$emit('changeRoute',this.breadcrumb)
}
}
</script>
<style lang="sass" scoped>
</style>
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<form @submit.prevent="refresh" class="mb-5"> <form @submit.prevent="refresh" class="mb-5">
<div class="mb-3"> <div class="mb-3">
<label for="rech" class="form-label">Votre recherche</label> <label for="rech" class="form-label">Votre recherche</label>
<input type="text" class="form-control" id="rech" aria-describedby="rechHelp"> <input type="text" class="form-control" id="rech" aria-describedby="rechHelp" v-model="search">
<small id="rechHelp" class="form-text text-muted">Saisissez le début d'un pseudo ou d'une clé publique</small> <small id="rechHelp" class="form-text text-muted">Saisissez le début d'un pseudo ou d'une clé publique</small>
</div> </div>
<btnloading :isWaiting="isWaiting"/> <btnloading :isWaiting="isWaiting"/>
...@@ -62,14 +62,13 @@ export default { ...@@ -62,14 +62,13 @@ export default {
text: 'Explorer la wot', text: 'Explorer la wot',
active: true active: true
} }
] ],
search : ""
} }
}, },
methods: { methods: {
refresh() { refresh() {
let rech = document.querySelector('#rech').value this.query = this.WWZ_REQUEST_DETAILS(this.search)
rech = this.WWZ_REQUEST_DETAILS(rech)
this.query = rech
} }
}, },
mounted () { mounted () {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment