Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] frontend improvements #294

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions container_provisioner/api/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"os"
"strconv"
"strings"

"github.com/algo7/TripAdvisor-Review-Scraper/container_provisioner/containers"
Expand Down Expand Up @@ -33,7 +32,7 @@ func getMain(c *fiber.Ctx) error {
return c.Render("main", fiber.Map{
"Title": "Algo7 TripAdvisor Scraper",
"RunningContainers": runningContainers,
})
}, "layouts/base")
}

// postProvision is the handler for the form submission
Expand Down Expand Up @@ -185,18 +184,10 @@ func getRunningTasks(c *fiber.Ctx) error {
// Get ids of all running containers
runningContainers := containers.ListContainersByType("scraper")

// The page status message
currentTaskStatus := "There are no running tasks"

if len(runningContainers) != 0 {
currentTaskStatus = fmt.Sprintf("%s task(s) running", strconv.Itoa(len(runningContainers)))
}

return c.Render("tasks", fiber.Map{
"Title": "Algo7 TripAdvisor Scraper",
"RunningTasks": runningContainers,
"CurrentTaskStatus": currentTaskStatus,
})
"Title": "Algo7 TripAdvisor Scraper",
"RunningTasks": runningContainers,
}, "layouts/base")
}

// getDownloads renders the downloads page
Expand Down Expand Up @@ -244,7 +235,7 @@ func getDownloads(c *fiber.Ctx) error {
// Store the encoded byte slice into redis
database.SetCache("r2StorageObjectsList", enrichedR2Objs)

return c.Render("main", fiber.Map{
return c.Render("downloads", fiber.Map{
"Title": "Algo7 TripAdvisor Scraper",
"Rows": enrichedR2Objs,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{define "radiant-background"}}
<div class="absolute inset-x-0 top-[-10rem] -z-10 transform-gpu overflow-hidden blur-3xl sm:top-[-20rem]" aria-hidden="true">
<div class="relative left-1/2 -z-10 aspect-[1155/678] w-[36.125rem] max-w-none -translate-x-1/2 rotate-[30deg] bg-gradient-to-tr from-[#ff80b5] to-[#9089fc] opacity-30 sm:left-[calc(50%-40rem)] sm:w-[72.1875rem]" style="clip-path: polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)"></div>
</div>
{{end}}
5 changes: 5 additions & 0 deletions container_provisioner/views/icons/warning.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{define "warning-icon"}}
<svg class="h-6 w-6 text-red-600" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" />
</svg>
{{end}}
37 changes: 37 additions & 0 deletions container_provisioner/views/layouts/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<script src="https://cdn.tailwindcss.com"></script>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@200,400;500;600;700;800&display=swap"
rel="stylesheet"
/>

<style>
body {
font-family: "Inter", sans-serif;
color: #374151;
font-weight: 200;
font-size: 1.125rem;
}

h1, h2, h3, h4, h5, h6 {
color: #111827;
}
</style>

<title>{{.Title}}</title>
</head>
<body class="bg-[#F9FAFB] w-10/12 mx-auto">
{{template "radiant-background"}}

<div class="flex flex-col h-screen justify-between">
{{template "header"}}
<main class="mb-auto">{{embed}}</main>
{{template "footer"}}
</div>
</body>
</html>
Loading