From b30f1b96ff122e2f1a66f9d2d63de881d2e6140e Mon Sep 17 00:00:00 2001 From: navanchauhan Date: Mon, 17 Oct 2022 00:57:17 -0600 Subject: began individual document --- main.go | 32 +++++++++++++++ templates/document_details.html | 89 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 templates/document_details.html diff --git a/main.go b/main.go index 535e575..2a2f4d9 100644 --- a/main.go +++ b/main.go @@ -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 @@ + + + + + + {{.SearchResults.id}} - DogeKnows + + + + + +
+
+

+ DogeKnows +

+

+ Full-text search FDA 510(k) database +

+
+
+
+ +
+
+
+
+
+ + + + +
+
+ +
+
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
510(k) Number{{ .SearchResults.id }}
Title{{.SearchResults.title}}
Applicant{{.SearchResults.applicant}}
Decision{{.SearchResults.decision}}
Decision Date{{.SearchResults.decision_date}}
Submission Date{{.SearchResults.submission_date}}
Predicates{{ range .SearchResults.predicates}} + {{ . }} + {{ end }}
+
+
+
+ + \ No newline at end of file -- cgit v1.2.3