Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f28a9e40c | ||
|
|
7762c9f308 | ||
|
|
d79f806c59 |
+36
-15
@@ -500,7 +500,6 @@ n .btn-secondary {
|
|||||||
<div id="createTab" class="tab-content">
|
<div id="createTab" class="tab-content">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<h2>➕ Create New Site Survey</h2>
|
<h2>➕ Create New Site Survey</h2>
|
||||||
<button class="btn" onclick="loadSampleData()" style="background: var(--success); color: #fff; margin-bottom: 15px;">📋 Load Sample Data</button>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Survey Name</label>
|
<label>Survey Name</label>
|
||||||
@@ -532,6 +531,7 @@ n .btn-secondary {
|
|||||||
<div id="surveyForm">
|
<div id="surveyForm">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<h2 id="currentSurveyName">Site Survey</h2>
|
<h2 id="currentSurveyName">Site Survey</h2>
|
||||||
|
<button class="btn" onclick="loadSampleData()" style="background: var(--success); color: #fff; margin-bottom: 15px;">📋 Load Sample Data</button>
|
||||||
<div id="surveyQuestions"></div>
|
<div id="surveyQuestions"></div>
|
||||||
|
|
||||||
<!-- Photo Upload Section -->
|
<!-- Photo Upload Section -->
|
||||||
@@ -921,9 +921,6 @@ n .btn-secondary {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we have question responses
|
|
||||||
const hasResponses = Object.keys(createSurveyResponses).length > 0;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/surveys', {
|
const response = await fetch('/api/surveys', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -932,23 +929,32 @@ n .btn-secondary {
|
|||||||
name,
|
name,
|
||||||
client_name: clientName,
|
client_name: clientName,
|
||||||
site_name: siteName,
|
site_name: siteName,
|
||||||
description,
|
description
|
||||||
responses: hasResponses ? createSurveyResponses : undefined
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorData = await response.json();
|
||||||
|
throw new Error(errorData.error || 'Failed to create survey');
|
||||||
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
|
// Clear form
|
||||||
document.getElementById('surveyName').value = '';
|
document.getElementById('surveyName').value = '';
|
||||||
document.getElementById('clientName').value = '';
|
document.getElementById('clientName').value = '';
|
||||||
document.getElementById('siteName').value = '';
|
document.getElementById('siteName').value = '';
|
||||||
document.getElementById('surveyDescription').value = '';
|
document.getElementById('surveyDescription').value = '';
|
||||||
|
|
||||||
await loadSurveys();
|
await loadSurveys();
|
||||||
loadSurvey(data.survey.id);
|
|
||||||
|
// Switch to surveys tab to show the new survey
|
||||||
|
switchTab('surveys');
|
||||||
|
alert('Survey created successfully! Click on it to take the survey.');
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert('Failed to create survey');
|
console.error('Error creating survey:', e);
|
||||||
|
alert('Failed to create survey: ' + e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1439,12 +1445,6 @@ n .btn-secondary {
|
|||||||
|
|
||||||
console.log('Loading sample data...');
|
console.log('Loading sample data...');
|
||||||
|
|
||||||
// Set survey metadata
|
|
||||||
document.getElementById('surveyName').value = 'Sample Corporate Office Survey';
|
|
||||||
document.getElementById('clientName').value = 'Acme Corporation';
|
|
||||||
document.getElementById('siteName').value = 'Main Office - Downtown';
|
|
||||||
document.getElementById('surveyDescription').value = 'Comprehensive network infrastructure assessment for downtown office location';
|
|
||||||
|
|
||||||
// Sample data for all questions (keyed by question number like 'q1', 'q2')
|
// Sample data for all questions (keyed by question number like 'q1', 'q2')
|
||||||
const sampleValues = {
|
const sampleValues = {
|
||||||
'q1': '3500',
|
'q1': '3500',
|
||||||
@@ -1567,7 +1567,28 @@ function confirmClearAll() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function clearAllSurveys() {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/surveys', {
|
||||||
|
method: 'DELETE'
|
||||||
|
});
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (data.success) {
|
||||||
|
showNotification('All surveys deleted successfully', 'success');
|
||||||
|
loadSurveys();
|
||||||
|
currentSurveyId = null;
|
||||||
|
currentSurvey = null;
|
||||||
|
document.getElementById('takeSurveyTab').style.display = 'none';
|
||||||
|
document.getElementById('analyzeTab').style.display = 'none';
|
||||||
|
} else {
|
||||||
|
showNotification(data.error || 'Failed to clear surveys', 'error');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error clearing surveys:', e);
|
||||||
|
showNotification('Failed to clear surveys', 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Notification helper
|
// Notification helper
|
||||||
function showNotification(message, type = 'info') {
|
function showNotification(message, type = 'info') {
|
||||||
|
|||||||
Reference in New Issue
Block a user