mirror of
https://github.com/thecyberlearn/quantum-ai-v2.git
synced 2026-08-18 12:52:59 +00:00
Implement unified CSS system and fix data analyzer network errors
## Unified Agent Architecture - Create agent-base.css with theme support (professional, creative, minimal) - Implement shared JavaScript utilities in agent-utils.js - Standardize form submission patterns across all agents - Reduce code duplication by ~600 lines ## CSS Theme System - Professional theme: Job posting, data analyzer, weather reporter - Creative theme: Social ads generator (glassmorphism effects) - Minimal theme: Available for future agents - Consistent component library with CSS custom properties ## Text Display Standardization - Replace complex markdown parsing with simple text formatting - Remove external dependencies (Marked.js + DOMPurify) - Implement basic text cleaning: remove **, convert line breaks to <br> - Fix layout stretching issues in job posting results ## Data Analyzer Fixes - Fix network errors by converting from button click to form submission - Update to use unified CSS system and professional theme - Improve file upload handling with conditional checks - Standardize template structure with other agents ## Form Submission Improvements - Unified form submission pattern across all agents - Automatic CSRF token handling via FormData(form) - Consistent error handling and user feedback - Reliable polling mechanism for webhook-based agents ## Documentation Updates - Document unified CSS system and theme architecture - Add text display standardization guidelines - Update agent examples with current features - Include form submission best practices 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8cc9bb0609
commit
aeaf0be031
@ -4,6 +4,17 @@
|
|||||||
{% block title %}Data Analyzer Agent - NetCop AI Hub{% endblock %}
|
{% block title %}Data Analyzer Agent - NetCop AI Hub{% endblock %}
|
||||||
|
|
||||||
{% block extra_css %}
|
{% block extra_css %}
|
||||||
|
<!-- Optimized Font Loading -->
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- External Stylesheets -->
|
||||||
|
<link rel="stylesheet" href="{% static 'css/themes.css' %}">
|
||||||
|
<link rel="stylesheet" href="{% static 'css/agent-base.css' %}">
|
||||||
|
|
||||||
|
<!-- Shared JavaScript Utilities -->
|
||||||
|
<script src="{% static 'js/agent-utils.js' %}"></script>
|
||||||
<style>
|
<style>
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@ -312,13 +323,13 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="data-analyzer-page">
|
<div class="agent-page theme-professional">
|
||||||
<div class="container">
|
<div class="agent-container">
|
||||||
{% csrf_token %}
|
<!-- Main Content -->
|
||||||
<!-- Main Content Grid -->
|
|
||||||
<div class="main-grid">
|
|
||||||
<!-- Input Form -->
|
|
||||||
<div>
|
<div>
|
||||||
|
<form method="POST" id="dataAnalyzerForm">
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
<!-- File Upload Section -->
|
<!-- File Upload Section -->
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h3 class="section-title">📁 Upload Your Data File</h3>
|
<h3 class="section-title">📁 Upload Your Data File</h3>
|
||||||
@ -405,6 +416,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
<!-- Processing Status -->
|
<!-- Processing Status -->
|
||||||
<div id="processingStatus" class="processing-status" style="display: none;">
|
<div id="processingStatus" class="processing-status" style="display: none;">
|
||||||
@ -460,9 +472,10 @@
|
|||||||
<div class="balance-label">Available Balance</div>
|
<div class="balance-label">Available Balance</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
type="submit"
|
||||||
|
form="dataAnalyzerForm"
|
||||||
class="btn btn-primary process-btn"
|
class="btn btn-primary process-btn"
|
||||||
id="processButton"
|
id="processButton"
|
||||||
onclick="analyzeData()"
|
|
||||||
>
|
>
|
||||||
📊 Analyze Data (5.00 AED)
|
📊 Analyze Data (5.00 AED)
|
||||||
</button>
|
</button>
|
||||||
@ -480,7 +493,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_js %}
|
{% block extra_js %}
|
||||||
@ -523,7 +535,7 @@
|
|||||||
fileInput.files = files;
|
fileInput.files = files;
|
||||||
showFilePreview(file);
|
showFilePreview(file);
|
||||||
} else {
|
} else {
|
||||||
showToast('Please select a valid data file (PDF, CSV, Excel)', 'error');
|
AgentUtils.showToast('Please select a valid data file (PDF, CSV, Excel)', 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -573,10 +585,11 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Analysis function
|
// Handle form submission
|
||||||
function analyzeData() {
|
document.getElementById('dataAnalyzerForm').addEventListener('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
if (!selectedFile) {
|
if (!selectedFile) {
|
||||||
showToast('Please select a data file', 'error');
|
AgentUtils.showToast('Please select a data file', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,15 +602,13 @@
|
|||||||
// Check wallet balance
|
// Check wallet balance
|
||||||
const balance = {{ user.wallet_balance|default:0 }};
|
const balance = {{ user.wallet_balance|default:0 }};
|
||||||
if (balance < 5.00) {
|
if (balance < 5.00) {
|
||||||
showToast('Insufficient balance! You need 5.00 AED.', 'error');
|
AgentUtils.showToast('Insufficient balance! You need 5.00 AED.', 'error');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = "{% url 'core:wallet' %}";
|
window.location.href = "{% url 'core:wallet' %}";
|
||||||
}, 2000);
|
}, 2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const analysisType = document.querySelector('input[name="analysisType"]:checked').value;
|
|
||||||
|
|
||||||
// Show processing status
|
// Show processing status
|
||||||
document.getElementById('processingStatus').style.display = 'block';
|
document.getElementById('processingStatus').style.display = 'block';
|
||||||
document.getElementById('processButton').disabled = true;
|
document.getElementById('processButton').disabled = true;
|
||||||
@ -624,12 +635,12 @@
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
// Submit form data to backend
|
// Submit form data to backend
|
||||||
const formData = new FormData();
|
const formData = new FormData(this);
|
||||||
|
if (selectedFile) {
|
||||||
formData.append('file', selectedFile);
|
formData.append('file', selectedFile);
|
||||||
formData.append('analysis_type', analysisType);
|
}
|
||||||
formData.append('csrfmiddlewaretoken', document.querySelector('[name=csrfmiddlewaretoken]').value);
|
|
||||||
|
|
||||||
fetch('/agents/data-analyzer/process/', {
|
fetch(window.location.href, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
headers: {
|
headers: {
|
||||||
@ -649,7 +660,7 @@
|
|||||||
document.getElementById('processButton').innerHTML = '📊 Analyze Data (5.00 AED)';
|
document.getElementById('processButton').innerHTML = '📊 Analyze Data (5.00 AED)';
|
||||||
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
showToast(`❌ ${result.error}`, 'error');
|
AgentUtils.showToast(`❌ ${result.error}`, 'error');
|
||||||
} else {
|
} else {
|
||||||
displayResults(result);
|
displayResults(result);
|
||||||
}
|
}
|
||||||
@ -661,30 +672,20 @@
|
|||||||
document.getElementById('processingStatus').style.display = 'none';
|
document.getElementById('processingStatus').style.display = 'none';
|
||||||
document.getElementById('processButton').disabled = false;
|
document.getElementById('processButton').disabled = false;
|
||||||
document.getElementById('processButton').innerHTML = '📊 Analyze Data (5.00 AED)';
|
document.getElementById('processButton').innerHTML = '📊 Analyze Data (5.00 AED)';
|
||||||
showToast('❌ Network error - please try again', 'error');
|
AgentUtils.showToast('❌ Network error - please try again', 'error');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Display analysis results
|
// Display analysis results with markdown parsing
|
||||||
function displayResults(result) {
|
function displayResults(result) {
|
||||||
const resultsContainer = document.getElementById('analysisResults');
|
AgentUtils.displayResults({
|
||||||
const contentContainer = document.getElementById('analysisContent');
|
result: result,
|
||||||
|
resultsId: 'analysisResults',
|
||||||
if (result.success && result.status === 'completed') {
|
contentId: 'analysisContent',
|
||||||
// Use the analysis content from backend
|
defaultMessage: 'Data analysis completed successfully!',
|
||||||
const content = result.report_text || result.analysis_results || result.insights_summary || 'Data analysis completed successfully!';
|
successMessage: '✅ Data analysis completed and payment processed!',
|
||||||
contentContainer.textContent = content;
|
errorMessage: '❌ Failed to analyze data - no charge applied'
|
||||||
resultsContainer.style.display = 'block';
|
});
|
||||||
|
|
||||||
// Update wallet balance if provided
|
|
||||||
if (result.wallet_balance !== undefined) {
|
|
||||||
updateWalletBalance(result.wallet_balance);
|
|
||||||
}
|
|
||||||
|
|
||||||
showToast('✅ Data analysis completed and payment processed!', 'success');
|
|
||||||
} else {
|
|
||||||
showToast('❌ Failed to analyze data - no charge applied', 'error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track polling and results to prevent duplicates
|
// Track polling and results to prevent duplicates
|
||||||
@ -706,7 +707,7 @@
|
|||||||
currentPollInterval = setInterval(() => {
|
currentPollInterval = setInterval(() => {
|
||||||
pollCount++;
|
pollCount++;
|
||||||
|
|
||||||
fetch(`/agents/data-analyzer/result/${requestId}/`)
|
fetch(`/agents/data-analyzer/status/${requestId}/`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP ${response.status}`);
|
throw new Error(`HTTP ${response.status}`);
|
||||||
@ -735,7 +736,7 @@
|
|||||||
document.getElementById('processingStatus').style.display = 'none';
|
document.getElementById('processingStatus').style.display = 'none';
|
||||||
document.getElementById('processButton').disabled = false;
|
document.getElementById('processButton').disabled = false;
|
||||||
document.getElementById('processButton').innerHTML = '📊 Analyze Data (5.00 AED)';
|
document.getElementById('processButton').innerHTML = '📊 Analyze Data (5.00 AED)';
|
||||||
showToast('❌ Processing timeout - please try again', 'error');
|
AgentUtils.showToast('❌ Processing timeout - please try again', 'error');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@ -745,7 +746,7 @@
|
|||||||
document.getElementById('processingStatus').style.display = 'none';
|
document.getElementById('processingStatus').style.display = 'none';
|
||||||
document.getElementById('processButton').disabled = false;
|
document.getElementById('processButton').disabled = false;
|
||||||
document.getElementById('processButton').innerHTML = '📊 Analyze Data (5.00 AED)';
|
document.getElementById('processButton').innerHTML = '📊 Analyze Data (5.00 AED)';
|
||||||
showToast('❌ Network error during processing - please try again', 'error');
|
AgentUtils.showToast('❌ Network error during processing - please try again', 'error');
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
@ -761,45 +762,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function copyAnalysisReport() {
|
function copyAnalysisReport() {
|
||||||
const reportText = document.getElementById('analysisContent').textContent;
|
const reportText = AgentUtils.generateTextForExport('analysisContent');
|
||||||
navigator.clipboard.writeText(reportText).then(() => {
|
AgentUtils.copyToClipboard(reportText, 'Analysis report copied to clipboard!');
|
||||||
showToast('📋 Analysis report copied to clipboard!', 'success');
|
|
||||||
}).catch(() => {
|
|
||||||
showToast('Failed to copy report', 'error');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadAnalysisReport() {
|
function downloadAnalysisReport() {
|
||||||
const reportText = document.getElementById('analysisContent').textContent;
|
const reportText = AgentUtils.generateTextForExport('analysisContent');
|
||||||
const blob = new Blob([reportText], { type: 'text/plain' });
|
AgentUtils.downloadAsFile(reportText, `data-analysis-report-${Date.now()}.txt`, 'Analysis report downloaded!');
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.href = url;
|
|
||||||
a.download = `data-analysis-report-${Date.now()}.txt`;
|
|
||||||
a.click();
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
showToast('💾 Analysis report downloaded!', 'success');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showToast(message, type = 'info') {
|
|
||||||
const toast = document.createElement('div');
|
|
||||||
toast.style.cssText = `
|
|
||||||
position: fixed;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
padding: 12px 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
color: white;
|
|
||||||
font-weight: 600;
|
|
||||||
z-index: 1000;
|
|
||||||
${type === 'success' ? 'background: var(--success-green);' : 'background: var(--error-red);'}
|
|
||||||
`;
|
|
||||||
toast.textContent = message;
|
|
||||||
document.body.appendChild(toast);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
toast.remove();
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
140
docs/CLAUDE.md
140
docs/CLAUDE.md
@ -192,9 +192,12 @@ The system uses Django templates in `agent_base/templates/agent_generator/` to g
|
|||||||
|
|
||||||
**Data Analysis Agent** (Price: 5.00 AED):
|
**Data Analysis Agent** (Price: 5.00 AED):
|
||||||
- **N8N Integration**: PDF analysis webhook processor
|
- **N8N Integration**: PDF analysis webhook processor
|
||||||
- **File Upload**: PDF-only with binary multipart upload
|
- **File Upload**: PDF, CSV, Excel files with drag-and-drop interface
|
||||||
- **Real-time Results**: AJAX display with wallet balance updates
|
- **Real-time Results**: AJAX display with wallet balance updates
|
||||||
- **Features**: Summary/Detailed/Statistical analysis types
|
- **Features**: Summary/Detailed/Statistical analysis types
|
||||||
|
- **Form Submission Pattern**: Uses unified form submission (not button click)
|
||||||
|
- **Unified CSS**: Uses agent-base.css with professional theme
|
||||||
|
- **Text Display**: Simple text formatting (no complex markdown parsing)
|
||||||
|
|
||||||
**Weather Reporter Agent** (Price: 2.00 AED):
|
**Weather Reporter Agent** (Price: 2.00 AED):
|
||||||
- **API Integration**: OpenWeatherMap API with direct calls
|
- **API Integration**: OpenWeatherMap API with direct calls
|
||||||
@ -202,6 +205,21 @@ The system uses Django templates in `agent_base/templates/agent_generator/` to g
|
|||||||
- **Formatted Reports**: Both current and detailed weather reports
|
- **Formatted Reports**: Both current and detailed weather reports
|
||||||
- **Real-time Results**: Dynamic display below form
|
- **Real-time Results**: Dynamic display below form
|
||||||
- **Error Handling**: API failures and invalid locations
|
- **Error Handling**: API failures and invalid locations
|
||||||
|
- **Unified CSS**: Uses agent-base.css with minimal theme
|
||||||
|
|
||||||
|
**Social Ads Generator Agent** (Price: 7.00 AED):
|
||||||
|
- **N8N Integration**: Social media ad generation via webhook
|
||||||
|
- **Platform Support**: Facebook, Instagram, LinkedIn, Twitter/X, TikTok, YouTube
|
||||||
|
- **Multi-language**: English, Arabic, Spanish, French, German, Chinese
|
||||||
|
- **Real-time Results**: Dynamic content generation and display
|
||||||
|
- **Unified CSS**: Uses agent-base.css with creative theme (glassmorphism)
|
||||||
|
|
||||||
|
**Job Posting Generator Agent** (Price: 4.00 AED):
|
||||||
|
- **N8N Integration**: Professional job posting creation
|
||||||
|
- **Comprehensive Forms**: Job details, requirements, company info
|
||||||
|
- **Multi-language Support**: Multiple output languages
|
||||||
|
- **Enhanced UX**: Progressive form validation and real-time feedback
|
||||||
|
- **Unified CSS**: Uses agent-base.css with professional theme
|
||||||
|
|
||||||
### Management Commands
|
### Management Commands
|
||||||
|
|
||||||
@ -511,6 +529,126 @@ STRIPE_WEBHOOK_SECRET=whsec_your_secret_here # Optional
|
|||||||
- **Simpler debugging** - You control the verification timing
|
- **Simpler debugging** - You control the verification timing
|
||||||
- **Production-proven** - Used by many successful platforms
|
- **Production-proven** - Used by many successful platforms
|
||||||
|
|
||||||
|
## Unified CSS and UI System
|
||||||
|
|
||||||
|
### Agent Styling Architecture
|
||||||
|
All agents now use a unified CSS system for consistent user experience and maintainability:
|
||||||
|
|
||||||
|
#### Core Files
|
||||||
|
- **`/static/css/agent-base.css`**: Unified component library for all agents
|
||||||
|
- **`/static/css/themes.css`**: Global color variables and themes
|
||||||
|
- **`/static/js/agent-utils.js`**: Shared JavaScript utilities for all agents
|
||||||
|
|
||||||
|
#### Theme System
|
||||||
|
The unified CSS supports multiple themes via CSS custom properties:
|
||||||
|
|
||||||
|
1. **Professional Theme** (Default - Black & White):
|
||||||
|
- Used by: Job Posting Generator, Data Analyzer, Weather Reporter
|
||||||
|
- Clean, corporate appearance with subtle shadows
|
||||||
|
- Focused on readability and professional presentation
|
||||||
|
|
||||||
|
2. **Creative Theme** (Pink/Purple with Glassmorphism):
|
||||||
|
- Used by: Social Ads Generator
|
||||||
|
- Vibrant gradients and glassmorphism effects
|
||||||
|
- Enhanced visual appeal for creative content
|
||||||
|
|
||||||
|
3. **Minimal Theme** (Light Gray):
|
||||||
|
- Available for future agents requiring minimal design
|
||||||
|
- Subtle styling with maximum content focus
|
||||||
|
|
||||||
|
#### Implementation Pattern
|
||||||
|
```html
|
||||||
|
<!-- Standard agent template structure -->
|
||||||
|
<div class="agent-page theme-professional"> <!-- or theme-creative, theme-minimal -->
|
||||||
|
<div class="agent-container">
|
||||||
|
<div>
|
||||||
|
<!-- Main content area -->
|
||||||
|
<div class="card">
|
||||||
|
<h3 class="section-title">Agent Title</h3>
|
||||||
|
<!-- Agent form and content -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="wallet-section">
|
||||||
|
<!-- Wallet sidebar -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Text Display Standardization
|
||||||
|
|
||||||
|
#### Simple Text Formatting Approach
|
||||||
|
After testing complex markdown parsing, the system now uses simplified text formatting for better reliability:
|
||||||
|
|
||||||
|
**Current Implementation:**
|
||||||
|
```javascript
|
||||||
|
// Simple text formatting in AgentUtils.parseMarkdown()
|
||||||
|
parseMarkdown(text) {
|
||||||
|
if (!text) return '';
|
||||||
|
return text
|
||||||
|
.replace(/\*\*/g, '') // Remove markdown bold syntax
|
||||||
|
.replace(/\#{1,3}\s/g, '') // Remove header syntax
|
||||||
|
.replace(/\n{3,}/g, '\n\n') // Reduce excessive line breaks
|
||||||
|
.replace(/\n/g, '<br>') // Convert line breaks to HTML
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Benefits:**
|
||||||
|
- No external dependencies (removed Marked.js + DOMPurify)
|
||||||
|
- Consistent formatting across all agents
|
||||||
|
- No risk of layout breaking from complex markdown
|
||||||
|
- Fast rendering and simple maintenance
|
||||||
|
|
||||||
|
#### CSS Text Styling
|
||||||
|
```css
|
||||||
|
.results-content {
|
||||||
|
line-height: 1.6;
|
||||||
|
word-wrap: break-word;
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
white-space: pre-line; /* Preserves line breaks */
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Form Submission Standardization
|
||||||
|
|
||||||
|
All agents now use consistent form submission patterns:
|
||||||
|
|
||||||
|
#### Unified Pattern
|
||||||
|
```javascript
|
||||||
|
// Standard form submission handler
|
||||||
|
document.getElementById('agentForm').addEventListener('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Validation, authentication, and balance checks
|
||||||
|
if (!isFormValid()) return;
|
||||||
|
|
||||||
|
// Submit via FormData with CSRF token (automatic inclusion)
|
||||||
|
const formData = new FormData(this);
|
||||||
|
|
||||||
|
fetch(window.location.href, {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData,
|
||||||
|
headers: { 'X-Requested-With': 'XMLHttpRequest' }
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(result => {
|
||||||
|
// Handle polling or immediate response
|
||||||
|
if (result.success && result.request_id) {
|
||||||
|
pollForResults(result.request_id);
|
||||||
|
} else {
|
||||||
|
displayResults(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Key Improvements
|
||||||
|
- **Form submission** instead of button click handlers
|
||||||
|
- **Automatic CSRF handling** via FormData(form)
|
||||||
|
- **Consistent error handling** across all agents
|
||||||
|
- **Unified polling mechanism** for webhook-based agents
|
||||||
|
|
||||||
## Current Architecture (Clean & Modern)
|
## Current Architecture (Clean & Modern)
|
||||||
|
|
||||||
The project uses a clean, modular individual agent architecture:
|
The project uses a clean, modular individual agent architecture:
|
||||||
|
|||||||
@ -4,453 +4,22 @@
|
|||||||
{% block title %}Job Posting Generator Agent - NetCop AI Hub{% endblock %}
|
{% block title %}Job Posting Generator Agent - NetCop AI Hub{% endblock %}
|
||||||
|
|
||||||
{% block extra_css %}
|
{% block extra_css %}
|
||||||
<!-- Google Fonts - Simple -->
|
<!-- Optimized Font Loading with Performance Hints -->
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- External Stylesheets -->
|
||||||
<link rel="stylesheet" href="{% static 'css/themes.css' %}">
|
<link rel="stylesheet" href="{% static 'css/themes.css' %}">
|
||||||
<style>
|
<link rel="stylesheet" href="{% static 'css/agent-base.css' %}">
|
||||||
/* Modern Typography & Theme System */
|
|
||||||
:root {
|
|
||||||
/* Color System */
|
|
||||||
--bg-color: #ffffff;
|
|
||||||
--text-color: #1a1a1a;
|
|
||||||
--primary-color: #000000;
|
|
||||||
--card-bg: #f8f9fa;
|
|
||||||
--border-color: #e0e0e0;
|
|
||||||
--hover-color: #f0f0f0;
|
|
||||||
--accent-color: #666666;
|
|
||||||
--success-color: #10b981;
|
|
||||||
--error-color: #ef4444;
|
|
||||||
--warning-color: #f59e0b;
|
|
||||||
|
|
||||||
/* Simple Typography */
|
<!-- Shared JavaScript Utilities -->
|
||||||
--font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
<script src="{% static 'js/agent-utils.js' %}"></script>
|
||||||
|
|
||||||
/* Small, Crisp Font Sizes */
|
|
||||||
--text-xs: 11px;
|
|
||||||
--text-sm: 13px;
|
|
||||||
--text-base: 14px;
|
|
||||||
--text-lg: 16px;
|
|
||||||
--text-xl: 18px;
|
|
||||||
|
|
||||||
/* Simple Spacing */
|
|
||||||
--space-xs: 4px;
|
|
||||||
--space-sm: 8px;
|
|
||||||
--space-md: 12px;
|
|
||||||
--space-lg: 16px;
|
|
||||||
--space-xl: 24px;
|
|
||||||
|
|
||||||
/* Simple Properties */
|
|
||||||
--radius: 6px;
|
|
||||||
--shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
||||||
--transition: 150ms ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: var(--font-primary);
|
|
||||||
font-size: var(--text-base);
|
|
||||||
line-height: 1.4;
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
|
||||||
|
|
||||||
.job-posting-page {
|
|
||||||
background: var(--bg-color);
|
|
||||||
min-height: calc(100vh - 80px);
|
|
||||||
padding: var(--space-lg);
|
|
||||||
width: 100vw;
|
|
||||||
margin-left: calc(-50vw + 50%);
|
|
||||||
color: var(--text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.job-posting-container {
|
|
||||||
max-width: 1200px;
|
|
||||||
margin: 0 auto;
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 350px;
|
|
||||||
gap: var(--space-xl);
|
|
||||||
align-items: start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
background: var(--card-bg);
|
|
||||||
border-radius: var(--radius);
|
|
||||||
padding: var(--space-lg);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
margin-bottom: var(--space-lg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-title {
|
|
||||||
font-size: var(--text-lg);
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--primary-color);
|
|
||||||
margin-bottom: var(--space-md);
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
padding-bottom: var(--space-sm);
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-container {
|
|
||||||
margin-bottom: var(--space-lg);
|
|
||||||
padding: var(--space-md);
|
|
||||||
border-radius: var(--radius);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-subtitle {
|
|
||||||
font-size: var(--text-sm);
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--accent-color);
|
|
||||||
margin-bottom: var(--space-md);
|
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-input, .form-textarea {
|
|
||||||
width: 100%;
|
|
||||||
padding: var(--space-md);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: var(--radius);
|
|
||||||
font-size: var(--text-base);
|
|
||||||
margin-bottom: var(--space-md);
|
|
||||||
background: white;
|
|
||||||
color: var(--text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-textarea {
|
|
||||||
min-height: 100px;
|
|
||||||
resize: vertical;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-input:focus, .form-textarea:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: var(--space-xs);
|
|
||||||
font-size: var(--text-sm);
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.processing-status {
|
|
||||||
padding: var(--space-lg);
|
|
||||||
background: var(--card-bg);
|
|
||||||
border: 1px solid var(--primary-color);
|
|
||||||
border-radius: var(--radius);
|
|
||||||
color: var(--primary-color);
|
|
||||||
font-weight: 500;
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: var(--space-lg);
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.processing-status .status-icon {
|
|
||||||
font-size: var(--text-xl);
|
|
||||||
margin-bottom: var(--space-sm);
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.processing-status .status-text {
|
|
||||||
font-size: var(--text-base);
|
|
||||||
font-weight: 500;
|
|
||||||
margin-bottom: var(--space-xs);
|
|
||||||
}
|
|
||||||
|
|
||||||
.processing-status .status-detail {
|
|
||||||
font-size: var(--text-sm);
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-card {
|
|
||||||
background: var(--card-bg);
|
|
||||||
border-radius: var(--radius);
|
|
||||||
padding: var(--space-lg);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
margin-top: var(--space-lg);
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
margin-bottom: var(--space-md);
|
|
||||||
padding-bottom: var(--space-sm);
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content {
|
|
||||||
background: white;
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: var(--radius);
|
|
||||||
padding: var(--space-lg);
|
|
||||||
margin-bottom: var(--space-md);
|
|
||||||
line-height: 1.6;
|
|
||||||
color: var(--text-color);
|
|
||||||
font-size: var(--text-base);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Markdown styling for results */
|
|
||||||
.results-content h1,
|
|
||||||
.results-content h2,
|
|
||||||
.results-content h3 {
|
|
||||||
color: var(--primary-color);
|
|
||||||
font-weight: 600;
|
|
||||||
margin: var(--space-lg) 0 var(--space-sm) 0;
|
|
||||||
line-height: 1.3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content h1 {
|
|
||||||
font-size: var(--text-xl);
|
|
||||||
border-bottom: 2px solid var(--border-color);
|
|
||||||
padding-bottom: var(--space-xs);
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content h2 {
|
|
||||||
font-size: var(--text-lg);
|
|
||||||
margin-top: var(--space-xl);
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content h3 {
|
|
||||||
font-size: var(--text-base);
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content p {
|
|
||||||
margin: var(--space-sm) 0;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content ul,
|
|
||||||
.results-content ol {
|
|
||||||
margin: var(--space-sm) 0;
|
|
||||||
padding-left: var(--space-xl);
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content li {
|
|
||||||
margin: var(--space-xs) 0;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content strong {
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content em {
|
|
||||||
font-style: italic;
|
|
||||||
color: var(--accent-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content code {
|
|
||||||
background: var(--card-bg);
|
|
||||||
padding: 2px 4px;
|
|
||||||
border-radius: 3px;
|
|
||||||
font-size: var(--text-sm);
|
|
||||||
color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content blockquote {
|
|
||||||
border-left: 3px solid var(--primary-color);
|
|
||||||
margin: var(--space-md) 0;
|
|
||||||
padding-left: var(--space-md);
|
|
||||||
color: var(--accent-color);
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content hr {
|
|
||||||
border: none;
|
|
||||||
border-top: 1px solid var(--border-color);
|
|
||||||
margin: var(--space-lg) 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-sm);
|
|
||||||
margin-top: var(--space-md);
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
padding: var(--space-md);
|
|
||||||
border: none;
|
|
||||||
border-radius: var(--radius);
|
|
||||||
font-weight: 500;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: var(--text-sm);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: var(--space-xs);
|
|
||||||
text-decoration: none;
|
|
||||||
transition: all var(--transition);
|
|
||||||
flex: 1;
|
|
||||||
min-width: 120px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
background: var(--primary-color);
|
|
||||||
color: white;
|
|
||||||
box-shadow: var(--shadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary {
|
|
||||||
background: var(--card-bg);
|
|
||||||
color: var(--primary-color);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:hover:not(:disabled) {
|
|
||||||
transform: translateY(-1px);
|
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:hover:not(:disabled) {
|
|
||||||
background: var(--accent-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary:hover:not(:disabled) {
|
|
||||||
border-color: var(--primary-color);
|
|
||||||
background: var(--hover-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:active {
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:disabled {
|
|
||||||
background: var(--accent-color);
|
|
||||||
cursor: not-allowed;
|
|
||||||
opacity: 0.5;
|
|
||||||
transform: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wallet-section {
|
|
||||||
position: sticky;
|
|
||||||
top: var(--space-lg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wallet-balance {
|
|
||||||
font-size: var(--text-lg);
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--primary-color);
|
|
||||||
margin-bottom: var(--space-xs);
|
|
||||||
}
|
|
||||||
|
|
||||||
.balance-label {
|
|
||||||
font-size: var(--text-sm);
|
|
||||||
color: var(--accent-color);
|
|
||||||
margin-bottom: var(--space-lg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.process-btn {
|
|
||||||
width: 100%;
|
|
||||||
margin-bottom: var(--space-sm);
|
|
||||||
}
|
|
||||||
|
|
||||||
.insufficient-balance {
|
|
||||||
background: var(--card-bg);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
color: var(--primary-color);
|
|
||||||
padding: var(--space-md);
|
|
||||||
border-radius: var(--radius);
|
|
||||||
text-align: center;
|
|
||||||
font-size: var(--text-sm);
|
|
||||||
margin-bottom: var(--space-sm);
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info {
|
|
||||||
padding: var(--space-md);
|
|
||||||
background: var(--card-bg);
|
|
||||||
border-radius: var(--radius);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info h4 {
|
|
||||||
margin: 0 0 var(--space-sm) 0;
|
|
||||||
font-size: var(--text-sm);
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info ul {
|
|
||||||
margin: 0;
|
|
||||||
font-size: var(--text-xs);
|
|
||||||
color: var(--text-color);
|
|
||||||
line-height: 1.4;
|
|
||||||
list-style: none;
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info li {
|
|
||||||
margin: var(--space-xs) 0;
|
|
||||||
padding-left: var(--space-md);
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info li::before {
|
|
||||||
content: "•";
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Simple Responsive Design */
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.job-posting-container {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
gap: var(--space-lg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.wallet-section {
|
|
||||||
position: static;
|
|
||||||
order: -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-input, .form-textarea {
|
|
||||||
font-size: 16px; /* Prevent zoom on iOS */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Form Help Text */
|
|
||||||
.form-help {
|
|
||||||
font-size: var(--text-xs);
|
|
||||||
color: var(--accent-color);
|
|
||||||
margin-top: var(--space-xs);
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group {
|
|
||||||
margin-bottom: var(--space-md);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group.error .form-input,
|
|
||||||
.form-group.error .form-textarea {
|
|
||||||
border-color: var(--error-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Simple loading state for buttons */
|
|
||||||
.btn.loading {
|
|
||||||
opacity: 0.6;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="job-posting-page">
|
<div class="agent-page theme-professional">
|
||||||
<div class="job-posting-container">
|
<div class="agent-container">
|
||||||
<!-- Messages -->
|
<!-- Messages -->
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
{% for message in messages %}
|
{% for message in messages %}
|
||||||
@ -642,35 +211,14 @@
|
|||||||
|
|
||||||
// Copy job posting to clipboard
|
// Copy job posting to clipboard
|
||||||
function copyJobPosting() {
|
function copyJobPosting() {
|
||||||
const jobText = generateJobText();
|
const jobText = AgentUtils.generateTextForExport('jobContent');
|
||||||
navigator.clipboard.writeText(jobText).then(() => {
|
AgentUtils.copyToClipboard(jobText, 'Job posting copied to clipboard!');
|
||||||
showToast('📋 Job posting copied to clipboard!', 'success');
|
|
||||||
}).catch(() => {
|
|
||||||
showToast('Failed to copy job posting', 'error');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download job posting as text file
|
// Download job posting as text file
|
||||||
function downloadJobPosting() {
|
function downloadJobPosting() {
|
||||||
const jobText = generateJobText();
|
const jobText = AgentUtils.generateTextForExport('jobContent');
|
||||||
const blob = new Blob([jobText], { type: 'text/plain' });
|
AgentUtils.downloadAsFile(jobText, `job-posting-${Date.now()}.txt`, 'Job posting downloaded!');
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.href = url;
|
|
||||||
a.download = 'job-posting-' + Date.now() + '.txt';
|
|
||||||
a.click();
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
showToast('💾 Job posting downloaded!', 'success');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate job text for copy/download
|
|
||||||
function generateJobText() {
|
|
||||||
const content = document.querySelector('#jobContent');
|
|
||||||
if (content) {
|
|
||||||
// Get text content without HTML tags for clean copying
|
|
||||||
return content.innerText || content.textContent || '';
|
|
||||||
}
|
|
||||||
return 'No job posting content available';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset form for creating another job posting
|
// Reset form for creating another job posting
|
||||||
@ -685,77 +233,24 @@
|
|||||||
// Reset form and UI
|
// Reset form and UI
|
||||||
document.getElementById('jobPostingForm').reset();
|
document.getElementById('jobPostingForm').reset();
|
||||||
document.getElementById('jobResults').style.display = 'none';
|
document.getElementById('jobResults').style.display = 'none';
|
||||||
document.getElementById('processingStatus').style.display = 'none';
|
resetUIState();
|
||||||
const processButton = document.getElementById('processButton');
|
|
||||||
processButton.disabled = false;
|
|
||||||
processButton.classList.remove('loading');
|
|
||||||
processButton.innerHTML = '💼 Generate Job Posting (4.00 AED)';
|
|
||||||
|
|
||||||
showToast('Form reset! Ready for another job posting.', 'success');
|
AgentUtils.showToast('Form reset! Ready for another job posting.', 'success');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toast management - prevent all duplicates
|
|
||||||
let toastTimeout = null;
|
|
||||||
let lastToastMessage = '';
|
|
||||||
let currentToast = null;
|
|
||||||
|
|
||||||
function showToast(message, type = 'info') {
|
// Enhanced form validation with visual feedback
|
||||||
// Prevent duplicate messages
|
|
||||||
if (message === lastToastMessage && currentToast) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear existing toast
|
|
||||||
if (currentToast) {
|
|
||||||
currentToast.remove();
|
|
||||||
currentToast = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear existing timeout
|
|
||||||
if (toastTimeout) {
|
|
||||||
clearTimeout(toastTimeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store message to prevent duplicates
|
|
||||||
lastToastMessage = message;
|
|
||||||
|
|
||||||
// Create new toast
|
|
||||||
currentToast = document.createElement('div');
|
|
||||||
currentToast.style.cssText = `
|
|
||||||
position: fixed;
|
|
||||||
top: 16px;
|
|
||||||
right: 16px;
|
|
||||||
padding: 8px 12px;
|
|
||||||
border-radius: 4px;
|
|
||||||
color: white;
|
|
||||||
font-size: 13px;
|
|
||||||
z-index: 1000;
|
|
||||||
max-width: 300px;
|
|
||||||
${type === 'success' ? 'background: var(--primary-color);' : 'background: var(--accent-color);'}
|
|
||||||
`;
|
|
||||||
currentToast.textContent = message;
|
|
||||||
document.body.appendChild(currentToast);
|
|
||||||
|
|
||||||
// Auto remove after 2 seconds
|
|
||||||
toastTimeout = setTimeout(() => {
|
|
||||||
if (currentToast) {
|
|
||||||
currentToast.remove();
|
|
||||||
currentToast = null;
|
|
||||||
}
|
|
||||||
lastToastMessage = '';
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Form validation with visual feedback
|
|
||||||
function validateField(field) {
|
function validateField(field) {
|
||||||
const isValid = field.value.trim() !== '';
|
const isValid = field.value.trim() !== '';
|
||||||
const container = field.closest('.form-group') || field.parentElement;
|
const container = field.closest('.form-group') || field.parentElement;
|
||||||
|
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
field.style.borderColor = 'var(--success-color)';
|
field.style.borderColor = 'var(--success-color)';
|
||||||
|
field.style.boxShadow = '0 0 0 2px rgba(16, 185, 129, 0.1)';
|
||||||
container.classList.remove('error');
|
container.classList.remove('error');
|
||||||
} else {
|
} else {
|
||||||
field.style.borderColor = 'var(--error-color)';
|
field.style.borderColor = 'var(--error-color)';
|
||||||
|
field.style.boxShadow = '0 0 0 2px rgba(239, 68, 68, 0.1)';
|
||||||
container.classList.add('error');
|
container.classList.add('error');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,6 +268,7 @@
|
|||||||
// Reset validation on focus
|
// Reset validation on focus
|
||||||
field.addEventListener('focus', () => {
|
field.addEventListener('focus', () => {
|
||||||
field.style.borderColor = 'var(--primary-color)';
|
field.style.borderColor = 'var(--primary-color)';
|
||||||
|
field.style.boxShadow = '0 0 0 2px rgba(0, 0, 0, 0.1)';
|
||||||
field.closest('.form-group')?.classList.remove('error');
|
field.closest('.form-group')?.classList.remove('error');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -798,55 +294,24 @@
|
|||||||
window.currentWalletBalance = newBalance;
|
window.currentWalletBalance = newBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple markdown to HTML converter
|
|
||||||
function parseMarkdown(text) {
|
|
||||||
return text
|
|
||||||
// Headers
|
|
||||||
.replace(/^### (.*$)/gm, '<h3>$1</h3>')
|
|
||||||
.replace(/^## (.*$)/gm, '<h2>$1</h2>')
|
|
||||||
.replace(/^# (.*$)/gm, '<h1>$1</h1>')
|
|
||||||
// Bold
|
|
||||||
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
|
|
||||||
// Italic
|
|
||||||
.replace(/\*(.*?)\*/g, '<em>$1</em>')
|
|
||||||
// Lists
|
|
||||||
.replace(/^- (.*$)/gm, '<li>$1</li>')
|
|
||||||
.replace(/(<li>.*<\/li>)/s, '<ul>$1</ul>')
|
|
||||||
// Line breaks
|
|
||||||
.replace(/\n\n/g, '</p><p>')
|
|
||||||
.replace(/\n/g, '<br>');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display job posting results with markdown formatting
|
// Display job posting results with markdown formatting
|
||||||
function displayResults(result) {
|
function displayResults(result) {
|
||||||
const resultsContainer = document.getElementById('jobResults');
|
AgentUtils.displayResults({
|
||||||
const contentContainer = document.getElementById('jobContent');
|
result: result,
|
||||||
|
resultsId: 'jobResults',
|
||||||
if (result.success && result.status === 'completed') {
|
contentId: 'jobContent',
|
||||||
const content = result.content || result.job_posting_content || result.output_text || 'Job posting generated successfully!';
|
defaultMessage: 'Job posting generated successfully!',
|
||||||
|
successMessage: '✅ Job posting created and payment processed!',
|
||||||
// Parse and display as HTML with markdown formatting
|
errorMessage: '❌ Failed to generate job posting - no charge applied'
|
||||||
const formattedContent = parseMarkdown(content);
|
});
|
||||||
contentContainer.innerHTML = '<p>' + formattedContent + '</p>';
|
|
||||||
|
|
||||||
resultsContainer.style.display = 'block';
|
|
||||||
|
|
||||||
// Update wallet balance if provided
|
|
||||||
if (result.wallet_balance !== undefined) {
|
|
||||||
updateWalletBalance(result.wallet_balance);
|
|
||||||
}
|
|
||||||
|
|
||||||
showToast('✅ Job posting created and payment processed!', 'success');
|
|
||||||
} else {
|
|
||||||
showToast('❌ Failed to generate job posting - no charge applied', 'error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track if results have been displayed to prevent duplicates
|
// Track if results have been displayed to prevent duplicates
|
||||||
let resultsDisplayed = false;
|
let resultsDisplayed = false;
|
||||||
let currentPollInterval = null;
|
let currentPollInterval = null;
|
||||||
|
|
||||||
// Poll for results
|
// Poll for results with improved error handling
|
||||||
function pollForResults(requestId) {
|
function pollForResults(requestId) {
|
||||||
let pollCount = 0;
|
let pollCount = 0;
|
||||||
const maxPolls = 30; // 30 seconds maximum
|
const maxPolls = 30; // 30 seconds maximum
|
||||||
@ -855,13 +320,19 @@
|
|||||||
// Clear any existing polling
|
// Clear any existing polling
|
||||||
if (currentPollInterval) {
|
if (currentPollInterval) {
|
||||||
clearInterval(currentPollInterval);
|
clearInterval(currentPollInterval);
|
||||||
|
currentPollInterval = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentPollInterval = setInterval(() => {
|
currentPollInterval = setInterval(() => {
|
||||||
pollCount++;
|
pollCount++;
|
||||||
|
|
||||||
fetch(`/agents/job-posting-generator/status/${requestId}/`)
|
fetch(`/agents/job-posting-generator/status/${requestId}/`)
|
||||||
.then(response => response.json())
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP ${response.status}`);
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.status === 'completed' || result.status === 'failed') {
|
if (result.status === 'completed' || result.status === 'failed') {
|
||||||
// Stop polling immediately
|
// Stop polling immediately
|
||||||
@ -869,11 +340,7 @@
|
|||||||
currentPollInterval = null;
|
currentPollInterval = null;
|
||||||
|
|
||||||
// Reset UI
|
// Reset UI
|
||||||
document.getElementById('processingStatus').style.display = 'none';
|
resetUIState();
|
||||||
const processButton = document.getElementById('processButton');
|
|
||||||
processButton.disabled = false;
|
|
||||||
processButton.classList.remove('loading');
|
|
||||||
processButton.innerHTML = '💼 Generate Job Posting (4.00 AED)';
|
|
||||||
|
|
||||||
// Display results only once
|
// Display results only once
|
||||||
if (!resultsDisplayed) {
|
if (!resultsDisplayed) {
|
||||||
@ -883,28 +350,27 @@
|
|||||||
} else if (pollCount >= maxPolls) {
|
} else if (pollCount >= maxPolls) {
|
||||||
clearInterval(currentPollInterval);
|
clearInterval(currentPollInterval);
|
||||||
currentPollInterval = null;
|
currentPollInterval = null;
|
||||||
document.getElementById('processingStatus').style.display = 'none';
|
resetUIState();
|
||||||
const processButton = document.getElementById('processButton');
|
AgentUtils.showToast('❌ Processing timeout - please try again', 'error');
|
||||||
processButton.disabled = false;
|
|
||||||
processButton.classList.remove('loading');
|
|
||||||
processButton.innerHTML = '💼 Generate Job Posting (4.00 AED)';
|
|
||||||
showToast('❌ Processing timeout - please try again', 'error');
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error polling results:', error);
|
console.error('Error polling results:', error);
|
||||||
if (pollCount >= maxPolls) {
|
|
||||||
clearInterval(currentPollInterval);
|
clearInterval(currentPollInterval);
|
||||||
currentPollInterval = null;
|
currentPollInterval = null;
|
||||||
|
resetUIState();
|
||||||
|
AgentUtils.showToast('❌ Network error during processing - please try again', 'error');
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to reset UI state
|
||||||
|
function resetUIState() {
|
||||||
document.getElementById('processingStatus').style.display = 'none';
|
document.getElementById('processingStatus').style.display = 'none';
|
||||||
const processButton = document.getElementById('processButton');
|
const processButton = document.getElementById('processButton');
|
||||||
processButton.disabled = false;
|
processButton.disabled = false;
|
||||||
processButton.classList.remove('loading');
|
processButton.classList.remove('loading');
|
||||||
processButton.innerHTML = '💼 Generate Job Posting (4.00 AED)';
|
processButton.innerHTML = '💼 Generate Job Posting (4.00 AED)';
|
||||||
showToast('❌ Network error - please try again', 'error');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle form submission
|
// Handle form submission
|
||||||
@ -912,7 +378,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!isFormValid()) {
|
if (!isFormValid()) {
|
||||||
showToast('Please fill in all required fields', 'error');
|
AgentUtils.showToast('Please fill in all required fields', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -931,7 +397,7 @@
|
|||||||
// Check wallet balance
|
// Check wallet balance
|
||||||
const balance = {{ user.wallet_balance|default:0 }};
|
const balance = {{ user.wallet_balance|default:0 }};
|
||||||
if (balance < 4.00) {
|
if (balance < 4.00) {
|
||||||
showToast('Insufficient balance! You need 4.00 AED.', 'error');
|
AgentUtils.showToast('Insufficient balance! You need 4.00 AED.', 'error');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = "{% url 'core:wallet' %}";
|
window.location.href = "{% url 'core:wallet' %}";
|
||||||
}, 2000);
|
}, 2000);
|
||||||
@ -953,11 +419,11 @@
|
|||||||
document.getElementById('jobResults').style.display = 'none';
|
document.getElementById('jobResults').style.display = 'none';
|
||||||
|
|
||||||
const steps = [
|
const steps = [
|
||||||
'Analyzing job requirements...',
|
'Analyzing job requirements and company details...',
|
||||||
'Structuring job description...',
|
'Structuring professional job description...',
|
||||||
'Optimizing for recruitment...',
|
'Optimizing content for recruitment platforms...',
|
||||||
'Adding company branding...',
|
'Adding company branding and tone...',
|
||||||
'Finalizing professional format...'
|
'Finalizing professional format and review...'
|
||||||
];
|
];
|
||||||
|
|
||||||
let currentStep = 0;
|
let currentStep = 0;
|
||||||
@ -988,14 +454,10 @@
|
|||||||
pollForResults(result.request_id);
|
pollForResults(result.request_id);
|
||||||
} else {
|
} else {
|
||||||
// Handle immediate response
|
// Handle immediate response
|
||||||
document.getElementById('processingStatus').style.display = 'none';
|
resetUIState();
|
||||||
const processButton = document.getElementById('processButton');
|
|
||||||
processButton.disabled = false;
|
|
||||||
processButton.classList.remove('loading');
|
|
||||||
processButton.innerHTML = '💼 Generate Job Posting (4.00 AED)';
|
|
||||||
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
showToast(`❌ ${result.error}`, 'error');
|
AgentUtils.showToast(`❌ ${result.error}`, 'error');
|
||||||
} else {
|
} else {
|
||||||
displayResults(result);
|
displayResults(result);
|
||||||
}
|
}
|
||||||
@ -1004,12 +466,8 @@
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
clearInterval(stepInterval);
|
clearInterval(stepInterval);
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
document.getElementById('processingStatus').style.display = 'none';
|
resetUIState();
|
||||||
const processButton = document.getElementById('processButton');
|
AgentUtils.showToast('❌ Network error - please try again', 'error');
|
||||||
processButton.disabled = false;
|
|
||||||
processButton.classList.remove('loading');
|
|
||||||
processButton.innerHTML = '💼 Generate Job Posting (4.00 AED)';
|
|
||||||
showToast('❌ Network error - please try again', 'error');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -4,295 +4,22 @@
|
|||||||
{% block title %}Social Ads Generator Agent - NetCop AI Hub{% endblock %}
|
{% block title %}Social Ads Generator Agent - NetCop AI Hub{% endblock %}
|
||||||
|
|
||||||
{% block extra_css %}
|
{% block extra_css %}
|
||||||
<style>
|
<!-- Optimized Font Loading -->
|
||||||
.social-ads-page {
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
background: var(--gradient-hero);
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
min-height: calc(100vh - 80px);
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
padding: clamp(20px, 5vw, 40px);
|
|
||||||
width: 100vw;
|
|
||||||
margin-left: calc(-50vw + 50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.social-ads-container {
|
<!-- External Stylesheets -->
|
||||||
max-width: 1280px;
|
<link rel="stylesheet" href="{% static 'css/themes.css' %}">
|
||||||
margin: 0 auto;
|
<link rel="stylesheet" href="{% static 'css/agent-base.css' %}">
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 400px;
|
|
||||||
gap: 24px;
|
|
||||||
align-items: start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
<!-- Shared JavaScript Utilities -->
|
||||||
background: rgba(255, 255, 255, 0.9);
|
<script src="{% static 'js/agent-utils.js' %}"></script>
|
||||||
border-radius: 16px;
|
|
||||||
padding: 24px;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
|
|
||||||
margin-bottom: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-title {
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-container {
|
|
||||||
margin-bottom: 24px;
|
|
||||||
padding: 16px;
|
|
||||||
border-radius: 12px;
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-info {
|
|
||||||
background: rgba(59, 130, 246, 0.1);
|
|
||||||
border-color: rgba(59, 130, 246, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.platform-info {
|
|
||||||
background: rgba(139, 92, 246, 0.1);
|
|
||||||
border-color: rgba(139, 92, 246, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-subtitle {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
margin-bottom: 16px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-input, .form-textarea {
|
|
||||||
width: 100%;
|
|
||||||
padding: 12px 16px;
|
|
||||||
border: 2px solid var(--border-medium);
|
|
||||||
border-radius: 12px;
|
|
||||||
font-size: 16px;
|
|
||||||
transition: border-color 0.2s ease;
|
|
||||||
min-height: 44px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
font-family: inherit;
|
|
||||||
background: var(--background-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-textarea {
|
|
||||||
min-height: 120px;
|
|
||||||
resize: vertical;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-input:focus, .form-textarea:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: rgba(236, 72, 153, 1);
|
|
||||||
background: white;
|
|
||||||
box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.processing-status {
|
|
||||||
padding: 20px;
|
|
||||||
background: rgba(236, 72, 153, 0.1);
|
|
||||||
border: 2px solid rgba(236, 72, 153, 1);
|
|
||||||
border-radius: 12px;
|
|
||||||
color: rgba(190, 24, 93, 1);
|
|
||||||
font-weight: 600;
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.processing-status .status-icon {
|
|
||||||
font-size: 32px;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
animation: pulse 2s infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes pulse {
|
|
||||||
0%, 100% { transform: scale(1); }
|
|
||||||
50% { transform: scale(1.1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-card {
|
|
||||||
background: rgba(255, 255, 255, 0.9);
|
|
||||||
border-radius: 16px;
|
|
||||||
padding: 24px;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
|
|
||||||
margin-top: 24px;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
padding-bottom: 16px;
|
|
||||||
border-bottom: 1px solid var(--border-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content {
|
|
||||||
background: var(--background-page);
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
border-radius: 12px;
|
|
||||||
padding: 24px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
white-space: pre-line;
|
|
||||||
line-height: 1.7;
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-size: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: 12px;
|
|
||||||
margin-top: 20px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
padding: 16px 32px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 12px;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 16px;
|
|
||||||
min-height: 48px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 8px;
|
|
||||||
transition: transform 0.1s ease;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
background: rgba(236, 72, 153, 1);
|
|
||||||
color: white;
|
|
||||||
flex: 1;
|
|
||||||
min-width: 120px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary {
|
|
||||||
background: var(--background-subtle);
|
|
||||||
color: var(--text-primary);
|
|
||||||
border: 2px solid var(--border-medium);
|
|
||||||
flex: 1;
|
|
||||||
min-width: 120px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:hover:not(:disabled) {
|
|
||||||
transform: translateY(-1px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:disabled {
|
|
||||||
background: var(--border-strong);
|
|
||||||
color: white;
|
|
||||||
cursor: not-allowed;
|
|
||||||
transform: none;
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wallet-section {
|
|
||||||
position: sticky;
|
|
||||||
top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wallet-balance {
|
|
||||||
font-size: 28px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--text-primary);
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.balance-label {
|
|
||||||
font-size: 16px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.process-btn {
|
|
||||||
width: 100%;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.insufficient-balance {
|
|
||||||
background: rgba(239, 68, 68, 0.1);
|
|
||||||
border: 1px solid rgba(239, 68, 68, 0.3);
|
|
||||||
color: var(--error-red);
|
|
||||||
padding: 12px;
|
|
||||||
border-radius: 8px;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 14px;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info {
|
|
||||||
padding: 16px;
|
|
||||||
background: rgba(236, 72, 153, 0.1);
|
|
||||||
border-radius: 12px;
|
|
||||||
border: 1px solid rgba(236, 72, 153, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info h4 {
|
|
||||||
margin: 0 0 8px 0;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: rgba(190, 24, 93, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info ul {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
line-height: 1.4;
|
|
||||||
list-style: none;
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info li {
|
|
||||||
margin: 4px 0;
|
|
||||||
padding-left: 16px;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info li::before {
|
|
||||||
content: "•";
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
color: rgba(236, 72, 153, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Mobile optimizations */
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.social-ads-container {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="social-ads-page">
|
<div class="agent-page theme-professional">
|
||||||
<div class="social-ads-container">
|
<div class="agent-container">
|
||||||
<!-- Messages -->
|
<!-- Messages -->
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
{% for message in messages %}
|
{% for message in messages %}
|
||||||
@ -441,34 +168,14 @@
|
|||||||
|
|
||||||
// Copy social ads to clipboard
|
// Copy social ads to clipboard
|
||||||
function copySocialAds() {
|
function copySocialAds() {
|
||||||
const adText = generateAdText();
|
const adText = AgentUtils.generateTextForExport('adContent');
|
||||||
navigator.clipboard.writeText(adText).then(() => {
|
AgentUtils.copyToClipboard(adText, 'Social ads copied to clipboard!');
|
||||||
showToast('📋 Social ads copied to clipboard!', 'success');
|
|
||||||
}).catch(() => {
|
|
||||||
showToast('Failed to copy ads', 'error');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download social ads as text file
|
// Download social ads as text file
|
||||||
function downloadSocialAds() {
|
function downloadSocialAds() {
|
||||||
const adText = generateAdText();
|
const adText = AgentUtils.generateTextForExport('adContent');
|
||||||
const blob = new Blob([adText], { type: 'text/plain' });
|
AgentUtils.downloadAsFile(adText, 'social-ads-' + Date.now() + '.txt', 'Social ads downloaded!');
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.href = url;
|
|
||||||
a.download = 'social-ads-' + Date.now() + '.txt';
|
|
||||||
a.click();
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
showToast('💾 Social ads downloaded!', 'success');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate ad text for copy/download
|
|
||||||
function generateAdText() {
|
|
||||||
const content = document.querySelector('#adContent');
|
|
||||||
if (content) {
|
|
||||||
return content.textContent || content.innerText || '';
|
|
||||||
}
|
|
||||||
return 'No ad content available';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset form for creating another ad
|
// Reset form for creating another ad
|
||||||
@ -482,62 +189,26 @@
|
|||||||
|
|
||||||
// Reset form and UI
|
// Reset form and UI
|
||||||
document.getElementById('socialAdsForm').reset();
|
document.getElementById('socialAdsForm').reset();
|
||||||
document.getElementById('adResults').style.display = 'none';
|
AgentUtils.resetUI({
|
||||||
document.getElementById('processingStatus').style.display = 'none';
|
processingStatusId: 'processingStatus',
|
||||||
document.getElementById('processButton').disabled = false;
|
processButtonId: 'processButton',
|
||||||
document.getElementById('processButton').innerHTML = '📢 Generate Social Ads (7.00 AED)';
|
resultsId: 'adResults',
|
||||||
showToast('Form reset! Ready for another ad campaign.', 'success');
|
buttonText: '📢 Generate Social Ads (7.00 AED)'
|
||||||
}
|
|
||||||
|
|
||||||
// Simple toast notification
|
|
||||||
function showToast(message, type = 'info') {
|
|
||||||
const toast = document.createElement('div');
|
|
||||||
toast.style.cssText = `
|
|
||||||
position: fixed;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
padding: 12px 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
color: white;
|
|
||||||
font-weight: 600;
|
|
||||||
z-index: 1000;
|
|
||||||
${type === 'success' ? 'background: var(--success-green);' : 'background: var(--error-red);'}
|
|
||||||
`;
|
|
||||||
toast.textContent = message;
|
|
||||||
document.body.appendChild(toast);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
toast.remove();
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update wallet balance display
|
|
||||||
function updateWalletBalance(newBalance) {
|
|
||||||
const balanceElements = document.querySelectorAll('[data-wallet-balance]');
|
|
||||||
balanceElements.forEach(element => {
|
|
||||||
element.textContent = `${newBalance.toFixed(2)} AED`;
|
|
||||||
});
|
});
|
||||||
window.currentWalletBalance = newBalance;
|
|
||||||
|
AgentUtils.showToast('Form reset! Ready for another ad campaign.', 'success');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display social ads results
|
// Display social ads results with markdown parsing
|
||||||
function displayResults(result) {
|
function displayResults(result) {
|
||||||
const resultsContainer = document.getElementById('adResults');
|
AgentUtils.displayResults({
|
||||||
const contentContainer = document.getElementById('adContent');
|
result: result,
|
||||||
|
resultsId: 'adResults',
|
||||||
if (result.success && result.status === 'completed') {
|
contentId: 'adContent',
|
||||||
contentContainer.textContent = result.content || result.ad_copy_content || result.output_text || 'Social ads generated successfully!';
|
defaultMessage: 'Social ads generated successfully!',
|
||||||
resultsContainer.style.display = 'block';
|
successMessage: '✅ Social ads created and payment processed!',
|
||||||
|
errorMessage: '❌ Failed to generate ads - no charge applied'
|
||||||
// Update wallet balance if provided
|
});
|
||||||
if (result.wallet_balance !== undefined) {
|
|
||||||
updateWalletBalance(result.wallet_balance);
|
|
||||||
}
|
|
||||||
|
|
||||||
showToast('✅ Social ads created and payment processed!', 'success');
|
|
||||||
} else {
|
|
||||||
showToast('❌ Failed to generate ads - no charge applied', 'error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track polling and results to prevent duplicates
|
// Track polling and results to prevent duplicates
|
||||||
@ -588,7 +259,7 @@
|
|||||||
document.getElementById('processingStatus').style.display = 'none';
|
document.getElementById('processingStatus').style.display = 'none';
|
||||||
document.getElementById('processButton').disabled = false;
|
document.getElementById('processButton').disabled = false;
|
||||||
document.getElementById('processButton').innerHTML = '📢 Generate Social Ads (7.00 AED)';
|
document.getElementById('processButton').innerHTML = '📢 Generate Social Ads (7.00 AED)';
|
||||||
showToast('❌ Processing timeout - please try again', 'error');
|
AgentUtils.showToast('❌ Processing timeout - please try again', 'error');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@ -598,7 +269,7 @@
|
|||||||
document.getElementById('processingStatus').style.display = 'none';
|
document.getElementById('processingStatus').style.display = 'none';
|
||||||
document.getElementById('processButton').disabled = false;
|
document.getElementById('processButton').disabled = false;
|
||||||
document.getElementById('processButton').innerHTML = '📢 Generate Social Ads (7.00 AED)';
|
document.getElementById('processButton').innerHTML = '📢 Generate Social Ads (7.00 AED)';
|
||||||
showToast('❌ Network error during processing - please try again', 'error');
|
AgentUtils.showToast('❌ Network error during processing - please try again', 'error');
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
@ -608,7 +279,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!isFormValid()) {
|
if (!isFormValid()) {
|
||||||
showToast('Please fill in all required fields', 'error');
|
AgentUtils.showToast('Please fill in all required fields', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,7 +292,7 @@
|
|||||||
// Check wallet balance
|
// Check wallet balance
|
||||||
const balance = {{ user.wallet_balance|default:0 }};
|
const balance = {{ user.wallet_balance|default:0 }};
|
||||||
if (balance < 7.00) {
|
if (balance < 7.00) {
|
||||||
showToast('Insufficient balance! You need 7.00 AED.', 'error');
|
AgentUtils.showToast('Insufficient balance! You need 7.00 AED.', 'error');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = "{% url 'core:wallet' %}";
|
window.location.href = "{% url 'core:wallet' %}";
|
||||||
}, 2000);
|
}, 2000);
|
||||||
@ -682,7 +353,7 @@
|
|||||||
document.getElementById('processButton').innerHTML = '📢 Generate Social Ads (7.00 AED)';
|
document.getElementById('processButton').innerHTML = '📢 Generate Social Ads (7.00 AED)';
|
||||||
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
showToast(`❌ ${result.error}`, 'error');
|
AgentUtils.showToast(`❌ ${result.error}`, 'error');
|
||||||
} else {
|
} else {
|
||||||
displayResults(result);
|
displayResults(result);
|
||||||
}
|
}
|
||||||
@ -694,7 +365,7 @@
|
|||||||
document.getElementById('processingStatus').style.display = 'none';
|
document.getElementById('processingStatus').style.display = 'none';
|
||||||
document.getElementById('processButton').disabled = false;
|
document.getElementById('processButton').disabled = false;
|
||||||
document.getElementById('processButton').innerHTML = '📢 Generate Social Ads (7.00 AED)';
|
document.getElementById('processButton').innerHTML = '📢 Generate Social Ads (7.00 AED)';
|
||||||
showToast('❌ Network error - please try again', 'error');
|
AgentUtils.showToast('❌ Network error - please try again', 'error');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
527
static/css/agent-base.css
Normal file
527
static/css/agent-base.css
Normal file
@ -0,0 +1,527 @@
|
|||||||
|
/* NetCop AI Agents - Unified CSS System */
|
||||||
|
/* Supports multiple themes with consistent components */
|
||||||
|
|
||||||
|
/* Base CSS Variables - Default Professional Theme */
|
||||||
|
:root {
|
||||||
|
/* Core Color System */
|
||||||
|
--bg-color: #ffffff;
|
||||||
|
--text-color: #1a1a1a;
|
||||||
|
--primary-color: #000000;
|
||||||
|
--card-bg: #f8f9fa;
|
||||||
|
--border-color: #e0e0e0;
|
||||||
|
--hover-color: #f0f0f0;
|
||||||
|
--accent-color: #666666;
|
||||||
|
--success-color: #10b981;
|
||||||
|
--error-color: #ef4444;
|
||||||
|
--warning-color: #f59e0b;
|
||||||
|
|
||||||
|
/* Typography */
|
||||||
|
--font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
||||||
|
|
||||||
|
/* Font Sizes - Crisp & Readable */
|
||||||
|
--text-xs: 11px;
|
||||||
|
--text-sm: 13px;
|
||||||
|
--text-base: 14px;
|
||||||
|
--text-lg: 16px;
|
||||||
|
--text-xl: 18px;
|
||||||
|
|
||||||
|
/* Spacing System */
|
||||||
|
--space-xs: 4px;
|
||||||
|
--space-sm: 8px;
|
||||||
|
--space-md: 12px;
|
||||||
|
--space-lg: 16px;
|
||||||
|
--space-xl: 24px;
|
||||||
|
|
||||||
|
/* Design Tokens */
|
||||||
|
--radius: 6px;
|
||||||
|
--shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
|
--transition: 150ms ease;
|
||||||
|
|
||||||
|
/* Theme-specific Properties */
|
||||||
|
--agent-bg: var(--bg-color);
|
||||||
|
--agent-primary: var(--primary-color);
|
||||||
|
--agent-card-bg: var(--card-bg);
|
||||||
|
--agent-border: var(--border-color);
|
||||||
|
--agent-backdrop-filter: none;
|
||||||
|
--agent-card-shadow: var(--shadow);
|
||||||
|
--agent-card-border: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Professional Theme (Default - Black & White) */
|
||||||
|
.theme-professional {
|
||||||
|
--agent-bg: #ffffff;
|
||||||
|
--agent-primary: #000000;
|
||||||
|
--agent-card-bg: #f8f9fa;
|
||||||
|
--agent-border: #e0e0e0;
|
||||||
|
--agent-backdrop-filter: none;
|
||||||
|
--agent-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
|
--agent-card-border: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creative Theme (Pink/Purple with Glassmorphism) */
|
||||||
|
.theme-creative {
|
||||||
|
--agent-bg: var(--gradient-hero);
|
||||||
|
--agent-primary: rgba(236, 72, 153, 1);
|
||||||
|
--agent-card-bg: rgba(255, 255, 255, 0.9);
|
||||||
|
--agent-border: rgba(255, 255, 255, 0.3);
|
||||||
|
--agent-backdrop-filter: blur(20px);
|
||||||
|
--agent-card-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
|
||||||
|
--agent-card-border: 1px solid rgba(255, 255, 255, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Minimal Theme (Light Gray) */
|
||||||
|
.theme-minimal {
|
||||||
|
--agent-bg: #fafafa;
|
||||||
|
--agent-primary: #374151;
|
||||||
|
--agent-card-bg: #ffffff;
|
||||||
|
--agent-border: #e5e7eb;
|
||||||
|
--agent-backdrop-filter: none;
|
||||||
|
--agent-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
||||||
|
--agent-card-border: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Base Styles */
|
||||||
|
body {
|
||||||
|
font-family: var(--font-primary);
|
||||||
|
font-size: var(--text-base);
|
||||||
|
line-height: 1.4;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Page Layout - Universal Agent Layout */
|
||||||
|
.agent-page {
|
||||||
|
background: var(--agent-bg);
|
||||||
|
min-height: calc(100vh - 80px);
|
||||||
|
padding: var(--space-lg);
|
||||||
|
width: 100vw;
|
||||||
|
margin-left: calc(-50vw + 50%);
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.agent-container {
|
||||||
|
max-width: 1280px;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 350px;
|
||||||
|
gap: var(--space-xl);
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Card Components */
|
||||||
|
.card {
|
||||||
|
background: var(--agent-card-bg);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
padding: var(--space-lg);
|
||||||
|
border: var(--agent-card-border);
|
||||||
|
margin-bottom: var(--space-lg);
|
||||||
|
backdrop-filter: var(--agent-backdrop-filter);
|
||||||
|
box-shadow: var(--agent-card-shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: var(--text-lg);
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-color);
|
||||||
|
margin-bottom: var(--space-md);
|
||||||
|
border-bottom: 1px solid var(--agent-border);
|
||||||
|
padding-bottom: var(--space-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-container {
|
||||||
|
margin-bottom: var(--space-lg);
|
||||||
|
padding: var(--space-md);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
border: 1px solid var(--agent-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Special Section Styling for Creative Theme */
|
||||||
|
.theme-creative .section-container.content-info {
|
||||||
|
background: rgba(59, 130, 246, 0.1);
|
||||||
|
border-color: rgba(59, 130, 246, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-creative .section-container.platform-info {
|
||||||
|
background: rgba(139, 92, 246, 0.1);
|
||||||
|
border-color: rgba(139, 92, 246, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-subtitle {
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--accent-color);
|
||||||
|
margin-bottom: var(--space-md);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Form Elements */
|
||||||
|
.form-input, .form-textarea {
|
||||||
|
width: 100%;
|
||||||
|
padding: var(--space-md);
|
||||||
|
border: 1px solid var(--agent-border);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
font-size: var(--text-base);
|
||||||
|
margin-bottom: var(--space-md);
|
||||||
|
background: white;
|
||||||
|
color: var(--text-color);
|
||||||
|
transition: border-color var(--transition);
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-textarea {
|
||||||
|
min-height: 100px;
|
||||||
|
resize: vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-input:focus, .form-textarea:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--agent-primary);
|
||||||
|
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creative theme focus styles */
|
||||||
|
.theme-creative .form-input:focus,
|
||||||
|
.theme-creative .form-textarea:focus {
|
||||||
|
border-color: var(--agent-primary);
|
||||||
|
box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: var(--space-xs);
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-help {
|
||||||
|
font-size: var(--text-xs);
|
||||||
|
color: var(--accent-color);
|
||||||
|
margin-top: var(--space-xs);
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: var(--space-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group.error .form-input,
|
||||||
|
.form-group.error .form-textarea {
|
||||||
|
border-color: var(--error-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Processing States */
|
||||||
|
.processing-status {
|
||||||
|
padding: var(--space-lg);
|
||||||
|
background: var(--agent-card-bg);
|
||||||
|
border: 1px solid var(--agent-primary);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
color: var(--agent-primary);
|
||||||
|
font-weight: 500;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: var(--space-lg);
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creative theme processing status */
|
||||||
|
.theme-creative .processing-status {
|
||||||
|
background: rgba(236, 72, 153, 0.1);
|
||||||
|
border: 2px solid var(--agent-primary);
|
||||||
|
color: rgba(190, 24, 93, 1);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.processing-status .status-icon {
|
||||||
|
font-size: var(--text-xl);
|
||||||
|
margin-bottom: var(--space-sm);
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creative theme icon animation */
|
||||||
|
.theme-creative .processing-status .status-icon {
|
||||||
|
font-size: 32px;
|
||||||
|
animation: pulse 2s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse {
|
||||||
|
0%, 100% { transform: scale(1); }
|
||||||
|
50% { transform: scale(1.1); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.processing-status .status-text {
|
||||||
|
font-size: var(--text-base);
|
||||||
|
font-weight: 500;
|
||||||
|
margin-bottom: var(--space-xs);
|
||||||
|
}
|
||||||
|
|
||||||
|
.processing-status .status-detail {
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Results Display */
|
||||||
|
.results-card {
|
||||||
|
background: var(--agent-card-bg);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
padding: var(--space-lg);
|
||||||
|
border: var(--agent-card-border);
|
||||||
|
margin-top: var(--space-lg);
|
||||||
|
backdrop-filter: var(--agent-backdrop-filter);
|
||||||
|
box-shadow: var(--agent-card-shadow);
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
margin-bottom: var(--space-md);
|
||||||
|
padding-bottom: var(--space-sm);
|
||||||
|
border-bottom: 1px solid var(--agent-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.results-content {
|
||||||
|
background: white;
|
||||||
|
border: 1px solid var(--agent-border);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
padding: var(--space-lg);
|
||||||
|
margin-bottom: var(--space-md);
|
||||||
|
line-height: 1.6;
|
||||||
|
color: var(--text-color);
|
||||||
|
font-size: var(--text-base);
|
||||||
|
white-space: pre-line;
|
||||||
|
word-wrap: break-word;
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Simple Text Styling for Results */
|
||||||
|
.results-content {
|
||||||
|
line-height: 1.6;
|
||||||
|
word-wrap: break-word;
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Buttons & Actions */
|
||||||
|
.action-buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-sm);
|
||||||
|
margin-top: var(--space-md);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
padding: var(--space-md);
|
||||||
|
border: none;
|
||||||
|
border-radius: var(--radius);
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: var(--space-xs);
|
||||||
|
text-decoration: none;
|
||||||
|
transition: all var(--transition);
|
||||||
|
flex: 1;
|
||||||
|
min-width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background: var(--agent-primary);
|
||||||
|
color: white;
|
||||||
|
box-shadow: var(--shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary {
|
||||||
|
background: var(--agent-card-bg);
|
||||||
|
color: var(--agent-primary);
|
||||||
|
border: 1px solid var(--agent-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creative theme button styles */
|
||||||
|
.theme-creative .btn {
|
||||||
|
padding: 16px 32px;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 16px;
|
||||||
|
min-height: 48px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-creative .btn-secondary {
|
||||||
|
border: 2px solid var(--border-medium);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:hover:not(:disabled) {
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover:not(:disabled) {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary:hover:not(:disabled) {
|
||||||
|
border-color: var(--agent-primary);
|
||||||
|
background: var(--hover-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:active {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn:disabled {
|
||||||
|
background: var(--accent-color);
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.5;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn.loading {
|
||||||
|
opacity: 0.6;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wallet Sidebar */
|
||||||
|
.wallet-section {
|
||||||
|
position: sticky;
|
||||||
|
top: var(--space-lg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-balance {
|
||||||
|
font-size: var(--text-lg);
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-color);
|
||||||
|
margin-bottom: var(--space-xs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creative theme larger wallet balance */
|
||||||
|
.theme-creative .wallet-balance {
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.balance-label {
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
color: var(--accent-color);
|
||||||
|
margin-bottom: var(--space-lg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creative theme larger balance label */
|
||||||
|
.theme-creative .balance-label {
|
||||||
|
font-size: 16px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.process-btn {
|
||||||
|
width: 100%;
|
||||||
|
margin-bottom: var(--space-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.insufficient-balance {
|
||||||
|
background: var(--agent-card-bg);
|
||||||
|
border: 1px solid var(--agent-border);
|
||||||
|
color: var(--text-color);
|
||||||
|
padding: var(--space-md);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
text-align: center;
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
margin-bottom: var(--space-sm);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creative theme insufficient balance */
|
||||||
|
.theme-creative .insufficient-balance {
|
||||||
|
background: rgba(239, 68, 68, 0.1);
|
||||||
|
border: 1px solid rgba(239, 68, 68, 0.3);
|
||||||
|
color: var(--error-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Usage Info */
|
||||||
|
.usage-info {
|
||||||
|
padding: var(--space-md);
|
||||||
|
background: var(--agent-card-bg);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
border: 1px solid var(--agent-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creative theme usage info */
|
||||||
|
.theme-creative .usage-info {
|
||||||
|
background: rgba(236, 72, 153, 0.1);
|
||||||
|
border: 1px solid rgba(236, 72, 153, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.usage-info h4 {
|
||||||
|
margin: 0 0 var(--space-sm) 0;
|
||||||
|
font-size: var(--text-sm);
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Creative theme usage info header */
|
||||||
|
.theme-creative .usage-info h4 {
|
||||||
|
color: rgba(190, 24, 93, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.usage-info ul {
|
||||||
|
margin: 0;
|
||||||
|
font-size: var(--text-xs);
|
||||||
|
color: var(--text-color);
|
||||||
|
line-height: 1.4;
|
||||||
|
list-style: none;
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.usage-info li {
|
||||||
|
margin: var(--space-xs) 0;
|
||||||
|
padding-left: var(--space-md);
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.usage-info li::before {
|
||||||
|
content: "•";
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
color: var(--agent-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive Design */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.agent-container {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
gap: var(--space-lg);
|
||||||
|
padding: var(--space-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-section {
|
||||||
|
position: static;
|
||||||
|
order: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-buttons {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-input, .form-textarea {
|
||||||
|
font-size: 16px; /* Prevent zoom on iOS */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.agent-page {
|
||||||
|
padding: var(--space-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
padding: var(--space-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-container {
|
||||||
|
padding: var(--space-sm);
|
||||||
|
}
|
||||||
|
}
|
||||||
225
static/js/agent-utils.js
Normal file
225
static/js/agent-utils.js
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
/**
|
||||||
|
* NetCop AI Agents - Shared Utilities
|
||||||
|
* Contains common functions used across all agent templates
|
||||||
|
*/
|
||||||
|
|
||||||
|
window.AgentUtils = {
|
||||||
|
/**
|
||||||
|
* Simple Text Formatter
|
||||||
|
* Cleans AI-generated text and converts to readable HTML
|
||||||
|
*/
|
||||||
|
parseMarkdown(text) {
|
||||||
|
if (!text) return '';
|
||||||
|
|
||||||
|
return text
|
||||||
|
.replace(/\*\*/g, '') // Remove markdown bold syntax
|
||||||
|
.replace(/\#{1,3}\s/g, '') // Remove header syntax
|
||||||
|
.replace(/\n{3,}/g, '\n\n') // Reduce excessive line breaks
|
||||||
|
.replace(/\n/g, '<br>') // Convert line breaks to HTML
|
||||||
|
.trim();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update wallet balance display across all agents
|
||||||
|
*/
|
||||||
|
updateWalletBalance(newBalance) {
|
||||||
|
const balanceElement = document.querySelector('[data-wallet-balance]') ||
|
||||||
|
document.getElementById('walletBalance');
|
||||||
|
if (balanceElement) {
|
||||||
|
balanceElement.textContent = `${newBalance.toFixed(2)} AED`;
|
||||||
|
}
|
||||||
|
window.currentWalletBalance = newBalance;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset UI to initial state
|
||||||
|
*/
|
||||||
|
resetUI(config) {
|
||||||
|
const elements = {
|
||||||
|
processingStatus: document.getElementById(config.processingStatusId || 'processingStatus'),
|
||||||
|
processButton: document.getElementById(config.processButtonId || 'processButton'),
|
||||||
|
results: document.getElementById(config.resultsId)
|
||||||
|
};
|
||||||
|
|
||||||
|
if (elements.processingStatus) {
|
||||||
|
elements.processingStatus.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elements.processButton) {
|
||||||
|
elements.processButton.disabled = false;
|
||||||
|
elements.processButton.innerHTML = config.buttonText || 'Process';
|
||||||
|
elements.processButton.classList.remove('loading');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elements.results) {
|
||||||
|
elements.results.style.display = 'none';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show processing status
|
||||||
|
*/
|
||||||
|
showProcessing(config) {
|
||||||
|
const elements = {
|
||||||
|
processingStatus: document.getElementById(config.processingStatusId || 'processingStatus'),
|
||||||
|
processButton: document.getElementById(config.processButtonId || 'processButton'),
|
||||||
|
results: document.getElementById(config.resultsId)
|
||||||
|
};
|
||||||
|
|
||||||
|
if (elements.processingStatus) {
|
||||||
|
elements.processingStatus.style.display = 'block';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elements.processButton) {
|
||||||
|
elements.processButton.disabled = true;
|
||||||
|
elements.processButton.classList.add('loading');
|
||||||
|
elements.processButton.innerHTML = config.processingText || '⏳ Processing...';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elements.results) {
|
||||||
|
elements.results.style.display = 'none';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show toast notification with duplicate prevention
|
||||||
|
*/
|
||||||
|
showToast(message, type = 'info') {
|
||||||
|
// Prevent duplicate toasts
|
||||||
|
const existingToast = document.querySelector('.agent-toast');
|
||||||
|
if (existingToast) {
|
||||||
|
existingToast.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
const toast = document.createElement('div');
|
||||||
|
toast.className = 'agent-toast';
|
||||||
|
toast.style.cssText = `
|
||||||
|
position: fixed;
|
||||||
|
top: 16px;
|
||||||
|
right: 16px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: white;
|
||||||
|
font-size: 13px;
|
||||||
|
z-index: 1000;
|
||||||
|
max-width: 300px;
|
||||||
|
font-weight: 500;
|
||||||
|
${type === 'success' ? 'background: #10b981;' : 'background: #ef4444;'}
|
||||||
|
`;
|
||||||
|
toast.textContent = message;
|
||||||
|
document.body.appendChild(toast);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (toast.parentNode) {
|
||||||
|
toast.remove();
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display results with markdown parsing
|
||||||
|
* Standardized across all agents
|
||||||
|
*/
|
||||||
|
displayResults(config) {
|
||||||
|
const resultsContainer = document.getElementById(config.resultsId);
|
||||||
|
const contentContainer = document.getElementById(config.contentId);
|
||||||
|
|
||||||
|
if (config.result.success && config.result.status === 'completed') {
|
||||||
|
// Get content from various possible fields
|
||||||
|
const content = config.result.content ||
|
||||||
|
config.result.job_posting_content ||
|
||||||
|
config.result.ad_copy_content ||
|
||||||
|
config.result.analysis_results ||
|
||||||
|
config.result.insights_summary ||
|
||||||
|
config.result.report_text ||
|
||||||
|
config.result.weather_data ||
|
||||||
|
config.result.formatted_report ||
|
||||||
|
config.result.output_text ||
|
||||||
|
config.defaultMessage ||
|
||||||
|
'Content generated successfully!';
|
||||||
|
|
||||||
|
// Parse markdown and display as HTML
|
||||||
|
const formattedContent = this.parseMarkdown(content);
|
||||||
|
contentContainer.innerHTML = formattedContent;
|
||||||
|
|
||||||
|
resultsContainer.style.display = 'block';
|
||||||
|
|
||||||
|
// Update wallet balance if provided
|
||||||
|
if (config.result.wallet_balance !== undefined) {
|
||||||
|
this.updateWalletBalance(config.result.wallet_balance);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.showToast(config.successMessage || '✅ Content generated and payment processed!', 'success');
|
||||||
|
} else {
|
||||||
|
this.showToast(config.errorMessage || '❌ Failed to generate content - no charge applied', 'error');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate text for copy/download functionality
|
||||||
|
*/
|
||||||
|
generateTextForExport(contentElementId) {
|
||||||
|
const content = document.getElementById(contentElementId);
|
||||||
|
if (content) {
|
||||||
|
return content.innerText || content.textContent || '';
|
||||||
|
}
|
||||||
|
return 'No content available';
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy content to clipboard
|
||||||
|
*/
|
||||||
|
copyToClipboard(text, successMessage = 'Content copied to clipboard!') {
|
||||||
|
navigator.clipboard.writeText(text).then(() => {
|
||||||
|
this.showToast(`📋 ${successMessage}`, 'success');
|
||||||
|
}).catch(() => {
|
||||||
|
this.showToast('Failed to copy content', 'error');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download content as text file
|
||||||
|
*/
|
||||||
|
downloadAsFile(text, filename, successMessage = 'File downloaded!') {
|
||||||
|
const blob = new Blob([text], { type: 'text/plain' });
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
a.download = filename || `content-${Date.now()}.txt`;
|
||||||
|
a.click();
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
this.showToast(`💾 ${successMessage}`, 'success');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Progressive status steps for better UX
|
||||||
|
*/
|
||||||
|
window.StatusStepper = class {
|
||||||
|
constructor(steps, statusTextElementId, interval = 800) {
|
||||||
|
this.steps = steps;
|
||||||
|
this.statusTextElement = document.getElementById(statusTextElementId);
|
||||||
|
this.interval = interval;
|
||||||
|
this.currentStep = 0;
|
||||||
|
this.stepInterval = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
this.currentStep = 0;
|
||||||
|
this.stepInterval = setInterval(() => {
|
||||||
|
if (this.currentStep < this.steps.length && this.statusTextElement) {
|
||||||
|
this.statusTextElement.textContent = this.steps[this.currentStep];
|
||||||
|
this.currentStep++;
|
||||||
|
} else {
|
||||||
|
this.stop();
|
||||||
|
}
|
||||||
|
}, this.interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
if (this.stepInterval) {
|
||||||
|
clearInterval(this.stepInterval);
|
||||||
|
this.stepInterval = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -4,292 +4,67 @@
|
|||||||
{% block title %}Weather Reporter Agent - NetCop AI Hub{% endblock %}
|
{% block title %}Weather Reporter Agent - NetCop AI Hub{% endblock %}
|
||||||
|
|
||||||
{% block extra_css %}
|
{% block extra_css %}
|
||||||
|
<!-- Optimized Font Loading -->
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- External Stylesheets -->
|
||||||
|
<link rel="stylesheet" href="{% static 'css/themes.css' %}">
|
||||||
|
<link rel="stylesheet" href="{% static 'css/agent-base.css' %}">
|
||||||
|
|
||||||
|
<!-- Shared JavaScript Utilities -->
|
||||||
|
<script src="{% static 'js/agent-utils.js' %}"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.weather-page {
|
/* Custom styles for weather reporter radio grid */
|
||||||
background: var(--gradient-hero);
|
|
||||||
min-height: calc(100vh - 80px);
|
|
||||||
padding: clamp(20px, 5vw, 40px);
|
|
||||||
width: 100vw;
|
|
||||||
margin-left: calc(-50vw + 50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.weather-container {
|
|
||||||
max-width: 1280px;
|
|
||||||
margin: 0 auto;
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 400px;
|
|
||||||
gap: 24px;
|
|
||||||
align-items: start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
background: rgba(255, 255, 255, 0.9);
|
|
||||||
border-radius: 16px;
|
|
||||||
padding: 24px;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
|
|
||||||
margin-bottom: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-title {
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-input {
|
|
||||||
width: 100%;
|
|
||||||
padding: 12px 16px;
|
|
||||||
border: 2px solid var(--border-medium);
|
|
||||||
border-radius: 12px;
|
|
||||||
font-size: 16px;
|
|
||||||
transition: border-color 0.2s ease;
|
|
||||||
min-height: 48px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
font-family: inherit;
|
|
||||||
background: var(--background-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-input:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: var(--primary-blue);
|
|
||||||
background: white;
|
|
||||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.help-text {
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
margin-top: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.radio-grid {
|
.radio-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
gap: 12px;
|
gap: var(--space-md);
|
||||||
}
|
}
|
||||||
|
|
||||||
.radio-option {
|
.radio-option {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 12px;
|
gap: var(--space-md);
|
||||||
padding: 16px;
|
padding: var(--space-lg);
|
||||||
border: 2px solid var(--border-light);
|
border: 1px solid var(--agent-border);
|
||||||
border-radius: 12px;
|
border-radius: var(--radius);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background: white;
|
background: white;
|
||||||
transition: all 0.2s ease;
|
transition: all var(--transition);
|
||||||
min-height: 60px;
|
min-height: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.radio-option.selected {
|
.radio-option.selected {
|
||||||
border-color: var(--primary-blue);
|
border-color: var(--agent-primary);
|
||||||
background: rgba(59, 130, 246, 0.1);
|
background: var(--agent-card-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.radio-option:hover {
|
||||||
|
border-color: var(--agent-primary);
|
||||||
|
background: var(--hover-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.radio-option input[type="radio"] {
|
.radio-option input[type="radio"] {
|
||||||
margin: 0;
|
|
||||||
width: 18px;
|
width: 18px;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
}
|
|
||||||
|
|
||||||
.processing-status {
|
|
||||||
padding: 20px;
|
|
||||||
background: rgba(59, 130, 246, 0.1);
|
|
||||||
border: 2px solid var(--primary-blue);
|
|
||||||
border-radius: 12px;
|
|
||||||
color: var(--primary-dark);
|
|
||||||
font-weight: 600;
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.processing-status .status-icon {
|
|
||||||
font-size: 32px;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
animation: pulse 2s infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes pulse {
|
|
||||||
0%, 100% { transform: scale(1); }
|
|
||||||
50% { transform: scale(1.1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-card {
|
|
||||||
background: rgba(255, 255, 255, 0.9);
|
|
||||||
border-radius: 16px;
|
|
||||||
padding: 24px;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
|
|
||||||
margin-top: 24px;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
padding-bottom: 16px;
|
|
||||||
border-bottom: 1px solid var(--border-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.results-content {
|
|
||||||
background: var(--background-page);
|
|
||||||
border: 1px solid var(--border-light);
|
|
||||||
border-radius: 12px;
|
|
||||||
padding: 24px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
white-space: pre-line;
|
|
||||||
line-height: 1.7;
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-size: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: 12px;
|
|
||||||
margin-top: 20px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
padding: 16px 32px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 12px;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 16px;
|
|
||||||
min-height: 48px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 8px;
|
|
||||||
transition: transform 0.1s ease;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
background: var(--gradient-primary);
|
|
||||||
color: white;
|
|
||||||
flex: 1;
|
|
||||||
min-width: 120px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary {
|
|
||||||
background: var(--background-subtle);
|
|
||||||
color: var(--text-primary);
|
|
||||||
border: 2px solid var(--border-medium);
|
|
||||||
flex: 1;
|
|
||||||
min-width: 120px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:hover:not(:disabled) {
|
|
||||||
transform: translateY(-1px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:disabled {
|
|
||||||
background: var(--border-strong);
|
|
||||||
color: white;
|
|
||||||
cursor: not-allowed;
|
|
||||||
transform: none;
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wallet-section {
|
|
||||||
position: sticky;
|
|
||||||
top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wallet-balance {
|
|
||||||
font-size: 28px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--text-primary);
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.balance-label {
|
|
||||||
font-size: 16px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.process-btn {
|
|
||||||
width: 100%;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.insufficient-balance {
|
|
||||||
background: rgba(239, 68, 68, 0.1);
|
|
||||||
border: 1px solid rgba(239, 68, 68, 0.3);
|
|
||||||
color: var(--error-red);
|
|
||||||
padding: 12px;
|
|
||||||
border-radius: 8px;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 14px;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info {
|
|
||||||
padding: 16px;
|
|
||||||
background: rgba(59, 130, 246, 0.1);
|
|
||||||
border-radius: 12px;
|
|
||||||
border: 1px solid rgba(59, 130, 246, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info h4 {
|
|
||||||
margin: 0 0 8px 0;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--primary-dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
.usage-info ul {
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-primary);
|
|
||||||
line-height: 1.4;
|
|
||||||
list-style: none;
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.usage-info li {
|
.form-help {
|
||||||
margin: 4px 0;
|
font-size: var(--text-xs);
|
||||||
padding-left: 16px;
|
color: var(--accent-color);
|
||||||
position: relative;
|
margin-top: var(--space-xs);
|
||||||
}
|
opacity: 0.7;
|
||||||
|
|
||||||
.usage-info li::before {
|
|
||||||
content: "•";
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
color: var(--primary-blue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Mobile optimizations */
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.weather-container {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="weather-page">
|
<div class="agent-page theme-professional">
|
||||||
<div class="weather-container">
|
<div class="agent-container">
|
||||||
<!-- Messages -->
|
<!-- Messages -->
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
{% for message in messages %}
|
{% for message in messages %}
|
||||||
@ -308,15 +83,15 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
<!-- Location Input -->
|
<!-- Location Input -->
|
||||||
<div style="margin-bottom: 24px;">
|
<div class="form-group">
|
||||||
<label for="location" style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 600; color: var(--text-primary);">📍 Enter Location *</label>
|
<label for="location" class="form-label">📍 Enter Location *</label>
|
||||||
<input type="text" name="location" id="location" class="form-input" placeholder="Enter city name, address, or coordinates..." required>
|
<input type="text" name="location" id="location" class="form-input" placeholder="Enter city name, address, or coordinates..." required>
|
||||||
<div class="help-text">Examples: "New York", "London, UK", "Tokyo, Japan", "37.7749,-122.4194"</div>
|
<div class="form-help">Examples: "New York", "London, UK", "Tokyo, Japan", "37.7749,-122.4194"</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Report Type Selection -->
|
<!-- Report Type Selection -->
|
||||||
<div>
|
<div>
|
||||||
<label style="display: block; margin-bottom: 12px; font-size: 14px; font-weight: 600; color: var(--text-primary);">📊 Report Type *</label>
|
<label class="form-label">📊 Report Type *</label>
|
||||||
<div class="radio-grid">
|
<div class="radio-grid">
|
||||||
<label class="radio-option selected" onclick="selectReportType('current')">
|
<label class="radio-option selected" onclick="selectReportType('current')">
|
||||||
<input type="radio" name="report_type" value="current" checked>
|
<input type="radio" name="report_type" value="current" checked>
|
||||||
@ -446,34 +221,14 @@
|
|||||||
|
|
||||||
// Copy weather report to clipboard
|
// Copy weather report to clipboard
|
||||||
function copyWeatherReport() {
|
function copyWeatherReport() {
|
||||||
const reportText = generateReportText();
|
const reportText = AgentUtils.generateTextForExport('weatherContent');
|
||||||
navigator.clipboard.writeText(reportText).then(() => {
|
AgentUtils.copyToClipboard(reportText, 'Weather report copied to clipboard!');
|
||||||
showToast('📋 Weather report copied to clipboard!', 'success');
|
|
||||||
}).catch(() => {
|
|
||||||
showToast('Failed to copy report', 'error');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download weather report as text file
|
// Download weather report as text file
|
||||||
function downloadWeatherReport() {
|
function downloadWeatherReport() {
|
||||||
const reportText = generateReportText();
|
const reportText = AgentUtils.generateTextForExport('weatherContent');
|
||||||
const blob = new Blob([reportText], { type: 'text/plain' });
|
AgentUtils.downloadAsFile(reportText, `weather-report-${Date.now()}.txt`, 'Weather report downloaded!');
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.href = url;
|
|
||||||
a.download = 'weather-report-' + Date.now() + '.txt';
|
|
||||||
a.click();
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
showToast('💾 Weather report downloaded!', 'success');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate report text for copy/download
|
|
||||||
function generateReportText() {
|
|
||||||
const content = document.querySelector('#weatherContent');
|
|
||||||
if (content) {
|
|
||||||
return content.textContent || content.innerText || '';
|
|
||||||
}
|
|
||||||
return 'No weather data available';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track processing state to prevent duplicates
|
// Track processing state to prevent duplicates
|
||||||
@ -498,58 +253,22 @@
|
|||||||
document.querySelector('.radio-option').classList.add('selected');
|
document.querySelector('.radio-option').classList.add('selected');
|
||||||
document.querySelector('input[value="current"]').checked = true;
|
document.querySelector('input[value="current"]').checked = true;
|
||||||
|
|
||||||
showToast('Form reset! Ready for another weather report.', 'success');
|
AgentUtils.showToast('Form reset! Ready for another weather report.', 'success');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple toast notification
|
// Simple toast notification
|
||||||
function showToast(message, type = 'info') {
|
|
||||||
const toast = document.createElement('div');
|
|
||||||
toast.style.cssText = `
|
|
||||||
position: fixed;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
padding: 12px 20px;
|
|
||||||
border-radius: 8px;
|
|
||||||
color: white;
|
|
||||||
font-weight: 600;
|
|
||||||
z-index: 1000;
|
|
||||||
${type === 'success' ? 'background: var(--success-green);' : 'background: var(--error-red);'}
|
|
||||||
`;
|
|
||||||
toast.textContent = message;
|
|
||||||
document.body.appendChild(toast);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
toast.remove();
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update wallet balance display
|
// Display weather results with markdown parsing
|
||||||
function updateWalletBalance(newBalance) {
|
|
||||||
const balanceElements = document.querySelectorAll('[data-wallet-balance]');
|
|
||||||
balanceElements.forEach(element => {
|
|
||||||
element.textContent = `${newBalance.toFixed(2)} AED`;
|
|
||||||
});
|
|
||||||
window.currentWalletBalance = newBalance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display weather results
|
|
||||||
function displayResults(result) {
|
function displayResults(result) {
|
||||||
const resultsContainer = document.getElementById('weatherResults');
|
AgentUtils.displayResults({
|
||||||
const contentContainer = document.getElementById('weatherContent');
|
result: result,
|
||||||
|
resultsId: 'weatherResults',
|
||||||
if (result.success && result.status === 'completed') {
|
contentId: 'weatherContent',
|
||||||
contentContainer.textContent = result.content || result.weather_data || result.formatted_report || 'Weather report generated successfully!';
|
defaultMessage: 'Weather report generated successfully!',
|
||||||
resultsContainer.style.display = 'block';
|
successMessage: '✅ Weather report completed and payment processed!',
|
||||||
|
errorMessage: '❌ Failed to generate weather report - no charge applied'
|
||||||
// Update wallet balance if provided
|
});
|
||||||
if (result.wallet_balance !== undefined) {
|
|
||||||
updateWalletBalance(result.wallet_balance);
|
|
||||||
}
|
|
||||||
|
|
||||||
showToast('✅ Weather report completed and payment processed!', 'success');
|
|
||||||
} else {
|
|
||||||
showToast('❌ Failed to generate weather report - no charge applied', 'error');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll for results
|
// Poll for results
|
||||||
@ -575,7 +294,7 @@
|
|||||||
document.getElementById('processingStatus').style.display = 'none';
|
document.getElementById('processingStatus').style.display = 'none';
|
||||||
document.getElementById('processButton').disabled = false;
|
document.getElementById('processButton').disabled = false;
|
||||||
document.getElementById('processButton').innerHTML = '🌤️ Get Weather Report (2.00 AED)';
|
document.getElementById('processButton').innerHTML = '🌤️ Get Weather Report (2.00 AED)';
|
||||||
showToast('❌ Processing timeout - please try again', 'error');
|
AgentUtils.showToast('❌ Processing timeout - please try again', 'error');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@ -585,7 +304,7 @@
|
|||||||
document.getElementById('processingStatus').style.display = 'none';
|
document.getElementById('processingStatus').style.display = 'none';
|
||||||
document.getElementById('processButton').disabled = false;
|
document.getElementById('processButton').disabled = false;
|
||||||
document.getElementById('processButton').innerHTML = '🌤️ Get Weather Report (2.00 AED)';
|
document.getElementById('processButton').innerHTML = '🌤️ Get Weather Report (2.00 AED)';
|
||||||
showToast('❌ Network error - please try again', 'error');
|
AgentUtils.showToast('❌ Network error - please try again', 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@ -596,7 +315,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!isFormValid()) {
|
if (!isFormValid()) {
|
||||||
showToast('Please fill in all required fields', 'error');
|
AgentUtils.showToast('Please fill in all required fields', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -614,7 +333,7 @@
|
|||||||
// Check wallet balance
|
// Check wallet balance
|
||||||
const balance = {{ user.wallet_balance|default:0 }};
|
const balance = {{ user.wallet_balance|default:0 }};
|
||||||
if (balance < 2.00) {
|
if (balance < 2.00) {
|
||||||
showToast('Insufficient balance! You need 2.00 AED.', 'error');
|
AgentUtils.showToast('Insufficient balance! You need 2.00 AED.', 'error');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = "{% url 'core:wallet' %}";
|
window.location.href = "{% url 'core:wallet' %}";
|
||||||
}, 2000);
|
}, 2000);
|
||||||
@ -651,7 +370,7 @@
|
|||||||
// Submit form via AJAX
|
// Submit form via AJAX
|
||||||
const formData = new FormData(this);
|
const formData = new FormData(this);
|
||||||
|
|
||||||
fetch('/agents/weather-reporter/process/', {
|
fetch(window.location.href, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
headers: {
|
headers: {
|
||||||
@ -671,11 +390,11 @@
|
|||||||
document.getElementById('processButton').innerHTML = '🌤️ Get Weather Report (2.00 AED)';
|
document.getElementById('processButton').innerHTML = '🌤️ Get Weather Report (2.00 AED)';
|
||||||
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
showToast(`❌ ${result.error}`, 'error');
|
AgentUtils.showToast(`❌ ${result.error}`, 'error');
|
||||||
} else if (result.success) {
|
} else if (result.success) {
|
||||||
displayResults(result);
|
displayResults(result);
|
||||||
} else {
|
} else {
|
||||||
showToast('❌ Failed to generate weather report', 'error');
|
AgentUtils.showToast('❌ Failed to generate weather report', 'error');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@ -688,7 +407,7 @@
|
|||||||
document.getElementById('processingStatus').style.display = 'none';
|
document.getElementById('processingStatus').style.display = 'none';
|
||||||
document.getElementById('processButton').disabled = false;
|
document.getElementById('processButton').disabled = false;
|
||||||
document.getElementById('processButton').innerHTML = '🌤️ Get Weather Report (2.00 AED)';
|
document.getElementById('processButton').innerHTML = '🌤️ Get Weather Report (2.00 AED)';
|
||||||
showToast('❌ Network error - please try again', 'error');
|
AgentUtils.showToast('❌ Network error - please try again', 'error');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user