Certificate table work, shows error message in popover

This commit is contained in:
Jamie Curnow 2023-01-16 11:32:45 +10:00
parent ba138581e1
commit 306ac20457
6 changed files with 77 additions and 6 deletions

View File

@ -107,7 +107,7 @@ func shExec(args []string, envs []string) (string, error) {
b, e := c.CombinedOutput() b, e := c.CombinedOutput()
if e != nil { if e != nil {
logger.Error("AcmeShError", fmt.Errorf("Command error: %s -- %v\n%+v", acmeSh, args, e)) // logger.Error("AcmeShError", fmt.Errorf("Command error: %s -- %v\n%+v", acmeSh, args, e))
logger.Warn(string(b)) logger.Warn(string(b))
} }
@ -128,7 +128,7 @@ func getCommonArgs() []string {
} }
args = append(args, "--log", "/data/logs/acme.sh.log") args = append(args, "--log", "/data/logs/acme.sh.log")
args = append(args, "--debug", "2") // args = append(args, "--debug", "2")
return args return args
} }

View File

@ -41,6 +41,7 @@ func Create(certificate *Model) (int, error) {
domain_names, domain_names,
expires_on, expires_on,
status, status,
error_message,
meta, meta,
is_ecc, is_ecc,
is_deleted is_deleted
@ -55,6 +56,7 @@ func Create(certificate *Model) (int, error) {
:domain_names, :domain_names,
:expires_on, :expires_on,
:status, :status,
:error_message,
:meta, :meta,
:is_ecc, :is_ecc,
:is_deleted :is_deleted
@ -93,6 +95,7 @@ func Update(certificate *Model) error {
domain_names = :domain_names, domain_names = :domain_names,
expires_on = :expires_on, expires_on = :expires_on,
status = :status, status = :status,
error_message = :error_message,
meta = :meta, meta = :meta,
is_ecc = :is_ecc, is_ecc = :is_ecc,
is_deleted = :is_deleted is_deleted = :is_deleted

View File

@ -1,4 +1,14 @@
import { Avatar, Badge, Text, Tooltip } from "@chakra-ui/react"; import {
Avatar,
Badge,
Text,
Tooltip,
Popover,
PopoverTrigger,
PopoverContent,
PopoverArrow,
PopoverBody,
} from "@chakra-ui/react";
import { Monospace, RowAction, RowActionsMenu } from "components"; import { Monospace, RowAction, RowActionsMenu } from "components";
import { intl } from "locale"; import { intl } from "locale";
import getNiceDNSProvider from "modules/Acmesh"; import getNiceDNSProvider from "modules/Acmesh";
@ -72,7 +82,7 @@ function CapabilitiesFormatter() {
} }
function CertificateStatusFormatter() { function CertificateStatusFormatter() {
const formatCell = ({ value }: any) => { const formatCell = ({ value, row }: any) => {
let color = "cyan.500"; let color = "cyan.500";
switch (value) { switch (value) {
case "failed": case "failed":
@ -85,6 +95,38 @@ function CertificateStatusFormatter() {
color = "yellow.400"; color = "yellow.400";
break; break;
} }
// special case for failed to show an error popover
if (value === "failed" && row?.original?.errorMessage) {
return (
<Popover>
<PopoverTrigger>
<Badge color={color} style={{ cursor: "pointer" }}>
{intl.formatMessage({ id: value })}
</Badge>
</PopoverTrigger>
<PopoverContent>
<PopoverArrow />
<PopoverBody>
<pre className="wrappable error">
{row?.original?.errorMessage}
</pre>
</PopoverBody>
</PopoverContent>
</Popover>
);
}
return <Badge color={color}>{intl.formatMessage({ id: value })}</Badge>;
};
return formatCell;
}
function CertificateTypeFormatter() {
const formatCell = ({ value }: any) => {
let color = "cyan.500";
if (value === "dns") {
color = "green.400";
}
return <Badge color={color}>{intl.formatMessage({ id: value })}</Badge>; return <Badge color={color}>{intl.formatMessage({ id: value })}</Badge>;
}; };
@ -252,6 +294,7 @@ export {
BooleanFormatter, BooleanFormatter,
CapabilitiesFormatter, CapabilitiesFormatter,
CertificateStatusFormatter, CertificateStatusFormatter,
CertificateTypeFormatter,
DisabledFormatter, DisabledFormatter,
DNSProviderFormatter, DNSProviderFormatter,
DomainsFormatter, DomainsFormatter,

View File

@ -29,6 +29,19 @@ span.monospace {
font-family: monospace; font-family: monospace;
} }
pre {
&.wrappable {
white-space: pre-wrap; /* Since CSS 2.1 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
&.error {
color: rgb(245, 101, 101); /* red.500 */
}
}
/* helpdoc */ /* helpdoc */
.helpdoc-body { .helpdoc-body {
p { p {

View File

@ -410,6 +410,9 @@
"disabled": { "disabled": {
"defaultMessage": "Disabled" "defaultMessage": "Disabled"
}, },
"dns": {
"defaultMessage": "DNS"
},
"dns-provider.acmesh-name": { "dns-provider.acmesh-name": {
"defaultMessage": "Acme.sh Provider" "defaultMessage": "Acme.sh Provider"
}, },
@ -449,6 +452,9 @@
"error.user-disabled": { "error.user-disabled": {
"defaultMessage": "Account is disabled" "defaultMessage": "Account is disabled"
}, },
"failed": {
"defaultMessage": "Failed"
},
"filter.apply": { "filter.apply": {
"defaultMessage": "Apply" "defaultMessage": "Apply"
}, },
@ -536,6 +542,9 @@
"hosts.title": { "hosts.title": {
"defaultMessage": "Hosts" "defaultMessage": "Hosts"
}, },
"http": {
"defaultMessage": "HTTP"
},
"http-https": { "http-https": {
"defaultMessage": "HTTP/HTTPS" "defaultMessage": "HTTP/HTTPS"
}, },
@ -584,6 +593,9 @@
"ready": { "ready": {
"defaultMessage": "Ready" "defaultMessage": "Ready"
}, },
"requesting": {
"defaultMessage": "Requesting"
},
"restricted-access": { "restricted-access": {
"defaultMessage": "Restricted Access" "defaultMessage": "Restricted Access"
}, },

View File

@ -4,6 +4,7 @@ import {
tableEvents, tableEvents,
ActionsFormatter, ActionsFormatter,
CertificateStatusFormatter, CertificateStatusFormatter,
CertificateTypeFormatter,
GravatarFormatter, GravatarFormatter,
IDFormatter, IDFormatter,
MonospaceFormatter, MonospaceFormatter,
@ -67,13 +68,12 @@ function CertificatesTable({
Header: intl.formatMessage({ id: "column.validation-type" }), Header: intl.formatMessage({ id: "column.validation-type" }),
accessor: "type", accessor: "type",
sortable: true, sortable: true,
Filter: TextFilter, Cell: CertificateTypeFormatter(),
}, },
{ {
Header: intl.formatMessage({ id: "column.status" }), Header: intl.formatMessage({ id: "column.status" }),
accessor: "status", accessor: "status",
sortable: true, sortable: true,
Filter: TextFilter,
Cell: CertificateStatusFormatter(), Cell: CertificateStatusFormatter(),
}, },
{ {