|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import Head from 'next/head'; |
| 3 | + |
| 4 | +interface SessionKeys { |
| 5 | + hostKey: string; |
| 6 | + clientKey: string; |
| 7 | +} |
| 8 | + |
| 9 | +export default function Home() { |
| 10 | + const [creatingSession, setCreatingSession] = useState<boolean>(false); |
| 11 | + const [sessionKeys, setSessionKeys] = useState<SessionKeys>(); |
| 12 | + |
| 13 | + const createSession = async () => { |
| 14 | + setCreatingSession(true); |
| 15 | + setSessionKeys(undefined); |
| 16 | + |
| 17 | + try { |
| 18 | + const response = await fetch('http://127.0.0.1:3000/sessions', { method: 'POST' }); |
| 19 | + |
| 20 | + setSessionKeys(await response.json()); |
| 21 | + } finally { |
| 22 | + setCreatingSession(false); |
| 23 | + } |
| 24 | + }; |
| 25 | + |
| 26 | + return ( |
| 27 | + <div className="container"> |
| 28 | + <Head> |
| 29 | + <title>Debug my pipeline</title> |
| 30 | + <link rel="icon" href="/favicon.ico" /> |
| 31 | + </Head> |
| 32 | + |
| 33 | + <main> |
| 34 | + <h1 className="title">Welcome to Debug My Pipeline</h1> |
| 35 | + |
| 36 | + <ol> |
| 37 | + <li> |
| 38 | + <button onClick={createSession} disabled={creatingSession}> |
| 39 | + Create a session |
| 40 | + </button> |
| 41 | + </li> |
| 42 | + {creatingSession && <li>Loading...</li>} |
| 43 | + {sessionKeys && ( |
| 44 | + <> |
| 45 | + <li> |
| 46 | + Run this command on your <strong>pipeline</strong>: |
| 47 | + <pre>sh <(curl -s https://lets1.debugmypipeline.com/{sessionKeys.hostKey}.sh)</pre> |
| 48 | + </li> |
| 49 | + |
| 50 | + <li> |
| 51 | + Run this command on your <strong>local machine</strong>: |
| 52 | + <pre>sh <(curl -s https://lets1.debugmypipeline.com/{sessionKeys.clientKey}.sh)</pre> |
| 53 | + </li> |
| 54 | + </> |
| 55 | + )} |
| 56 | + </ol> |
| 57 | + </main> |
| 58 | + |
| 59 | + <style jsx>{` |
| 60 | + .container { |
| 61 | + min-height: 100vh; |
| 62 | + padding: 0 0.5rem; |
| 63 | + display: flex; |
| 64 | + flex-direction: column; |
| 65 | + justify-content: center; |
| 66 | + align-items: center; |
| 67 | + } |
| 68 | +
|
| 69 | + main { |
| 70 | + padding: 5rem 0; |
| 71 | + flex: 1; |
| 72 | + display: flex; |
| 73 | + flex-direction: column; |
| 74 | + justify-content: center; |
| 75 | + align-items: center; |
| 76 | + } |
| 77 | +
|
| 78 | + ol * { |
| 79 | + font-size: 16px; |
| 80 | + } |
| 81 | +
|
| 82 | + ol li { |
| 83 | + margin-bottom: 20px; |
| 84 | + } |
| 85 | + `}</style> |
| 86 | + |
| 87 | + <style jsx global>{` |
| 88 | + html, |
| 89 | + body { |
| 90 | + padding: 0; |
| 91 | + margin: 0; |
| 92 | + font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, |
| 93 | + Droid Sans, Helvetica Neue, sans-serif; |
| 94 | + } |
| 95 | +
|
| 96 | + * { |
| 97 | + box-sizing: border-box; |
| 98 | + } |
| 99 | + `}</style> |
| 100 | + </div> |
| 101 | + ); |
| 102 | +} |
0 commit comments