aboutsummaryrefslogtreecommitdiff
path: root/docker/crupest-nginx/sites/www/src/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'docker/crupest-nginx/sites/www/src/main.js')
-rw-r--r--docker/crupest-nginx/sites/www/src/main.js62
1 files changed, 13 insertions, 49 deletions
diff --git a/docker/crupest-nginx/sites/www/src/main.js b/docker/crupest-nginx/sites/www/src/main.js
index bbdecab..111b0bd 100644
--- a/docker/crupest-nginx/sites/www/src/main.js
+++ b/docker/crupest-nginx/sites/www/src/main.js
@@ -1,4 +1,3 @@
-import { Octokit } from "https://cdn.skypack.dev/octokit";
import "./style.css";
const colorStripContainer = document.getElementById("color-strip-container");
@@ -21,63 +20,28 @@ document.addEventListener("DOMContentLoaded", async () => {
const todoMessage = document.getElementById("todo-message");
const todoContainer = document.getElementById("todo-container");
- // TODO: we need another way to do this!
- const octokit = new Octokit({
- auth: "xxx",
- });
+ const res = await fetch("/api/todos");
+ const body = res.json();
- try {
- const res = await octokit.graphql(
- `
- {
- user(login: "crupest") {
- projectV2(number: 2) {
- items(last: 100) {
- nodes {
- __typename
- fieldValueByName(name: "Status")
- content {
- __typename
- ... on Issue {
- title
- closed
- }
- ... on PullRequest {
- title
- closed
- }
- ... on DraftIssue {
- title
- }
- }
- }
- }
- }
- }
- }
- `
+ if (res.status !== 200) {
+ todoMessage.style.color = "red";
+ todoMessage.textContent =
+ "Failed to fetch TODOs. (Maybe due to rate limit. Please try later.)";
+ console.log(
+ `Failed to get GitHub project info. Status: ${res.status}. Body: ${body}`
);
-
- const items = res.user.projectV2.items.nodes.map((node) => node.content);
-
- items.forEach((item) => {
- if (item.__typename == "DraftIssue") {
- item.closed = false;
- }
- const { title, closed } = item;
+ } else {
+ body.forEach((item) => {
+ const { status, title, color } = item;
const li = document.createElement("li");
const span = document.createElement("span");
- span.textContent = closed ? "Done:" : "Todo:";
- span.style.color = closed ? "green" : "blue";
+ span.textContent = status;
+ span.style.color = color;
li.appendChild(span);
li.append(title);
todoContainer.appendChild(li);
});
todoMessage.parentElement.removeChild(todoMessage);
- } catch (e) {
- todoMessage.style.color = "red";
- todoMessage.textContent = "Failed to fetch TODOs.";
- console.log("Failed to get GitHub project info.", e);
}
});