diff --git a/README.md b/README.md index 99e60823b0dce2e75150f0d0baba277f120ebb9d..5f4ef4934b1d934de9bd3e0c0f52963e587de735 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ The schema documentation is stored in the `./graphql/doc/graphQLschema.txt` file In `queries.js` you'll find all queries. -If you want to add a 2nd graphQL server, edit `./graphql/clients/endpoints.js` to put your URL and uncomment the line concerning the `apollo.clientConfigs.myotherclient` option in `nuxt.config.js`. I have not tested this functionnality. +If you want to add a 2nd graphQL server, edit `./graphql/endpoints.js` to put your URL. ### Special Directories diff --git a/assets/css/_bootstrap.scss b/assets/css/_bootstrap.scss index 46f8b766818acec840e3d82fa21fdad6ec0f58c6..826ad6053365e179488a1fa9cecf47c828ba1d6d 100644 --- a/assets/css/_bootstrap.scss +++ b/assets/css/_bootstrap.scss @@ -28,7 +28,7 @@ @import "~bootstrap/scss/forms/form-select"; @import "~bootstrap/scss/forms/form-check"; // @import "~bootstrap/scss/forms/form-range"; -// @import "~bootstrap/scss/forms/floating-labels"; +@import "~bootstrap/scss/forms/floating-labels"; @import "~bootstrap/scss/forms/input-group"; // @import "~bootstrap/scss/forms/validation"; diff --git a/components/apollo/List.vue b/components/apollo/List.vue new file mode 100644 index 0000000000000000000000000000000000000000..40c5003336b86d0cd46c1287742482c7a98363c7 --- /dev/null +++ b/components/apollo/List.vue @@ -0,0 +1,38 @@ +<template> + <div class="form-floating"> + <select + class="form-select" + id="selectClient" + @change="setClient($event)" + v-model="currentClient"> + <option + :value="clientName" + v-for="(clientObject, clientName) in $nuxt.$apolloProvider.clients" + :key="clientName"> + {{ + clientName + .split(/(?=[A-Z])/) + .map((s) => s.toLowerCase()) + .join(".") + }} + </option> + </select> + <label for="selectClient">{{ $t("wotwizard.nodeselect") }}</label> + </div> +</template> + +<script> +export default { + data() { + return { + currentClient: this.$getApolloClient() + } + }, + methods: { + setClient(e) { + localStorage.setItem("apollo-client", e.target.value) + location.reload() + } + } +} +</script> diff --git a/components/navigation/menu/Sidebar.vue b/components/navigation/menu/Sidebar.vue index 90b3117fe7d65099dff962cd4f62718f540c71dd..df54c05c457765907826e2a2e857183ae156a422 100644 --- a/components/navigation/menu/Sidebar.vue +++ b/components/navigation/menu/Sidebar.vue @@ -16,6 +16,7 @@ </div> </nuxt-link> <div class="p-3 border-bottom border-2 text-muted"> + <ApolloList /> <div class="small mt-2">API graphQL v{{ version }}</div> <div class="small" v-if="countMax"> {{ $t("bloc.title") }} n°<span class="font-weight-bold">{{ @@ -78,6 +79,9 @@ export default { } }, apollo: { + $client() { + return this.$getApolloClient() + }, countMax: { query: LAST_BLOCK }, diff --git a/graphql/cache.js b/graphql/cache.js index 435b8921d707b8e77b356b2582f815f8ab8b3c95..80866f311f46ee3dc6d9df7ce14b931e4c65baa3 100644 --- a/graphql/cache.js +++ b/graphql/cache.js @@ -1,5 +1,4 @@ import { - InMemoryCache, IntrospectionFragmentMatcher, defaultDataIdFromObject } from "apollo-cache-inmemory" @@ -10,7 +9,7 @@ const fragmentMatcher = new IntrospectionFragmentMatcher({ }) // Apparemment il faut utiliser la syntaxe Apollo v2 -export const cache = new InMemoryCache({ +export const cache = { addTypename: false, fragmentMatcher, dataIdFromObject: (object) => { @@ -35,4 +34,4 @@ export const cache = new InMemoryCache({ return defaultDataIdFromObject(object) // fall back to default handling } } -}) +} diff --git a/graphql/clients/coindufeu.js b/graphql/clients/coindufeu.js deleted file mode 100644 index defa9024c6a36a07ac2131e08231b0eb8821409c..0000000000000000000000000000000000000000 --- a/graphql/clients/coindufeu.js +++ /dev/null @@ -1,28 +0,0 @@ -import { HttpLink } from 'apollo-link-http' -import { setContext } from 'apollo-link-context' -import { from } from 'apollo-link' - -import { ENDPOINT1 } from './endpoints' -import { cache } from '../cache' - -export default ctx => { - const ssrMiddleware = setContext((_, { headers }) => { - if (process.client) return headers - return { - headers - } - }) - - const httpLink = new HttpLink({ - uri: ENDPOINT1 - }) - - const link = from([ssrMiddleware, httpLink]) - - return { - link, - cache, - // https://github.com/nuxt-community/apollo-module/issues/306#issuecomment-607225431 - defaultHttpLink: false - } -} \ No newline at end of file diff --git a/graphql/clients/endpoints.js b/graphql/clients/endpoints.js deleted file mode 100644 index c3fb96a02dbafff165f1de59391b3bb1a2ed89ac..0000000000000000000000000000000000000000 --- a/graphql/clients/endpoints.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - ENDPOINT1: 'https://wwgql.coinduf.eu', - ENDPOINT2: 'https://myserver.com' -} \ No newline at end of file diff --git a/graphql/clients/otherclient.js b/graphql/clients/otherclient.js deleted file mode 100644 index a2b2016973f3722ae8f7923c224d8f4e0beb73ff..0000000000000000000000000000000000000000 --- a/graphql/clients/otherclient.js +++ /dev/null @@ -1,28 +0,0 @@ -import { HttpLink } from 'apollo-link-http' -import { setContext } from 'apollo-link-context' -import { from } from 'apollo-link' - -import { ENDPOINT2 } from './endpoints' -import { cache } from '../cache' - -export default ctx => { - const ssrMiddleware = setContext((_, { headers }) => { - if (process.client) return headers - return { - headers - } - }) - - const httpLink = new HttpLink({ - uri: ENDPOINT2 - }) - - const link = from([ssrMiddleware, httpLink]) - - return { - link, - cache, - // https://github.com/nuxt-community/apollo-module/issues/306#issuecomment-607225431 - defaultHttpLink: false - } -} \ No newline at end of file diff --git a/graphql/config.js b/graphql/config.js new file mode 100644 index 0000000000000000000000000000000000000000..db4b788665770fe6762b8cff8ee556c0674d07c0 --- /dev/null +++ b/graphql/config.js @@ -0,0 +1,17 @@ +import { cache } from "./cache" +import * as endpoints from "./endpoints" + +let clientConfigs = {} + +for (const key in endpoints) { + if (key != "default") + clientConfigs[key] = { + httpEndpoint: endpoints[key], + inMemoryCacheOptions: cache, + httpLinkOptions: { + credentials: "same-origin" + } + } +} + +export default { clientConfigs } diff --git a/graphql/endpoints.js b/graphql/endpoints.js new file mode 100644 index 0000000000000000000000000000000000000000..959aeb9b1bc87920170d4e2a73103099921a16cb --- /dev/null +++ b/graphql/endpoints.js @@ -0,0 +1,4 @@ +module.exports = { + coindufEu: "https://wwgql.coinduf.eu", + trentesauxFr: "https://gql.wotwizard.trentesaux.fr/" +} diff --git a/graphql/schemaQuery.js b/graphql/schemaQuery.js index da45416839a9da9b87718dc5d44a25bc06e84a05..31c2bba669d465e78f9b6cd1ac125e35d60c4054 100644 --- a/graphql/schemaQuery.js +++ b/graphql/schemaQuery.js @@ -1,13 +1,13 @@ -const { ENDPOINT1 } = require('./clients/endpoints'); -const fetch = require('node-fetch'); -const fs = require('fs'); +const endpoints = require("./endpoints") +const fetch = require("node-fetch") +const fs = require("fs") -fetch(ENDPOINT1, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - variables: {}, - query: ` +fetch(Object.values(endpoints)[0], { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + variables: {}, + query: ` { __schema { types { @@ -19,21 +19,28 @@ fetch(ENDPOINT1, { } } } - `, - }), + ` + }) }) - .then(result => result.json()) - .then(result => { - const filteredData = result.data.__schema.types.filter( - type => type.possibleTypes !== null - ) - result.data.__schema.types = filteredData; + .then((result) => result.json()) + .then((result) => { + const filteredData = result.data.__schema.types.filter( + (type) => type.possibleTypes !== null + ) + result.data.__schema.types = filteredData - fs.writeFile('./graphql/fragmentTypes.json', JSON.stringify(result.data), err => { - if (err) { - console.error('Error writing fragmentTypes file', err); - } else { - console.log('Fragment types successfully extracted!'); - } - }); - }); \ No newline at end of file + fs.writeFile( + "./graphql/fragmentTypes.json", + JSON.stringify(result.data), + (err) => { + if (err) { + console.error("Error writing fragmentTypes file", err) + } else { + console.log("Fragment types successfully extracted!") + } + } + ) + }) + .catch(function (error) { + console.log(error.message) + }) diff --git a/i18n/locales/de.json b/i18n/locales/de.json index 833dafe22538af5b1e212f98cf04c7d5764ec689..33bfa6d4f84dbf6cba6a8bdedc437542c4c76d90 100644 --- a/i18n/locales/de.json +++ b/i18n/locales/de.json @@ -279,5 +279,8 @@ "wot": { "desc": "Gesamtheit der Mitglieder und der Zertifizierungen, die sie miteinander verbinden", "title": "Vertrauensnetz" + }, + "wotwizard": { + "nodeselect": "Wählen Sie einen Server" } } diff --git a/i18n/locales/en.json b/i18n/locales/en.json index aabe706635241e8dba1625fc815449113115cdd2..73cccc64de3dd771c1efa62f54e75313c3fe3cfe 100644 --- a/i18n/locales/en.json +++ b/i18n/locales/en.json @@ -280,5 +280,8 @@ "wot": { "desc": "Set of the individuals recognized as such by their peers including the links that bind them together through certifications", "title": "Web of trust" + }, + "wotwizard": { + "nodeselect": "Select a server" } } diff --git a/i18n/locales/es.json b/i18n/locales/es.json index e272c2f1a119206a80fef12d8e94191601d38b5b..490dfc58796b8049a53a9fe8ed43420f3e7ba405 100644 --- a/i18n/locales/es.json +++ b/i18n/locales/es.json @@ -280,5 +280,8 @@ "wot": { "desc": "Conjunto de los seres humanos reconocidos como tales por sus pares incluyendo los vÃnculos que las unen a través de certificaciones (Web of Trust en inglés WOT)", "title": "Red De Confianza(RdC)" + }, + "wotwizard": { + "nodeselect": "Seleccione un servidor" } } diff --git a/i18n/locales/fr.json b/i18n/locales/fr.json index 4027492c3c0e3da859f96cd49a28d4909cbddf0f..d20ce91a73bd109388c2f00980d42f9deaabede2 100644 --- a/i18n/locales/fr.json +++ b/i18n/locales/fr.json @@ -280,5 +280,8 @@ "wot": { "desc": "Ensemble des membres et des certifications qui les relient entre eux (<a href='https://www.youtube.com/watch?v=8GaTKfa-ADU' target='_blank'>en savoir plus</a>)", "title": "Toile de confiance" + }, + "wotwizard": { + "nodeselect": "Sélectionnez un serveur" } } diff --git a/i18n/locales/it.json b/i18n/locales/it.json index 3de0144139b96c609ad1349d37c86636fa14d2ef..1edfa4b1561401a6034445ef82d097cc01217a31 100644 --- a/i18n/locales/it.json +++ b/i18n/locales/it.json @@ -280,5 +280,8 @@ "wot": { "desc": "Insieme di esseri umani riconosciuti come tali dai loro coetanei, compresi i collegamenti che li uniscono attraverso le certificazioni (Web of Trust in inglese WOT)", "title": "Rete Di Fiducia(RdF)" + }, + "wotwizard": { + "nodeselect": "Seleziona un server" } } diff --git a/nuxt.config.js b/nuxt.config.js index e962a02cee9e03d948871652399e47a15157e6ce..114d7b843fc98384f7309abb15115ab4fe515972 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -1,5 +1,6 @@ import i18n from "./i18n" import pkg from "./package.json" +import APOLLO_CONFIG from "./graphql/config" export default { // Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode @@ -33,7 +34,8 @@ export default { plugins: [ "~plugins/favourites.js", "~plugins/filters.js", - "~plugins/bootstrap.js" + "~plugins/bootstrap.js", + "~plugins/getApolloClient.js" ], // Auto import components: https://go.nuxtjs.dev/config-components @@ -67,10 +69,10 @@ export default { file: "en.json" }, { - code: "it", - name: "Italiano", - file: "it.json" - }, + code: "it", + name: "Italiano", + file: "it.json" + }, { code: "fr", @@ -87,11 +89,9 @@ export default { name: "Deutsch", file: "de.json" } - ] - , + ], detectBrowserLanguage: { - alwaysRedirect: true - , + alwaysRedirect: true, fallbackLocale: "en" }, vueI18n: i18n @@ -130,13 +130,7 @@ export default { } }, - apollo: { - clientConfigs: { - default: "~/graphql/clients/coindufeu" - //you can setup multiple clients with arbitrary names - //, myotherclient : '~/graphql/clients/otherclient' - } - }, + apollo: APOLLO_CONFIG, router: { linkExactActiveClass: "active" @@ -151,5 +145,3 @@ export default { } } } - - diff --git a/package.json b/package.json index 9c8a8a771e04a4f80b3cbf3de10faa729d653abf..50ddf8e6ced4327db5ea0db3048a249315c1f4cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wotwizard-ui", - "version": "2.3.1", + "version": "2.4.0", "private": true, "scripts": { "dev": "nuxt", @@ -21,7 +21,7 @@ "@nuxtjs/pwa": "^3.3.5", "apollo-link-context": "^1.0.20", "apollo-link-http": "^1.5.17", - "bootstrap": "^5.1.3", + "bootstrap": "5.1.3", "core-js": "^3.15.1", "graphql-tag": "^2.12.6", "nuxt": "^2.15.8", diff --git a/pages/a-propos.vue b/pages/a-propos.vue index aba2fdebcbaa90a7b298066f24503a40322577cc..930f3baa338092790f0587d786d10aca0e1d1f74 100644 --- a/pages/a-propos.vue +++ b/pages/a-propos.vue @@ -72,7 +72,7 @@ export default { }, { title: "traducteurs", - contrib: ["paidge", "kapis", "Trayeur"] + contrib: ["paidge", "kapis", "Trayeur", "wellno1"] }, { title: "graphql", @@ -119,6 +119,8 @@ export default { cgeek: "E35D142DBC3B967FED049B6CCF48782440AC2F5230352D194BFB0DA62A80259C", poka: "D01102D1D649EE65A027BC47FD1FB5BB6FECE7B6230414DB66EC490B51DBED7A", + wellno1: + "751F817B36AAE403EC4BAE95D15B55132D8CED7ED05F58E791189B0348AE6FE2", Trayeur: "", Spiranne13: "", philmarg1: "" diff --git a/pages/favoris.vue b/pages/favoris.vue index 24c68bb4849256efadc48e6a886888fe178b2a41..18a1e12d4ae58d59603951fcc9ef6f998b559f99 100644 --- a/pages/favoris.vue +++ b/pages/favoris.vue @@ -74,6 +74,9 @@ export default { } }, apollo: { + $client() { + return this.$getApolloClient() + }, favoris: { query: FAVORIS, variables() { diff --git a/pages/index.vue b/pages/index.vue index 4923ffdc9753c4840e68f3ee369bf8129640b403..66febf5d16f98b6ed83b72c5554db0d7426f50d2 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -77,6 +77,9 @@ export default { } }, apollo: { + $client() { + return this.$getApolloClient() + }, newMembers: { query: LAST_EVENTS, variables() { diff --git a/pages/membre.vue b/pages/membre.vue index 9f2f7be24f9758f5d3d66ca790ae0104e1c6d15d..4cd4918bbe64fc8880dee5afcb5ee50087fa2f31 100644 --- a/pages/membre.vue +++ b/pages/membre.vue @@ -44,6 +44,9 @@ export default { } }, apollo: { + $client() { + return this.$getApolloClient() + }, idFromHash: { query: SEARCH_MEMBER, variables() { diff --git a/pages/membres/index.vue b/pages/membres/index.vue index 8b985cc8244548ed0b03d6978479f64f9e524f11..6fc26c0966685071524a5cb6f5678fc95587bec2 100644 --- a/pages/membres/index.vue +++ b/pages/membres/index.vue @@ -58,6 +58,9 @@ export default { } }, apollo: { + $client() { + return this.$getApolloClient() + }, idSearch: { query: SEARCH_MEMBERS, variables() { diff --git a/pages/parametres.vue b/pages/parametres.vue index 4cd3d647b9b9e69f19ffddc3eefc807ecff07e20..8e17fba5fab71773f6a639aba14dd5e6c4e1e318 100644 --- a/pages/parametres.vue +++ b/pages/parametres.vue @@ -87,6 +87,9 @@ export default { } }, apollo: { + $client() { + return this.$getApolloClient() + }, allParameters: { query: PARAMS, update(data) { diff --git a/pages/previsions/futures_entrees.vue b/pages/previsions/futures_entrees.vue index 0bfac33ff53e4420ad67d56bb12e8bbf92c9c511..927726b90c159360bdfd634be6d2ecc245781522 100644 --- a/pages/previsions/futures_entrees.vue +++ b/pages/previsions/futures_entrees.vue @@ -198,6 +198,9 @@ export default { } }, apollo: { + $client() { + return this.$getApolloClient() + }, wwResult: { query: NEWCOMERS, update(data) { diff --git a/pages/previsions/futures_sorties.vue b/pages/previsions/futures_sorties.vue index 2bb31b8ac6091ffa6070cd992fa0db1191c84396..3786db67a63eff06a9a48b5ae58cd014d5768e28 100644 --- a/pages/previsions/futures_sorties.vue +++ b/pages/previsions/futures_sorties.vue @@ -88,6 +88,9 @@ export default { } }, apollo: { + $client() { + return this.$getApolloClient() + }, memEnds: { query: NEXT_EXITS, variables() { diff --git a/plugins/getApolloClient.js b/plugins/getApolloClient.js new file mode 100644 index 0000000000000000000000000000000000000000..6eb01deff5fd90ae3d5e01da4375c1d734f32ed0 --- /dev/null +++ b/plugins/getApolloClient.js @@ -0,0 +1,8 @@ +import * as endpoints from "../graphql/endpoints" + +export default ({ app }, inject) => { + inject( + "getApolloClient", + () => localStorage.getItem("apollo-client") || Object.keys(endpoints)[0] + ) +} diff --git a/web-ext/manifest.json b/web-ext/manifest.json index 536c69cc24e55018a4db695a0340d352678c463c..9174b16d2a97c8880c356dff23688a67f1dab328 100644 --- a/web-ext/manifest.json +++ b/web-ext/manifest.json @@ -2,16 +2,16 @@ "manifest_version": 2, "name": "Wotwizard UI", "description": "Le magicien de la toile de confiance", - "version": "1.0.0", + "version": "2.4.0", "homepage_url": "https://wotwizard.axiom-team.fr", "browser_action": { "browser_style": true, "default_icon": "/_nuxt/icons/icon_64x64.0424c5.png", "default_title": "Wotwizard UI" }, - "background" : { - "scripts": ["/launch-web-ext.js"] - }, + "background": { + "scripts": ["/launch-web-ext.js"] + }, "icons": { "64": "/_nuxt/icons/icon_64x64.0424c5.png", "120": "/_nuxt/icons/icon_120x120.0424c5.png"