|
| 1 | +package app |
| 2 | + |
| 3 | +const page = ` |
| 4 | +<!doctype html> |
| 5 | +<html lang="en"> |
| 6 | +<head> |
| 7 | + <meta charset="utf-8"> |
| 8 | + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 9 | + <meta name="description" content=""> |
| 10 | + <meta name="author" content=""> |
| 11 | + <link rel="icon" href="https://secrethub.io/img/favicon/favicon.ico"> |
| 12 | +
|
| 13 | + <title>SecretHub Example App</title> |
| 14 | +
|
| 15 | + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.min.css" integrity="sha256-zmfNZmXoNWBMemUOo1XUGFfc0ihGGLYdgtJS3KCr/l0=" crossorigin="anonymous" /> |
| 16 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> |
| 17 | +
|
| 18 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script> |
| 19 | +
|
| 20 | + <style> |
| 21 | + html, |
| 22 | + body { |
| 23 | + height: 100%; |
| 24 | + } |
| 25 | +
|
| 26 | + body { |
| 27 | + display: -ms-flexbox; |
| 28 | + display: -webkit-box; |
| 29 | + display: flex; |
| 30 | + -ms-flex-align: center; |
| 31 | + -ms-flex-pack: center; |
| 32 | + -webkit-box-align: center; |
| 33 | + align-items: center; |
| 34 | + -webkit-box-pack: center; |
| 35 | + justify-content: center; |
| 36 | + padding-top: 40px; |
| 37 | + padding-bottom: 40px; |
| 38 | + background-color: #f5f5f5; |
| 39 | + } |
| 40 | +
|
| 41 | + .container { |
| 42 | + width: 100%; |
| 43 | + max-width: 400px; |
| 44 | + padding: 15px; |
| 45 | + margin: 0 auto; |
| 46 | + } |
| 47 | + </style> |
| 48 | +
|
| 49 | + <script> |
| 50 | + function processResult(status, icon, color, result){ |
| 51 | + $("#status").html(status); |
| 52 | + $("#animation").attr("class", "fas fa-"+icon+" fa-5x"); |
| 53 | + $("#animation").css("color", color); |
| 54 | + if(result !== "") { |
| 55 | + $(".result-container").attr("hidden",false); |
| 56 | + try { |
| 57 | + j = JSON.parse(result); |
| 58 | + $("#result").html(j['message']); |
| 59 | + } catch (e) { |
| 60 | + $("#result").html(result); |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | +
|
| 65 | + function processError(message){ |
| 66 | + processResult("An error occurred!", "times", "red", message); |
| 67 | + } |
| 68 | +
|
| 69 | + $(function(){ |
| 70 | + $.get("/api", {}, function(res, status, xhr){ |
| 71 | + if(xhr.status === 200) { |
| 72 | + processResult("Successfully connected to https://demo.secrethub.io/api!", "check", "green", res); |
| 73 | + } else { |
| 74 | + console.log(res, status, xhr); |
| 75 | + processError(res); |
| 76 | + } |
| 77 | + }).catch(function(res){ |
| 78 | + processError(res.responseText); |
| 79 | + }); |
| 80 | + }); |
| 81 | + </script> |
| 82 | +</head> |
| 83 | +
|
| 84 | +<body class="text-center"> |
| 85 | +<div class="container"> |
| 86 | + <img class="mb-4" src="https://secrethub.io/img/secrethub-logo-rgb-shield-square.png" alt="SecretHub logo" width="60" height="60"> |
| 87 | + <h1 class="h3 mb-3 font-weight-normal">Demo App</h1> |
| 88 | + <i id="animation" class="fas fa-spinner fa-spin fa-3x"> </i> |
| 89 | + <p id="status">Trying to connect to https://demo.secrethub.io/api...</p> |
| 90 | + <div class="result-container mt-3 card" hidden> |
| 91 | + <div class="card-header"> |
| 92 | + Result |
| 93 | + </div> |
| 94 | + <div class="card-body" id="result"> |
| 95 | + </div> |
| 96 | + </div> |
| 97 | + <p class="mt-5 mb-3 text-muted">Read the <a href="https://secrethub.io/docs/reference/cli/demo/" target="_blank">documentation</a> for this app</p> |
| 98 | +</div> |
| 99 | +</body> |
| 100 | +</html> |
| 101 | +` |
0 commit comments