diff --git a/admin/package.json b/admin/package.json index 3406c326a..521f34bfc 100644 --- a/admin/package.json +++ b/admin/package.json @@ -33,6 +33,7 @@ "bootstrap": "4.3.1", "bootstrap-vue": "^2.21.2", "core-js": "^3.6.5", + "date-fns": "^2.29.3", "dotenv-webpack": "^7.0.3", "express": "^4.17.1", "graphql": "^15.6.1", diff --git a/admin/src/components/Fedaration/FederationVisualizeItem.vue b/admin/src/components/Fedaration/FederationVisualizeItem.vue new file mode 100644 index 000000000..ba23c0433 --- /dev/null +++ b/admin/src/components/Fedaration/FederationVisualizeItem.vue @@ -0,0 +1,76 @@ + + + + + + {{ item.url }} + {{ `${item.publicKey.substring(0, 26)}…` }} + + {{ lastAnnouncedAt }} + {{ createdAt }} + + + + diff --git a/admin/src/components/Fedaration/FederationVisualizeitem.spec.js b/admin/src/components/Fedaration/FederationVisualizeitem.spec.js new file mode 100644 index 000000000..d82a12f33 --- /dev/null +++ b/admin/src/components/Fedaration/FederationVisualizeitem.spec.js @@ -0,0 +1,44 @@ +import { mount } from '@vue/test-utils' +import FederationVisualizeItem from './FederationVisualizeItem.vue' + +const localVue = global.localVue + +const mocks = { + $t: (key) => key, + $i18n: { + locale: 'de', + t: (key) => key, + }, +} + +describe('FederationVisualizeItem', () => { + let wrapper + + const propsData = { + item: { + id: 7590, + foreign: false, + publicKey: 'eaf6a426b24fd54f8fbae11c17700fc595080ca25159579c63d38dbc64284ba7', + url: 'http://localhost/api/api/2_0', + lastAnnouncedAt: null, + verifiedAt: null, + lastErrorAt: null, + createdAt: '2023-03-29T04:46:38.823Z', + updatedAt: null, + }, + } + + const Wrapper = () => { + return mount(FederationVisualizeItem, { localVue, mocks, propsData }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the component', () => { + expect(wrapper.find('div.federation-visualize-item').exists()).toBe(true) + }) + }) +}) diff --git a/admin/src/components/NavBar.spec.js b/admin/src/components/NavBar.spec.js index 1927f258c..6a4a69959 100644 --- a/admin/src/components/NavBar.spec.js +++ b/admin/src/components/NavBar.spec.js @@ -62,8 +62,12 @@ describe('NavBar', () => { ) }) + it('has a link to /federation', () => { + expect(wrapper.findAll('.nav-item').at(3).find('a').attributes('href')).toBe('/federation') + }) + it('has a link to /statistic', () => { - expect(wrapper.findAll('.nav-item').at(3).find('a').attributes('href')).toBe('/statistic') + expect(wrapper.findAll('.nav-item').at(4).find('a').attributes('href')).toBe('/statistic') }) }) @@ -72,7 +76,7 @@ describe('NavBar', () => { beforeEach(async () => { delete window.location window.location = '' - await wrapper.findAll('.nav-item').at(4).find('a').trigger('click') + await wrapper.findAll('.nav-item').at(5).find('a').trigger('click') }) afterEach(() => { @@ -97,7 +101,7 @@ describe('NavBar', () => { window.location = { assign: windowLocationMock, } - await wrapper.findAll('.nav-item').at(5).find('a').trigger('click') + await wrapper.findAll('.nav-item').at(6).find('a').trigger('click') }) afterEach(() => { diff --git a/admin/src/components/NavBar.vue b/admin/src/components/NavBar.vue index dae4bba91..2efeda048 100644 --- a/admin/src/components/NavBar.vue +++ b/admin/src/components/NavBar.vue @@ -1,6 +1,6 @@ - + @@ -19,6 +19,9 @@ {{ $t('navbar.automaticContributions') }} + + {{ $t('navbar.instances') }} + {{ $t('navbar.statistic') }} {{ $t('navbar.my-account') }} {{ $t('navbar.logout') }} diff --git a/admin/src/graphql/getCommunities.js b/admin/src/graphql/getCommunities.js new file mode 100644 index 000000000..ccf894f6b --- /dev/null +++ b/admin/src/graphql/getCommunities.js @@ -0,0 +1,17 @@ +import gql from 'graphql-tag' + +export const getCommunities = gql` + query { + getCommunities { + id + foreign + publicKey + url + lastAnnouncedAt + verifiedAt + lastErrorAt + createdAt + updatedAt + } + } +` diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index 0d05eaa88..18e037abd 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -76,6 +76,13 @@ }, "short_hash": "({shortHash})" }, + "federation": { + "gradidoInstances":"Gradido Instanzen", + "verified":"Verifiziert", + "url":"Url", + "lastAnnouncedAt":"letzte Bekanntgabe", + "createdAt":"Erstellt am" + }, "form": { "cancel": "Abbrechen", "submit": "Senden" @@ -104,6 +111,7 @@ "name": "Name", "navbar": { "automaticContributions": "Automatische Beiträge", + "instances":"Instanzen", "logout": "Abmelden", "my-account": "Mein Konto", "statistic": "Statistik", diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index f36944a63..20549fb9e 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -76,6 +76,13 @@ }, "short_hash": "({shortHash})" }, + "federation": { + "gradidoInstances":"Gradido Instances", + "verified":"Verified", + "url":"Url", + "lastAnnouncedAt":"Last Announced", + "createdAt":"Created At " + }, "form": { "cancel": "Cancel", "submit": "Send" @@ -104,6 +111,7 @@ "name": "Name", "navbar": { "automaticContributions": "Automatic Contributions", + "instances":"Instances", "logout": "Logout", "my-account": "My Account", "statistic": "Statistic", diff --git a/admin/src/pages/FederationVisualize.spec.js b/admin/src/pages/FederationVisualize.spec.js new file mode 100644 index 000000000..867f87ecd --- /dev/null +++ b/admin/src/pages/FederationVisualize.spec.js @@ -0,0 +1,30 @@ +import { mount } from '@vue/test-utils' +import FederationVisualize from './FederationVisualize' + +const localVue = global.localVue + +const mocks = { + $t: (key) => key, + $i18n: { + locale: 'de', + t: (key) => key, + }, +} + +describe('Overview', () => { + let wrapper + + const Wrapper = () => { + return mount(FederationVisualize, { localVue, mocks }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('has a DIV element with the class.component-confirm-register-mail', () => { + expect(wrapper.find('div.federation-visualize').exists()).toBe(true) + }) + }) +}) diff --git a/admin/src/pages/FederationVisualize.vue b/admin/src/pages/FederationVisualize.vue new file mode 100644 index 000000000..25c1b11a3 --- /dev/null +++ b/admin/src/pages/FederationVisualize.vue @@ -0,0 +1,68 @@ + + + + {{ $t('federation.gradidoInstances') }} + + + + + + + {{ $t('federation.verified') }} + {{ $t('federation.url') }} + {{ $t('federation.lastAnnouncedAt') }} + {{ $t('federation.createdAt') }} + + + + + + + + diff --git a/admin/src/router/router.test.js b/admin/src/router/router.test.js index ad1ad1245..886d4eeab 100644 --- a/admin/src/router/router.test.js +++ b/admin/src/router/router.test.js @@ -45,7 +45,7 @@ describe('router', () => { describe('routes', () => { it('has nine routes defined', () => { - expect(routes).toHaveLength(8) + expect(routes).toHaveLength(9) }) it('has "/overview" as default', async () => { @@ -88,6 +88,13 @@ describe('router', () => { }) }) + describe('federation', () => { + it('loads the "FederationVisualize" page', async () => { + const component = await routes.find((r) => r.path === '/federation').component() + expect(component.default.name).toBe('FederationVisualize') + }) + }) + describe('not found page', () => { it('renders the "NotFound" component', async () => { const component = await routes.find((r) => r.path === '*').component() diff --git a/admin/src/router/routes.js b/admin/src/router/routes.js index b01466cfc..d26fdfd96 100644 --- a/admin/src/router/routes.js +++ b/admin/src/router/routes.js @@ -31,6 +31,10 @@ const routes = [ path: '*', component: () => import('@/components/NotFoundPage.vue'), }, + { + path: '/federation', + component: () => import('@/pages/FederationVisualize.vue'), + }, ] export default routes diff --git a/admin/yarn.lock b/admin/yarn.lock index ee4d635a6..c270b80bf 100644 --- a/admin/yarn.lock +++ b/admin/yarn.lock @@ -5038,6 +5038,11 @@ data-urls@^2.0.0: whatwg-mimetype "^2.3.0" whatwg-url "^8.0.0" +date-fns@^2.29.3: + version "2.29.3" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8" + integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA== + de-indent@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"