Spaces:
Running
Running
Download index.html from cpotenzone/nofriction: direct link, hf CLI and curl.
- Browser
- Download file 79.8 kB
-
https://huggingface.co/spaces/cpotenzone/nofriction/resolve/main/index.html
- Command line
-
hf download hf://spaces/cpotenzone/nofriction/index.html
-
curl -L -o index.html https://huggingface.co/spaces/cpotenzone/nofriction/resolve/main/index.html
79.8 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Proposal Presentation System</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Inter', sans-serif;
transition: background-color 0.3s ease;
}
.sidebar {
transition: transform 0.3s ease;
}
.proposal-card {
transition: all 0.3s ease;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.proposal-card:hover {
transform: translateY(-4px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.content-frame {
min-height: calc(100vh - 80px);
}
.tag {
transition: all 0.2s ease;
}
.tag:hover {
transform: scale(1.05);
}
/* Loading animation */
.loader {
border-top-color: #3B82F6;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Admin badge */
.admin-badge {
position: absolute;
top: -4px;
right: -4px;
width: 16px;
height: 16px;
background-color: #EF4444;
border-radius: 50%;
border: 2px solid white;
}
/* Slide transitions */
.slide-enter-active, .slide-leave-active {
transition: all 0.3s ease;
}
.slide-enter-from, .slide-leave-to {
transform: translateX(20px);
opacity: 0;
}
/* Toast notification */
.toast {
position: fixed;
top: 20px;
right: 20px;
z-index: 1000;
padding: 12px 20px;
border-radius: 4px;
color: white;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
transform: translateY(-100px);
opacity: 0;
transition: all 0.3s ease;
}
.toast.show {
transform: translateY(0);
opacity: 1;
}
.toast.success {
background-color: #10B981;
}
.toast.error {
background-color: #EF4444;
}
.toast.info {
background-color: #3B82F6;
}
</style>
</head>
<body class="bg-gray-50">
<!-- Toast notification -->
<div id="toast" class="toast hidden"></div>
<!-- Mobile menu button -->
<div class="md:hidden fixed top-4 right-4 z-50">
<button id="mobile-menu-button" class="p-2 rounded-md bg-white shadow-md text-gray-700">
<i class="fas fa-bars"></i>
</button>
</div>
<!-- Sidebar -->
<div id="sidebar" class="sidebar fixed inset-y-0 left-0 transform -translate-x-full md:translate-x-0 w-64 bg-white shadow-lg z-40 overflow-y-auto">
<div class="p-4 border-b border-gray-200">
<h1 class="text-xl font-bold text-gray-800 flex items-center">
<i class="fas fa-folder-open text-blue-500 mr-2"></i>
Proposal System
</h1>
<p class="text-sm text-gray-500 mt-1">Version 2.0</p>
</div>
<div class="p-4">
<div class="relative">
<input type="text" id="search" placeholder="Search proposals..." class="w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
<i class="fas fa-search absolute right-3 top-2.5 text-gray-400"></i>
</div>
<div class="mt-4">
<h3 class="text-xs font-semibold text-gray-500 uppercase tracking-wider">Categories</h3>
<div id="category-filters" class="mt-2 space-y-1">
<!-- Categories will be populated by JavaScript -->
</div>
</div>
<div class="mt-6">
<h3 class="text-xs font-semibold text-gray-500 uppercase tracking-wider">Tags</h3>
<div id="tag-filters" class="mt-2 flex flex-wrap gap-2">
<!-- Tags will be populated by JavaScript -->
</div>
</div>
<div class="mt-6">
<button id="new-proposal-btn" class="w-full flex items-center justify-center px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition duration-200">
<i class="fas fa-plus mr-2"></i> New Proposal
</button>
</div>
</div>
<div class="p-4 border-t border-gray-200">
<div class="flex items-center space-x-3 relative">
<img id="user-avatar" src="https://ui-avatars.com/api/?name=Casey&background=EF4444&color=fff" alt="User" class="w-8 h-8 rounded-full">
<div>
<p id="user-name" class="text-sm font-medium text-gray-700">Casey</p>
<p id="user-email" class="text-xs text-gray-500">casey@nofriction.io</p>
</div>
<div id="admin-badge" class="admin-badge"></div>
</div>
<div id="user-menu" class="mt-3 space-y-1">
<button id="admin-panel-btn" class="w-full text-left text-sm text-gray-500 hover:text-gray-700 flex items-center">
<i class="fas fa-cog mr-2"></i> Admin Panel
</button>
<button id="logout-btn" class="w-full text-left text-sm text-gray-500 hover:text-gray-700 flex items-center">
<i class="fas fa-sign-out-alt mr-2"></i> Logout
</button>
</div>
</div>
</div>
<!-- Overlay for mobile menu -->
<div id="overlay" class="fixed inset-0 bg-black bg-opacity-50 z-30 hidden"></div>
<!-- Main content area -->
<div class="md:ml-64 min-h-screen">
<!-- Top navigation -->
<nav class="bg-white shadow-sm">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<h2 id="current-view" class="text-lg font-medium text-gray-900">Proposal Catalog</h2>
</div>
<div class="flex items-center">
<div class="relative">
<button id="notifications-btn" class="p-1 rounded-full text-gray-400 hover:text-gray-500 focus:outline-none">
<i class="fas fa-bell"></i>
<span id="notification-count" class="absolute top-0 right-0 h-2 w-2 rounded-full bg-red-500 hidden"></span>
</button>
</div>
<div class="ml-4 relative">
<button id="user-menu-btn" class="flex text-sm rounded-full focus:outline-none">
<img id="top-user-avatar" class="h-8 w-8 rounded-full" src="https://ui-avatars.com/api/?name=Casey&background=EF4444&color=fff" alt="User menu">
<div id="top-admin-badge" class="admin-badge"></div>
</button>
</div>
</div>
</div>
</div>
</nav>
<!-- Content area -->
<main>
<!-- Catalog view -->
<div id="catalog-view" class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-bold text-gray-900">All Proposals</h2>
<div class="flex space-x-2">
<div class="relative">
<select id="sort-by" class="appearance-none bg-white border border-gray-300 rounded-md pl-3 pr-8 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="date-desc">Newest First</option>
<option value="date-asc">Oldest First</option>
<option value="name-asc">A-Z</option>
<option value="name-desc">Z-A</option>
</select>
<div class="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
<i class="fas fa-chevron-down text-gray-400"></i>
</div>
</div>
<button id="grid-view-btn" class="p-2 rounded-md bg-blue-500 text-white">
<i class="fas fa-th"></i>
</button>
<button id="list-view-btn" class="p-2 rounded-md bg-gray-200 text-gray-700">
<i class="fas fa-list"></i>
</button>
</div>
</div>
<div id="proposals-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Proposals will be loaded here -->
<div class="text-center py-10">
<div class="loader ease-linear rounded-full border-4 border-t-4 border-gray-200 h-12 w-12 mx-auto"></div>
<p class="mt-3 text-gray-500">Loading proposals...</p>
</div>
</div>
</div>
<!-- Proposal view (hidden by default) -->
<div id="proposal-view" class="hidden max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
<div class="flex justify-between items-center mb-6">
<button id="back-to-catalog" class="flex items-center text-blue-500 hover:text-blue-700">
<i class="fas fa-arrow-left mr-2"></i> Back to catalog
</button>
<div class="flex space-x-3">
<button id="edit-proposal" class="px-3 py-1 bg-gray-100 rounded-md text-gray-700 hover:bg-gray-200 flex items-center">
<i class="fas fa-pencil-alt mr-2"></i> Edit
</button>
<button id="delete-proposal" class="px-3 py-1 bg-red-50 rounded-md text-red-600 hover:bg-red-100 flex items-center">
<i class="fas fa-trash mr-2"></i> Delete
</button>
</div>
</div>
<div class="bg-white shadow-sm rounded-lg overflow-hidden">
<div class="p-6 border-b border-gray-200">
<h2 id="proposal-title" class="text-2xl font-bold text-gray-900">Proposal Title</h2>
<div class="mt-2 flex flex-wrap items-center gap-2">
<span id="proposal-category" class="px-2 py-1 text-xs font-medium bg-blue-100 text-blue-800 rounded-full">Category</span>
<span id="proposal-date" class="text-sm text-gray-500">Created on: <span class="font-medium">Jan 1, 2023</span></span>
<span id="proposal-author" class="text-sm text-gray-500">By: <span class="font-medium">Admin</span></span>
</div>
<div id="proposal-tags" class="mt-2 flex flex-wrap gap-1">
<!-- Tags will be added here -->
</div>
</div>
<div class="content-frame">
<iframe id="proposal-content" class="w-full h-full min-h-screen border-0" frameborder="0"></iframe>
</div>
</div>
</div>
<!-- Admin Panel View -->
<div id="admin-view" class="hidden max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-bold text-gray-900">Admin Panel</h2>
<button id="back-from-admin" class="flex items-center text-blue-500 hover:text-blue-700">
<i class="fas fa-arrow-left mr-2"></i> Back to catalog
</button>
</div>
<div class="bg-white shadow rounded-lg overflow-hidden">
<div class="border-b border-gray-200">
<nav class="flex -mb-px">
<button id="users-tab" class="admin-tab active px-4 py-4 text-sm font-medium text-blue-600 border-b-2 border-blue-500">
User Management
</button>
<button id="system-tab" class="admin-tab px-4 py-4 text-sm font-medium text-gray-500 hover:text-gray-700 border-b-2 border-transparent hover:border-gray-300">
System Settings
</button>
<button id="activity-tab" class="admin-tab px-4 py-4 text-sm font-medium text-gray-500 hover:text-gray-700 border-b-2 border-transparent hover:border-gray-300">
Activity Log
</button>
</nav>
</div>
<!-- Users Management Panel -->
<div id="users-panel" class="admin-panel">
<div class="p-6">
<div class="flex justify-between items-center mb-6">
<h3 class="text-lg font-medium text-gray-900">User Management</h3>
<button id="add-user-btn" class="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600 flex items-center">
<i class="fas fa-plus mr-2"></i> Add User
</button>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Role</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody id="users-table-body" class="bg-white divide-y divide-gray-200">
<!-- Users will be loaded here -->
</tbody>
</table>
</div>
</div>
</div>
<!-- System Settings Panel -->
<div id="system-panel" class="admin-panel hidden">
<div class="p-6">
<h3 class="text-lg font-medium text-gray-900 mb-6">System Settings</h3>
<div class="space-y-6">
<div>
<h4 class="text-md font-medium text-gray-900 mb-3">General Settings</h4>
<div class="space-y-4">
<div class="flex items-center">
<input id="allow-registration" type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<label for="allow-registration" class="ml-2 block text-sm text-gray-700">Allow new user registration</label>
</div>
<div class="flex items-center">
<input id="email-notifications" type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<label for="email-notifications" class="ml-2 block text-sm text-gray-700">Enable email notifications</label>
</div>
</div>
</div>
<div>
<h4 class="text-md font-medium text-gray-900 mb-3">Storage Settings</h4>
<div class="space-y-4">
<div>
<label for="storage-limit" class="block text-sm font-medium text-gray-700">Storage limit per user (MB)</label>
<input type="number" id="storage-limit" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm" value="500">
</div>
</div>
</div>
<div class="pt-4 border-t border-gray-200">
<button id="save-settings" class="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600">
Save Settings
</button>
</div>
</div>
</div>
</div>
<!-- Activity Log Panel -->
<div id="activity-panel" class="admin-panel hidden">
<div class="p-6">
<h3 class="text-lg font-medium text-gray-900 mb-6">Activity Log</h3>
<div class="overflow-y-auto max-h-96">
<div class="space-y-4">
<div id="activity-log" class="space-y-4">
<!-- Activity items will be loaded here -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- New/Edit Proposal Modal -->
<div id="proposal-modal" class="fixed inset-0 z-50 hidden">
<div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity" aria-hidden="true">
<div class="absolute inset-0 bg-gray-500 opacity-75"></div>
</div>
<div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-2xl sm:w-full">
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
<h3 class="text-lg font-medium leading-6 text-gray-900" id="modal-title">New Proposal</h3>
<div class="mt-4">
<div class="space-y-4">
<div>
<label for="modal-title-input" class="block text-sm font-medium text-gray-700">Title</label>
<input type="text" id="modal-title-input" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
</div>
<div>
<label for="modal-category" class="block text-sm font-medium text-gray-700">Category</label>
<select id="modal-category" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
<option value="business">Business</option>
<option value="technology">Technology</option>
<option value="marketing">Marketing</option>
<option value="design">Design</option>
</select>
</div>
<div>
<label for="modal-tags" class="block text-sm font-medium text-gray-700">Tags (comma separated)</label>
<input type="text" id="modal-tags" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm" placeholder="web, design, development">
</div>
<div>
<label for="modal-file" class="block text-sm font-medium text-gray-700">HTML File</label>
<div class="mt-1 flex items-center">
<input type="file" id="modal-file" accept=".html" class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100">
</div>
</div>
</div>
</div>
</div>
<div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
<button type="button" id="modal-save" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-500 text-base font-medium text-white hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm">
Save
</button>
<button type="button" id="modal-cancel" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm">
Cancel
</button>
</div>
</div>
</div>
</div>
<!-- Add/Edit User Modal -->
<div id="user-modal" class="fixed inset-0 z-50 hidden">
<div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity" aria-hidden="true">
<div class="absolute inset-0 bg-gray-500 opacity-75"></div>
</div>
<div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-md sm:w-full">
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
<h3 class="text-lg font-medium leading-6 text-gray-900" id="user-modal-title">Add New User</h3>
<div class="mt-4">
<div class="space-y-4">
<div>
<label for="user-name-input" class="block text-sm font-medium text-gray-700">Full Name</label>
<input type="text" id="user-name-input" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
</div>
<div>
<label for="user-email-input" class="block text-sm font-medium text-gray-700">Email</label>
<input type="email" id="user-email-input" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
</div>
<div>
<label for="user-role" class="block text-sm font-medium text-gray-700">Role</label>
<select id="user-role" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
<option value="user">Regular User</option>
<option value="editor">Editor</option>
<option value="admin">Administrator</option>
</select>
</div>
<div id="password-fields">
<label for="user-password-input" class="block text-sm font-medium text-gray-700">Password</label>
<input type="password" id="user-password-input" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
<label for="user-password-confirm" class="block text-sm font-medium text-gray-700 mt-3">Confirm Password</label>
<input type="password" id="user-password-confirm" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm">
</div>
<div class="flex items-center">
<input id="user-active" type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<label for="user-active" class="ml-2 block text-sm text-gray-700">Active Account</label>
</div>
</div>
</div>
</div>
<div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
<button type="button" id="user-modal-save" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-500 text-base font-medium text-white hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm">
Save User
</button>
<button type="button" id="user-modal-cancel" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm">
Cancel
</button>
</div>
</div>
</div>
</div>
<!-- Confirmation Modal -->
<div id="confirm-modal" class="fixed inset-0 z-50 hidden">
<div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity" aria-hidden="true">
<div class="absolute inset-0 bg-gray-500 opacity-75"></div>
</div>
<div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
<div class="sm:flex sm:items-start">
<div class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
<i class="fas fa-exclamation-triangle text-red-600"></i>
</div>
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
<h3 class="text-lg leading-6 font-medium text-gray-900" id="confirm-modal-title">Confirm Action</h3>
<div class="mt-2">
<p class="text-sm text-gray-500" id="confirm-modal-message">Are you sure you want to perform this action?</p>
</div>
</div>
</div>
</div>
<div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
<button type="button" id="confirm-modal-yes" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:ml-3 sm:w-auto sm:text-sm">
Confirm
</button>
<button type="button" id="confirm-modal-no" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm">
Cancel
</button>
</div>
</div>
</div>
</div>
</main>
</div>
<script>
// Sample data - in a real app this would come from an API or database
let proposals = [
{
id: '1',
title: 'Website Redesign Proposal',
category: 'design',
tags: ['web', 'design', 'ux'],
date: '2023-06-15',
file: 'proposal1.html',
author: 'casey@nofriction.io'
},
{
id: '2',
title: 'Marketing Strategy 2023',
category: 'marketing',
tags: ['marketing', 'strategy', 'social'],
date: '2023-05-22',
file: 'proposal2.html',
author: 'casey@nofriction.io'
},
{
id: '3',
title: 'Cloud Migration Plan',
category: 'technology',
tags: ['cloud', 'aws', 'migration'],
date: '2023-04-10',
file: 'proposal3.html',
author: 'casey@nofriction.io'
},
{
id: '4',
title: 'E-commerce Expansion',
category: 'business',
tags: ['ecommerce', 'growth', 'sales'],
date: '2023-03-30',
file: 'proposal4.html',
author: 'casey@nofriction.io'
},
{
id: '5',
title: 'Mobile App Development',
category: 'technology',
tags: ['mobile', 'app', 'development'],
date: '2023-02-18',
file: 'proposal5.html',
author: 'casey@nofriction.io'
},
{
id: '6',
title: 'Brand Identity Refresh',
category: 'design',
tags: ['branding', 'logo', 'identity'],
date: '2023-01-05',
file: 'proposal6.html',
author: 'casey@nofriction.io'
}
];
// Users data
let users = [
{
id: '1',
name: 'Casey',
email: 'casey@nofriction.io',
role: 'superadmin',
status: 'active',
avatar: 'https://ui-avatars.com/api/?name=Casey&background=EF4444&color=fff',
lastLogin: '2023-06-20T14:30:00Z'
},
{
id: '2',
name: 'Alex Johnson',
email: 'alex@example.com',
role: 'admin',
status: 'active',
avatar: 'https://ui-avatars.com/api/?name=Alex+Johnson&background=3B82F6&color=fff',
lastLogin: '2023-06-18T09:15:00Z'
},
{
id: '3',
name: 'Sam Wilson',
email: 'sam@example.com',
role: 'editor',
status: 'active',
avatar: 'https://ui-avatars.com/api/?name=Sam+Wilson&background=10B981&color=fff',
lastLogin: '2023-06-15T16:45:00Z'
},
{
id: '4',
name: 'Taylor Smith',
email: 'taylor@example.com',
role: 'user',
status: 'pending',
avatar: 'https://ui-avatars.com/api/?name=Taylor+Smith&background=6366F1&color=fff',
lastLogin: null
},
{
id: '5',
name: 'Jamie Brown',
email: 'jamie@example.com',
role: 'user',
status: 'suspended',
avatar: 'https://ui-avatars.com/api/?name=Jamie+Brown&background=F59E0B&color=fff',
lastLogin: '2023-05-30T11:20:00Z'
}
];
// Activity log
let activityLog = [
{
id: '1',
type: 'login',
user: 'Casey',
timestamp: '2023-06-20T14:30:00Z',
details: 'User logged in from IP 192.168.1.1'
},
{
id: '2',
type: 'proposal',
user: 'Casey',
timestamp: '2023-06-20T13:45:00Z',
details: 'Created new proposal "Website Redesign"'
},
{
id: '3',
type: 'user',
user: 'Casey',
timestamp: '2023-06-20T12:15:00Z',
details: 'Updated user permissions for Alex Johnson'
},
{
id: '4',
type: 'system',
user: 'System',
timestamp: '2023-06-20T10:00:00Z',
details: 'Scheduled backup completed successfully'
},
{
id: '5',
type: 'login',
user: 'Alex Johnson',
timestamp: '2023-06-18T09:15:00Z',
details: 'User logged in from IP 192.168.1.5'
}
];
// System settings
let systemSettings = {
allowRegistration: true,
emailNotifications: true,
storageLimit: 500
};
// DOM elements
const sidebar = document.getElementById('sidebar');
const overlay = document.getElementById('overlay');
const mobileMenuButton = document.getElementById('mobile-menu-button');
const catalogView = document.getElementById('catalog-view');
const proposalView = document.getElementById('proposal-view');
const adminView = document.getElementById('admin-view');
const proposalsContainer = document.getElementById('proposals-container');
const backToCatalog = document.getElementById('back-to-catalog');
const backFromAdmin = document.getElementById('back-from-admin');
const currentView = document.getElementById('current-view');
const proposalModal = document.getElementById('proposal-modal');
const userModal = document.getElementById('user-modal');
const confirmModal = document.getElementById('confirm-modal');
const newProposalBtn = document.getElementById('new-proposal-btn');
const adminPanelBtn = document.getElementById('admin-panel-btn');
const modalSave = document.getElementById('modal-save');
const modalCancel = document.getElementById('modal-cancel');
const userModalSave = document.getElementById('user-modal-save');
const userModalCancel = document.getElementById('user-modal-cancel');
const confirmModalYes = document.getElementById('confirm-modal-yes');
const confirmModalNo = document.getElementById('confirm-modal-no');
const modalTitleInput = document.getElementById('modal-title-input');
const modalCategory = document.getElementById('modal-category');
const modalTags = document.getElementById('modal-tags');
const modalFile = document.getElementById('modal-file');
const userNameInput = document.getElementById('user-name-input');
const userEmailInput = document.getElementById('user-email-input');
const userRole = document.getElementById('user-role');
const userPasswordInput = document.getElementById('user-password-input');
const userPasswordConfirm = document.getElementById('user-password-confirm');
const userActive = document.getElementById('user-active');
const searchInput = document.getElementById('search');
const sortBy = document.getElementById('sort-by');
const gridViewBtn = document.getElementById('grid-view-btn');
const listViewBtn = document.getElementById('list-view-btn');
const proposalTitle = document.getElementById('proposal-title');
const proposalCategory = document.getElementById('proposal-category');
const proposalDate = document.getElementById('proposal-date');
const proposalAuthor = document.getElementById('proposal-author');
const proposalTags = document.getElementById('proposal-tags');
const proposalContent = document.getElementById('proposal-content');
const editProposal = document.getElementById('edit-proposal');
const deleteProposal = document.getElementById('delete-proposal');
const categoryFilters = document.getElementById('category-filters');
const tagFilters = document.getElementById('tag-filters');
const usersTab = document.getElementById('users-tab');
const systemTab = document.getElementById('system-tab');
const activityTab = document.getElementById('activity-tab');
const usersPanel = document.getElementById('users-panel');
const systemPanel = document.getElementById('system-panel');
const activityPanel = document.getElementById('activity-panel');
const usersTableBody = document.getElementById('users-table-body');
const addUserBtn = document.getElementById('add-user-btn');
const activityLogContainer = document.getElementById('activity-log');
const allowRegistration = document.getElementById('allow-registration');
const emailNotifications = document.getElementById('email-notifications');
const storageLimit = document.getElementById('storage-limit');
const saveSettings = document.getElementById('save-settings');
const userAvatar = document.getElementById('user-avatar');
const userName = document.getElementById('user-name');
const userEmail = document.getElementById('user-email');
const topUserAvatar = document.getElementById('top-user-avatar');
const adminBadge = document.getElementById('admin-badge');
const topAdminBadge = document.getElementById('top-admin-badge');
const userMenu = document.getElementById('user-menu');
const notificationCount = document.getElementById('notification-count');
const logoutBtn = document.getElementById('logout-btn');
const toast = document.getElementById('toast');
// State
let currentProposal = null;
let currentUser = users[0]; // Casey is the current user
let isEditing = false;
let isEditingUser = false;
let currentEditingUserId = null;
let viewMode = 'grid'; // 'grid' or 'list'
let activeCategoryFilter = null;
let activeTagFilters = [];
let confirmCallback = null;
// Initialize the app
function init() {
// Set current user
updateUserUI();
// Only show admin features if user is admin
if (currentUser.role === 'superadmin' || currentUser.role === 'admin') {
adminPanelBtn.classList.remove('hidden');
adminBadge.classList.remove('hidden');
topAdminBadge.classList.remove('hidden');
}
renderProposals();
setupEventListeners();
renderCategoryFilters();
renderTagFilters();
renderUsersTable();
renderActivityLog();
loadSystemSettings();
}
// Set up event listeners
function setupEventListeners() {
// Mobile menu toggle
mobileMenuButton.addEventListener('click', toggleMobileMenu);
overlay.addEventListener('click', toggleMobileMenu);
// New proposal button
newProposalBtn.addEventListener('click', () => {
isEditing = false;
document.getElementById('modal-title').textContent = 'New Proposal';
modalTitleInput.value = '';
modalCategory.value = 'business';
modalTags.value = '';
modalFile.value = '';
proposalModal.classList.remove('hidden');
});
// Modal buttons
modalSave.addEventListener('click', saveProposal);
modalCancel.addEventListener('click', () => proposalModal.classList.add('hidden'));
// User modal buttons
userModalSave.addEventListener('click', saveUser);
userModalCancel.addEventListener('click', () => userModal.classList.add('hidden'));
// Confirmation modal buttons
confirmModalYes.addEventListener('click', confirmAction);
confirmModalNo.addEventListener('click', () => confirmModal.classList.add('hidden'));
// Back to catalog
backToCatalog.addEventListener('click', showCatalogView);
backFromAdmin.addEventListener('click', showCatalogView);
// Admin panel
adminPanelBtn.addEventListener('click', showAdminView);
// Admin tabs
usersTab.addEventListener('click', () => showAdminTab('users'));
systemTab.addEventListener('click', () => showAdminTab('system'));
activityTab.addEventListener('click', () => showAdminTab('activity'));
// Add user button
addUserBtn.addEventListener('click', () => {
isEditingUser = false;
currentEditingUserId = null;
document.getElementById('user-modal-title').textContent = 'Add New User';
userNameInput.value = '';
userEmailInput.value = '';
userRole.value = 'user';
userPasswordInput.value = '';
userPasswordConfirm.value = '';
userActive.checked = true;
document.getElementById('password-fields').classList.remove('hidden');
userModal.classList.remove('hidden');
});
// Save system settings
saveSettings.addEventListener('click', saveSystemSettings);
// Search
searchInput.addEventListener('input', debounce(renderProposals, 300));
// Sort
sortBy.addEventListener('change', renderProposals);
// View mode
gridViewBtn.addEventListener('click', () => {
viewMode = 'grid';
gridViewBtn.classList.remove('bg-gray-200', 'text-gray-700');
gridViewBtn.classList.add('bg-blue-500', 'text-white');
listViewBtn.classList.remove('bg-blue-500', 'text-white');
listViewBtn.classList.add('bg-gray-200', 'text-gray-700');
renderProposals();
});
listViewBtn.addEventListener('click', () => {
viewMode = 'list';
listViewBtn.classList.remove('bg-gray-200', 'text-gray-700');
listViewBtn.classList.add('bg-blue-500', 'text-white');
gridViewBtn.classList.remove('bg-blue-500', 'text-white');
gridViewBtn.classList.add('bg-gray-200', 'text-gray-700');
renderProposals();
});
// Edit/delete proposal
editProposal.addEventListener('click', editCurrentProposal);
deleteProposal.addEventListener('click', deleteCurrentProposal);
// Logout
logoutBtn.addEventListener('click', () => {
showToast('Logged out successfully', 'success');
// In a real app, this would redirect to login page
setTimeout(() => {
window.location.href = 'login.html';
}, 1000);
});
}
// Update user UI elements
function updateUserUI() {
userAvatar.src = currentUser.avatar;
userName.textContent = currentUser.name;
userEmail.textContent = currentUser.email;
topUserAvatar.src = currentUser.avatar;
// Show admin badge if user is admin
if (currentUser.role === 'superadmin' || currentUser.role === 'admin') {
adminBadge.classList.remove('hidden');
topAdminBadge.classList.remove('hidden');
} else {
adminBadge.classList.add('hidden');
topAdminBadge.classList.add('hidden');
}
}
// Toggle mobile menu
function toggleMobileMenu() {
sidebar.classList.toggle('-translate-x-full');
overlay.classList.toggle('hidden');
}
// Render proposals based on current filters and sort
function renderProposals() {
const searchTerm = searchInput.value.toLowerCase();
const sortValue = sortBy.value;
// Filter proposals
let filteredProposals = proposals.filter(proposal => {
// Search filter
const matchesSearch = proposal.title.toLowerCase().includes(searchTerm) ||
proposal.tags.some(tag => tag.includes(searchTerm));
// Category filter
const matchesCategory = !activeCategoryFilter || proposal.category === activeCategoryFilter;
// Tag filter
const matchesTags = activeTagFilters.length === 0 ||
activeTagFilters.every(tag => proposal.tags.includes(tag));
return matchesSearch && matchesCategory && matchesTags;
});
// Sort proposals
filteredProposals.sort((a, b) => {
switch(sortValue) {
case 'date-desc':
return new Date(b.date) - new Date(a.date);
case 'date-asc':
return new Date(a.date) - new Date(b.date);
case 'name-asc':
return a.title.localeCompare(b.title);
case 'name-desc':
return b.title.localeCompare(a.title);
default:
return 0;
}
});
// Clear container
proposalsContainer.innerHTML = '';
// Show message if no proposals
if (filteredProposals.length === 0) {
proposalsContainer.innerHTML = `
<div class="col-span-full text-center py-10">
<i class="fas fa-folder-open text-gray-300 text-4xl mb-3"></i>
<p class="text-gray-500">No proposals found matching your criteria</p>
</div>
`;
return;
}
// Render proposals
filteredProposals.forEach(proposal => {
const proposalElement = document.createElement('div');
if (viewMode === 'grid') {
proposalElement.className = 'proposal-card bg-white rounded-lg overflow-hidden';
proposalElement.innerHTML = `
<div class="h-48 bg-gray-100 flex items-center justify-center">
<i class="fas fa-file-alt text-gray-300 text-5xl"></i>
</div>
<div class="p-4">
<h3 class="font-medium text-gray-900 truncate">${proposal.title}</h3>
<div class="mt-2 flex items-center justify-between">
<span class="px-2 py-1 text-xs font-medium ${getCategoryColor(proposal.category)} rounded-full">${formatCategory(proposal.category)}</span>
<span class="text-xs text-gray-500">${formatDate(proposal.date)}</span>
</div>
<div class="mt-3 flex flex-wrap gap-1">
${proposal.tags.map(tag => `<span class="tag px-2 py-1 text-xs font-medium bg-gray-100 text-gray-700 rounded-full">${tag}</span>`).join('')}
</div>
<button class="mt-4 w-full py-2 px-3 bg-blue-50 text-blue-600 rounded-md text-sm font-medium hover:bg-blue-100 transition duration-200 view-proposal" data-id="${proposal.id}">
View Proposal
</button>
</div>
`;
} else {
proposalElement.className = 'proposal-card col-span-full bg-white rounded-lg overflow-hidden';
proposalElement.innerHTML = `
<div class="flex">
<div class="w-32 flex-shrink-0 bg-gray-100 flex items-center justify-center">
<i class="fas fa-file-alt text-gray-300 text-4xl"></i>
</div>
<div class="flex-1 p-4">
<div class="flex items-start justify-between">
<div>
<h3 class="font-medium text-gray-900">${proposal.title}</h3>
<div class="mt-1 flex items-center space-x-2">
<span class="px-2 py-1 text-xs font-medium ${getCategoryColor(proposal.category)} rounded-full">${formatCategory(proposal.category)}</span>
<span class="text-xs text-gray-500">${formatDate(proposal.date)}</span>
<span class="text-xs text-gray-500">By: ${getUserName(proposal.author)}</span>
</div>
</div>
<button class="py-2 px-3 bg-blue-50 text-blue-600 rounded-md text-sm font-medium hover:bg-blue-100 transition duration-200 view-proposal" data-id="${proposal.id}">
View
</button>
</div>
<div class="mt-3 flex flex-wrap gap-1">
${proposal.tags.map(tag => `<span class="tag px-2 py-1 text-xs font-medium bg-gray-100 text-gray-700 rounded-full">${tag}</span>`).join('')}
</div>
</div>
</div>
`;
}
proposalsContainer.appendChild(proposalElement);
});
// Add event listeners to view buttons
document.querySelectorAll('.view-proposal').forEach(button => {
button.addEventListener('click', (e) => {
const proposalId = e.target.getAttribute('data-id');
showProposalView(proposalId);
});
});
}
// Render category filters
function renderCategoryFilters() {
const categories = [...new Set(proposals.map(p => p.category))];
categoryFilters.innerHTML = `
<button class="w-full text-left px-3 py-2 rounded-md text-sm font-medium ${!activeCategoryFilter ? 'bg-blue-50 text-blue-700' : 'text-gray-600 hover:bg-gray-100'}" data-category="all">
All Categories
</button>
${categories.map(category => `
<button class="w-full text-left px-3 py-2 rounded-md text-sm font-medium ${activeCategoryFilter === category ? 'bg-blue-50 text-blue-700' : 'text-gray-600 hover:bg-gray-100'}" data-category="${category}">
${formatCategory(category)}
</button>
`).join('')}
`;
// Add event listeners
document.querySelectorAll('#category-filters button').forEach(button => {
button.addEventListener('click', (e) => {
const category = e.target.getAttribute('data-category');
activeCategoryFilter = category === 'all' ? null : category;
renderCategoryFilters();
renderTagFilters();
renderProposals();
});
});
}
// Render tag filters
function renderTagFilters() {
// Get all unique tags from proposals
let tags = [];
proposals.forEach(proposal => {
if (!activeCategoryFilter || proposal.category === activeCategoryFilter) {
tags.push(...proposal.tags);
}
});
tags = [...new Set(tags)];
tagFilters.innerHTML = tags.map(tag => `
<button class="tag px-3 py-1 text-xs font-medium rounded-full ${activeTagFilters.includes(tag) ? 'bg-blue-500 text-white' : 'bg-gray-100 text-gray-700 hover:bg-gray-200'}" data-tag="${tag}">
${tag}
</button>
`).join('');
// Add event listeners
document.querySelectorAll('#tag-filters button').forEach(button => {
button.addEventListener('click', (e) => {
const tag = e.target.getAttribute('data-tag');
if (activeTagFilters.includes(tag)) {
activeTagFilters = activeTagFilters.filter(t => t !== tag);
} else {
activeTagFilters.push(tag);
}
renderTagFilters();
renderProposals();
});
});
}
// Render users table
function renderUsersTable() {
usersTableBody.innerHTML = users.map(user => `
<tr>
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<div class="flex-shrink-0 h-10 w-10 relative">
<img class="h-10 w-10 rounded-full" src="${user.avatar}" alt="">
${user.role === 'superadmin' || user.role === 'admin' ? '<div class="admin-badge"></div>' : ''}
</div>
<div class="ml-4">
<div class="text-sm font-medium text-gray-900">${user.name}</div>
</div>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">${user.email}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 py-1 text-xs font-medium ${getRoleColor(user.role)} rounded-full">${formatRole(user.role)}</span>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 py-1 text-xs font-medium ${getStatusColor(user.status)} rounded-full">${formatStatus(user.status)}</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
${user.email !== 'casey@nofriction.io' ? `
<button class="text-blue-600 hover:text-blue-900 edit-user mr-3" data-id="${user.id}">Edit</button>
<button class="text-red-600 hover:text-red-900 delete-user" data-id="${user.id}">Delete</button>
` : `
<span class="text-gray-400">Master Admin</span>
`}
</td>
</tr>
`).join('');
// Add event listeners to edit/delete buttons
document.querySelectorAll('.edit-user').forEach(button => {
button.addEventListener('click', (e) => {
const userId = e.target.getAttribute('data-id');
editUser(userId);
});
});
document.querySelectorAll('.delete-user').forEach(button => {
button.addEventListener('click', (e) => {
const userId = e.target.getAttribute('data-id');
showConfirmModal(
'Delete User',
`Are you sure you want to delete this user? This action cannot be undone.`,
() => deleteUser(userId)
);
});
});
}
// Render activity log
function renderActivityLog() {
activityLogContainer.innerHTML = activityLog.map(activity => `
<div class="flex items-start">
<div class="flex-shrink-0 mt-1">
<div class="h-8 w-8 rounded-full ${getActivityIconColor(activity.type)} flex items-center justify-center">
<i class="fas ${getActivityIcon(activity.type)} text-white text-sm"></i>
</div>
</div>
<div class="ml-3">
<p class="text-sm text-gray-700">
<span class="font-medium">${activity.user}</span> ${activity.details}
</p>
<p class="text-xs text-gray-500 mt-1">${formatDateTime(activity.timestamp)}</p>
</div>
</div>
`).join('');
}
// Load system settings
function loadSystemSettings() {
allowRegistration.checked = systemSettings.allowRegistration;
emailNotifications.checked = systemSettings.emailNotifications;
storageLimit.value = systemSettings.storageLimit;
}
// Save system settings
function saveSystemSettings() {
systemSettings.allowRegistration = allowRegistration.checked;
systemSettings.emailNotifications = emailNotifications.checked;
systemSettings.storageLimit = parseInt(storageLimit.value);
// Show success message
showToast('Settings saved successfully', 'success');
// Log activity
addActivityLog('system', 'Updated system settings');
}
// Show proposal view
function showProposalView(proposalId) {
currentProposal = proposals.find(p => p.id === proposalId);
if (!currentProposal) return;
// Update UI
catalogView.classList.add('hidden');
proposalView.classList.remove('hidden');
adminView.classList.add('hidden');
currentView.textContent = currentProposal.title;
// Set proposal details
proposalTitle.textContent = currentProposal.title;
proposalCategory.textContent = formatCategory(currentProposal.category);
proposalCategory.className = `px-2 py-1 text-xs font-medium ${getCategoryColor(currentProposal.category)} rounded-full`;
proposalDate.innerHTML = `Created on: <span class="font-medium">${formatDate(currentProposal.date)}</span>`;
proposalAuthor.innerHTML = `By: <span class="font-medium">${getUserName(currentProposal.author)}</span>`;
// Set tags
proposalTags.innerHTML = currentProposal.tags.map(tag => `
<span class="tag px-2 py-1 text-xs font-medium bg-gray-100 text-gray-700 rounded-full">${tag}</span>
`).join('');
// Only show edit/delete if user is author or admin
if (currentProposal.author === currentUser.email || currentUser.role === 'superadmin' || currentUser.role === 'admin') {
editProposal.classList.remove('hidden');
deleteProposal.classList.remove('hidden');
} else {
editProposal.classList.add('hidden');
deleteProposal.classList.add('hidden');
}
// Load content (in a real app this would be from a server)
proposalContent.src = currentProposal.file;
}
// Show catalog view
function showCatalogView() {
catalogView.classList.remove('hidden');
proposalView.classList.add('hidden');
adminView.classList.add('hidden');
currentView.textContent = 'Proposal Catalog';
currentProposal = null;
}
// Show admin view
function showAdminView() {
catalogView.classList.add('hidden');
proposalView.classList.add('hidden');
adminView.classList.remove('hidden');
currentView.textContent = 'Admin Panel';
// Show users tab by default
showAdminTab('users');
}
// Show admin tab
function showAdminTab(tab) {
// Update tabs
usersTab.classList.remove('active', 'text-blue-600', 'border-blue-500');
systemTab.classList.remove('active', 'text-blue-600', 'border-blue-500');
activityTab.classList.remove('active', 'text-blue-600', 'border-blue-500');
usersTab.classList.add('text-gray-500', 'border-transparent');
systemTab.classList.add('text-gray-500', 'border-transparent');
activityTab.classList.add('text-gray-500', 'border-transparent');
// Hide all panels
usersPanel.classList.add('hidden');
systemPanel.classList.add('hidden');
activityPanel.classList.add('hidden');
// Show selected tab
if (tab === 'users') {
usersTab.classList.remove('text-gray-500', 'border-transparent');
usersTab.classList.add('active', 'text-blue-600', 'border-blue-500');
usersPanel.classList.remove('hidden');
} else if (tab === 'system') {
systemTab.classList.remove('text-gray-500', 'border-transparent');
systemTab.classList.add('active', 'text-blue-600', 'border-blue-500');
systemPanel.classList.remove('hidden');
} else if (tab === 'activity') {
activityTab.classList.remove('text-gray-500', 'border-transparent');
activityTab.classList.add('active', 'text-blue-600', 'border-blue-500');
activityPanel.classList.remove('hidden');
}
}
// Edit current proposal
function editCurrentProposal() {
if (!currentProposal) return;
isEditing = true;
document.getElementById('modal-title').textContent = 'Edit Proposal';
modalTitleInput.value = currentProposal.title;
modalCategory.value = currentProposal.category;
modalTags.value = currentProposal.tags.join(', ');
modalFile.value = '';
proposalModal.classList.remove('hidden');
}
// Edit user
function editUser(userId) {
const user = users.find(u => u.id === userId);
if (!user) return;
isEditingUser = true;
currentEditingUserId = userId;
document.getElementById('user-modal-title').textContent = 'Edit User';
userNameInput.value = user.name;
userEmailInput.value = user.email;
userRole.value = user.role;
userActive.checked = user.status === 'active';
// Hide password fields for existing users
document.getElementById('password-fields').classList.add('hidden');
userModal.classList.remove('hidden');
}
// Delete current proposal
function deleteCurrentProposal() {
if (!currentProposal) return;
showConfirmModal(
'Delete Proposal',
`Are you sure you want to delete "${currentProposal.title}"? This action cannot be undone.`,
() => {
// In a real app, this would call an API to delete
const index = proposals.findIndex(p => p.id === currentProposal.id);
if (index !== -1) {
proposals.splice(index, 1);
showCatalogView();
renderProposals();
renderCategoryFilters();
renderTagFilters();
// Log activity
addActivityLog('proposal', `Deleted proposal "${currentProposal.title}"`);
showToast('Proposal deleted successfully', 'success');
}
}
);
}
// Delete user
function deleteUser(userId) {
// Can't delete master admin
const user = users.find(u => u.id === userId);
if (user && user.email === 'casey@nofriction.io') {
showToast('Cannot delete master admin', 'error');
return;
}
// In a real app, this would call an API to delete
const index = users.findIndex(u => u.id === userId);
if (index !== -1) {
const deletedUser = users[index];
users.splice(index, 1);
renderUsersTable();
// Log activity
addActivityLog('user', `Deleted user "${deletedUser.name}" (${deletedUser.email})`);
showToast('User deleted successfully', 'success');
}
confirmModal.classList.add('hidden');
}
// Save proposal (new or edit)
function saveProposal() {
const title = modalTitleInput.value.trim();
const category = modalCategory.value;
const tags = modalTags.value.split(',').map(tag => tag.trim()).filter(tag => tag);
const file = modalFile.files[0];
if (!title) {
showToast('Please enter a title', 'error');
return;
}
if (isEditing && currentProposal) {
// Update existing proposal
currentProposal.title = title;
currentProposal.category = category;
currentProposal.tags = tags;
if (file) {
// In a real app, upload the file
currentProposal.file = file.name;
}
// Update UI
showProposalView(currentProposal.id);
// Log activity
addActivityLog('proposal', `Updated proposal "${title}"`);
showToast('Proposal updated successfully', 'success');
} else {
// Create new proposal
const newProposal = {
id: Date.now().toString(),
title,
category,
tags,
date: new Date().toISOString().split('T')[0],
file: file ? file.name : 'new-proposal.html',
author: currentUser.email
};
// In a real app, upload the file and save to database
proposals.unshift(newProposal);
// Update UI
showProposalView(newProposal.id);
// Log activity
addActivityLog('proposal', `Created new proposal "${title}"`);
showToast('Proposal created successfully', 'success');
}
// Reset and close modal
proposalModal.classList.add('hidden');
renderProposals();
renderCategoryFilters();
renderTagFilters();
}
// Save user (new or edit)
function saveUser() {
const name = userNameInput.value.trim();
const email = userEmailInput.value.trim();
const role = userRole.value;
const password = userPasswordInput.value;
const passwordConfirm = userPasswordConfirm.value;
const active = userActive.checked;
if (!name || !email) {
showToast('Please fill in all required fields', 'error');
return;
}
if (!isEditingUser && (!password || !passwordConfirm)) {
showToast('Please enter a password', 'error');
return;
}
if (!isEditingUser && password !== passwordConfirm) {
showToast('Passwords do not match', 'error');
return;
}
// Check if email is already taken (for new users)
if (!isEditingUser && users.some(u => u.email === email)) {
showToast('Email already in use', 'error');
return;
}
if (isEditingUser && currentEditingUserId) {
// Update existing user
const userIndex = users.findIndex(u => u.id === currentEditingUserId);
if (userIndex !== -1) {
users[userIndex].name = name;
users[userIndex].email = email;
users[userIndex].role = role;
users[userIndex].status = active ? 'active' : 'suspended';
// Update avatar
users[userIndex].avatar = `https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=${getAvatarColor(role)}&color=fff`;
// If editing current user, update UI
if (users[userIndex].id === currentUser.id) {
currentUser = users[userIndex];
updateUserUI();
}
renderUsersTable();
// Log activity
addActivityLog('user', `Updated user "${name}" (${email})`);
showToast('User updated successfully', 'success');
}
} else {
// Create new user
const newUser = {
id: Date.now().toString(),
name,
email,
role,
status: active ? 'active' : 'pending',
avatar: `https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=${getAvatarColor(role)}&color=fff`,
lastLogin: null
};
// In a real app, this would call an API to create user
users.push(newUser);
renderUsersTable();
// Log activity
addActivityLog('user', `Created new user "${name}" (${email})`);
showToast('User created successfully', 'success');
}
// Reset and close modal
userModal.classList.add('hidden');
document.getElementById('password-fields').classList.remove('hidden');
}
// Show confirmation modal
function showConfirmModal(title, message, callback) {
document.getElementById('confirm-modal-title').textContent = title;
document.getElementById('confirm-modal-message').textContent = message;
confirmCallback = callback;
confirmModal.classList.remove('hidden');
}
// Confirm action
function confirmAction() {
if (confirmCallback) {
confirmCallback();
}
confirmModal.classList.add('hidden');
}
// Add activity log entry
function addActivityLog(type, details) {
const newActivity = {
id: Date.now().toString(),
type,
user: currentUser.name,
timestamp: new Date().toISOString(),
details
};
activityLog.unshift(newActivity);
renderActivityLog();
}
// Show toast notification
function showToast(message, type) {
const toast = document.getElementById('toast');
toast.textContent = message;
toast.className = `toast ${type} show`;
setTimeout(() => {
toast.className = 'toast hidden';
}, 3000);
}
// Helper functions
function formatCategory(category) {
return category.charAt(0).toUpperCase() + category.slice(1);
}
function formatRole(role) {
const roles = {
superadmin: 'Super Admin',
admin: 'Administrator',
editor: 'Editor',
user: 'Regular User'
};
return roles[role] || role;
}
function formatStatus(status) {
const statuses = {
active: 'Active',
pending: 'Pending',
suspended: 'Suspended'
};
return statuses[status] || status;
}
function formatDate(dateString) {
const options = { year: 'numeric', month: 'short', day: 'numeric' };
return new Date(dateString).toLocaleDateString(undefined, options);
}
function formatDateTime(dateTimeString) {
const options = {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: '2-digit',
minute: '2-digit'
};
return new Date(dateTimeString).toLocaleDateString(undefined, options);
}
function getCategoryColor(category) {
const colors = {
business: 'bg-purple-100 text-purple-800',
technology: 'bg-blue-100 text-blue-800',
marketing: 'bg-green-100 text-green-800',
design: 'bg-yellow-100 text-yellow-800'
};
return colors[category] || 'bg-gray-100 text-gray-800';
}
function getRoleColor(role) {
const colors = {
superadmin: 'bg-red-100 text-red-800',
admin: 'bg-purple-100 text-purple-800',
editor: 'bg-blue-100 text-blue-800',
user: 'bg-gray-100 text-gray-800'
};
return colors[role] || 'bg-gray-100 text-gray-800';
}
function getStatusColor(status) {
const colors = {
active: 'bg-green-100 text-green-800',
pending: 'bg-yellow-100 text-yellow-800',
suspended: 'bg-red-100 text-red-800'
};
return colors[status] || 'bg-gray-100 text-gray-800';
}
function getAvatarColor(role) {
const colors = {
superadmin: 'EF4444',
admin:
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Proposal Presentation System</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Inter', sans-serif;
transition: background-color 0.3s ease;
}
.sidebar {
transition: transform 0.3s ease;
}
.proposal-card {
transition: all 0.3s ease;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.proposal-card:hover {
transform: translateY(-4px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.content-frame {
min-height: calc(100vh - 80px);
}
.tag {
transition: all 0.2s ease;
}
.tag:hover {
transform: scale(1.05);
}
/* Loading animation */
.loader {
border-top-color: #3B82F6;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Admin badge */
.admin-badge {
position: absolute;
top: -4px;
right: -4px;
width: 16px;
height: 16px;
background-color: #EF4444;
border-radius: 50%;
border: 2px solid white;
}
/* Slide transitions */
.slide-enter-active, .slide-leave-active {
transition: all 0.3s ease;
}
.slide-enter-from, .slide-leave-to {
transform: translateX(20px);
opacity: 0;
}
/* Toast notification */
.toast {
position: fixed;
top: 20px;
right: 20px;
z-index: 1000;
padding: 12px 20px;
border-radius: 4px;
color: white;
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
transform: translateY(-100px);
opacity: 0;
transition: all 0.3s ease;
}
.toast.show {
transform: translateY(0);
opacity: 1;
}
.toast.success {
background-color: #10B981;
}
.toast.error {
background-color: #EF4444;