feat(hosting,prospecting): add hosting unit tests and fix template bugs
All checks were successful
All checks were successful
- Add 55 unit tests for hosting module (hosted site service, client service service, stats service) with full fixture setup - Fix table_empty_state macro: add x_message param for dynamic Alpine.js expressions rendered via x-text instead of server-side Jinja - Fix hosting templates (sites, clients) using message= with Alpine expressions that rendered as literal text - Fix prospecting templates (leads, scan-jobs, prospects) using nonexistent subtitle= param, migrated to x_message= - Align hosting and prospecting admin templates with shared design system Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% from 'shared/macros/headers.html' import page_header %}
|
||||
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
|
||||
{% from 'shared/macros/pagination.html' import pagination_controls %}
|
||||
{% from 'shared/macros/tables.html' import table_wrapper, table_header, table_empty_state %}
|
||||
{% from 'shared/macros/pagination.html' import pagination %}
|
||||
|
||||
{% block title %}Client Services{% endblock %}
|
||||
|
||||
@@ -11,37 +12,35 @@
|
||||
{{ page_header('Client Services') }}
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="mb-6 p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<div class="grid gap-4 md:grid-cols-3">
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400">Service Type</label>
|
||||
<select x-model="filterType" @change="loadServices()"
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300">
|
||||
<option value="">All</option>
|
||||
<div x-show="!loading && !error" class="mb-6 p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<select x-model="filterType" @change="pagination.page = 1; loadServices()"
|
||||
class="px-4 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none">
|
||||
<option value="">All Types</option>
|
||||
<option value="domain">Domain</option>
|
||||
<option value="email">Email</option>
|
||||
<option value="ssl">SSL</option>
|
||||
<option value="hosting">Hosting</option>
|
||||
<option value="website_maintenance">Website Maintenance</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400">Status</label>
|
||||
<select x-model="filterStatus" @change="loadServices()"
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300">
|
||||
<option value="">All</option>
|
||||
|
||||
<select x-model="filterStatus" @change="pagination.page = 1; loadServices()"
|
||||
class="px-4 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none">
|
||||
<option value="">All Status</option>
|
||||
<option value="pending">Pending</option>
|
||||
<option value="active">Active</option>
|
||||
<option value="suspended">Suspended</option>
|
||||
<option value="expired">Expired</option>
|
||||
<option value="cancelled">Cancelled</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex items-end">
|
||||
<button @click="showExpiringOnly = !showExpiringOnly; loadServices()"
|
||||
:class="showExpiringOnly ? 'bg-red-600 text-white' : 'bg-gray-200 text-gray-700 dark:bg-gray-700 dark:text-gray-300'"
|
||||
class="px-4 py-2 text-sm font-medium rounded-lg">
|
||||
<span x-html="$icon('clock', 'w-4 h-4 inline mr-1')"></span>
|
||||
|
||||
<button type="button" @click="showExpiringOnly = !showExpiringOnly; pagination.page = 1; loadServices()"
|
||||
:class="showExpiringOnly
|
||||
? 'bg-red-600 text-white border-red-600'
|
||||
: 'bg-white text-gray-700 border-gray-300 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600'"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium rounded-lg border transition-colors duration-150">
|
||||
<span x-html="$icon('clock', 'w-4 h-4 mr-2')"></span>
|
||||
Expiring Soon
|
||||
</button>
|
||||
</div>
|
||||
@@ -52,95 +51,87 @@
|
||||
{{ error_state('Error loading services') }}
|
||||
|
||||
<!-- Services Table -->
|
||||
<div x-show="!loading && !error" class="w-full overflow-hidden rounded-lg shadow">
|
||||
<div class="w-full overflow-x-auto">
|
||||
<table class="w-full whitespace-nowrap">
|
||||
<thead>
|
||||
<tr class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800">
|
||||
<th class="px-4 py-3">Service</th>
|
||||
<th class="px-4 py-3">Type</th>
|
||||
<th class="px-4 py-3">Status</th>
|
||||
<th class="px-4 py-3">Price</th>
|
||||
<th class="px-4 py-3">Expires</th>
|
||||
<th class="px-4 py-3">Site</th>
|
||||
<div x-show="!loading && !error">
|
||||
{% call table_wrapper() %}
|
||||
{{ table_header(['Service', 'Type', 'Status', 'Price', 'Expires', 'Site']) }}
|
||||
<tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
|
||||
{{ table_empty_state(6, title='No services found', x_message="filterType || filterStatus || showExpiringOnly ? 'Try adjusting your filters' : 'No client services yet'", show_condition='services.length === 0', icon='cube') }}
|
||||
<template x-for="svc in services" :key="svc.id">
|
||||
<tr class="text-gray-700 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors"
|
||||
:class="isExpiringSoon(svc) ? 'bg-red-50 dark:bg-red-900/20' : ''">
|
||||
<td class="px-4 py-3 text-sm font-semibold" x-text="svc.name"></td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span class="px-2.5 py-0.5 text-xs font-medium rounded-full bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400"
|
||||
x-text="svc.service_type.replace('_', ' ')"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span class="px-2.5 py-0.5 text-xs font-medium rounded-full"
|
||||
:class="svc.status === 'active' ? 'bg-green-100 text-green-700 dark:bg-green-700 dark:text-green-100' : svc.status === 'expired' ? 'bg-red-100 text-red-700 dark:bg-red-700 dark:text-red-100' : 'bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400'"
|
||||
x-text="svc.status"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span x-text="svc.price_cents ? '€' + (svc.price_cents / 100).toFixed(2) : '—'"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span x-text="svc.expires_at ? new Date(svc.expires_at).toLocaleDateString() : '—'"
|
||||
:class="isExpiringSoon(svc) ? 'text-red-600 dark:text-red-400 font-semibold' : ''"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<a :href="'/admin/hosting/sites/' + svc.hosted_site_id"
|
||||
class="flex items-center justify-center p-2 text-teal-600 rounded-lg hover:bg-teal-50 dark:text-teal-400 dark:hover:bg-gray-700 focus:outline-none transition-colors"
|
||||
title="View site">
|
||||
<span x-html="$icon('eye', 'w-5 h-5')"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
|
||||
<template x-for="svc in services" :key="svc.id">
|
||||
<tr class="text-gray-700 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700"
|
||||
:class="isExpiringSoon(svc) ? 'bg-red-50 dark:bg-red-900/20' : ''">
|
||||
<td class="px-4 py-3 text-sm font-semibold" x-text="svc.name"></td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span class="px-2 py-1 text-xs rounded-full bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400"
|
||||
x-text="svc.service_type.replace('_', ' ')"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span class="px-2 py-1 text-xs font-semibold rounded-full"
|
||||
:class="svc.status === 'active' ? 'bg-green-100 text-green-700' : svc.status === 'expired' ? 'bg-red-100 text-red-700' : 'bg-gray-100 text-gray-600'"
|
||||
x-text="svc.status"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span x-text="svc.price_cents ? '€' + (svc.price_cents / 100).toFixed(2) : '—'"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span x-text="svc.expires_at ? new Date(svc.expires_at).toLocaleDateString() : '—'"
|
||||
:class="isExpiringSoon(svc) ? 'text-red-600 font-semibold' : ''"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<a :href="'/admin/hosting/sites/' + svc.hosted_site_id"
|
||||
class="text-teal-600 hover:text-teal-900 dark:text-teal-400">
|
||||
View Site
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div x-show="services.length === 0" class="p-8 text-center text-gray-400 dark:text-gray-500">
|
||||
No services found
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</tbody>
|
||||
{% endcall %}
|
||||
|
||||
{{ pagination_controls() }}
|
||||
{{ pagination() }}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
<script>
|
||||
function hostingClientsList() {
|
||||
return {
|
||||
...data(),
|
||||
currentPage: 'hosting-clients',
|
||||
loading: true,
|
||||
error: false,
|
||||
error: null,
|
||||
services: [],
|
||||
total: 0,
|
||||
page: 1,
|
||||
perPage: 20,
|
||||
pages: 0,
|
||||
filterType: '',
|
||||
filterStatus: '',
|
||||
showExpiringOnly: false,
|
||||
async init() { await this.loadServices(); },
|
||||
pagination: { page: 1, per_page: 20, total: 0, pages: 0 },
|
||||
async init() {
|
||||
if (window.PlatformSettings) {
|
||||
this.pagination.per_page = await window.PlatformSettings.getRowsPerPage();
|
||||
}
|
||||
await this.loadServices();
|
||||
},
|
||||
async loadServices() {
|
||||
this.loading = true;
|
||||
this.error = false;
|
||||
this.error = null;
|
||||
try {
|
||||
// Use the sites endpoint to get all services across all sites
|
||||
const params = new URLSearchParams({ page: this.page, per_page: this.perPage });
|
||||
const params = new URLSearchParams({
|
||||
page: this.pagination.page,
|
||||
per_page: this.pagination.per_page,
|
||||
});
|
||||
if (this.filterStatus) params.set('status', this.filterStatus);
|
||||
|
||||
// Get sites and flatten their services
|
||||
const resp = await fetch('/api/admin/hosting/sites?' + params);
|
||||
if (!resp.ok) throw new Error('Failed to load');
|
||||
const data = await resp.json();
|
||||
const response = await apiClient.get('/admin/hosting/sites?' + params);
|
||||
const sites = response.items || [];
|
||||
|
||||
// Collect all services from all sites
|
||||
let allServices = [];
|
||||
for (const site of data.items) {
|
||||
const svcResp = await fetch('/api/admin/hosting/sites/' + site.id + '/services');
|
||||
if (svcResp.ok) {
|
||||
const svcs = await svcResp.json();
|
||||
allServices = allServices.concat(svcs);
|
||||
}
|
||||
for (const site of sites) {
|
||||
try {
|
||||
const svcs = await apiClient.get('/admin/hosting/sites/' + site.id + '/services');
|
||||
const svcList = Array.isArray(svcs) ? svcs : (svcs.items || []);
|
||||
allServices = allServices.concat(svcList.map(s => ({ ...s, hosted_site_id: site.id })));
|
||||
} catch (e) { /* skip */ }
|
||||
}
|
||||
|
||||
// Apply client-side filters
|
||||
@@ -149,16 +140,47 @@ function hostingClientsList() {
|
||||
if (this.showExpiringOnly) allServices = allServices.filter(s => this.isExpiringSoon(s));
|
||||
|
||||
this.services = allServices;
|
||||
this.total = allServices.length;
|
||||
} catch (e) { this.error = true; }
|
||||
finally { this.loading = false; }
|
||||
this.pagination.total = allServices.length;
|
||||
this.pagination.pages = Math.ceil(allServices.length / this.pagination.per_page) || 1;
|
||||
} catch (e) {
|
||||
this.error = e.message;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
isExpiringSoon(svc) {
|
||||
if (!svc.expires_at || svc.status !== 'active') return false;
|
||||
const daysLeft = (new Date(svc.expires_at) - new Date()) / (1000 * 60 * 60 * 24);
|
||||
return daysLeft <= 30 && daysLeft > 0;
|
||||
},
|
||||
goToPage(p) { this.page = p; this.loadServices(); },
|
||||
get startIndex() {
|
||||
if (this.pagination.total === 0) return 0;
|
||||
return (this.pagination.page - 1) * this.pagination.per_page + 1;
|
||||
},
|
||||
get endIndex() {
|
||||
const end = this.pagination.page * this.pagination.per_page;
|
||||
return end > this.pagination.total ? this.pagination.total : end;
|
||||
},
|
||||
get totalPages() { return this.pagination.pages; },
|
||||
get pageNumbers() {
|
||||
const pages = [];
|
||||
const total = this.totalPages;
|
||||
const current = this.pagination.page;
|
||||
if (total <= 7) { for (let i = 1; i <= total; i++) pages.push(i); return pages; }
|
||||
pages.push(1);
|
||||
if (current > 3) pages.push('...');
|
||||
for (let i = Math.max(2, current - 1); i <= Math.min(total - 1, current + 1); i++) pages.push(i);
|
||||
if (current < total - 2) pages.push('...');
|
||||
pages.push(total);
|
||||
return pages;
|
||||
},
|
||||
goToPage(page) {
|
||||
if (page === '...' || page < 1 || page > this.totalPages) return;
|
||||
this.pagination.page = page;
|
||||
this.loadServices();
|
||||
},
|
||||
nextPage() { if (this.pagination.page < this.totalPages) { this.pagination.page++; this.loadServices(); } },
|
||||
previousPage() { if (this.pagination.page > 1) { this.pagination.page--; this.loadServices(); } },
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% from 'shared/macros/headers.html' import page_header %}
|
||||
{% from 'shared/macros/headers.html' import page_header, section_header %}
|
||||
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
|
||||
|
||||
{% block title %}Hosting Dashboard{% endblock %}
|
||||
@@ -14,7 +14,7 @@
|
||||
<div x-show="!loading && !error" class="space-y-6">
|
||||
<!-- KPI Cards -->
|
||||
<div class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4">
|
||||
<div class="flex items-center p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
<div class="p-3 mr-4 text-teal-500 bg-teal-100 rounded-full dark:text-teal-100 dark:bg-teal-500">
|
||||
<span x-html="$icon('globe', 'w-5 h-5')"></span>
|
||||
</div>
|
||||
@@ -23,7 +23,7 @@
|
||||
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.total_sites || 0"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
<div class="p-3 mr-4 text-green-500 bg-green-100 rounded-full dark:text-green-100 dark:bg-green-500">
|
||||
<span x-html="$icon('check-circle', 'w-5 h-5')"></span>
|
||||
</div>
|
||||
@@ -32,7 +32,7 @@
|
||||
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.live_sites || 0"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
<div class="p-3 mr-4 text-orange-500 bg-orange-100 rounded-full dark:text-orange-100 dark:bg-orange-500">
|
||||
<span x-html="$icon('eye', 'w-5 h-5')"></span>
|
||||
</div>
|
||||
@@ -41,7 +41,7 @@
|
||||
<p class="text-lg font-semibold text-gray-700 dark:text-gray-200" x-text="stats.poc_sites || 0"></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
<div class="p-3 mr-4 text-red-500 bg-red-100 rounded-full dark:text-red-100 dark:bg-red-500">
|
||||
<span x-html="$icon('clock', 'w-5 h-5')"></span>
|
||||
</div>
|
||||
@@ -53,41 +53,44 @@
|
||||
</div>
|
||||
|
||||
<!-- Quick Actions -->
|
||||
<div class="flex flex-wrap gap-3 mb-6">
|
||||
<a href="/admin/hosting/sites/new"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-teal-600 rounded-lg hover:bg-teal-700">
|
||||
<span x-html="$icon('plus', 'w-4 h-4 mr-2')"></span>
|
||||
New Site
|
||||
</a>
|
||||
<a href="/admin/hosting/sites"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-lg hover:bg-gray-300 dark:text-gray-300 dark:bg-gray-700">
|
||||
<span x-html="$icon('globe', 'w-4 h-4 mr-2')"></span>
|
||||
All Sites
|
||||
</a>
|
||||
<a href="/admin/hosting/clients"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-lg hover:bg-gray-300 dark:text-gray-300 dark:bg-gray-700">
|
||||
<span x-html="$icon('cube', 'w-4 h-4 mr-2')"></span>
|
||||
All Services
|
||||
</a>
|
||||
<div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
{{ section_header('Quick Actions', icon='cursor-click') }}
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<a href="/admin/hosting/sites/new"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-teal-600 border border-transparent rounded-lg hover:bg-teal-700 focus:outline-none">
|
||||
<span x-html="$icon('plus', 'w-4 h-4 mr-2')"></span>
|
||||
New Site
|
||||
</a>
|
||||
<a href="/admin/hosting/sites"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-gray-700 dark:text-gray-300 transition-colors duration-150 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none">
|
||||
<span x-html="$icon('globe', 'w-4 h-4 mr-2')"></span>
|
||||
All Sites
|
||||
</a>
|
||||
<a href="/admin/hosting/clients"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-gray-700 dark:text-gray-300 transition-colors duration-150 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none">
|
||||
<span x-html="$icon('cube', 'w-4 h-4 mr-2')"></span>
|
||||
All Services
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sites by Status + Services by Type -->
|
||||
<!-- Sites by Status + Active Services -->
|
||||
<div class="grid gap-6 md:grid-cols-2">
|
||||
<div class="p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<h3 class="mb-4 text-lg font-semibold text-gray-700 dark:text-gray-200">Sites by Status</h3>
|
||||
<div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
{{ section_header('Sites by Status', icon='globe') }}
|
||||
<div class="space-y-3">
|
||||
<template x-for="status in ['draft', 'poc_ready', 'proposal_sent', 'accepted', 'live', 'suspended', 'cancelled']" :key="status">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-sm text-gray-600 dark:text-gray-400 capitalize" x-text="status.replace('_', ' ')"></span>
|
||||
<span class="px-2 py-1 text-xs font-semibold rounded-full"
|
||||
<span class="px-2.5 py-0.5 text-xs font-medium rounded-full"
|
||||
:class="statusBadgeClass(status)"
|
||||
x-text="stats.sites_by_status?.[status] || 0"></span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<h3 class="mb-4 text-lg font-semibold text-gray-700 dark:text-gray-200">Active Services</h3>
|
||||
<div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
{{ section_header('Active Services', icon='cube') }}
|
||||
<div class="space-y-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-sm text-gray-600 dark:text-gray-400">Total Active</span>
|
||||
@@ -100,7 +103,7 @@
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="mt-4 pt-4 border-t dark:border-gray-700">
|
||||
<div class="mt-4 pt-4 border-t border-gray-100 dark:border-gray-700">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-sm font-medium text-gray-600 dark:text-gray-400">Monthly Revenue</span>
|
||||
<span class="text-lg font-semibold text-green-600 dark:text-green-400"
|
||||
@@ -116,16 +119,16 @@
|
||||
<script>
|
||||
function hostingDashboard() {
|
||||
return {
|
||||
...data(),
|
||||
currentPage: 'hosting-dashboard',
|
||||
loading: true,
|
||||
error: false,
|
||||
error: null,
|
||||
stats: {},
|
||||
async init() {
|
||||
try {
|
||||
const resp = await fetch('/api/admin/hosting/stats/dashboard');
|
||||
if (!resp.ok) throw new Error('Failed to load');
|
||||
this.stats = await resp.json();
|
||||
this.stats = await apiClient.get('/admin/hosting/stats/dashboard');
|
||||
} catch (e) {
|
||||
this.error = true;
|
||||
this.error = e.message;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% from 'shared/macros/headers.html' import page_header %}
|
||||
{% from 'shared/macros/headers.html' import section_header, tab_header %}
|
||||
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
|
||||
{% from 'shared/macros/modals.html' import modal %}
|
||||
{% from 'shared/macros/inputs.html' import number_stepper %}
|
||||
|
||||
{% block title %}Site Detail{% endblock %}
|
||||
@@ -13,122 +14,124 @@
|
||||
|
||||
<div x-show="!loading && !error && site" class="space-y-6">
|
||||
<!-- Header -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex flex-col sm:flex-row sm:items-center justify-between my-6 gap-4">
|
||||
<div class="flex items-center space-x-4">
|
||||
<a href="/admin/hosting/sites"
|
||||
class="p-2 text-gray-500 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700">
|
||||
class="flex items-center justify-center p-2 text-gray-500 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"
|
||||
title="Back to sites">
|
||||
<span x-html="$icon('arrow-left', 'w-5 h-5')"></span>
|
||||
</a>
|
||||
<div class="relative hidden w-10 h-10 rounded-full md:block">
|
||||
<div class="absolute inset-0 rounded-full bg-teal-100 dark:bg-teal-600 flex items-center justify-center">
|
||||
<span class="text-sm font-semibold text-teal-600 dark:text-teal-100"
|
||||
x-text="site.business_name?.charAt(0).toUpperCase() || '?'"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="text-2xl font-semibold text-gray-700 dark:text-gray-200"
|
||||
x-text="site.business_name"></h2>
|
||||
<p class="text-sm text-gray-500" x-show="site.live_domain" x-text="site.live_domain"></p>
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400" x-show="site.live_domain" x-text="site.live_domain"></p>
|
||||
</div>
|
||||
<span class="px-3 py-1 text-xs font-semibold rounded-full"
|
||||
<span class="px-2.5 py-0.5 text-xs font-medium rounded-full"
|
||||
:class="statusBadgeClass(site.status)"
|
||||
x-text="site.status.replace('_', ' ')"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Lifecycle Actions -->
|
||||
<div class="flex flex-wrap gap-3 p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<button x-show="site.status === 'draft'" @click="doAction('mark-poc-ready')"
|
||||
class="px-3 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700">
|
||||
<div class="flex flex-wrap gap-3 p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
<button type="button" x-show="site.status === 'draft'" @click="doAction('mark-poc-ready')"
|
||||
class="inline-flex items-center px-3 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-blue-600 border border-transparent rounded-lg hover:bg-blue-700 focus:outline-none">
|
||||
Mark POC Ready
|
||||
</button>
|
||||
<button x-show="site.status === 'poc_ready'" @click="showProposalModal = true"
|
||||
class="px-3 py-2 text-sm font-medium text-white bg-yellow-600 rounded-lg hover:bg-yellow-700">
|
||||
<button type="button" x-show="site.status === 'poc_ready'" @click="showProposalModal = true"
|
||||
class="inline-flex items-center px-3 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-yellow-600 border border-transparent rounded-lg hover:bg-yellow-700 focus:outline-none">
|
||||
Send Proposal
|
||||
</button>
|
||||
<button x-show="site.status === 'proposal_sent'" @click="showAcceptModal = true"
|
||||
class="px-3 py-2 text-sm font-medium text-white bg-purple-600 rounded-lg hover:bg-purple-700">
|
||||
<button type="button" x-show="site.status === 'proposal_sent'" @click="showAcceptModal = true"
|
||||
class="inline-flex items-center px-3 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg hover:bg-purple-700 focus:outline-none">
|
||||
Accept Proposal
|
||||
</button>
|
||||
<button x-show="site.status === 'accepted'" @click="showGoLiveModal = true"
|
||||
class="px-3 py-2 text-sm font-medium text-white bg-green-600 rounded-lg hover:bg-green-700">
|
||||
<button type="button" x-show="site.status === 'accepted'" @click="showGoLiveModal = true"
|
||||
class="inline-flex items-center px-3 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-green-600 border border-transparent rounded-lg hover:bg-green-700 focus:outline-none">
|
||||
Go Live
|
||||
</button>
|
||||
<button x-show="site.status === 'live'" @click="doAction('suspend')"
|
||||
class="px-3 py-2 text-sm font-medium text-white bg-red-600 rounded-lg hover:bg-red-700">
|
||||
<button type="button" x-show="site.status === 'live'" @click="doAction('suspend')"
|
||||
class="inline-flex items-center px-3 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-red-600 border border-transparent rounded-lg hover:bg-red-700 focus:outline-none">
|
||||
Suspend
|
||||
</button>
|
||||
<button x-show="site.status === 'suspended'" @click="doAction('go-live', {domain: site.live_domain})"
|
||||
class="px-3 py-2 text-sm font-medium text-white bg-green-600 rounded-lg hover:bg-green-700">
|
||||
<button type="button" x-show="site.status === 'suspended'" @click="doAction('go-live', {domain: site.live_domain})"
|
||||
class="inline-flex items-center px-3 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-green-600 border border-transparent rounded-lg hover:bg-green-700 focus:outline-none">
|
||||
Reactivate
|
||||
</button>
|
||||
<button x-show="site.status !== 'cancelled' && site.status !== 'live'"
|
||||
<button type="button" x-show="site.status !== 'cancelled' && site.status !== 'live'"
|
||||
@click="doAction('cancel')"
|
||||
class="px-3 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-lg hover:bg-gray-300 dark:text-gray-300 dark:bg-gray-700">
|
||||
class="inline-flex items-center px-3 py-2 text-sm font-medium leading-5 text-gray-700 dark:text-gray-300 transition-colors duration-150 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none">
|
||||
Cancel
|
||||
</button>
|
||||
<a x-show="['poc_ready', 'proposal_sent'].includes(site.status)"
|
||||
:href="'/hosting/sites/' + site.id + '/preview'" target="_blank"
|
||||
class="ml-auto px-3 py-2 text-sm font-medium text-teal-700 bg-teal-100 rounded-lg hover:bg-teal-200 dark:text-teal-300 dark:bg-teal-900">
|
||||
<span x-html="$icon('eye', 'w-4 h-4 inline mr-1')"></span>
|
||||
class="sm:ml-auto inline-flex items-center px-3 py-2 text-sm font-medium leading-5 text-teal-700 dark:text-teal-300 transition-colors duration-150 bg-teal-100 dark:bg-teal-900 border border-transparent rounded-lg hover:bg-teal-200 dark:hover:bg-teal-800 focus:outline-none">
|
||||
<span x-html="$icon('eye', 'w-4 h-4 mr-1')"></span>
|
||||
Preview POC
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Tabs -->
|
||||
<div class="border-b border-gray-200 dark:border-gray-700">
|
||||
<nav class="flex -mb-px space-x-8">
|
||||
<template x-for="tab in tabs" :key="tab.id">
|
||||
<button @click="activeTab = tab.id"
|
||||
:class="activeTab === tab.id ? 'border-teal-500 text-teal-600 dark:text-teal-400' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'"
|
||||
class="py-4 px-1 border-b-2 font-medium text-sm whitespace-nowrap"
|
||||
x-text="tab.label"></button>
|
||||
</template>
|
||||
</nav>
|
||||
</div>
|
||||
{{ tab_header([
|
||||
{'id': 'overview', 'label': 'Overview', 'icon': 'eye'},
|
||||
{'id': 'services', 'label': 'Services', 'icon': 'cube'},
|
||||
{'id': 'store', 'label': 'Store', 'icon': 'shopping-bag'},
|
||||
], active_var='activeTab') }}
|
||||
|
||||
<!-- Tab: Overview -->
|
||||
<div x-show="activeTab === 'overview'" class="grid gap-6 md:grid-cols-2">
|
||||
<div class="p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<h3 class="mb-3 text-sm font-semibold text-gray-700 dark:text-gray-200 uppercase">Contact Info</h3>
|
||||
<div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
{{ section_header('Contact Info', icon='phone') }}
|
||||
<div class="space-y-2 text-sm">
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-600 dark:text-gray-400">Name</span>
|
||||
<span class="text-gray-700 dark:text-gray-300" x-text="site.contact_name || '—'"></span>
|
||||
<span class="font-medium text-gray-700 dark:text-gray-300" x-text="site.contact_name || '—'"></span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-600 dark:text-gray-400">Email</span>
|
||||
<span class="text-gray-700 dark:text-gray-300" x-text="site.contact_email || '—'"></span>
|
||||
<span class="font-medium text-gray-700 dark:text-gray-300" x-text="site.contact_email || '—'"></span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-600 dark:text-gray-400">Phone</span>
|
||||
<span class="text-gray-700 dark:text-gray-300" x-text="site.contact_phone || '—'"></span>
|
||||
<span class="font-medium text-gray-700 dark:text-gray-300" x-text="site.contact_phone || '—'"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<h3 class="mb-3 text-sm font-semibold text-gray-700 dark:text-gray-200 uppercase">Timeline</h3>
|
||||
<div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
{{ section_header('Timeline', icon='clock') }}
|
||||
<div class="space-y-2 text-sm">
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-600 dark:text-gray-400">Created</span>
|
||||
<span class="text-gray-700 dark:text-gray-300" x-text="site.created_at ? new Date(site.created_at).toLocaleDateString() : '—'"></span>
|
||||
<span class="font-medium text-gray-700 dark:text-gray-300" x-text="site.created_at ? new Date(site.created_at).toLocaleDateString() : '—'"></span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-600 dark:text-gray-400">Proposal Sent</span>
|
||||
<span class="text-gray-700 dark:text-gray-300" x-text="site.proposal_sent_at ? new Date(site.proposal_sent_at).toLocaleDateString() : '—'"></span>
|
||||
<span class="font-medium text-gray-700 dark:text-gray-300" x-text="site.proposal_sent_at ? new Date(site.proposal_sent_at).toLocaleDateString() : '—'"></span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-600 dark:text-gray-400">Accepted</span>
|
||||
<span class="text-gray-700 dark:text-gray-300" x-text="site.proposal_accepted_at ? new Date(site.proposal_accepted_at).toLocaleDateString() : '—'"></span>
|
||||
<span class="font-medium text-gray-700 dark:text-gray-300" x-text="site.proposal_accepted_at ? new Date(site.proposal_accepted_at).toLocaleDateString() : '—'"></span>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-600 dark:text-gray-400">Went Live</span>
|
||||
<span class="text-gray-700 dark:text-gray-300" x-text="site.went_live_at ? new Date(site.went_live_at).toLocaleDateString() : '—'"></span>
|
||||
<span class="font-medium text-gray-700 dark:text-gray-300" x-text="site.went_live_at ? new Date(site.went_live_at).toLocaleDateString() : '—'"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-4 bg-white rounded-lg shadow dark:bg-gray-800 md:col-span-2" x-show="site.proposal_notes || site.internal_notes">
|
||||
<h3 class="mb-3 text-sm font-semibold text-gray-700 dark:text-gray-200 uppercase">Notes</h3>
|
||||
<div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800 md:col-span-2" x-show="site.proposal_notes || site.internal_notes">
|
||||
{{ section_header('Notes', icon='document-text') }}
|
||||
<div x-show="site.proposal_notes" class="mb-3">
|
||||
<p class="text-xs text-gray-500 uppercase mb-1">Proposal Notes</p>
|
||||
<p class="text-xs font-medium text-gray-500 dark:text-gray-400 uppercase mb-1">Proposal Notes</p>
|
||||
<p class="text-sm text-gray-700 dark:text-gray-300" x-text="site.proposal_notes"></p>
|
||||
</div>
|
||||
<div x-show="site.internal_notes">
|
||||
<p class="text-xs text-gray-500 uppercase mb-1">Internal Notes</p>
|
||||
<p class="text-xs font-medium text-gray-500 dark:text-gray-400 uppercase mb-1">Internal Notes</p>
|
||||
<p class="text-sm text-gray-700 dark:text-gray-300" x-text="site.internal_notes"></p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -137,25 +140,25 @@
|
||||
<!-- Tab: Services -->
|
||||
<div x-show="activeTab === 'services'" class="space-y-4">
|
||||
<div class="flex justify-end">
|
||||
<button @click="showServiceModal = true"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-teal-600 rounded-lg hover:bg-teal-700">
|
||||
<span x-html="$icon('plus', 'w-4 h-4 inline mr-1')"></span>
|
||||
<button type="button" @click="showServiceModal = true"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-teal-600 border border-transparent rounded-lg hover:bg-teal-700 focus:outline-none">
|
||||
<span x-html="$icon('plus', 'w-4 h-4 mr-2')"></span>
|
||||
Add Service
|
||||
</button>
|
||||
</div>
|
||||
<template x-for="svc in site.client_services || []" :key="svc.id">
|
||||
<div class="p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<div class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800 border border-gray-200 dark:border-gray-700 hover:shadow-md transition-shadow">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<span class="text-sm font-semibold text-gray-700 dark:text-gray-200" x-text="svc.name"></span>
|
||||
<span class="ml-2 px-2 py-0.5 text-xs rounded-full bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400"
|
||||
<span class="ml-2 px-2 py-0.5 text-xs font-medium rounded-full bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400"
|
||||
x-text="svc.service_type.replace('_', ' ')"></span>
|
||||
</div>
|
||||
<span class="px-2 py-1 text-xs font-semibold rounded-full"
|
||||
:class="svc.status === 'active' ? 'bg-green-100 text-green-700' : svc.status === 'expired' ? 'bg-red-100 text-red-700' : 'bg-gray-100 text-gray-600'"
|
||||
<span class="px-2.5 py-0.5 text-xs font-medium rounded-full"
|
||||
:class="svc.status === 'active' ? 'bg-green-100 text-green-700 dark:bg-green-700 dark:text-green-100' : svc.status === 'expired' ? 'bg-red-100 text-red-700 dark:bg-red-700 dark:text-red-100' : 'bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400'"
|
||||
x-text="svc.status"></span>
|
||||
</div>
|
||||
<div class="mt-2 flex gap-4 text-xs text-gray-500">
|
||||
<div class="mt-2 flex flex-wrap gap-4 text-xs text-gray-500 dark:text-gray-400">
|
||||
<span x-show="svc.price_cents" x-text="'€' + (svc.price_cents / 100).toFixed(2) + '/' + (svc.billing_period || 'month')"></span>
|
||||
<span x-show="svc.domain_name" x-text="svc.domain_name"></span>
|
||||
<span x-show="svc.expires_at" x-text="'Expires: ' + new Date(svc.expires_at).toLocaleDateString()"></span>
|
||||
@@ -167,17 +170,17 @@
|
||||
</div>
|
||||
|
||||
<!-- Tab: Store -->
|
||||
<div x-show="activeTab === 'store'" class="p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<h3 class="mb-3 text-sm font-semibold text-gray-700 dark:text-gray-200 uppercase">Store Info</h3>
|
||||
<div x-show="activeTab === 'store'" class="p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
{{ section_header('Store Info', icon='shopping-bag') }}
|
||||
<div class="space-y-2 text-sm">
|
||||
<div class="flex justify-between">
|
||||
<span class="text-gray-600 dark:text-gray-400">Store ID</span>
|
||||
<span class="text-gray-700 dark:text-gray-300" x-text="site.store_id"></span>
|
||||
<span class="font-medium text-gray-700 dark:text-gray-300" x-text="site.store_id"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<a :href="'/admin/stores/' + site.store_id"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-teal-700 bg-teal-100 rounded-lg hover:bg-teal-200 dark:text-teal-300 dark:bg-teal-900">
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-teal-700 dark:text-teal-300 transition-colors duration-150 bg-teal-100 dark:bg-teal-900 border border-transparent rounded-lg hover:bg-teal-200 dark:hover:bg-teal-800 focus:outline-none">
|
||||
<span x-html="$icon('external-link', 'w-4 h-4 mr-2')"></span>
|
||||
Open in Store Admin
|
||||
</a>
|
||||
@@ -185,152 +188,115 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Send Proposal Modal --> {# noqa: FE-004 #}
|
||||
<div x-show="showProposalModal" x-cloak
|
||||
class="fixed inset-0 z-30 flex items-end bg-black bg-opacity-50 sm:items-center sm:justify-center"
|
||||
@click.self="showProposalModal = false">
|
||||
<div class="w-full px-6 py-4 overflow-hidden bg-white rounded-t-lg dark:bg-gray-800 sm:rounded-lg sm:m-4 sm:max-w-xl"
|
||||
@keydown.escape.window="showProposalModal = false">
|
||||
<header class="flex justify-between mb-4">
|
||||
<h3 class="text-lg font-semibold text-gray-700 dark:text-gray-200">Send Proposal</h3>
|
||||
<button @click="showProposalModal = false" class="text-gray-400 hover:text-gray-600">
|
||||
<span x-html="$icon('x', 'w-5 h-5')"></span>
|
||||
</button>
|
||||
</header>
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400">Proposal Notes</label>
|
||||
<textarea x-model="proposalNotes" rows="4"
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300"></textarea>
|
||||
</div>
|
||||
<footer class="flex justify-end mt-6 space-x-3">
|
||||
<button @click="showProposalModal = false"
|
||||
class="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-lg hover:bg-gray-300 dark:text-gray-300 dark:bg-gray-700">Cancel</button>
|
||||
<button @click="sendProposal()"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-yellow-600 rounded-lg hover:bg-yellow-700">Send</button>
|
||||
</footer>
|
||||
<!-- Send Proposal Modal -->
|
||||
{% call modal('proposalModal', 'Send Proposal', show_var='showProposalModal', size='md', show_footer=false) %}
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Proposal Notes</label>
|
||||
<textarea x-model="proposalNotes" rows="4"
|
||||
class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Accept Proposal Modal --> {# noqa: FE-004 #}
|
||||
<div x-show="showAcceptModal" x-cloak
|
||||
class="fixed inset-0 z-30 flex items-end bg-black bg-opacity-50 sm:items-center sm:justify-center"
|
||||
@click.self="showAcceptModal = false">
|
||||
<div class="w-full px-6 py-4 overflow-hidden bg-white rounded-t-lg dark:bg-gray-800 sm:rounded-lg sm:m-4 sm:max-w-xl"
|
||||
@keydown.escape.window="showAcceptModal = false">
|
||||
<header class="flex justify-between mb-4">
|
||||
<h3 class="text-lg font-semibold text-gray-700 dark:text-gray-200">Accept Proposal</h3>
|
||||
<button @click="showAcceptModal = false" class="text-gray-400 hover:text-gray-600">
|
||||
<span x-html="$icon('x', 'w-5 h-5')"></span>
|
||||
</button>
|
||||
</header>
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400">Existing Merchant ID (leave empty to create new)</label>
|
||||
<input type="number" x-model="acceptMerchantId" placeholder="Optional"
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300">
|
||||
</div>
|
||||
<footer class="flex justify-end mt-6 space-x-3">
|
||||
<button @click="showAcceptModal = false"
|
||||
class="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-lg hover:bg-gray-300 dark:text-gray-300 dark:bg-gray-700">Cancel</button>
|
||||
<button @click="acceptProposal()"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-purple-600 rounded-lg hover:bg-purple-700">Accept</button>
|
||||
</footer>
|
||||
<div class="flex justify-end mt-6 pt-4 border-t border-gray-200 dark:border-gray-700 space-x-3">
|
||||
<button type="button" @click="showProposalModal = false"
|
||||
class="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors">Cancel</button>
|
||||
<button type="button" @click="sendProposal()"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-yellow-600 border border-transparent rounded-lg hover:bg-yellow-700 focus:outline-none transition-colors duration-150">
|
||||
<span x-html="$icon('mail', 'w-4 h-4 mr-2')"></span> Send
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endcall %}
|
||||
|
||||
<!-- Go Live Modal --> {# noqa: FE-004 #}
|
||||
<div x-show="showGoLiveModal" x-cloak
|
||||
class="fixed inset-0 z-30 flex items-end bg-black bg-opacity-50 sm:items-center sm:justify-center"
|
||||
@click.self="showGoLiveModal = false">
|
||||
<div class="w-full px-6 py-4 overflow-hidden bg-white rounded-t-lg dark:bg-gray-800 sm:rounded-lg sm:m-4 sm:max-w-xl"
|
||||
@keydown.escape.window="showGoLiveModal = false">
|
||||
<header class="flex justify-between mb-4">
|
||||
<h3 class="text-lg font-semibold text-gray-700 dark:text-gray-200">Go Live</h3>
|
||||
<button @click="showGoLiveModal = false" class="text-gray-400 hover:text-gray-600">
|
||||
<span x-html="$icon('x', 'w-5 h-5')"></span>
|
||||
</button>
|
||||
</header>
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400">Domain *</label>
|
||||
<input type="text" x-model="goLiveDomain" placeholder="example.lu"
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300">
|
||||
</div>
|
||||
<footer class="flex justify-end mt-6 space-x-3">
|
||||
<button @click="showGoLiveModal = false"
|
||||
class="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-lg hover:bg-gray-300 dark:text-gray-300 dark:bg-gray-700">Cancel</button>
|
||||
<button @click="goLive()"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-green-600 rounded-lg hover:bg-green-700">Go Live</button>
|
||||
</footer>
|
||||
<!-- Accept Proposal Modal -->
|
||||
{% call modal('acceptModal', 'Accept Proposal', show_var='showAcceptModal', size='md', show_footer=false) %}
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Existing Merchant ID (leave empty to create new)</label>
|
||||
<input type="number" x-model="acceptMerchantId" placeholder="Optional" {# noqa: FE008 - merchant ID input #}
|
||||
class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end mt-6 pt-4 border-t border-gray-200 dark:border-gray-700 space-x-3">
|
||||
<button type="button" @click="showAcceptModal = false"
|
||||
class="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors">Cancel</button>
|
||||
<button type="button" @click="acceptProposal()"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-purple-600 border border-transparent rounded-lg hover:bg-purple-700 focus:outline-none transition-colors duration-150">
|
||||
<span x-html="$icon('check', 'w-4 h-4 mr-2')"></span> Accept
|
||||
</button>
|
||||
</div>
|
||||
{% endcall %}
|
||||
|
||||
<!-- Add Service Modal --> {# noqa: FE-004 #}
|
||||
<div x-show="showServiceModal" x-cloak
|
||||
class="fixed inset-0 z-30 flex items-end bg-black bg-opacity-50 sm:items-center sm:justify-center"
|
||||
@click.self="showServiceModal = false">
|
||||
<div class="w-full px-6 py-4 overflow-hidden bg-white rounded-t-lg dark:bg-gray-800 sm:rounded-lg sm:m-4 sm:max-w-xl"
|
||||
@keydown.escape.window="showServiceModal = false">
|
||||
<header class="flex justify-between mb-4">
|
||||
<h3 class="text-lg font-semibold text-gray-700 dark:text-gray-200">Add Service</h3>
|
||||
<button @click="showServiceModal = false" class="text-gray-400 hover:text-gray-600">
|
||||
<span x-html="$icon('x', 'w-5 h-5')"></span>
|
||||
</button>
|
||||
</header>
|
||||
<div class="space-y-4">
|
||||
<!-- Go Live Modal -->
|
||||
{% call modal('goLiveModal', 'Go Live', show_var='showGoLiveModal', size='md', show_footer=false) %}
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">
|
||||
Domain <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<input type="text" x-model="goLiveDomain" placeholder="example.lu"
|
||||
class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
|
||||
</div>
|
||||
<div class="flex justify-end mt-6 pt-4 border-t border-gray-200 dark:border-gray-700 space-x-3">
|
||||
<button type="button" @click="showGoLiveModal = false"
|
||||
class="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors">Cancel</button>
|
||||
<button type="button" @click="goLive()"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-green-600 border border-transparent rounded-lg hover:bg-green-700 focus:outline-none transition-colors duration-150">
|
||||
<span x-html="$icon('check', 'w-4 h-4 mr-2')"></span> Go Live
|
||||
</button>
|
||||
</div>
|
||||
{% endcall %}
|
||||
|
||||
<!-- Add Service Modal -->
|
||||
{% call modal('serviceModal', 'Add Service', show_var='showServiceModal', size='md', show_footer=false) %}
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Type</label>
|
||||
<select x-model="newService.service_type"
|
||||
class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
|
||||
<option value="domain">Domain</option>
|
||||
<option value="email">Email</option>
|
||||
<option value="ssl">SSL</option>
|
||||
<option value="hosting">Hosting</option>
|
||||
<option value="website_maintenance">Website Maintenance</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Name</label>
|
||||
<input type="text" x-model="newService.name" placeholder="e.g., acme.lu domain"
|
||||
class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400">Type</label>
|
||||
<select x-model="newService.service_type"
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300">
|
||||
<option value="domain">Domain</option>
|
||||
<option value="email">Email</option>
|
||||
<option value="ssl">SSL</option>
|
||||
<option value="hosting">Hosting</option>
|
||||
<option value="website_maintenance">Website Maintenance</option>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Price (cents)</label>
|
||||
{{ number_stepper(model='newService.price_cents', min=0, step=100, size='sm', label='Price (cents)') }}
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Billing</label>
|
||||
<select x-model="newService.billing_period"
|
||||
class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
|
||||
<option value="monthly">Monthly</option>
|
||||
<option value="annual">Annual</option>
|
||||
<option value="one_time">One-time</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400">Name</label>
|
||||
<input type="text" x-model="newService.name" placeholder="e.g., acme.lu domain"
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300">
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400">Price (cents)</label>
|
||||
{{ number_stepper(model='newService.price_cents', min=0, step=100, size='sm', label='Price (cents)') }}
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400">Billing</label>
|
||||
<select x-model="newService.billing_period"
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300">
|
||||
<option value="monthly">Monthly</option>
|
||||
<option value="annual">Annual</option>
|
||||
<option value="one_time">One-time</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="flex justify-end mt-6 space-x-3">
|
||||
<button @click="showServiceModal = false"
|
||||
class="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-lg hover:bg-gray-300 dark:text-gray-300 dark:bg-gray-700">Cancel</button>
|
||||
<button @click="addService()"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-teal-600 rounded-lg hover:bg-teal-700">Add</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end mt-6 pt-4 border-t border-gray-200 dark:border-gray-700 space-x-3">
|
||||
<button type="button" @click="showServiceModal = false"
|
||||
class="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors">Cancel</button>
|
||||
<button type="button" @click="addService()"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-white bg-teal-600 border border-transparent rounded-lg hover:bg-teal-700 focus:outline-none transition-colors duration-150">
|
||||
<span x-html="$icon('plus', 'w-4 h-4 mr-2')"></span> Add
|
||||
</button>
|
||||
</div>
|
||||
{% endcall %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
<script>
|
||||
function hostingSiteDetail(siteId) {
|
||||
return {
|
||||
...data(),
|
||||
currentPage: 'hosting-sites',
|
||||
loading: true,
|
||||
error: false,
|
||||
error: null,
|
||||
site: null,
|
||||
activeTab: 'overview',
|
||||
tabs: [
|
||||
{ id: 'overview', label: 'Overview' },
|
||||
{ id: 'services', label: 'Services' },
|
||||
{ id: 'store', label: 'Store' },
|
||||
],
|
||||
showProposalModal: false,
|
||||
showAcceptModal: false,
|
||||
showGoLiveModal: false,
|
||||
@@ -342,23 +308,23 @@ function hostingSiteDetail(siteId) {
|
||||
async init() { await this.loadSite(); },
|
||||
async loadSite() {
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
try {
|
||||
const resp = await fetch('/api/admin/hosting/sites/' + siteId);
|
||||
if (!resp.ok) throw new Error('Failed to load');
|
||||
this.site = await resp.json();
|
||||
} catch (e) { this.error = true; }
|
||||
finally { this.loading = false; }
|
||||
this.site = await apiClient.get('/admin/hosting/sites/' + siteId);
|
||||
} catch (e) {
|
||||
this.error = e.message;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
async doAction(action, body = {}) {
|
||||
try {
|
||||
const resp = await fetch('/api/admin/hosting/sites/' + siteId + '/' + action, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
if (!resp.ok) { const err = await resp.json(); alert(err.detail || 'Action failed'); return; }
|
||||
await apiClient.post('/admin/hosting/sites/' + siteId + '/' + action, body);
|
||||
Utils.showToast('Action completed', 'success');
|
||||
await this.loadSite();
|
||||
} catch (e) { alert('Action failed'); }
|
||||
} catch (e) {
|
||||
Utils.showToast(e.message || 'Action failed', 'error');
|
||||
}
|
||||
},
|
||||
async sendProposal() {
|
||||
await this.doAction('send-proposal', { notes: this.proposalNotes });
|
||||
@@ -376,16 +342,14 @@ function hostingSiteDetail(siteId) {
|
||||
},
|
||||
async addService() {
|
||||
try {
|
||||
const resp = await fetch('/api/admin/hosting/sites/' + siteId + '/services', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(this.newService),
|
||||
});
|
||||
if (!resp.ok) { const err = await resp.json(); alert(err.detail || 'Failed'); return; }
|
||||
await apiClient.post('/admin/hosting/sites/' + siteId + '/services', this.newService);
|
||||
Utils.showToast('Service added', 'success');
|
||||
this.showServiceModal = false;
|
||||
this.newService = { service_type: 'domain', name: '', price_cents: null, billing_period: 'monthly' };
|
||||
await this.loadSite();
|
||||
} catch (e) { alert('Failed to add service'); }
|
||||
} catch (e) {
|
||||
Utils.showToast(e.message || 'Failed to add service', 'error');
|
||||
}
|
||||
},
|
||||
statusBadgeClass(status) {
|
||||
const classes = {
|
||||
|
||||
@@ -6,67 +6,71 @@
|
||||
{% block alpine_data %}hostingSiteNew(){% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ page_header('New Hosted Site') }}
|
||||
{{ page_header('New Hosted Site', back_url='/admin/hosting/sites', back_label='Back') }}
|
||||
|
||||
<div class="max-w-2xl">
|
||||
<div class="p-6 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<div class="space-y-6">
|
||||
<div class="max-w-2xl mx-auto">
|
||||
<div class="px-4 py-5 sm:p-6 bg-white rounded-lg shadow-md dark:bg-gray-800">
|
||||
<div class="space-y-5">
|
||||
<div>
|
||||
<label class="text-sm font-medium text-gray-700 dark:text-gray-300">Business Name *</label>
|
||||
<input type="text" x-model="form.business_name" placeholder="Acme Luxembourg SARL"
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300 focus:border-teal-400 focus:ring-teal-300">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">
|
||||
Business Name <span class="text-red-500">*</span>
|
||||
</label>
|
||||
<input type="text" x-model="form.business_name" placeholder="Acme Luxembourg SARL" autofocus
|
||||
class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-2">
|
||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<label class="text-sm font-medium text-gray-700 dark:text-gray-300">Contact Name</label>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Contact Name</label>
|
||||
<input type="text" x-model="form.contact_name" placeholder="Jean Dupont"
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300">
|
||||
class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-sm font-medium text-gray-700 dark:text-gray-300">Contact Email</label>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Contact Email</label>
|
||||
<input type="email" x-model="form.contact_email" placeholder="contact@acme.lu"
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300">
|
||||
class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="text-sm font-medium text-gray-700 dark:text-gray-300">Contact Phone</label>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Contact Phone</label>
|
||||
<input type="tel" x-model="form.contact_phone" placeholder="+352 ..."
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300">
|
||||
class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="text-sm font-medium text-gray-700 dark:text-gray-300">Internal Notes</label>
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Internal Notes</label>
|
||||
<textarea x-model="form.internal_notes" rows="3" placeholder="Any internal notes..."
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300"></textarea>
|
||||
class="w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300"></textarea>
|
||||
</div>
|
||||
|
||||
<!-- Prospect Selector -->
|
||||
<div>
|
||||
<label class="text-sm font-medium text-gray-700 dark:text-gray-300">Create from Prospect (optional)</label>
|
||||
<div class="pt-4 border-t border-gray-200 dark:border-gray-700">
|
||||
<label class="block text-sm font-medium text-gray-700 dark:text-gray-400 mb-1">Create from Prospect (optional)</label>
|
||||
<div class="flex mt-1 space-x-2">
|
||||
<input type="number" x-model="prospectId" placeholder="Prospect ID"
|
||||
class="flex-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300">
|
||||
<button @click="createFromProspect()"
|
||||
<input type="number" x-model="prospectId" placeholder="Prospect ID" {# noqa: FE008 - prospect ID input #}
|
||||
class="flex-1 px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray dark:bg-gray-700 dark:text-gray-300">
|
||||
<button type="button" @click="createFromProspect()"
|
||||
:disabled="!prospectId || creating"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-teal-600 rounded-lg hover:bg-teal-700 disabled:opacity-50">
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-teal-600 border border-transparent rounded-lg hover:bg-teal-700 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed">
|
||||
Create from Prospect
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end mt-8 space-x-3">
|
||||
<!-- Footer Actions -->
|
||||
<div class="flex flex-col sm:flex-row justify-end mt-8 pt-4 border-t border-gray-200 dark:border-gray-700 gap-3">
|
||||
<a href="/admin/hosting/sites"
|
||||
class="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-200 rounded-lg hover:bg-gray-300 dark:text-gray-300 dark:bg-gray-700">
|
||||
class="inline-flex items-center justify-center px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors">
|
||||
Cancel
|
||||
</a>
|
||||
<button @click="createSite()"
|
||||
<button type="button" @click="createSite()"
|
||||
:disabled="!form.business_name || creating"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-teal-600 rounded-lg hover:bg-teal-700 disabled:opacity-50">
|
||||
<span x-show="!creating">Create Site</span>
|
||||
<span x-show="creating">Creating...</span>
|
||||
class="inline-flex items-center justify-center px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-teal-600 border border-transparent rounded-lg hover:bg-teal-700 focus:outline-none focus:shadow-outline-purple disabled:opacity-50 disabled:cursor-not-allowed">
|
||||
<span x-show="!creating" x-html="$icon('plus', 'w-4 h-4 mr-2')"></span>
|
||||
<span x-show="creating" x-html="$icon('spinner', 'w-4 h-4 mr-2')"></span>
|
||||
<span x-text="creating ? 'Creating...' : 'Create Site'"></span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -79,6 +83,8 @@
|
||||
<script>
|
||||
function hostingSiteNew() {
|
||||
return {
|
||||
...data(),
|
||||
currentPage: 'hosting-sites',
|
||||
form: { business_name: '', contact_name: '', contact_email: '', contact_phone: '', internal_notes: '' },
|
||||
prospectId: '',
|
||||
creating: false,
|
||||
@@ -87,27 +93,25 @@ function hostingSiteNew() {
|
||||
this.creating = true;
|
||||
this.errorMsg = '';
|
||||
try {
|
||||
const resp = await fetch('/api/admin/hosting/sites', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(this.form),
|
||||
});
|
||||
if (!resp.ok) { const err = await resp.json(); this.errorMsg = err.detail || 'Failed to create'; return; }
|
||||
const site = await resp.json();
|
||||
const site = await apiClient.post('/admin/hosting/sites', this.form);
|
||||
window.location.href = '/admin/hosting/sites/' + site.id;
|
||||
} catch (e) { this.errorMsg = 'Failed to create site'; }
|
||||
finally { this.creating = false; }
|
||||
} catch (e) {
|
||||
this.errorMsg = e.message || 'Failed to create site';
|
||||
} finally {
|
||||
this.creating = false;
|
||||
}
|
||||
},
|
||||
async createFromProspect() {
|
||||
this.creating = true;
|
||||
this.errorMsg = '';
|
||||
try {
|
||||
const resp = await fetch('/api/admin/hosting/sites/from-prospect/' + this.prospectId, { method: 'POST' });
|
||||
if (!resp.ok) { const err = await resp.json(); this.errorMsg = err.detail || 'Failed to create'; return; }
|
||||
const site = await resp.json();
|
||||
const site = await apiClient.post('/admin/hosting/sites/from-prospect/' + this.prospectId);
|
||||
window.location.href = '/admin/hosting/sites/' + site.id;
|
||||
} catch (e) { this.errorMsg = 'Failed to create from prospect'; }
|
||||
finally { this.creating = false; }
|
||||
} catch (e) {
|
||||
this.errorMsg = e.message || 'Failed to create from prospect';
|
||||
} finally {
|
||||
this.creating = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,30 +1,36 @@
|
||||
{% extends "admin/base.html" %}
|
||||
{% from 'shared/macros/headers.html' import page_header %}
|
||||
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
|
||||
{% from 'shared/macros/tables.html' import table_header, table_empty %}
|
||||
{% from 'shared/macros/pagination.html' import pagination_controls %}
|
||||
{% from 'shared/macros/tables.html' import table_wrapper, table_header, table_empty_state %}
|
||||
{% from 'shared/macros/pagination.html' import pagination %}
|
||||
|
||||
{% block title %}Hosted Sites{% endblock %}
|
||||
|
||||
{% block alpine_data %}hostingSitesList(){% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ page_header('Hosted Sites', action_label='New Site', action_href='/admin/hosting/sites/new', action_icon='plus') }}
|
||||
{{ page_header('Hosted Sites', action_label='New Site', action_url='/admin/hosting/sites/new', action_icon='plus') }}
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="mb-6 p-4 bg-white rounded-lg shadow dark:bg-gray-800">
|
||||
<div class="grid gap-4 md:grid-cols-3">
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400">Search</label>
|
||||
<input type="text" x-model="search" @input.debounce.300ms="loadSites()"
|
||||
placeholder="Business name, email, domain..."
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300 focus:border-teal-400 focus:ring-teal-300">
|
||||
<div x-show="!loading && !error" class="mb-6 p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
|
||||
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
|
||||
<!-- Search -->
|
||||
<div class="flex-1 max-w-md">
|
||||
<div class="relative">
|
||||
<span class="absolute inset-y-0 left-0 flex items-center pl-3">
|
||||
<span x-html="$icon('search', 'w-5 h-5 text-gray-400')"></span>
|
||||
</span>
|
||||
<input type="text" x-model="search" @input.debounce.300ms="pagination.page = 1; loadSites()"
|
||||
placeholder="Business name, email, domain..."
|
||||
class="w-full pl-10 pr-4 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none dark:bg-gray-700 dark:text-gray-300">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-sm text-gray-600 dark:text-gray-400">Status</label>
|
||||
<select x-model="filterStatus" @change="loadSites()"
|
||||
class="w-full mt-1 text-sm rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-300">
|
||||
<option value="">All</option>
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<select x-model="filterStatus" @change="pagination.page = 1; loadSites()"
|
||||
class="px-4 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:border-purple-400 focus:outline-none">
|
||||
<option value="">All Status</option>
|
||||
<option value="draft">Draft</option>
|
||||
<option value="poc_ready">POC Ready</option>
|
||||
<option value="proposal_sent">Proposal Sent</option>
|
||||
@@ -33,10 +39,9 @@
|
||||
<option value="suspended">Suspended</option>
|
||||
<option value="cancelled">Cancelled</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex items-end">
|
||||
|
||||
<a href="/admin/prospecting/prospects"
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium text-teal-700 bg-teal-100 rounded-lg hover:bg-teal-200 dark:text-teal-300 dark:bg-teal-900 dark:hover:bg-teal-800">
|
||||
class="inline-flex items-center px-4 py-2 text-sm font-medium leading-5 text-teal-700 dark:text-teal-300 transition-colors duration-150 bg-teal-100 dark:bg-teal-900 border border-transparent rounded-lg hover:bg-teal-200 dark:hover:bg-teal-800 focus:outline-none">
|
||||
<span x-html="$icon('cursor-click', 'w-4 h-4 mr-2')"></span>
|
||||
Create from Prospect
|
||||
</a>
|
||||
@@ -48,92 +53,125 @@
|
||||
{{ error_state('Error loading sites') }}
|
||||
|
||||
<!-- Sites Table -->
|
||||
<div x-show="!loading && !error" class="w-full overflow-hidden rounded-lg shadow">
|
||||
<div class="w-full overflow-x-auto">
|
||||
<table class="w-full whitespace-nowrap">
|
||||
<thead>
|
||||
<tr class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800">
|
||||
<th class="px-4 py-3">Business</th>
|
||||
<th class="px-4 py-3">Status</th>
|
||||
<th class="px-4 py-3">Contact</th>
|
||||
<th class="px-4 py-3">Domain</th>
|
||||
<th class="px-4 py-3">Created</th>
|
||||
<th class="px-4 py-3">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
|
||||
<template x-for="s in sites" :key="s.id">
|
||||
<tr class="text-gray-700 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700">
|
||||
<td class="px-4 py-3">
|
||||
<div class="flex items-center text-sm">
|
||||
<div>
|
||||
<p class="font-semibold" x-text="s.business_name"></p>
|
||||
<p class="text-xs text-gray-600 dark:text-gray-400" x-text="s.contact_name || ''"></p>
|
||||
<div x-show="!loading && !error">
|
||||
{% call table_wrapper() %}
|
||||
{{ table_header(['Business', 'Status', 'Contact', 'Domain', 'Created', 'Actions']) }}
|
||||
<tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
|
||||
{{ table_empty_state(6, title='No hosted sites found', x_message="search || filterStatus ? 'Try adjusting your search or filters' : 'Create your first hosted site to get started'", show_condition='sites.length === 0', icon='globe') }}
|
||||
<template x-for="s in sites" :key="s.id">
|
||||
<tr class="text-gray-700 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors">
|
||||
<td class="px-4 py-3">
|
||||
<div class="flex items-center text-sm">
|
||||
<div class="relative hidden w-8 h-8 mr-3 rounded-full md:block">
|
||||
<div class="absolute inset-0 rounded-full bg-teal-100 dark:bg-teal-600 flex items-center justify-center">
|
||||
<span class="text-xs font-semibold text-teal-600 dark:text-teal-100"
|
||||
x-text="s.business_name?.charAt(0).toUpperCase() || '?'"></span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span class="px-2 py-1 text-xs font-semibold rounded-full"
|
||||
:class="statusBadgeClass(s.status)"
|
||||
x-text="s.status.replace('_', ' ')"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span x-text="s.contact_email || '—'" class="text-xs"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span x-text="s.live_domain || '—'" class="text-xs"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span x-text="new Date(s.created_at).toLocaleDateString()" class="text-xs"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<div>
|
||||
<p class="font-semibold" x-text="s.business_name"></p>
|
||||
<p class="text-xs text-gray-600 dark:text-gray-400" x-text="s.contact_name || ''"></p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span class="px-2.5 py-0.5 text-xs font-medium rounded-full"
|
||||
:class="statusBadgeClass(s.status)"
|
||||
x-text="s.status.replace('_', ' ')"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span x-text="s.contact_email || '—'" class="text-xs"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span x-text="s.live_domain || '—'" class="text-xs"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span x-text="new Date(s.created_at).toLocaleDateString()" class="text-xs"></span>
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<div class="flex items-center space-x-2 text-sm">
|
||||
<a :href="'/admin/hosting/sites/' + s.id"
|
||||
class="text-teal-600 hover:text-teal-900 dark:text-teal-400 dark:hover:text-teal-300">
|
||||
View
|
||||
class="flex items-center justify-center p-2 text-teal-600 rounded-lg hover:bg-teal-50 dark:text-teal-400 dark:hover:bg-gray-700 focus:outline-none transition-colors"
|
||||
title="View details">
|
||||
<span x-html="$icon('eye', 'w-5 h-5')"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{ table_empty('No hosted sites found') }}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
{% endcall %}
|
||||
|
||||
{{ pagination_controls() }}
|
||||
{{ pagination() }}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
<script>
|
||||
function hostingSitesList() {
|
||||
return {
|
||||
...data(),
|
||||
currentPage: 'hosting-sites',
|
||||
loading: true,
|
||||
error: false,
|
||||
error: null,
|
||||
sites: [],
|
||||
total: 0,
|
||||
page: 1,
|
||||
perPage: 20,
|
||||
pages: 0,
|
||||
search: '',
|
||||
filterStatus: '',
|
||||
async init() { await this.loadSites(); },
|
||||
pagination: { page: 1, per_page: 20, total: 0, pages: 0 },
|
||||
async init() {
|
||||
if (window.PlatformSettings) {
|
||||
this.pagination.per_page = await window.PlatformSettings.getRowsPerPage();
|
||||
}
|
||||
await this.loadSites();
|
||||
},
|
||||
async loadSites() {
|
||||
this.loading = true;
|
||||
this.error = false;
|
||||
this.error = null;
|
||||
try {
|
||||
const params = new URLSearchParams({ page: this.page, per_page: this.perPage });
|
||||
const params = new URLSearchParams({
|
||||
page: this.pagination.page,
|
||||
per_page: this.pagination.per_page,
|
||||
});
|
||||
if (this.search) params.set('search', this.search);
|
||||
if (this.filterStatus) params.set('status', this.filterStatus);
|
||||
const resp = await fetch('/api/admin/hosting/sites?' + params);
|
||||
if (!resp.ok) throw new Error('Failed to load');
|
||||
const data = await resp.json();
|
||||
this.sites = data.items;
|
||||
this.total = data.total;
|
||||
this.pages = data.pages;
|
||||
} catch (e) { this.error = true; }
|
||||
finally { this.loading = false; }
|
||||
const response = await apiClient.get('/admin/hosting/sites?' + params);
|
||||
this.sites = response.items || [];
|
||||
this.pagination.total = response.total || 0;
|
||||
this.pagination.pages = response.pages || 0;
|
||||
} catch (e) {
|
||||
this.error = e.message;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
goToPage(p) { this.page = p; this.loadSites(); },
|
||||
get startIndex() {
|
||||
if (this.pagination.total === 0) return 0;
|
||||
return (this.pagination.page - 1) * this.pagination.per_page + 1;
|
||||
},
|
||||
get endIndex() {
|
||||
const end = this.pagination.page * this.pagination.per_page;
|
||||
return end > this.pagination.total ? this.pagination.total : end;
|
||||
},
|
||||
get totalPages() { return this.pagination.pages; },
|
||||
get pageNumbers() {
|
||||
const pages = [];
|
||||
const total = this.totalPages;
|
||||
const current = this.pagination.page;
|
||||
if (total <= 7) { for (let i = 1; i <= total; i++) pages.push(i); return pages; }
|
||||
pages.push(1);
|
||||
if (current > 3) pages.push('...');
|
||||
for (let i = Math.max(2, current - 1); i <= Math.min(total - 1, current + 1); i++) pages.push(i);
|
||||
if (current < total - 2) pages.push('...');
|
||||
pages.push(total);
|
||||
return pages;
|
||||
},
|
||||
goToPage(page) {
|
||||
if (page === '...' || page < 1 || page > this.totalPages) return;
|
||||
this.pagination.page = page;
|
||||
this.loadSites();
|
||||
},
|
||||
nextPage() { if (this.pagination.page < this.totalPages) { this.pagination.page++; this.loadSites(); } },
|
||||
previousPage() { if (this.pagination.page > 1) { this.pagination.page--; this.loadSites(); } },
|
||||
statusBadgeClass(status) {
|
||||
const classes = {
|
||||
draft: 'text-gray-700 bg-gray-100 dark:text-gray-300 dark:bg-gray-700',
|
||||
|
||||
Reference in New Issue
Block a user