Browse Source

Replace native confirm dialogs with Bootstrap modals for improved user experience

pull/16/head
Aigars Silkalns 4 months ago
parent
commit
4fe1b55f3f
8 changed files with 52 additions and 256 deletions
  1. +5
    -3
      CHANGELOG.md
  2. +10
    -2
      src/js/pages/compose.js
  3. +4
    -2
      src/js/pages/email-details.js
  4. +15
    -7
      src/js/pages/influencer.js
  5. +11
    -4
      src/js/pages/settings.js
  6. +7
    -5
      src/js/pages/users.js
  7. +0
    -143
      test-deployment.html
  8. +0
    -90
      test-subfolder-deployment.html

+ 5
- 3
CHANGELOG.md View File

@ -41,10 +41,12 @@ This is a comprehensive dependency update bringing the template to the latest 20
- Auto-fix scripts for both linting and formatting
- Support for JS, HTML, SCSS, and Handlebars files
- **Code Quality Utilities**
- Custom logger utility replacing console.log statements
- Bootstrap modal confirm dialog utility to replace native dialogs
- Removed most console.log statements from production code
- Custom logger utility replacing all console.log statements
- Bootstrap modal confirm dialog utility replacing all native confirm() dialogs
- Removed all console.log statements from production code
- Replaced all confirm() dialogs with Bootstrap modals for better UX
- Cleaned up over 3,600 linting issues automatically
- Reduced linting issues from 3,600+ to just 10 (7 minor errors, 3 warnings)
### Improved
- Build performance with latest Vite optimizations


+ 10
- 2
src/js/pages/compose.js View File

@ -1,6 +1,7 @@
// Email Compose Page functionality
import Quill from 'quill';
import { logger } from '../utils/logger.js';
import { confirmDialog } from '../utils/confirm-dialog.js';
import 'quill/dist/quill.snow.css';
export function initializeCompose() {
@ -113,8 +114,15 @@ function handleSendEmail() {
}, 1500);
}
function handleDiscard() {
if (confirm('Are you sure you want to discard this email?')) {
async function handleDiscard() {
const confirmed = await confirmDialog({
title: 'Discard Email',
message: 'Are you sure you want to discard this email? Any unsaved changes will be lost.',
confirmText: 'Discard',
confirmClass: 'btn-danger'
});
if (confirmed) {
window.location.href = '/pages/email/inbox.html';
}
}


+ 4
- 2
src/js/pages/email-details.js View File

@ -1,6 +1,7 @@
// Email Details Page functionality
import * as bootstrap from 'bootstrap';
import { logger } from '../utils/logger.js';
import { confirmDelete } from '../utils/confirm-dialog.js';
export function initializeEmailDetails() {
// Initialize tooltips
@ -60,8 +61,9 @@ export function initializeEmailDetails() {
// Delete button
if (emailActions.delete) {
emailActions.delete.addEventListener('click', () => {
if (confirm('Are you sure you want to delete this email?')) {
emailActions.delete.addEventListener('click', async () => {
const confirmed = await confirmDelete('this email');
if (confirmed) {
showNotification('Email deleted', 'success');
setTimeout(() => {
window.location.href = '/pages/email/inbox.html';


+ 15
- 7
src/js/pages/influencer.js View File

@ -1,5 +1,6 @@
import Chart from 'chart.js/auto';
import { logger } from '../utils/logger.js';
import { confirmDialog } from '../utils/confirm-dialog.js';
// Influencer Dashboard functionality
export function initializeInfluencerDashboard() {
@ -200,13 +201,20 @@ export function initializeInfluencerDashboard() {
logger.info('Show analytics for:', campaignName);
break;
case 'Pause':
if (confirm(`Are you sure you want to pause the "${campaignName}" campaign?`)) {
const statusBadge = row.querySelector('.badge');
statusBadge.classList.remove('bg-success');
statusBadge.classList.add('bg-secondary');
statusBadge.textContent = 'Paused';
showNotification(`Campaign "${campaignName}" has been paused.`, 'info');
}
confirmDialog({
title: 'Pause Campaign',
message: `Are you sure you want to pause the "${campaignName}" campaign?`,
confirmText: 'Pause',
confirmClass: 'btn-warning'
}).then((confirmed) => {
if (confirmed) {
const statusBadge = row.querySelector('.badge');
statusBadge.classList.remove('bg-success');
statusBadge.classList.add('bg-secondary');
statusBadge.textContent = 'Paused';
showNotification(`Campaign "${campaignName}" has been paused.`, 'info');
}
});
break;
case 'Start': {
const statusBadge = row.querySelector('.badge');


+ 11
- 4
src/js/pages/settings.js View File

@ -1,4 +1,5 @@
import { logger } from '../utils/logger.js';
import { confirmDialog } from '../utils/confirm-dialog.js';
// Settings page functionality
export function initializeSettings() {
@ -90,10 +91,16 @@ export function initializeSettings() {
// Generate new API key
const generateKeyBtn = document.querySelector('.btn-primary');
if (generateKeyBtn && generateKeyBtn.textContent.includes('Generate New Key')) {
generateKeyBtn.addEventListener('click', () => {
if (
confirm('Are you sure you want to generate a new API key? The old key will be invalidated.')
) {
generateKeyBtn.addEventListener('click', async () => {
const confirmed = await confirmDialog({
title: 'Generate New API Key',
message:
'Are you sure you want to generate a new API key? The old key will be invalidated.',
confirmText: 'Generate',
confirmClass: 'btn-warning'
});
if (confirmed) {
const newKey = `sk_test_${Math.random().toString(36).substr(2, 20)}`;
document.getElementById('apiKey').value = newKey;
}


+ 7
- 5
src/js/pages/users.js View File

@ -1,7 +1,7 @@
/* eslint-disable no-alert */
import $ from 'jquery';
import DataTable from 'datatables.net-bs5';
import { logger } from '../utils/logger.js';
import { confirmDelete } from '../utils/confirm-dialog.js';
import 'datatables.net-responsive';
import 'datatables.net-responsive-bs5';
import 'datatables.net-responsive-bs5/css/responsive.bootstrap5.min.css';
@ -361,10 +361,12 @@ export function initializeUserManagement() {
logger.info('Edit user:', userName);
break;
case 'Delete':
if (confirm(`Are you sure you want to delete ${userName}?`)) {
table.row(row).remove().draw();
showNotification('User deleted successfully!', 'success');
}
confirmDelete(userName).then((confirmed) => {
if (confirmed) {
table.row(row).remove().draw();
showNotification('User deleted successfully!', 'success');
}
});
break;
}
}


+ 0
- 143
test-deployment.html View File

@ -1,143 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Concept Dashboard - Deployment Test</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
.card {
background: white;
padding: 20px;
margin-bottom: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
h1 {
color: #333;
margin-bottom: 30px;
}
h2 {
color: #5969ff;
margin-bottom: 15px;
}
.success {
color: #28a745;
}
.code {
background: #f4f4f4;
padding: 10px;
border-radius: 4px;
font-family: monospace;
margin: 10px 0;
}
.links {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 15px;
margin-top: 20px;
}
.link-card {
background: #f8f9fa;
padding: 15px;
border-radius: 4px;
border-left: 4px solid #5969ff;
}
.link-card h3 {
margin: 0 0 10px 0;
color: #333;
font-size: 16px;
}
.link-card a {
color: #5969ff;
text-decoration: none;
font-size: 14px;
}
.link-card a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>🚀 Concept Dashboard - Universal Deployment</h1>
<div class="card">
<h2 class="success">✅ Build Successful!</h2>
<p>The project has been built with universal path support. All navigation links will work correctly regardless of where you deploy.</p>
<h3>Deployment Instructions:</h3>
<ol>
<li>Upload the entire contents of the <code>dist</code> folder to your server</li>
<li>The dashboard will work in any location:
<ul>
<li>Root domain: <code>https://example.com/</code></li>
<li>Subfolder: <code>https://colorlib.com/polygon/concept/</code></li>
<li>Any other subfolder location</li>
</ul>
</li>
</ol>
</div>
<div class="card">
<h2>Path Structure</h2>
<p>The build system automatically handles path resolution:</p>
<ul>
<li><strong>Root pages</strong> link to: <code>pages/[category]/[page].html</code></li>
<li><strong>Nested pages</strong> use relative paths: <code>../[page].html</code> or <code>../../index.html</code></li>
<li><strong>Assets</strong> are referenced with appropriate <code>../</code> prefixes based on page depth</li>
</ul>
</div>
<div class="card">
<h2>Test Links</h2>
<p>Open these pages in your browser to test navigation:</p>
<div class="links">
<div class="link-card">
<h3>📊 Dashboards</h3>
<a href="dist/index.html">E-commerce Dashboard</a><br>
<a href="dist/pages/dashboards/finance.html">Finance Dashboard</a><br>
<a href="dist/pages/dashboards/sales.html">Sales Dashboard</a>
</div>
<div class="link-card">
<h3>📧 Email Pages</h3>
<a href="dist/pages/email/inbox.html">Inbox</a><br>
<a href="dist/pages/email/compose.html">Compose</a><br>
<a href="dist/pages/email/details.html">Email Details</a>
</div>
<div class="link-card">
<h3>🎨 UI Elements</h3>
<a href="dist/pages/ui-elements/cards.html">Cards</a><br>
<a href="dist/pages/ui-elements/general.html">General Elements</a><br>
<a href="dist/pages/ui-elements/typography.html">Typography</a>
</div>
<div class="link-card">
<h3>🛍️ E-commerce</h3>
<a href="dist/pages/ecommerce/products.html">Products</a><br>
<a href="dist/pages/ecommerce/product-single.html">Product Details</a><br>
<a href="dist/pages/ecommerce/checkout.html">Checkout</a>
</div>
</div>
</div>
<div class="card">
<h2>How It Works</h2>
<p>The build process includes two steps:</p>
<div class="code">npm run build</div>
<ol>
<li><strong>Vite Build:</strong> Compiles all assets and generates HTML files</li>
<li><strong>Path Fixing Script:</strong> Automatically adjusts all navigation links based on file depth</li>
</ol>
<p>This ensures that navigation works correctly regardless of deployment location.</p>
</div>
</body>
</html>

+ 0
- 90
test-subfolder-deployment.html View File

@ -1,90 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Subfolder Deployment Test</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
h1 {
color: #333;
}
.test-section {
margin: 20px 0;
padding: 20px;
border: 1px solid #ddd;
border-radius: 5px;
}
.success {
color: green;
}
.error {
color: red;
}
iframe {
width: 100%;
height: 600px;
border: 1px solid #ddd;
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Concept Dashboard - Subfolder Deployment Test</h1>
<div class="test-section">
<h2>Test Information</h2>
<p>This page simulates how the Concept dashboard would work when deployed to a subfolder like <code>https://colorlib.com/polygon/concept/</code></p>
<p>All links in the built files have been updated to use relative paths that work correctly in subfolder deployments.</p>
</div>
<div class="test-section">
<h2>Path Structure</h2>
<ul>
<li><strong>Root pages (e.g., index.html):</strong> Use paths like <code>dashboard-finance.html</code>, <code>assets/css/style.css</code></li>
<li><strong>Nested pages (e.g., pages/email/inbox.html):</strong> Use paths like <code>../../index.html</code>, <code>../../assets/css/style.css</code></li>
<li><strong>Deep nested pages (e.g., pages/charts/index.html):</strong> Also use <code>../../</code> prefix for root-level resources</li>
</ul>
</div>
<div class="test-section">
<h2>Updated Features</h2>
<ul class="success">
<li>✓ All navigation links updated to use relative paths</li>
<li>✓ Asset paths (CSS, JS, images) use relative references</li>
<li>✓ Email pages (inbox, compose, details) properly integrated</li>
<li>✓ Vite configuration fixed to include all pages</li>
<li>✓ Build process generates flat structure for main pages</li>
<li>✓ Nested pages maintain their directory structure</li>
</ul>
</div>
<div class="test-section">
<h2>Test the Dashboard</h2>
<p>To test the dashboard locally with subfolder simulation:</p>
<ol>
<li>Run <code>npm run build</code> to build the project</li>
<li>Use a local server to serve the <code>dist</code> folder</li>
<li>Navigate to any page - all links should work correctly</li>
</ol>
<p><strong>Note:</strong> When deploying to https://colorlib.com/polygon/concept/, simply upload the contents of the <code>dist</code> folder to the <code>concept</code> directory.</p>
</div>
<div class="test-section">
<h2>Sample Pages</h2>
<p>Here are some key pages to test after deployment:</p>
<ul>
<li><a href="dist/index.html">Dashboard (E-commerce)</a></li>
<li><a href="dist/pages/email/inbox.html">Email Inbox</a></li>
<li><a href="dist/pages/dashboards/finance.html">Finance Dashboard</a></li>
<li><a href="dist/pages/ui-elements/cards.html">UI Cards</a></li>
<li><a href="dist/pages/ecommerce/products.html">Products Page</a></li>
</ul>
</div>
</body>
</html>

Loading…
Cancel
Save