Skip to content

Commit

Permalink
query to get certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
kayra1 committed Jun 12, 2024
1 parent 2142819 commit 875a6d0
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 60 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
7. Run the project: `gocert -config config.yaml`

Commands assume you're running them from the top level git repo directory

## Testing

### Unit Tests
Expand Down Expand Up @@ -42,4 +43,4 @@ rockcraft pack -v
version=$(yq '.version' rockcraft.yaml)
sudo skopeo --insecure-policy copy oci-archive:gocert_${version}_amd64.rock docker-daemon:gocert:${version}
docker run gocert:${version}
```
```
140 changes: 113 additions & 27 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"next": "14.2.3",
"react": "^18",
"react-dom": "^18",
"react-query": "^3.39.3",
"sass": "^1.77.4",
"vanilla-framework": "^4.11.0"
},
Expand Down
10 changes: 9 additions & 1 deletion ui/src/app/certificate_requests/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
"use client"

import { useQuery } from "react-query"
import { CertificateRequestsTable } from "./table"
import { getCertificateRequests } from "./queries"
import { CSREntry } from "./types"

export default function CertificateRequests() {
const query = useQuery<CSREntry[], Error>('csrs', getCertificateRequests)
if (query.status == "loading"){ return <div>Loading...</div> }
if (query.status == "error") { return <div>error :(</div>}
if (query.data == undefined) { return <div>No data</div>}
const csrs = Array.from(query.data)
return (
<CertificateRequestsTable />
<CertificateRequestsTable csrs={csrs}/>
)
}
9 changes: 9 additions & 0 deletions ui/src/app/certificate_requests/queries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { CSREntry } from "./types"

export async function getCertificateRequests(): Promise<CSREntry[]> {
const response = await fetch("/api/v1/certificate_requests")
if (!response.ok) {
throw new Error('Network response was not ok')
}
return response.json()
}
Loading

0 comments on commit 875a6d0

Please sign in to comment.