Commit ·
722ee06
1
Parent(s): d34735d
update file 014
Browse files- templates/index.html +101 -31
templates/index.html
CHANGED
|
@@ -5,55 +5,56 @@
|
|
| 5 |
<style>
|
| 6 |
body {
|
| 7 |
font-family: Arial, sans-serif;
|
| 8 |
-
padding: 40px;
|
| 9 |
background-color: #f0f2f5;
|
|
|
|
| 10 |
}
|
| 11 |
-
|
| 12 |
-
background: white;
|
| 13 |
-
padding: 30px;
|
| 14 |
-
border-radius: 10px;
|
| 15 |
-
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1);
|
| 16 |
max-width: 600px;
|
|
|
|
|
|
|
| 17 |
margin: auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
width: 100%;
|
| 21 |
-
padding:
|
| 22 |
-
margin: 10px
|
|
|
|
| 23 |
border: 1px solid #ccc;
|
| 24 |
-
border-radius: 8px;
|
| 25 |
}
|
| 26 |
button {
|
|
|
|
|
|
|
| 27 |
background-color: #007bff;
|
|
|
|
| 28 |
border: none;
|
| 29 |
-
padding: 12px 25px;
|
| 30 |
border-radius: 8px;
|
| 31 |
-
color: white;
|
| 32 |
-
font-size: 16px;
|
| 33 |
-
}
|
| 34 |
-
.ticket-box {
|
| 35 |
-
background: #e6ffe6;
|
| 36 |
-
padding: 20px;
|
| 37 |
-
margin-top: 30px;
|
| 38 |
-
border-radius: 10px;
|
| 39 |
}
|
| 40 |
</style>
|
| 41 |
</head>
|
| 42 |
<body>
|
| 43 |
|
| 44 |
-
<
|
| 45 |
-
|
| 46 |
-
<
|
| 47 |
-
<label for="name">Employee Name:</label>
|
| 48 |
-
<input type="text" name="name" required>
|
| 49 |
-
|
| 50 |
-
<label for="email">Email:</label>
|
| 51 |
-
<input type="email" name="email" required>
|
| 52 |
-
|
| 53 |
-
<label for="issue">Issue Description:</label>
|
| 54 |
-
<textarea name="issue" rows="5" required></textarea>
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
</form>
|
| 58 |
|
| 59 |
{% if ticket %}
|
|
@@ -68,5 +69,74 @@
|
|
| 68 |
<a href="/tickets">📄 View Submitted Tickets</a>
|
| 69 |
</p>
|
| 70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
</body>
|
| 72 |
</html>
|
|
|
|
| 5 |
<style>
|
| 6 |
body {
|
| 7 |
font-family: Arial, sans-serif;
|
|
|
|
| 8 |
background-color: #f0f2f5;
|
| 9 |
+
padding: 40px;
|
| 10 |
}
|
| 11 |
+
.chat-box {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
max-width: 600px;
|
| 13 |
+
background: white;
|
| 14 |
+
padding: 20px;
|
| 15 |
margin: auto;
|
| 16 |
+
border-radius: 10px;
|
| 17 |
+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
|
| 18 |
+
}
|
| 19 |
+
.message {
|
| 20 |
+
margin: 10px 0;
|
| 21 |
+
}
|
| 22 |
+
.message.bot {
|
| 23 |
+
color: #333;
|
| 24 |
}
|
| 25 |
+
.message.user {
|
| 26 |
+
color: #007bff;
|
| 27 |
+
text-align: right;
|
| 28 |
+
}
|
| 29 |
+
input, select {
|
| 30 |
width: 100%;
|
| 31 |
+
padding: 10px;
|
| 32 |
+
margin-top: 10px;
|
| 33 |
+
border-radius: 6px;
|
| 34 |
border: 1px solid #ccc;
|
|
|
|
| 35 |
}
|
| 36 |
button {
|
| 37 |
+
margin-top: 20px;
|
| 38 |
+
padding: 12px 20px;
|
| 39 |
background-color: #007bff;
|
| 40 |
+
color: white;
|
| 41 |
border: none;
|
|
|
|
| 42 |
border-radius: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
</style>
|
| 45 |
</head>
|
| 46 |
<body>
|
| 47 |
|
| 48 |
+
<div class="chat-box" id="chatBox">
|
| 49 |
+
<div class="message bot">Hi! Let's create your HR ticket. What is your first name?</div>
|
| 50 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
<form id="chatForm" style="display:none;" action="/generate" method="post">
|
| 53 |
+
<input type="hidden" name="name" id="nameField">
|
| 54 |
+
<input type="hidden" name="email" id="emailField">
|
| 55 |
+
<input type="hidden" name="issue" id="issueField">
|
| 56 |
+
<input type="hidden" name="priority" id="priorityField">
|
| 57 |
+
<input type="hidden" name="date" id="dateField">
|
| 58 |
</form>
|
| 59 |
|
| 60 |
{% if ticket %}
|
|
|
|
| 69 |
<a href="/tickets">📄 View Submitted Tickets</a>
|
| 70 |
</p>
|
| 71 |
|
| 72 |
+
<script>
|
| 73 |
+
const chatBox = document.getElementById("chatBox");
|
| 74 |
+
const form = document.getElementById("chatForm");
|
| 75 |
+
|
| 76 |
+
const questions = [
|
| 77 |
+
{ label: "First Name", field: "firstName", type: "text" },
|
| 78 |
+
{ label: "Last Name", field: "lastName", type: "text" },
|
| 79 |
+
{ label: "Email Address", field: "email", type: "email" },
|
| 80 |
+
{ label: "Describe the issue you're facing", field: "issue", type: "textarea" },
|
| 81 |
+
{
|
| 82 |
+
label: "Select priority",
|
| 83 |
+
field: "priority",
|
| 84 |
+
type: "select",
|
| 85 |
+
options: ["High", "Medium", "Low"]
|
| 86 |
+
},
|
| 87 |
+
{ label: "Date of issue", field: "date", type: "date" }
|
| 88 |
+
];
|
| 89 |
+
|
| 90 |
+
let current = 0;
|
| 91 |
+
let responses = {};
|
| 92 |
+
|
| 93 |
+
function nextQuestion() {
|
| 94 |
+
if (current >= questions.length) {
|
| 95 |
+
document.getElementById("nameField").value = responses.firstName + " " + responses.lastName;
|
| 96 |
+
document.getElementById("emailField").value = responses.email;
|
| 97 |
+
document.getElementById("issueField").value = responses.issue;
|
| 98 |
+
document.getElementById("priorityField").value = responses.priority;
|
| 99 |
+
document.getElementById("dateField").value = responses.date;
|
| 100 |
+
form.submit();
|
| 101 |
+
return;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
const q = questions[current];
|
| 105 |
+
const inputId = "input_" + q.field;
|
| 106 |
+
let inputElement;
|
| 107 |
+
|
| 108 |
+
let html = `<div class="message bot">${q.label}</div>`;
|
| 109 |
+
|
| 110 |
+
if (q.type === "select") {
|
| 111 |
+
html += `<select id="${inputId}">`;
|
| 112 |
+
q.options.forEach(opt => {
|
| 113 |
+
html += `<option value="${opt}">${opt}</option>`;
|
| 114 |
+
});
|
| 115 |
+
html += `</select>`;
|
| 116 |
+
} else if (q.type === "textarea") {
|
| 117 |
+
html += `<textarea id="${inputId}" rows="4"></textarea>`;
|
| 118 |
+
} else {
|
| 119 |
+
html += `<input type="${q.type}" id="${inputId}" />`;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
html += `<button onclick="handleInput('${q.field}', '${inputId}'); return false;">Next</button>`;
|
| 123 |
+
chatBox.innerHTML += html;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
function handleInput(field, inputId) {
|
| 127 |
+
const value = document.getElementById(inputId).value.trim();
|
| 128 |
+
if (!value) return;
|
| 129 |
+
|
| 130 |
+
responses[field] = value;
|
| 131 |
+
|
| 132 |
+
const userReply = `<div class="message user">${value}</div>`;
|
| 133 |
+
chatBox.innerHTML += userReply;
|
| 134 |
+
current++;
|
| 135 |
+
setTimeout(nextQuestion, 500);
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
window.onload = nextQuestion;
|
| 139 |
+
</script>
|
| 140 |
+
|
| 141 |
</body>
|
| 142 |
</html>
|