Add domain names to certificates table

This commit is contained in:
Jamie Curnow 2024-09-15 22:33:11 +10:00
parent d121de808c
commit d2048e540d
No known key found for this signature in database
GPG Key ID: FFBB624C43388E9E
4 changed files with 19 additions and 4 deletions

View File

@ -12,6 +12,7 @@ import (
func GetByID(id uint) (Model, error) { func GetByID(id uint) (Model, error) {
var m Model var m Model
err := m.LoadByID(id) err := m.LoadByID(id)
m.generateGravatar()
return m, err return m, err
} }

View File

@ -2,7 +2,6 @@ import { useEffect, ReactNode } from "react";
import { Box, Container, useToast } from "@chakra-ui/react"; import { Box, Container, useToast } from "@chakra-ui/react";
import { useQueryClient } from "@tanstack/react-query"; import { useQueryClient } from "@tanstack/react-query";
import { getSSEToken, SSEMessage } from "src/api/npm"; import { getSSEToken, SSEMessage } from "src/api/npm";
import { Footer, Navigation } from "src/components"; import { Footer, Navigation } from "src/components";
import { intl } from "src/locale"; import { intl } from "src/locale";
@ -26,6 +25,7 @@ function SiteWrapper({ children }: Props) {
eventSource.onmessage = (e: any) => { eventSource.onmessage = (e: any) => {
const j: SSEMessage = JSON.parse(e.data); const j: SSEMessage = JSON.parse(e.data);
if (j) { if (j) {
console.log("SSE Message:", j);
if (j.affects) { if (j.affects) {
queryClient.invalidateQueries({ queryKey: [j.affects] }); queryClient.invalidateQueries({ queryKey: [j.affects] });
} }

View File

@ -8,6 +8,7 @@ import {
ActionsFormatter, ActionsFormatter,
CertificateStatusFormatter, CertificateStatusFormatter,
CertificateTypeFormatter, CertificateTypeFormatter,
DomainsFormatter,
GravatarFormatter, GravatarFormatter,
IDFormatter, IDFormatter,
MonospaceFormatter, MonospaceFormatter,
@ -59,7 +60,14 @@ function Table({
Cell: MonospaceFormatter(), Cell: MonospaceFormatter(),
}, },
{ {
Header: intl.formatMessage({ id: "column.validation-type" }), Header: intl.formatMessage({ id: "column.domain-names" }),
accessor: "domainNames",
sortable: true,
Filter: TextFilter,
Cell: DomainsFormatter(),
},
{
Header: intl.formatMessage({ id: "column.type" }),
accessor: "type", accessor: "type",
sortable: true, sortable: true,
Cell: CertificateTypeFormatter(), Cell: CertificateTypeFormatter(),

View File

@ -37,11 +37,14 @@ describe('Certificates endpoints', () => {
it('Should be able to get a certificate', function() { it('Should be able to get a certificate', function() {
cy.task('backendApiGet', { cy.task('backendApiGet', {
token: token, token: token,
path: '/api/certificates/' + certID path: '/api/certificates/' + certID + '?expand=user'
}).then((data) => { }).then((data) => {
// Check the swagger schema: // Check the swagger schema:
cy.validateSwaggerSchema('get', 200, '/certificates/{certificateID}', data); cy.validateSwaggerSchema('get', 200, '/certificates/{certificateID}', data);
expect(data.result).to.have.property('id', certID); expect(data.result).to.have.property('id', certID);
expect(data.result).to.have.property('user');
expect(data.result.user).to.have.property('gravatar_url');
expect(data.result.user.gravatar_url).to.include('gravatar.com');
}); });
}); });
@ -63,12 +66,15 @@ describe('Certificates endpoints', () => {
it('Should be able to get all certificates', function() { it('Should be able to get all certificates', function() {
cy.task('backendApiGet', { cy.task('backendApiGet', {
token: token, token: token,
path: '/api/certificates' path: '/api/certificates?expand=user'
}).then((data) => { }).then((data) => {
cy.validateSwaggerSchema('get', 200, '/certificates', data); cy.validateSwaggerSchema('get', 200, '/certificates', data);
expect(data).to.have.property('result'); expect(data).to.have.property('result');
expect(data.result).to.have.property('items'); expect(data.result).to.have.property('items');
expect(data.result.items.length).to.be.greaterThan(0); expect(data.result.items.length).to.be.greaterThan(0);
expect(data.result.items[0]).to.have.property('user');
expect(data.result.items[0].user).to.have.property('gravatar_url');
expect(data.result.items[0].user.gravatar_url).to.include('gravatar.com');
}); });
}); });