diff --git a/app/_components/AddCollectionSelectServer.js b/app/_components/AddCollectionSelectServer.js new file mode 100644 index 0000000..16983af --- /dev/null +++ b/app/_components/AddCollectionSelectServer.js @@ -0,0 +1,22 @@ + +'use server' + +export async function pollJob(jobId) { + + let res = await fetch(`http://production-tools/plot-navigator/cache/job/${jobId}`) + let data = await res.json() + return data +} + +export async function putCollection(repo, collectionName) { + + let res = await fetch("http://production-tools/plot-navigator/cache", + {method: "PUT", + body: JSON.stringify({repo: repo, collection: collectionName}), + headers: {"Content-Type": "application/json"}} + ) + let data = await res.json() + + return data.jobId + +} diff --git a/app/_components/addCollectionSelect.js b/app/_components/addCollectionSelect.js new file mode 100644 index 0000000..b73c241 --- /dev/null +++ b/app/_components/addCollectionSelect.js @@ -0,0 +1,48 @@ +'use client' + +import React from 'react'; +import { useState } from 'react' + +import {putCollection, pollJob} from './AddCollectionSelectServer.js' + +export default function AddCollectionSelect({repos}) { + + const [repo, setRepo] = useState(repos[0]); + const [collectionName, setCollectionName] = useState(""); + const [jobId, setJobId] = useState(""); + + const pollUpdates = async () => { + await wait(5000) + console.log(`Polling ${jobId}`) + const res = await pollJob(jobId) + console.log(`Status ${res.status}`) + if(res.status == "in_progress") { + await pollUpdates() + } + + + } + + const submitForm = async () => { + const jobId = await putCollection(repo, collectionName) + setJobId(jobId) + await wait(5000) + await pollUpdates() + + } + + return ( +
+ + setCollectionName(e.target.value)} /> + +
+ ) +} + diff --git a/app/addcollection/page.js b/app/addcollection/page.js new file mode 100644 index 0000000..7b532d9 --- /dev/null +++ b/app/addcollection/page.js @@ -0,0 +1,21 @@ + +import Link from 'next/link' + +import AddCollectionSelect from '@/components/addCollectionSelect' + +export default async function AddCollection() { + + + const repoUrls = JSON.parse(process.env.REPO_URLS) + + /* REPO_URLS */ + return ( +
+
<- Back to collections
+
Add a Collection:
+ +
+ + ) + +} diff --git a/app/layout.js b/app/layout.js index 820bbe2..3dc3d45 100644 --- a/app/layout.js +++ b/app/layout.js @@ -20,8 +20,9 @@ export default function RootLayout({ children }) {
Rubin Plot Navigator
{children} diff --git a/env.local.example b/env.local.example index 6636405..4cbefce 100644 --- a/env.local.example +++ b/env.local.example @@ -3,5 +3,6 @@ BASE_URL= BUTLER_URL= BUCKET_NAME= BUCKET_URL= +PAGE_LINKS= S3_KEY= S3_SECRET=