diff options
author | navanchauhan <navanchauhan@gmail.com> | 2022-10-17 00:57:17 -0600 |
---|---|---|
committer | navanchauhan <navanchauhan@gmail.com> | 2022-10-17 00:57:17 -0600 |
commit | b30f1b96ff122e2f1a66f9d2d63de881d2e6140e (patch) | |
tree | 94c9c41258ca2e75e9e0137e51bbfd5aebc3e41d | |
parent | ca5c3e37b231baac8b39aa6f789da29ac6dc501f (diff) |
began individual document
-rw-r--r-- | main.go | 32 | ||||
-rw-r--r-- | templates/document_details.html | 89 |
2 files changed, 121 insertions, 0 deletions
@@ -30,6 +30,10 @@ type SearchResponse struct { NumPages int } +type DocumentResponse struct { + SearchResults interface{} +} + func pageCount(total int, perPage int) int { return int(math.Ceil(float64(total) / float64(perPage))) } @@ -73,12 +77,40 @@ func main() { // v2.0 UI searchResultsTemplate2 := template.Must(template.New("search_results.html").Funcs(funcMap).ParseFiles("templates/search_results.html")) + //documentDetailsTemplate2 := template.Must(template.New("document_details.html").Funcs(funcMap).ParseFiles("templates/document_details.html")) + documentDetailsTemplate2 := template.Must(template.ParseFiles("templates/document_details.html")) if err != nil { fmt.Println("Error parsing template") os.Exit(1) } + http.HandleFunc("/dbentry", func(w http.ResponseWriter, r *http.Request) { + r.ParseForm() + fmt.Println(r.Form) + var res interface{} + var documentID string = r.FormValue("id") + if r.Form["id"] != nil { + index.GetDocument(documentID, &meilisearch.DocumentQuery{ + Fields: []string{ + "title", + "applicant", + "decision", + "decision_date", + "id", + "predicates", + "submission_date", + }}, &res) + fmt.Println(res) + documentDetailsTemplate2.Execute(w, DocumentResponse{ + SearchResults: res, + }) + } else { + fmt.Println("No ID provided") + } + + }) + http.HandleFunc("/search", func(w http.ResponseWriter, r *http.Request) { r.ParseForm() fmt.Println(r.Form) diff --git a/templates/document_details.html b/templates/document_details.html new file mode 100644 index 0000000..7726d13 --- /dev/null +++ b/templates/document_details.html @@ -0,0 +1,89 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>{{.SearchResults.id}} - DogeKnows</title> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css"> + <script src="https://kit.fontawesome.com/32c297b57b.js" crossorigin="anonymous"></script> + </head> + <body> + + <section class="hero is-small is-primary"> + <div class="hero-body"> + <h1 class="title"> + DogeKnows + </h1> + <p class="subtitle"> + Full-text search FDA 510(k) database + </p> + </div> + </section> + <section class="section"> + <nav class="breadcrumb" aria-label="breadcrumbs"> + <ul> + <li><a href="/">DogeKnows</a></li> + <li class="is-active"><a href="#" aria-current="page">{{.SearchResults.id}}</a></li> + </ul> + </nav> + <div class="container"> + <div class="container"> + <form action="/search" method="GET"> + <div class="field has-addons"> + <div class="control is-expanded has-icons-left"> + <input class="input" type="text" name="query" placeholder="Query" spellcheck="false"> + <span class="icon is-left"> + <i class="fa-regular fa-magnifying-glass"></i> + </span> + </div> + <div class="control"> + <input class="button is-primary" type="submit" value="Search"> + </div> + </div> + </form> + </div> + </div> + </section> + + <section class="section"> + <div class="container"> + <div class="table-container"> + <table class="table"> + <tbody> + <tr> + <th>510(k) Number</th> + <td><a href="https://www.accessdata.fda.gov/scripts/cdrh/cfdocs/cfPMN/pmn.cfm?ID={{.SearchResults.id}}">{{ .SearchResults.id }}</a></td> + </tr> + <tr> + <th>Title</th> + <td>{{.SearchResults.title}}</td> + </tr> + <tr> + <th>Applicant</th> + <td>{{.SearchResults.applicant}}</td> + </tr> + <tr> + <th>Decision</th> + <td>{{.SearchResults.decision}}</td> + </tr> + <tr> + <th>Decision Date</th> + <td>{{.SearchResults.decision_date}}</td> + </tr> + <tr> + <th>Submission Date</th> + <td>{{.SearchResults.submission_date}}</td> + </tr> + <tr> + <th>Predicates</th> + <td>{{ range .SearchResults.predicates}} + <a href="https://www.accessdata.fda.gov/scripts/cdrh/cfdocs/cfPMN/pmn.cfm?ID={{.}}">{{ . }}</a>  + {{ end }}</td> + </tr> + </tbody> + </table> + </div> + </div> + </section> +</body> +</html>
\ No newline at end of file |