TANMIHA commited on
Commit
e8438a4
Β·
verified Β·
1 Parent(s): f1c52e7

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +159 -159
static/index.html CHANGED
@@ -1,160 +1,160 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>MTOR - Intelligent, Script-Driven Support</title>
7
- <link rel="stylesheet" href="/static/style.css">
8
- </head>
9
- <body>
10
-
11
- <div class="main-container">
12
- <div class="title-container">
13
- <h1>πŸ€– MTOR - Intelligent, Script-Driven Support</h1>
14
- </div>
15
- <div class="subtitle">Your Personalized AI IT Support Assistant</div>
16
- <div class="description"><em>Facing a tech issue? Describe it below and let MTOR handle it for you.</em></div>
17
-
18
- <div class="input-label">πŸ’¬ <strong>Describe your IT issue:</strong></div>
19
- <textarea id="userInput" placeholder="e.g. My VPN keeps disconnecting every 10 minutes..." rows="6"></textarea>
20
- <button id="submitBtn" onclick="resolveIssue()">πŸš€ Resolve Now</button>
21
-
22
- <div id="loading" style="display: none;"><em>MTOR is resolving your issue... ⏳</em></div>
23
-
24
- <div id="responseSection" style="display: none;">
25
- <div class="success-box">βœ… **AI Response:**</div>
26
- <div id="aiResponseText"></div>
27
-
28
- <div id="batDownloadSection" class="download-section" style="display: none;">
29
- <p>⚑ <strong>Auto-Fix Script Available!</strong> Download and run this file to fix your issue automatically.</p>
30
- <button id="batBtn" class="download-btn">⬇️ Download Windows Fix (.bat)</button>
31
- </div>
32
-
33
- <div id="shDownloadSection" class="download-section" style="display: none;">
34
- <p>⚑ <strong>Auto-Fix Script Available!</strong> Download and run this file in your terminal to fix your issue automatically.</p>
35
- <button id="shBtn" class="download-btn">⬇️ Download Mac/Linux Fix (.sh)</button>
36
- </div>
37
- </div>
38
-
39
- <div id="feedbackSection" class="feedback-section" style="display: none;">
40
- <h3>πŸ™‹ Was this solution helpful?</h3>
41
- <div class="feedback-buttons">
42
- <button onclick="handleFeedback(true)">βœ… Yes, issue resolved</button>
43
- <button onclick="handleFeedback(false)">❌ No, not helpful</button>
44
- </div>
45
- <div id="feedbackResult"></div>
46
- </div>
47
- </div>
48
-
49
- <script>
50
- // Global variables to store generated scripts
51
- let batScript = "";
52
- let shScript = "";
53
- let currentUserInput = "";
54
-
55
- async function resolveIssue() {
56
- const inputField = document.getElementById("userInput");
57
- currentUserInput = inputField.value.trim();
58
-
59
- if (!currentUserInput) return;
60
-
61
- // Update UI State
62
- document.getElementById("submitBtn").disabled = true;
63
- document.getElementById("loading").style.display = "block";
64
- document.getElementById("responseSection").style.display = "none";
65
- document.getElementById("feedbackSection").style.display = "none";
66
- document.getElementById("batDownloadSection").style.display = "none";
67
- document.getElementById("shDownloadSection").style.display = "none";
68
- document.getElementById("feedbackResult").innerHTML = "";
69
-
70
- try {
71
- // Send request to your FastAPI backend
72
- const response = await fetch('/chat', {
73
- method: 'POST',
74
- headers: { 'Content-Type': 'application/json' },
75
- body: JSON.stringify({ message: currentUserInput })
76
- });
77
-
78
- const data = await response.json();
79
- let finalResponse = data.reply;
80
-
81
- // --- SCRIPT EXTRACTION (Regex) ---
82
- const batRegex = /<SCRIPT_BAT>([\s\S]*?)<\/SCRIPT_BAT>/;
83
- const shRegex = /<SCRIPT_SH>([\s\S]*?)<\/SCRIPT_SH>/;
84
-
85
- const batMatch = finalResponse.match(batRegex);
86
- if (batMatch) {
87
- batScript = batMatch[1].trim();
88
- document.getElementById("batDownloadSection").style.display = "block";
89
- document.getElementById("batBtn").onclick = () => downloadFile(batScript, "supportx_autofix.bat");
90
- }
91
-
92
- const shMatch = finalResponse.match(shRegex);
93
- if (shMatch) {
94
- shScript = shMatch[1].trim();
95
- document.getElementById("shDownloadSection").style.display = "block";
96
- document.getElementById("shBtn").onclick = () => downloadFile(shScript, "supportx_autofix.sh");
97
- }
98
-
99
- // Clean the text for display (remove the tags)
100
- let displayText = finalResponse.replace(batRegex, '').replace(shRegex, '').trim();
101
-
102
- // Show response
103
- document.getElementById("aiResponseText").innerText = displayText;
104
- document.getElementById("responseSection").style.display = "block";
105
- document.getElementById("feedbackSection").style.display = "block";
106
-
107
- } catch (error) {
108
- alert("Error connecting to MTOR backend. Is FastAPI running?");
109
- } finally {
110
- document.getElementById("submitBtn").disabled = false;
111
- document.getElementById("loading").style.display = "none";
112
- }
113
- }
114
-
115
- async function handleFeedback(isResolved) {
116
- const feedbackContainer = document.getElementById("feedbackResult");
117
-
118
- if (isResolved) {
119
- feedbackContainer.innerHTML = "<div class='success-box'>πŸŽ‰ Great! We're glad your issue is resolved. Thank you!</div>";
120
- document.querySelector('.feedback-buttons').style.display = "none";
121
- } else {
122
- // Generate Ticket ID
123
- const ticketId = "TKT-" + Math.random().toString(36).substring(2, 8).toUpperCase();
124
- feedbackContainer.innerHTML = `
125
- <div class='warning-box'>⚠️ We're escalating this issue to IT support.</div>
126
- <div class='ticket-id'>πŸ“„ Ticket Created: ${ticketId}</div>
127
- <div id='escalationLoading'><em>Notifying IT Agent... ⏳</em></div>
128
- `;
129
- document.querySelector('.feedback-buttons').style.display = "none";
130
-
131
- // Call backend to trigger Notification Agent
132
- try {
133
- const response = await fetch('/escalate', {
134
- method: 'POST',
135
- headers: { 'Content-Type': 'application/json' },
136
- body: JSON.stringify({ issue: currentUserInput, ticket_id: ticketId })
137
- });
138
- const data = await response.json();
139
-
140
- document.getElementById('escalationLoading').style.display = "none";
141
- feedbackContainer.innerHTML += `<div class='info-box'>πŸ“¨ **Notification Agent Response:**<br><br>${data.reply}</div>`;
142
- } catch (error) {
143
- document.getElementById('escalationLoading').innerHTML = "Failed to notify agent.";
144
- }
145
- }
146
- }
147
-
148
- // Helper function to trigger browser file download
149
- function downloadFile(content, filename) {
150
- const blob = new Blob([content], { type: 'text/plain' });
151
- const url = URL.createObjectURL(blob);
152
- const a = document.createElement('a');
153
- a.href = url;
154
- a.download = filename;
155
- a.click();
156
- URL.revokeObjectURL(url);
157
- }
158
- </script>
159
- </body>
160
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>MTOR - Intelligent, Script-Driven Support</title>
7
+ <link rel="stylesheet" href="/static/style.css">
8
+ </head>
9
+ <body>
10
+
11
+ <div class="main-container">
12
+ <div class="title-container">
13
+ <h1>πŸ€– MTOR - Intelligent, Script-Driven Support</h1>
14
+ </div>
15
+ <div class="subtitle">Your Personalized AI IT Support Assistant</div>
16
+ <div class="description"><em>Facing a tech issue? Describe it below and let MTOR handle it for you.</em></div>
17
+
18
+ <div class="input-label">πŸ’¬ <strong>Describe your IT issue:</strong></div>
19
+ <textarea id="userInput" placeholder="e.g. My VPN keeps disconnecting every 10 minutes..." rows="6"></textarea>
20
+ <button id="submitBtn" onclick="resolveIssue()">πŸš€ Resolve Now</button>
21
+
22
+ <div id="loading" style="display: none;"><em>MTOR is resolving your issue... ⏳</em></div>
23
+
24
+ <div id="responseSection" style="display: none;">
25
+ <div class="success-box">βœ… **AI Response:**</div>
26
+ <div id="aiResponseText"></div>
27
+
28
+ <div id="batDownloadSection" class="download-section" style="display: none;">
29
+ <p>⚑ <strong>Auto-Fix Script Available!</strong> Download and run this file to fix your issue automatically.</p>
30
+ <button id="batBtn" class="download-btn">⬇️ Download Windows Fix (.bat)</button>
31
+ </div>
32
+
33
+ <div id="shDownloadSection" class="download-section" style="display: none;">
34
+ <p>⚑ <strong>Auto-Fix Script Available!</strong> Download and run this file in your terminal to fix your issue automatically.</p>
35
+ <button id="shBtn" class="download-btn">⬇️ Download Mac/Linux Fix (.sh)</button>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="feedbackSection" class="feedback-section" style="display: none;">
40
+ <h3>πŸ™‹ Was this solution helpful?</h3>
41
+ <div class="feedback-buttons">
42
+ <button onclick="handleFeedback(true)">βœ… Yes, issue resolved</button>
43
+ <button onclick="handleFeedback(false)">❌ No, not helpful</button>
44
+ </div>
45
+ <div id="feedbackResult"></div>
46
+ </div>
47
+ </div>
48
+
49
+ <script>
50
+ // Global variables to store generated scripts
51
+ let batScript = "";
52
+ let shScript = "";
53
+ let currentUserInput = "";
54
+
55
+ async function resolveIssue() {
56
+ const inputField = document.getElementById("userInput");
57
+ currentUserInput = inputField.value.trim();
58
+
59
+ if (!currentUserInput) return;
60
+
61
+ // Update UI State
62
+ document.getElementById("submitBtn").disabled = true;
63
+ document.getElementById("loading").style.display = "block";
64
+ document.getElementById("responseSection").style.display = "none";
65
+ document.getElementById("feedbackSection").style.display = "none";
66
+ document.getElementById("batDownloadSection").style.display = "none";
67
+ document.getElementById("shDownloadSection").style.display = "none";
68
+ document.getElementById("feedbackResult").innerHTML = "";
69
+
70
+ try {
71
+ // Send request to your FastAPI backend
72
+ const response = await fetch('/chat', {
73
+ method: 'POST',
74
+ headers: { 'Content-Type': 'application/json' },
75
+ body: JSON.stringify({ message: currentUserInput })
76
+ });
77
+
78
+ const data = await response.json();
79
+ let finalResponse = data.reply;
80
+
81
+ // --- SCRIPT EXTRACTION (Regex) ---
82
+ const batRegex = /<SCRIPT_BAT>([\s\S]*?)<\/SCRIPT_BAT>/;
83
+ const shRegex = /<SCRIPT_SH>([\s\S]*?)<\/SCRIPT_SH>/;
84
+
85
+ const batMatch = finalResponse.match(batRegex);
86
+ if (batMatch) {
87
+ batScript = batMatch[1].trim();
88
+ document.getElementById("batDownloadSection").style.display = "block";
89
+ document.getElementById("batBtn").onclick = () => downloadFile(batScript, "supportx_autofix.bat");
90
+ }
91
+
92
+ const shMatch = finalResponse.match(shRegex);
93
+ if (shMatch) {
94
+ shScript = shMatch[1].trim();
95
+ document.getElementById("shDownloadSection").style.display = "block";
96
+ document.getElementById("shBtn").onclick = () => downloadFile(shScript, "supportx_autofix.sh");
97
+ }
98
+
99
+ // Clean the text for display (remove the tags)
100
+ let displayText = finalResponse.replace(batRegex, '').replace(shRegex, '').trim();
101
+
102
+ // Show response
103
+ document.getElementById("aiResponseText").innerText = displayText;
104
+ document.getElementById("responseSection").style.display = "block";
105
+ document.getElementById("feedbackSection").style.display = "block";
106
+
107
+ } catch (error) {
108
+ alert("Error connecting to MTOR backend. Is FastAPI running?");
109
+ } finally {
110
+ document.getElementById("submitBtn").disabled = false;
111
+ document.getElementById("loading").style.display = "none";
112
+ }
113
+ }
114
+
115
+ async function handleFeedback(isResolved) {
116
+ const feedbackContainer = document.getElementById("feedbackResult");
117
+
118
+ if (isResolved) {
119
+ feedbackContainer.innerHTML = "<div class='success-box'>πŸŽ‰ Great! We're glad your issue is resolved. Thank you!</div>";
120
+ document.querySelector('.feedback-buttons').style.display = "none";
121
+ } else {
122
+ // Generate Ticket ID
123
+ const ticketId = "TKT-" + Math.random().toString(36).substring(2, 8).toUpperCase();
124
+ feedbackContainer.innerHTML = `
125
+ <div class='warning-box'>⚠️ We're escalating this issue to IT support.</div>
126
+ <div class='ticket-id'>πŸ“„ Ticket Created: ${ticketId}</div>
127
+ <div id='escalationLoading'><em>Notifying IT Agent... ⏳</em></div>
128
+ `;
129
+ document.querySelector('.feedback-buttons').style.display = "none";
130
+
131
+ // Call backend to trigger Notification Agent
132
+ try {
133
+ const response = await fetch('/escalate', {
134
+ method: 'POST',
135
+ headers: { 'Content-Type': 'application/json' },
136
+ body: JSON.stringify({ issue: currentUserInput, ticket_id: ticketId })
137
+ });
138
+ const data = await response.json();
139
+
140
+ document.getElementById('escalationLoading').style.display = "none";
141
+ feedbackContainer.innerHTML += `<div class='info-box'>πŸ“¨ **Notification Agent Response:**<br><br>${data.reply}</div>`;
142
+ } catch (error) {
143
+ document.getElementById('escalationLoading').innerHTML = "Failed to notify agent.";
144
+ }
145
+ }
146
+ }
147
+
148
+ // Helper function to trigger browser file download
149
+ function downloadFile(content, filename) {
150
+ const blob = new Blob([content], { type: 'text/plain' });
151
+ const url = URL.createObjectURL(blob);
152
+ const a = document.createElement('a');
153
+ a.href = url;
154
+ a.download = filename;
155
+ a.click();
156
+ URL.revokeObjectURL(url);
157
+ }
158
+ </script>
159
+ </body>
160
  </html>