Spaces:
Build error
Build error
File size: 5,436 Bytes
26063ff |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BPMN Diagram Generator</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<style>
body {
background-color: #f8f9fa;
}
.card {
background-color: #fff;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.card-header {
background-color: #343a40;
color: #fff;
border-top-left-radius: 12px;
border-top-right-radius: 12px;
}
.btn-primary {
background-color: #007bff;
border-color: #007bff;
}
.btn-primary:hover {
background-color: #0056b3;
border-color: #004a99;
}
.btn-secondary {
background-color: #6c757d;
border-color: #6c757d;
}
.btn-secondary:hover {
background-color: #5a6268;
border-color: #545b62;
}
.loader {
border: 4px solid #f3f3f3;
border-top: 4px solid #007bff;
border-radius: 50%;
width: 30px;
height: 30px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="container my-5">
<h1 class="mb-4 text-center text-dark">
<i class="fas fa-project-diagram mr-2"></i>
BPMN Generator
</h1>
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card mb-4">
<div class="card-header">
<i class="fas fa-code mr-2"></i>
Generate BPMN
</div>
<div class="card-body">
<div class="form-group">
<label for="promptInput" class="form-label">Enter text:</label>
<textarea class="form-control" id="promptInput" rows="3"></textarea>
</div>
<div class="form-group" style="margin-top: 20px;">
<div class="d-flex justify-content-between">
<button class="btn btn-primary" id="generateButton">
<i class="fa fa-cog fa-spin d-none" id="loadingIcon"></i>
Generate
</button>
<button class="btn btn-secondary" id="saveButton" style="display: none;">
<i class="fas fa-download mr-2"></i>
Save Image
</button>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<i class="fas fa-file-alt mr-2"></i>
Output
</div>
<div class="card-body">
<div class="form-group" style="display: none;">
<label for="pipeFlowText" class="form-label">Pipe Flow Text:</label>
<p id="pipeFlowText"></p>
</div>
<div class="form-group">
<label for="pipeFlowImage" class="form-label">Pipe Flow Image:</label>
<img id="pipeFlowImage" alt="Pipe Flow Image" class="img-fluid d-none">
</div>
</div>
</div>
</div>
</div>
</div>
<script>
const generateButton = document.getElementById('generateButton');
const saveButton = document.getElementById('saveButton');
const loadingIcon = document.getElementById('loadingIcon');
const pipeFlowText = document.getElementById('pipeFlowText');
const pipeFlowImage = document.getElementById('pipeFlowImage');
generateButton.addEventListener('click', async () => {
const promptInput = document.getElementById('promptInput').value;
if (!promptInput) {
alert('Please enter some text.');
return;
}
// Show the loading indicator
loadingIcon.classList.remove('d-none');
try {
const response = await fetch('http://localhost:8000/generate/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ prompt: promptInput })
});
const data = await response.json();
// Hide the loading indicator
loadingIcon.classList.add('d-none');
pipeFlowText.textContent = data.pipeFlowText;
if (data.pipeFlowImage) {
pipeFlowImage.src = `data:image/png;base64,${data.pipeFlowImage}`;
pipeFlowImage.classList.remove('d-none');
saveButton.style.display = 'inline-block';
} else {
pipeFlowImage.classList.add('d-none');
saveButton.style.display = 'none';
}
saveButton.addEventListener('click', () => {
const link = document.createElement('a');
link.download = 'bpmn-diagram.png';
link.href = pipeFlowImage.src;
link.click();
});
} catch (error) {
// Hide the loading indicator
loadingIcon.classList.add('d-none');
alert('Error generating the BPMN diagram. Please try again later.');
console.error('Error:', error);
}
});
</script>
</body>
</html>
|