From 3e4d9cf7553c1ebf5fa2ecde8d24ed9bb4b5cc5a Mon Sep 17 00:00:00 2001 From: Cannon Lock Date: Wed, 28 Aug 2024 15:11:37 -0500 Subject: [PATCH] Add iframe visuals from Kibana --- registry/public.py | 8 +++ registry/static/images/icons/download.svg | 4 +- registry/static/images/icons/tags-white.svg | 13 ++++ registry/static/images/icons/tags.svg | 13 ++++ registry/static/images/icons/upload.svg | 4 ++ registry/static/js/components/card.js | 66 ++++++++++++++++++++- registry/templates/public/image.html | 16 +++++ registry/templates/public/repositories.html | 1 + registry/templates/public/tags.html | 50 ++++++++++++++++ 9 files changed, 172 insertions(+), 3 deletions(-) create mode 100644 registry/static/images/icons/tags-white.svg create mode 100644 registry/static/images/icons/tags.svg create mode 100644 registry/static/images/icons/upload.svg create mode 100644 registry/templates/public/image.html create mode 100644 registry/templates/public/tags.html diff --git a/registry/public.py b/registry/public.py index f788c65..69cf259 100644 --- a/registry/public.py +++ b/registry/public.py @@ -19,3 +19,11 @@ def public_projects(): @bp.route("/projects//repositories") def public_project_repositories(project: str): return flask.render_template("/public/repositories.html", project=project) + +@bp.route("/projects//repositories//tags") +def public_project_repository_tags(project: str, repository: str): + return flask.render_template("/public/tags.html", project=project, repository=repository) + +@bp.route("/projects//repositories//tags/") +def public_project_repository_image(project: str, repository: str, tag: str): + return flask.render_template("/public/image.html", project=project, repository=repository, tag=tag) \ No newline at end of file diff --git a/registry/static/images/icons/download.svg b/registry/static/images/icons/download.svg index 80a5817..90a34a3 100644 --- a/registry/static/images/icons/download.svg +++ b/registry/static/images/icons/download.svg @@ -1,4 +1,4 @@ - - + + \ No newline at end of file diff --git a/registry/static/images/icons/tags-white.svg b/registry/static/images/icons/tags-white.svg new file mode 100644 index 0000000..d8329ae --- /dev/null +++ b/registry/static/images/icons/tags-white.svg @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/registry/static/images/icons/tags.svg b/registry/static/images/icons/tags.svg new file mode 100644 index 0000000..57ee510 --- /dev/null +++ b/registry/static/images/icons/tags.svg @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/registry/static/images/icons/upload.svg b/registry/static/images/icons/upload.svg new file mode 100644 index 0000000..9a4a363 --- /dev/null +++ b/registry/static/images/icons/upload.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/registry/static/js/components/card.js b/registry/static/js/components/card.js index 971265f..0b0bd7a 100644 --- a/registry/static/js/components/card.js +++ b/registry/static/js/components/card.js @@ -159,7 +159,7 @@ export const RepositoryCard = ({ let [project, repository] = name.split("/") return ( - h("a", {href: `https://hub.opensciencegrid.org/harbor/projects/${project_id}/repositories/${repository}`, className:"text-decoration-none"}, + h("a", {href: `/public/projects/${project}/repositories/${repository}/tags`, className:"text-decoration-none"}, h( ImageCard, {src: "/static/images/icons/Repo_Icon.svg", alt: "Building Graphic", className: "project-card mb-1 mb-sm-2 p-3 rounded bg-light"}, @@ -208,3 +208,67 @@ export const RepositoryCard = ({ ) ) } + +export const TagCard = ({ + project, + repository, + digest, + pull_time, + push_time, + tags +}) => { + let localePushTime = new Date(Date.parse(push_time)).toLocaleString("en-US") + let localePullTime = new Date(Date.parse(pull_time)).toLocaleString("en-US") + + if(tags === null) { + return null + } + + return ( + h("a", {href: `/public/projects/${project}/repositories/${repository}/tags/${tags?.[0].name}`, className:"text-decoration-none"}, + h( + ImageCard, + {src: "/static/images/icons/tags-white.svg", alt: "Tag Graphic", className: "project-card mb-1 mb-sm-2 p-3 rounded bg-light"}, + h("div", {className: "description"}, ...[ + h("div", {className: "row gx-2"}, ...[ + h("h4", {className: "col-12 col-md-auto fw-bold mb-1"}, digest.substring(0, 10)), + ]), + h("div", {className: "row gx-2"}, ...[ + ... push_time ? [h(ImageTextRow, { + className: "col-auto", + src: "/static/images/icons/upload.svg", + alt: "Repository Graphic", + tag: "h6", + "data-bs-toggle": "tooltip", + "data-bs-placement": "top", + title: `Push Time: ${localePushTime}`, + text: `Push Time: ${localePushTime}` + })] : [], + ]), + h("div", {className: "row gx-2 text-truncate"}, ...[ + ... push_time ? [h(ImageTextRow, { + className: "col-auto", + src: "/static/images/icons/download.svg", + alt: "Repository Graphic", + tag: "h6", + "data-bs-toggle": "tooltip", + "data-bs-placement": "top", + title: `Pull Time: ${localePullTime}`, + text: `Pull Time: ${localePullTime}` + })] : [], + ]), + h("div", {className: "row gx-2 text-truncate"}, ...[ + ... tags ? [h(ImageTextRow, { + className: "col-auto", + src: "/static/images/icons/tags.svg", + alt: "Download Graphic", + tag: "h6", + title: `${tags.length} Tags`, + text: `${tags.length} Tags: ${tags.reverse().map(x => x.name).join(", ")}` + })] : [], + ]) + ]) + ) + ) + ) +} diff --git a/registry/templates/public/image.html b/registry/templates/public/image.html new file mode 100644 index 0000000..4d32571 --- /dev/null +++ b/registry/templates/public/image.html @@ -0,0 +1,16 @@ +{% extends "layout/base.html" %} +{% from "macros/layout/title.html" import title %} +{% from "macros/card.html" import card %} +{% block title %}SOTERIA: Public Projects{% endblock %} +{% block page_class %}subpage{% endblock %} +{% block body_class %}container{% endblock %} +{% block body %} +
+
+ {{ title("Tag Statistics") }} + +
+
+{% endblock %} +{% block scripts %} +{% endblock %} \ No newline at end of file diff --git a/registry/templates/public/repositories.html b/registry/templates/public/repositories.html index 7e4f6da..8b41cf6 100644 --- a/registry/templates/public/repositories.html +++ b/registry/templates/public/repositories.html @@ -9,6 +9,7 @@
{{ title(project + " Repositories") }} +
diff --git a/registry/templates/public/tags.html b/registry/templates/public/tags.html new file mode 100644 index 0000000..d55e2a1 --- /dev/null +++ b/registry/templates/public/tags.html @@ -0,0 +1,50 @@ +{% extends "layout/base.html" %} +{% from "macros/layout/title.html" import title %} +{% from "macros/card.html" import card %} +{% block title %}SOTERIA: Public Projects{% endblock %} +{% block page_class %}subpage{% endblock %} +{% block body_class %}container{% endblock %} +{% block body %} +
+
+ {{ title(project + "/" + repository) }} + +
+
+
+{% endblock %} +{% block scripts %} + +{% endblock %} \ No newline at end of file