Making the code easier to read and more consistent.

This commit is contained in:
Scott Idem
2026-03-24 12:05:22 -04:00
parent 94849137f0
commit 9a75243d9c
29 changed files with 4096 additions and 2281 deletions

View File

@@ -4,6 +4,14 @@
"singleQuote": true, "singleQuote": true,
"trailingComma": "none", "trailingComma": "none",
"printWidth": 80, "printWidth": 80,
"plugins": ["prettier-plugin-svelte"], "bracketSameLine": true,
"svelteSortOrder": "options-scripts-markup-styles",
"svelteIndentScriptAndStyle": false,
"svelteAllowShorthand": true,
"plugins": [
"prettier-plugin-svelte",
"prettier-plugin-tailwindcss"
],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
} }

106
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "osit-aether-app-svelte", "name": "osit-aether-app-svelte",
"version": "3.12.08", "version": "3.00.05",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "osit-aether-app-svelte", "name": "osit-aether-app-svelte",
"version": "3.12.08", "version": "3.00.05",
"dependencies": { "dependencies": {
"@codemirror/autocomplete": "^6.20.0", "@codemirror/autocomplete": "^6.20.0",
"@codemirror/commands": "^6.10.0", "@codemirror/commands": "^6.10.0",
@@ -34,6 +34,7 @@
"lucide-svelte": "^0.*.0", "lucide-svelte": "^0.*.0",
"marked": "^17.0.0", "marked": "^17.0.0",
"openai": "^6.10.0", "openai": "^6.10.0",
"prettier-plugin-tailwindcss": "^0.7.2",
"qrcode": "^1.5.4", "qrcode": "^1.5.4",
"shadcn-svelte": "^1.0.11", "shadcn-svelte": "^1.0.11",
"svelte-persisted-store": "^0.12.0", "svelte-persisted-store": "^0.12.0",
@@ -6161,6 +6162,16 @@
} }
} }
}, },
"node_modules/postcss-load-config/node_modules/yaml": {
"version": "1.10.3",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.3.tgz",
"integrity": "sha512-vIYeF1u3CjlhAFekPPAk2h/Kv4T3mAkMox5OymRiJQB0spDP10LHvt+K7G9Ny6NuuMAb25/6n1qyUjAcGNf/AA==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">= 6"
}
},
"node_modules/postcss-safe-parser": { "node_modules/postcss-safe-parser": {
"version": "7.0.1", "version": "7.0.1",
"resolved": "https://registry.npmjs.org/postcss-safe-parser/-/postcss-safe-parser-7.0.1.tgz", "resolved": "https://registry.npmjs.org/postcss-safe-parser/-/postcss-safe-parser-7.0.1.tgz",
@@ -6242,7 +6253,6 @@
"version": "3.8.1", "version": "3.8.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz",
"integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==", "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==",
"dev": true,
"license": "MIT", "license": "MIT",
"bin": { "bin": {
"prettier": "bin/prettier.cjs" "prettier": "bin/prettier.cjs"
@@ -6258,13 +6268,91 @@
"version": "3.5.1", "version": "3.5.1",
"resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-3.5.1.tgz", "resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-3.5.1.tgz",
"integrity": "sha512-65+fr5+cgIKWKiqM1Doum4uX6bY8iFCdztvvp2RcF+AJoieaw9kJOFMNcJo/bkmKYsxFaM9OsVZK/gWauG/5mg==", "integrity": "sha512-65+fr5+cgIKWKiqM1Doum4uX6bY8iFCdztvvp2RcF+AJoieaw9kJOFMNcJo/bkmKYsxFaM9OsVZK/gWauG/5mg==",
"dev": true, "devOptional": true,
"license": "MIT", "license": "MIT",
"peerDependencies": { "peerDependencies": {
"prettier": "^3.0.0", "prettier": "^3.0.0",
"svelte": "^3.2.0 || ^4.0.0-next.0 || ^5.0.0-next.0" "svelte": "^3.2.0 || ^4.0.0-next.0 || ^5.0.0-next.0"
} }
}, },
"node_modules/prettier-plugin-tailwindcss": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.7.2.tgz",
"integrity": "sha512-LkphyK3Fw+q2HdMOoiEHWf93fNtYJwfamoKPl7UwtjFQdei/iIBoX11G6j706FzN3ymX9mPVi97qIY8328vdnA==",
"license": "MIT",
"engines": {
"node": ">=20.19"
},
"peerDependencies": {
"@ianvs/prettier-plugin-sort-imports": "*",
"@prettier/plugin-hermes": "*",
"@prettier/plugin-oxc": "*",
"@prettier/plugin-pug": "*",
"@shopify/prettier-plugin-liquid": "*",
"@trivago/prettier-plugin-sort-imports": "*",
"@zackad/prettier-plugin-twig": "*",
"prettier": "^3.0",
"prettier-plugin-astro": "*",
"prettier-plugin-css-order": "*",
"prettier-plugin-jsdoc": "*",
"prettier-plugin-marko": "*",
"prettier-plugin-multiline-arrays": "*",
"prettier-plugin-organize-attributes": "*",
"prettier-plugin-organize-imports": "*",
"prettier-plugin-sort-imports": "*",
"prettier-plugin-svelte": "*"
},
"peerDependenciesMeta": {
"@ianvs/prettier-plugin-sort-imports": {
"optional": true
},
"@prettier/plugin-hermes": {
"optional": true
},
"@prettier/plugin-oxc": {
"optional": true
},
"@prettier/plugin-pug": {
"optional": true
},
"@shopify/prettier-plugin-liquid": {
"optional": true
},
"@trivago/prettier-plugin-sort-imports": {
"optional": true
},
"@zackad/prettier-plugin-twig": {
"optional": true
},
"prettier-plugin-astro": {
"optional": true
},
"prettier-plugin-css-order": {
"optional": true
},
"prettier-plugin-jsdoc": {
"optional": true
},
"prettier-plugin-marko": {
"optional": true
},
"prettier-plugin-multiline-arrays": {
"optional": true
},
"prettier-plugin-organize-attributes": {
"optional": true
},
"prettier-plugin-organize-imports": {
"optional": true
},
"prettier-plugin-sort-imports": {
"optional": true
},
"prettier-plugin-svelte": {
"optional": true
}
}
},
"node_modules/proxy-compare": { "node_modules/proxy-compare": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/proxy-compare/-/proxy-compare-3.0.1.tgz", "resolved": "https://registry.npmjs.org/proxy-compare/-/proxy-compare-3.0.1.tgz",
@@ -7737,16 +7825,6 @@
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"license": "ISC" "license": "ISC"
}, },
"node_modules/yaml": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz",
"integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==",
"devOptional": true,
"license": "ISC",
"engines": {
"node": ">= 6"
}
},
"node_modules/yargs": { "node_modules/yargs": {
"version": "15.4.1", "version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",

View File

@@ -112,6 +112,7 @@
"lucide-svelte": "^0.*.0", "lucide-svelte": "^0.*.0",
"marked": "^17.0.0", "marked": "^17.0.0",
"openai": "^6.10.0", "openai": "^6.10.0",
"prettier-plugin-tailwindcss": "^0.7.2",
"qrcode": "^1.5.4", "qrcode": "^1.5.4",
"shadcn-svelte": "^1.0.11", "shadcn-svelte": "^1.0.11",
"svelte-persisted-store": "^0.12.0", "svelte-persisted-store": "^0.12.0",

View File

@@ -1,34 +1,47 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { ae_loc, ae_sess, ae_api, slct } from '$lib/stores/ae_stores'; import { ae_loc, ae_sess, ae_api, slct } from '$lib/stores/ae_stores';
import { Building, Globe, History, LayoutDashboard, List, Lock, MapPin, Phone, ShieldCheck, Users } from '@lucide/svelte'; import {
interface Props { Building,
data: any; Globe,
children?: import('svelte').Snippet; History,
} LayoutDashboard,
let { data, children }: Props = $props(); List,
Lock,
MapPin,
Phone,
ShieldCheck,
Users
} from '@lucide/svelte';
interface Props {
data: any;
children?: import('svelte').Snippet;
}
let { data, children }: Props = $props();
onMount(() => { onMount(() => {
if (!$ae_loc.manager_access) { if (!$ae_loc.manager_access) {
// Wait for a second to see if the permissions load before redirecting. // Wait for a second to see if the permissions load before redirecting.
setTimeout(() => { setTimeout(() => {
if (!$ae_loc.manager_access) { if (!$ae_loc.manager_access) {
console.log('Access Denied to /core. Redirecting to home.'); console.log('Access Denied to /core. Redirecting to home.');
goto('/'); goto('/');
} }
}, 500); }, 500);
} }
}); });
</script> </script>
<svelte:head> <svelte:head>
<title>Core - {$ae_loc.title ?? 'Æ loading...'}</title> <title>Core - {$ae_loc.title ?? 'Æ loading...'}</title>
</svelte:head> </svelte:head>
<div class="ae_core h-full max-h-full max-w-6xl overflow-auto flex flex-col gap-1 m-auto p-4"> <div
class="ae_core h-full max-h-full max-w-6xl overflow-auto flex flex-col gap-1 m-auto p-4">
{#if $ae_loc.manager_access} {#if $ae_loc.manager_access}
<nav class="flex flex-wrap gap-2 mb-6 border-b border-surface-500/30 pb-4"> <nav
class="flex flex-wrap gap-2 mb-6 border-b border-surface-500/30 pb-4">
<a href="/core" class="btn btn-sm preset-tonal-surface"> <a href="/core" class="btn btn-sm preset-tonal-surface">
<LayoutDashboard size={14} class="mr-1" /> Dashboard <LayoutDashboard size={14} class="mr-1" /> Dashboard
</a> </a>
@@ -44,7 +57,9 @@
<a href="/core/people" class="btn btn-sm preset-tonal-warning"> <a href="/core/people" class="btn btn-sm preset-tonal-warning">
<Users size={14} class="mr-1" /> People <Users size={14} class="mr-1" /> People
</a> </a>
<a href="/core/activity_logs" class="btn btn-sm preset-tonal-success"> <a
href="/core/activity_logs"
class="btn btn-sm preset-tonal-success">
<History size={14} class="mr-1" /> Logs <History size={14} class="mr-1" /> Logs
</a> </a>
<a href="/core/addresses" class="btn btn-sm preset-tonal-surface"> <a href="/core/addresses" class="btn btn-sm preset-tonal-surface">
@@ -62,14 +77,20 @@
{@render children?.()} {@render children?.()}
</section> </section>
{:else} {:else}
<section class="flex flex-col items-center justify-center grow text-center space-y-4 py-20"> <section
class="flex flex-col items-center justify-center grow text-center space-y-4 py-20">
<div class="p-6 bg-error-500/10 rounded-full"> <div class="p-6 bg-error-500/10 rounded-full">
<Lock size={64} class="text-error-500" /> <Lock size={64} class="text-error-500" />
</div> </div>
<h1 class="h1 font-black">Access Restricted</h1> <h1 class="h1 font-black">Access Restricted</h1>
<p class="max-w-md opacity-70">The area you are trying to access is reserved for system managers. If you believe you should have access, please sign in with an authorized account.</p> <p class="max-w-md opacity-70">
The area you are trying to access is reserved for system
managers. If you believe you should have access, please sign in
with an authorized account.
</p>
<div class="flex gap-4 pt-4"> <div class="flex gap-4 pt-4">
<a href="/" class="btn preset-filled-primary font-bold">Return Home</a> <a href="/" class="btn preset-filled-primary font-bold"
>Return Home</a>
</div> </div>
</section> </section>
{/if} {/if}

View File

@@ -1,161 +1,236 @@
<script lang="ts"> <script lang="ts">
import { Building, Globe, History, Landmark, LayoutDashboard, List, MapPin, Phone, ShieldCheck, Users } from '@lucide/svelte'; import {
import { ae_loc, slct } from '$lib/stores/ae_stores'; Building,
Globe,
History,
Landmark,
LayoutDashboard,
List,
MapPin,
Phone,
ShieldCheck,
Users
} from '@lucide/svelte';
import { ae_loc, slct } from '$lib/stores/ae_stores';
interface Props { interface Props {
data: any; data: any;
} }
let { data }: Props = $props(); let { data }: Props = $props();
// Quickly save the data passed from the parent(s) // Quickly save the data passed from the parent(s)
$effect(() => { $slct.account_id = data.account_id; }); $effect(() => {
$slct.account_id = data.account_id;
});
</script> </script>
<div class="container mx-auto p-4 space-y-8"> <div class="container mx-auto p-4 space-y-8">
<header class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-6 rounded-2xl shadow-xl border border-surface-500/10 gap-4"> <header
class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-6 rounded-2xl shadow-xl border border-surface-500/10 gap-4">
<div class="flex items-center gap-4"> <div class="flex items-center gap-4">
<div class="p-3 bg-primary-500/10 rounded-xl"> <div class="p-3 bg-primary-500/10 rounded-xl">
<LayoutDashboard size={32} class="text-primary-500" /> <LayoutDashboard size={32} class="text-primary-500" />
</div> </div>
<div> <div>
<h1 class="h2 font-black tracking-tight text-balance">Æ Core Management</h1> <h1 class="h2 font-black tracking-tight text-balance">
<p class="text-xs font-bold opacity-50 uppercase tracking-widest">System Infrastructure & Identity</p> Æ Core Management
</h1>
<p
class="text-xs font-bold opacity-50 uppercase tracking-widest">
System Infrastructure & Identity
</p>
</div> </div>
</div> </div>
<div class="bg-black/5 p-3 rounded-xl border border-surface-500/10 min-w-50"> <div
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1 mb-1"> class="bg-black/5 p-3 rounded-xl border border-surface-500/10 min-w-50">
<p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1 mb-1">
<Landmark size={10} /> Active Account <Landmark size={10} /> Active Account
</p> </p>
<p class="font-bold text-sm">{$ae_loc.account_name ?? 'Loading...'}</p> <p class="font-bold text-sm">
{$ae_loc.account_name ?? 'Loading...'}
</p>
</div> </div>
</header> </header>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6"> <div
class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
<!-- Account Management Card --> <!-- Account Management Card -->
<div class="card p-6 space-y-4 preset-tonal-primary shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between"> <div
class="card p-6 space-y-4 preset-tonal-primary shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between">
<div class="space-y-4"> <div class="space-y-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-primary-500/20 rounded-lg group-hover:scale-110 transition-transform"> <div
class="p-2 bg-primary-500/20 rounded-lg group-hover:scale-110 transition-transform">
<Building size={24} /> <Building size={24} />
</div> </div>
<h3 class="h4 font-black">Accounts</h3> <h3 class="h4 font-black">Accounts</h3>
</div> </div>
<p class="text-sm opacity-80 leading-relaxed">Manage client accounts and high-level system settings.</p> <p class="text-sm opacity-80 leading-relaxed">
Manage client accounts and high-level system settings.
</p>
</div> </div>
<a class="btn preset-filled-primary font-bold shadow-md w-full mt-4" href="/core/accounts"> <a
class="btn preset-filled-primary font-bold shadow-md w-full mt-4"
href="/core/accounts">
Manage Manage
</a> </a>
</div> </div>
<!-- Site Management Card --> <!-- Site Management Card -->
<div class="card p-6 space-y-4 preset-tonal-secondary shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between"> <div
class="card p-6 space-y-4 preset-tonal-secondary shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between">
<div class="space-y-4"> <div class="space-y-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-secondary-500/20 rounded-lg group-hover:scale-110 transition-transform"> <div
class="p-2 bg-secondary-500/20 rounded-lg group-hover:scale-110 transition-transform">
<Globe size={24} /> <Globe size={24} />
</div> </div>
<h3 class="h4 font-black">Sites</h3> <h3 class="h4 font-black">Sites</h3>
</div> </div>
<p class="text-sm opacity-80 leading-relaxed">Configure sites and domains associated with the active account.</p> <p class="text-sm opacity-80 leading-relaxed">
Configure sites and domains associated with the active
account.
</p>
</div> </div>
<a class="btn preset-filled-secondary font-bold shadow-md w-full mt-4" href="/core/sites"> <a
class="btn preset-filled-secondary font-bold shadow-md w-full mt-4"
href="/core/sites">
Manage Manage
</a> </a>
</div> </div>
<!-- User Management Card --> <!-- User Management Card -->
<div class="card p-6 space-y-4 preset-tonal-error shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between"> <div
class="card p-6 space-y-4 preset-tonal-error shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between">
<div class="space-y-4"> <div class="space-y-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-error-500/20 rounded-lg group-hover:scale-110 transition-transform"> <div
class="p-2 bg-error-500/20 rounded-lg group-hover:scale-110 transition-transform">
<ShieldCheck size={24} /> <ShieldCheck size={24} />
</div> </div>
<h3 class="h4 font-black">Users</h3> <h3 class="h4 font-black">Users</h3>
</div> </div>
<p class="text-sm opacity-80 leading-relaxed">Manage system access, permissions, and user credentials.</p> <p class="text-sm opacity-80 leading-relaxed">
Manage system access, permissions, and user credentials.
</p>
</div> </div>
<a class="btn preset-filled-error font-bold shadow-md w-full mt-4" href="/core/users"> <a
class="btn preset-filled-error font-bold shadow-md w-full mt-4"
href="/core/users">
Manage Manage
</a> </a>
</div> </div>
<!-- Person Management Card --> <!-- Person Management Card -->
<div class="card p-6 space-y-4 preset-tonal-warning shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between"> <div
class="card p-6 space-y-4 preset-tonal-warning shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between">
<div class="space-y-4"> <div class="space-y-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-warning-500/20 rounded-lg group-hover:scale-110 transition-transform"> <div
class="p-2 bg-warning-500/20 rounded-lg group-hover:scale-110 transition-transform">
<Users size={24} /> <Users size={24} />
</div> </div>
<h3 class="h4 font-black">People</h3> <h3 class="h4 font-black">People</h3>
</div> </div>
<p class="text-sm opacity-80 leading-relaxed">Search and manage person records and their user linking.</p> <p class="text-sm opacity-80 leading-relaxed">
Search and manage person records and their user linking.
</p>
</div> </div>
<a class="btn preset-filled-warning font-bold shadow-md w-full mt-4" href="/core/people"> <a
class="btn preset-filled-warning font-bold shadow-md w-full mt-4"
href="/core/people">
Manage Manage
</a> </a>
</div> </div>
<!-- Address Management Card --> <!-- Address Management Card -->
<div class="card p-6 space-y-4 preset-tonal-surface shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between border border-surface-500/10"> <div
class="card p-6 space-y-4 preset-tonal-surface shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between border border-surface-500/10">
<div class="space-y-4"> <div class="space-y-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-surface-500/20 rounded-lg group-hover:scale-110 transition-transform"> <div
class="p-2 bg-surface-500/20 rounded-lg group-hover:scale-110 transition-transform">
<MapPin size={24} /> <MapPin size={24} />
</div> </div>
<h3 class="h4 font-black">Addresses</h3> <h3 class="h4 font-black">Addresses</h3>
</div> </div>
<p class="text-sm opacity-80 leading-relaxed">Manage physical locations, shipping, and billing addresses.</p> <p class="text-sm opacity-80 leading-relaxed">
Manage physical locations, shipping, and billing addresses.
</p>
</div> </div>
<a class="btn preset-filled-surface font-bold shadow-md w-full mt-4" href="/core/addresses"> <a
class="btn preset-filled-surface font-bold shadow-md w-full mt-4"
href="/core/addresses">
Manage Manage
</a> </a>
</div> </div>
<!-- Contact Management Card --> <!-- Contact Management Card -->
<div class="card p-6 space-y-4 preset-tonal-surface shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between border border-surface-500/10"> <div
class="card p-6 space-y-4 preset-tonal-surface shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between border border-surface-500/10">
<div class="space-y-4"> <div class="space-y-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-surface-500/20 rounded-lg group-hover:scale-110 transition-transform"> <div
class="p-2 bg-surface-500/20 rounded-lg group-hover:scale-110 transition-transform">
<Phone size={24} /> <Phone size={24} />
</div> </div>
<h3 class="h4 font-black">Contacts</h3> <h3 class="h4 font-black">Contacts</h3>
</div> </div>
<p class="text-sm opacity-80 leading-relaxed">Maintain support contacts, office numbers, and digital links.</p> <p class="text-sm opacity-80 leading-relaxed">
Maintain support contacts, office numbers, and digital
links.
</p>
</div> </div>
<a class="btn preset-filled-surface font-bold shadow-md w-full mt-4" href="/core/contacts"> <a
class="btn preset-filled-surface font-bold shadow-md w-full mt-4"
href="/core/contacts">
Manage Manage
</a> </a>
</div> </div>
<!-- Activity Log Card --> <!-- Activity Log Card -->
<div class="card p-6 space-y-4 preset-tonal-success shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between"> <div
class="card p-6 space-y-4 preset-tonal-success shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between">
<div class="space-y-4"> <div class="space-y-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-success-500/20 rounded-lg group-hover:scale-110 transition-transform"> <div
class="p-2 bg-success-500/20 rounded-lg group-hover:scale-110 transition-transform">
<History size={24} /> <History size={24} />
</div> </div>
<h3 class="h4 font-black">Activity Logs</h3> <h3 class="h4 font-black">Activity Logs</h3>
</div> </div>
<p class="text-sm opacity-80 leading-relaxed">Monitor system actions and historical changes for the account.</p> <p class="text-sm opacity-80 leading-relaxed">
Monitor system actions and historical changes for the
account.
</p>
</div> </div>
<a class="btn preset-filled-success font-bold shadow-md w-full mt-4" href="/core/activity_logs"> <a
class="btn preset-filled-success font-bold shadow-md w-full mt-4"
href="/core/activity_logs">
View Logs View Logs
</a> </a>
</div> </div>
<!-- Lookups Card --> <!-- Lookups Card -->
<div class="card p-6 space-y-4 preset-tonal-surface shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between border border-surface-500/10"> <div
class="card p-6 space-y-4 preset-tonal-surface shadow-lg hover:brightness-110 transition-all group flex flex-col justify-between border border-surface-500/10">
<div class="space-y-4"> <div class="space-y-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-surface-500/20 rounded-lg group-hover:scale-110 transition-transform"> <div
class="p-2 bg-surface-500/20 rounded-lg group-hover:scale-110 transition-transform">
<List size={24} /> <List size={24} />
</div> </div>
<h3 class="h4 font-black">Lookups</h3> <h3 class="h4 font-black">Lookups</h3>
</div> </div>
<p class="text-sm opacity-80 leading-relaxed">View system lookup tables (countries, time zones, etc).</p> <p class="text-sm opacity-80 leading-relaxed">
View system lookup tables (countries, time zones, etc).
</p>
</div> </div>
<a class="btn preset-filled-surface font-bold shadow-md w-full mt-4" href="/core/lookups"> <a
class="btn preset-filled-surface font-bold shadow-md w-full mt-4"
href="/core/lookups">
View View
</a> </a>
</div> </div>

View File

@@ -1,96 +1,125 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { load_ae_obj_li__account, create_ae_obj__account } from '$lib/ae_core/ae_core__account'; import {
import { ae_api, ae_loc, slct } from '$lib/stores/ae_stores'; load_ae_obj_li__account,
import { goto } from '$app/navigation'; create_ae_obj__account
import { Building, Calendar, ExternalLink, FileText, ListFilter, Plus, RefreshCcw, Search, ShieldCheck, X } from '@lucide/svelte'; } from '$lib/ae_core/ae_core__account';
let account_li: any[] = $state([]); import { ae_api, ae_loc, slct } from '$lib/stores/ae_stores';
let loading = $state(true); import { goto } from '$app/navigation';
let qry_enabled = $state('all'); import {
let qry_hidden = $state('all'); Building,
let qry_str = $state(''); Calendar,
ExternalLink,
FileText,
ListFilter,
Plus,
RefreshCcw,
Search,
ShieldCheck,
X
} from '@lucide/svelte';
let account_li: any[] = $state([]);
let loading = $state(true);
let qry_enabled = $state('all');
let qry_hidden = $state('all');
let qry_str = $state('');
let filtered_li = $derived( let filtered_li = $derived(
qry_str qry_str
? account_li.filter(a => ? account_li.filter(
a.name?.toLowerCase().includes(qry_str.toLowerCase()) || (a) =>
a.code?.toLowerCase().includes(qry_str.toLowerCase()) a.name?.toLowerCase().includes(qry_str.toLowerCase()) ||
) a.code?.toLowerCase().includes(qry_str.toLowerCase())
: account_li )
); : account_li
);
async function load_accounts() { async function load_accounts() {
loading = true; loading = true;
account_li = await load_ae_obj_li__account({ account_li = await load_ae_obj_li__account({
api_cfg: $ae_api, api_cfg: $ae_api,
enabled: qry_enabled as any, enabled: qry_enabled as any,
hidden: qry_hidden as any, hidden: qry_hidden as any,
log_lvl: 1 log_lvl: 1
}); });
loading = false; loading = false;
} }
onMount(() => { onMount(() => {
load_accounts(); load_accounts();
});
async function handle_add_account() {
const name = prompt('Enter new account name:');
if (!name) return;
const code = prompt('Enter account code (optional):');
const new_acct = await create_ae_obj__account({
api_cfg: $ae_api,
data_kv: {
name,
code: code || undefined,
enable: true
},
log_lvl: 1
}); });
async function handle_add_account() { if (new_acct) {
const name = prompt('Enter new account name:'); load_accounts();
if (!name) return;
const code = prompt('Enter account code (optional):');
const new_acct = await create_ae_obj__account({
api_cfg: $ae_api,
data_kv: {
name,
code: code || undefined,
enable: true
},
log_lvl: 1
});
if (new_acct) {
load_accounts();
}
} }
}
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10 gap-4"> <header
class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10 gap-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-primary-500/10 rounded-lg"> <div class="p-2 bg-primary-500/10 rounded-lg">
<Building size={24} class="text-primary-500" /> <Building size={24} class="text-primary-500" />
</div> </div>
<div> <div>
<h1 class="h2 font-black tracking-tight">Account Management</h1> <h1 class="h2 font-black tracking-tight">Account Management</h1>
<p class="text-xs font-bold opacity-50 uppercase tracking-widest">Client Entities & Billing</p> <p
class="text-xs font-bold opacity-50 uppercase tracking-widest">
Client Entities & Billing
</p>
</div> </div>
</div> </div>
<button class="btn btn-sm preset-filled-primary font-bold shadow-lg" onclick={handle_add_account}> <button
class="btn btn-sm preset-filled-primary font-bold shadow-lg"
onclick={handle_add_account}>
<Plus size={16} class="mr-2" /> Add Account <Plus size={16} class="mr-2" /> Add Account
</button> </button>
</header> </header>
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-4"> <div
class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-4">
<div class="flex flex-wrap gap-6 items-end"> <div class="flex flex-wrap gap-6 items-end">
<div class="flex-1 min-w-[280px] space-y-1"> <div class="flex-1 min-w-[280px] space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Search Accounts</span> <span
<div class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all"> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
<div class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20"> >Search Accounts</span>
<div
class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all">
<div
class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20">
<Search size={18} class="opacity-50" /> <Search size={18} class="opacity-50" />
</div> </div>
<input <input
class="bg-transparent border-0 ring-0 focus:ring-0 p-3 grow placeholder:opacity-50" class="bg-transparent border-0 ring-0 focus:ring-0 p-3 grow placeholder:opacity-50"
type="search" type="search"
bind:value={qry_str} bind:value={qry_str}
placeholder="Search by name or code..." placeholder="Search by name or code..." />
/> <button
<button class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]" onclick={load_accounts} disabled={loading}> class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]"
onclick={load_accounts}
disabled={loading}>
{#if loading} {#if loading}
<span class="animate-spin text-xl"></span> <span class="animate-spin text-xl"></span>
{:else} {:else}
<span class="whitespace-nowrap tracking-wide">Refresh</span> <span class="whitespace-nowrap tracking-wide"
>Refresh</span>
{/if} {/if}
</button> </button>
</div> </div>
@@ -98,8 +127,13 @@
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Status</span> <span
<select class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2" bind:value={qry_enabled} onchange={load_accounts}> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Status</span>
<select
class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2"
bind:value={qry_enabled}
onchange={load_accounts}>
<option value="all">All Statuses</option> <option value="all">All Statuses</option>
<option value="enabled">Enabled Only</option> <option value="enabled">Enabled Only</option>
<option value="not_enabled">Disabled Only</option> <option value="not_enabled">Disabled Only</option>
@@ -107,8 +141,13 @@
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Visibility</span> <span
<select class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2" bind:value={qry_hidden} onchange={load_accounts}> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Visibility</span>
<select
class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2"
bind:value={qry_hidden}
onchange={load_accounts}>
<option value="all">All Visibility</option> <option value="all">All Visibility</option>
<option value="not_hidden">Not Hidden Only</option> <option value="not_hidden">Not Hidden Only</option>
<option value="hidden">Hidden Only</option> <option value="hidden">Hidden Only</option>
@@ -120,56 +159,87 @@
{#if loading} {#if loading}
<div class="card p-8 flex justify-center items-center h-64"> <div class="card p-8 flex justify-center items-center h-64">
<div class="placeholder animate-pulse w-full h-full rounded-2xl"></div> <div class="placeholder animate-pulse w-full h-full rounded-2xl">
</div>
</div> </div>
{:else if filtered_li.length === 0} {:else if filtered_li.length === 0}
<div class="card p-12 text-center preset-tonal-surface border-2 border-dashed border-surface-500/20 rounded-2xl"> <div
class="card p-12 text-center preset-tonal-surface border-2 border-dashed border-surface-500/20 rounded-2xl">
<Building size={48} class="mx-auto mb-4 opacity-20" /> <Building size={48} class="mx-auto mb-4 opacity-20" />
<h3 class="h3 font-bold opacity-50">No Accounts Found</h3> <h3 class="h3 font-bold opacity-50">No Accounts Found</h3>
<p class="opacity-60 max-w-xs mx-auto mt-2">Try adjusting your filters or add a new client account.</p> <p class="opacity-60 max-w-xs mx-auto mt-2">
Try adjusting your filters or add a new client account.
</p>
</div> </div>
{:else} {:else}
<div class="card p-6 preset-tonal-surface shadow-xl border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 mb-6 flex items-center gap-2"> class="card p-6 preset-tonal-surface shadow-xl border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 mb-6 flex items-center gap-2">
<ListFilter size={18} class="text-secondary-500" /> <ListFilter size={18} class="text-secondary-500" />
Directory Results Directory Results
<span class="badge preset-tonal-secondary ml-auto">{filtered_li.length} found</span> <span class="badge preset-tonal-secondary ml-auto"
>{filtered_li.length} found</span>
</h3> </h3>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{#each filtered_li as acct (acct.account_id_random)} {#each filtered_li as acct (acct.account_id_random)}
<div class="card p-5 space-y-4 preset-tonal-surface shadow-md border border-surface-500/10 hover:border-primary-500/30 transition-all group relative"> <div
class="card p-5 space-y-4 preset-tonal-surface shadow-md border border-surface-500/10 hover:border-primary-500/30 transition-all group relative">
<div class="absolute top-4 right-4 flex gap-1"> <div class="absolute top-4 right-4 flex gap-1">
{#if acct.hide} {#if acct.hide}
<span class="badge preset-filled-warning text-[8px] uppercase font-bold shadow-sm">Hidden</span> <span
class="badge preset-filled-warning text-[8px] uppercase font-bold shadow-sm"
>Hidden</span>
{/if} {/if}
<span class="badge {acct.enable ? 'preset-filled-success' : 'preset-filled-error'} text-[8px] uppercase font-bold shadow-sm"> <span
class="badge {acct.enable
? 'preset-filled-success'
: 'preset-filled-error'} text-[8px] uppercase font-bold shadow-sm">
{acct.enable ? 'Active' : 'Disabled'} {acct.enable ? 'Active' : 'Disabled'}
</span> </span>
</div> </div>
<header class="flex items-center gap-3"> <header class="flex items-center gap-3">
<div class="avatar preset-filled-primary w-12 h-12 flex items-center justify-center rounded-lg shadow-inner group-hover:scale-110 transition-transform"> <div
class="avatar preset-filled-primary w-12 h-12 flex items-center justify-center rounded-lg shadow-inner group-hover:scale-110 transition-transform">
<Building size={24} /> <Building size={24} />
</div> </div>
<div class="pr-12"> <div class="pr-12">
<p class="font-black tracking-tight truncate">{acct.name}</p> <p class="font-black tracking-tight truncate">
<p class="text-[10px] uppercase font-bold opacity-50 font-mono tracking-tighter">Code: {acct.code || '--'}</p> {acct.name}
</p>
<p
class="text-[10px] uppercase font-bold opacity-50 font-mono tracking-tighter">
Code: {acct.code || '--'}
</p>
</div> </div>
</header> </header>
<div class="space-y-2 text-xs opacity-70"> <div class="space-y-2 text-xs opacity-70">
<div class="flex items-center gap-2 bg-black/5 p-2 rounded-lg"> <div
<Calendar size={14} class="text-primary-500 shrink-0" /> class="flex items-center gap-2 bg-black/5 p-2 rounded-lg">
<span>Created: {new Date(acct.created_on).toLocaleDateString()}</span> <Calendar
size={14}
class="text-primary-500 shrink-0" />
<span
>Created: {new Date(
acct.created_on
).toLocaleDateString()}</span>
</div> </div>
<div class="flex items-center gap-2 bg-black/5 p-2 rounded-lg"> <div
<ShieldCheck size={14} class="text-secondary-500 shrink-0" /> class="flex items-center gap-2 bg-black/5 p-2 rounded-lg">
<span class="font-mono truncate">{acct.account_id_random}</span> <ShieldCheck
size={14}
class="text-secondary-500 shrink-0" />
<span class="font-mono truncate"
>{acct.account_id_random}</span>
</div> </div>
</div> </div>
<a class="btn btn-sm preset-filled-primary font-bold w-full shadow-lg group-hover:brightness-110 transition-all" href="/core/accounts/{acct.account_id_random}"> <a
class="btn btn-sm preset-filled-primary font-bold w-full shadow-lg group-hover:brightness-110 transition-all"
href="/core/accounts/{acct.account_id_random}">
Manage Account Manage Account
</a> </a>
</div> </div>

View File

@@ -1,91 +1,114 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { page } from '$app/stores'; import { page } from '$app/stores';
import { load_ae_obj_id__account, update_ae_obj__account, delete_ae_obj_id__account } from '$lib/ae_core/ae_core__account'; import {
import { editable_fields__account } from '$lib/ae_core/ae_core__account.editable_fields'; load_ae_obj_id__account,
import { ae_api, ae_loc } from '$lib/stores/ae_stores'; update_ae_obj__account,
import { goto } from '$app/navigation'; delete_ae_obj_id__account
import { Activity, ArrowLeft, Building, Info, Save, Settings, Trash2 } from '@lucide/svelte'; } from '$lib/ae_core/ae_core__account';
let account_id = $derived($page.params.account_id ?? ''); import { editable_fields__account } from '$lib/ae_core/ae_core__account.editable_fields';
let account: any = $state(null); import { ae_api, ae_loc } from '$lib/stores/ae_stores';
let loading = $state(true); import { goto } from '$app/navigation';
let saving = $state(false); import {
Activity,
ArrowLeft,
Building,
Info,
Save,
Settings,
Trash2
} from '@lucide/svelte';
let account_id = $derived($page.params.account_id ?? '');
let account: any = $state(null);
let loading = $state(true);
let saving = $state(false);
async function load_account() { async function load_account() {
loading = true; loading = true;
account = await load_ae_obj_id__account({ account = await load_ae_obj_id__account({
api_cfg: $ae_api, api_cfg: $ae_api,
account_id, account_id,
log_lvl: 1 log_lvl: 1
}); });
loading = false; loading = false;
}
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
return;
} }
load_account();
});
onMount(() => { async function handle_save() {
if (!$ae_loc.manager_access) { saving = true;
goto('/core'); // Filter fields to only include editable ones
return; const data_kv: any = {};
editable_fields__account.forEach((field) => {
if (account[field] !== undefined) {
data_kv[field] = account[field];
} }
load_account();
}); });
async function handle_save() { const result = await update_ae_obj__account({
saving = true; api_cfg: $ae_api,
// Filter fields to only include editable ones account_id,
const data_kv: any = {}; data_kv,
editable_fields__account.forEach(field => { log_lvl: 1
if (account[field] !== undefined) { });
data_kv[field] = account[field];
}
});
const result = await update_ae_obj__account({ if (result) {
api_cfg: $ae_api, alert('Account updated successfully');
account_id,
data_kv,
log_lvl: 1
});
if (result) {
alert('Account updated successfully');
}
saving = false;
} }
saving = false;
}
async function handle_delete() { async function handle_delete() {
if (!confirm('Are you sure you want to disable this account?')) return; if (!confirm('Are you sure you want to disable this account?')) return;
const result = await delete_ae_obj_id__account({ const result = await delete_ae_obj_id__account({
api_cfg: $ae_api, api_cfg: $ae_api,
account_id, account_id,
method: 'disable', method: 'disable',
log_lvl: 1 log_lvl: 1
}); });
if (result) { if (result) {
goto('/core/accounts'); goto('/core/accounts');
}
} }
}
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10"> <header
class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10">
<div class="flex items-center gap-4"> <div class="flex items-center gap-4">
<a class="btn btn-sm preset-tonal-surface shadow-sm" href="/core/accounts"> <a
class="btn btn-sm preset-tonal-surface shadow-sm"
href="/core/accounts">
<ArrowLeft size={16} /> <ArrowLeft size={16} />
</a> </a>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<div class="p-2 bg-primary-500/10 rounded-lg"> <div class="p-2 bg-primary-500/10 rounded-lg">
<Building size={24} class="text-primary-500" /> <Building size={24} class="text-primary-500" />
</div> </div>
<h1 class="h2 font-black tracking-tight">{account?.name ?? 'Loading...'}</h1> <h1 class="h2 font-black tracking-tight">
{account?.name ?? 'Loading...'}
</h1>
</div> </div>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
<button class="btn btn-sm preset-filled-error font-bold shadow-lg" onclick={handle_delete} disabled={loading || saving}> <button
class="btn btn-sm preset-filled-error font-bold shadow-lg"
onclick={handle_delete}
disabled={loading || saving}>
<Trash2 size={16} class="mr-2" /> Disable <Trash2 size={16} class="mr-2" /> Disable
</button> </button>
<button class="btn btn-sm preset-filled-primary font-bold shadow-lg" onclick={handle_save} disabled={loading || saving}> <button
class="btn btn-sm preset-filled-primary font-bold shadow-lg"
onclick={handle_save}
disabled={loading || saving}>
{#if saving} {#if saving}
<span class="animate-spin mr-2"></span> <span class="animate-spin mr-2"></span>
{:else} {:else}
@@ -98,70 +121,129 @@
{#if loading} {#if loading}
<div class="card p-8 flex justify-center items-center h-64"> <div class="card p-8 flex justify-center items-center h-64">
<div class="placeholder animate-pulse w-full h-full rounded-2xl"></div> <div class="placeholder animate-pulse w-full h-full rounded-2xl">
</div>
</div> </div>
{:else if account} {:else if account}
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Info size={18} class="text-primary-500" /> Basic Information <Info size={18} class="text-primary-500" /> Basic Information
</h3> </h3>
<div class="space-y-4"> <div class="space-y-4">
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Account Name</span> <span
<input class="input preset-filled-surface rounded-lg p-3" type="text" bind:value={account.name} /> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Account Name</span>
<input
class="input preset-filled-surface rounded-lg p-3"
type="text"
bind:value={account.name} />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Short Name</span> <span
<input class="input preset-filled-surface rounded-lg p-3" type="text" bind:value={account.short_name} /> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Short Name</span>
<input
class="input preset-filled-surface rounded-lg p-3"
type="text"
bind:value={account.short_name} />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Account Code</span> <span
<input class="input preset-filled-surface rounded-lg font-mono p-3" type="text" bind:value={account.code} /> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Account Code</span>
<input
class="input preset-filled-surface rounded-lg font-mono p-3"
type="text"
bind:value={account.code} />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Description</span> <span
<textarea class="textarea preset-filled-surface rounded-lg p-3" rows="3" bind:value={account.description}></textarea> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Description</span>
<textarea
class="textarea preset-filled-surface rounded-lg p-3"
rows="3"
bind:value={account.description}></textarea>
</div> </div>
</div> </div>
</div> </div>
<div class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Settings size={18} class="text-secondary-500" /> Settings & Status <Settings size={18} class="text-secondary-500" /> Settings & Status
</h3> </h3>
<div class="flex flex-col gap-4 py-2"> <div class="flex flex-col gap-4 py-2">
<label class="flex items-center space-x-3 cursor-pointer group"> <label
<input class="checkbox" type="checkbox" bind:checked={account.enable} /> class="flex items-center space-x-3 cursor-pointer group">
<span class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity">Enabled</span> <input
class="checkbox"
type="checkbox"
bind:checked={account.enable} />
<span
class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity"
>Enabled</span>
</label> </label>
<label class="flex items-center space-x-3 cursor-pointer group"> <label
<input class="checkbox" type="checkbox" bind:checked={account.hide} /> class="flex items-center space-x-3 cursor-pointer group">
<span class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity">Hidden</span> <input
class="checkbox"
type="checkbox"
bind:checked={account.hide} />
<span
class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity"
>Hidden</span>
</label> </label>
<label class="flex items-center space-x-3 cursor-pointer group"> <label
<input class="checkbox" type="checkbox" bind:checked={account.priority} /> class="flex items-center space-x-3 cursor-pointer group">
<span class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity">Priority Account</span> <input
class="checkbox"
type="checkbox"
bind:checked={account.priority} />
<span
class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity"
>Priority Account</span>
</label> </label>
</div> </div>
<div class="space-y-4 border-t border-surface-500/30 pt-4"> <div class="space-y-4 border-t border-surface-500/30 pt-4">
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Group</span> <span
<input class="input preset-filled-surface rounded-lg p-3" type="text" bind:value={account.group} /> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Group</span>
<input
class="input preset-filled-surface rounded-lg p-3"
type="text"
bind:value={account.group} />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Sort Order</span> <span
<input class="input preset-filled-surface rounded-lg p-3" type="number" bind:value={account.sort} /> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Sort Order</span>
<input
class="input preset-filled-surface rounded-lg p-3"
type="number"
bind:value={account.sort} />
</div> </div>
</div> </div>
</div> </div>
<div class="card p-6 space-y-4 md:col-span-2 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 space-y-4 md:col-span-2 shadow-xl preset-tonal-surface border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Activity size={18} class="text-tertiary-500" /> Internal Notes <Activity size={18} class="text-tertiary-500" /> Internal Notes
</h3> </h3>
<div class="space-y-1"> <div class="space-y-1">
<textarea class="textarea preset-filled-surface rounded-lg p-3" rows="4" bind:value={account.notes} placeholder="Private notes for staff..."></textarea> <textarea
class="textarea preset-filled-surface rounded-lg p-3"
rows="4"
bind:value={account.notes}
placeholder="Private notes for staff..."></textarea>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,64 +1,82 @@
<script lang="ts"> <script lang="ts">
/** @type {import('./$types').PageData} */ /** @type {import('./$types').PageData} */
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { qry__activity_log } from '$lib/ae_core/ae_core__activity_log'; import { qry__activity_log } from '$lib/ae_core/ae_core__activity_log';
import { ae_api, ae_loc } from '$lib/stores/ae_stores'; import { ae_api, ae_loc } from '$lib/stores/ae_stores';
import { Activity, Calendar, Clock, History, ListFilter, RefreshCcw, Search, ShieldCheck, Tag, User } from '@lucide/svelte'; import {
import { ae_util } from '$lib/ae_utils/ae_utils'; Activity,
Calendar,
Clock,
History,
ListFilter,
RefreshCcw,
Search,
ShieldCheck,
Tag,
User
} from '@lucide/svelte';
import { ae_util } from '$lib/ae_utils/ae_utils';
// State // State
let log_li: any[] = $state([]); let log_li: any[] = $state([]);
let loading = $state(true); let loading = $state(true);
let qry_str = $state(''); let qry_str = $state('');
let limit = $state(50); let limit = $state(50);
/** /**
* Fetches activity logs from the API based on current filters. * Fetches activity logs from the API based on current filters.
*/ */
async function load_logs() { async function load_logs() {
if (!$ae_loc.account_id) return; if (!$ae_loc.account_id) return;
loading = true; loading = true;
const results = await qry__activity_log({ const results = await qry__activity_log({
api_cfg: $ae_api, api_cfg: $ae_api,
account_id: $ae_loc.account_id, account_id: $ae_loc.account_id,
qry_str: qry_str || undefined, qry_str: qry_str || undefined,
enabled: 'all', enabled: 'all',
hidden: 'all', hidden: 'all',
limit: limit, limit: limit,
log_lvl: 1 log_lvl: 1
});
log_li = results || [];
loading = false;
}
onMount(() => {
load_logs();
}); });
/** log_li = results || [];
* Handles the search form submission. loading = false;
*/ }
function handle_search(e: Event) {
e.preventDefault(); onMount(() => {
load_logs(); load_logs();
} });
/**
* Handles the search form submission.
*/
function handle_search(e: Event) {
e.preventDefault();
load_logs();
}
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10 gap-4"> <header
class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10 gap-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-primary-500/10 rounded-lg"> <div class="p-2 bg-primary-500/10 rounded-lg">
<History size={24} class="text-primary-500" /> <History size={24} class="text-primary-500" />
</div> </div>
<div> <div>
<h1 class="h2 font-black tracking-tight">Activity Logs</h1> <h1 class="h2 font-black tracking-tight">Activity Logs</h1>
<p class="text-xs font-bold opacity-50 uppercase tracking-widest">Audit Trail & History</p> <p
class="text-xs font-bold opacity-50 uppercase tracking-widest">
Audit Trail & History
</p>
</div> </div>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
<button class="btn btn-sm preset-filled-primary font-bold shadow-lg" onclick={load_logs} disabled={loading}> <button
class="btn btn-sm preset-filled-primary font-bold shadow-lg"
onclick={load_logs}
disabled={loading}>
{#if loading} {#if loading}
<RefreshCcw size={16} class="mr-2 animate-spin" /> Updating... <RefreshCcw size={16} class="mr-2 animate-spin" /> Updating...
{:else} {:else}
@@ -69,29 +87,43 @@
</header> </header>
<!-- Filter Bar --> <!-- Filter Bar -->
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-4"> <div
class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-4">
<div class="flex flex-wrap gap-6 items-end"> <div class="flex flex-wrap gap-6 items-end">
<div class="flex-1 min-w-[280px] space-y-1"> <div class="flex-1 min-w-[280px] space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Search Keywords</span> <span
<form onsubmit={handle_search} class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all"> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
<div class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20"> >Search Keywords</span>
<form
onsubmit={handle_search}
class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all">
<div
class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20">
<Search size={18} class="opacity-50" /> <Search size={18} class="opacity-50" />
</div> </div>
<input <input
class="bg-transparent border-0 ring-0 focus:ring-0 p-3 grow placeholder:opacity-50" class="bg-transparent border-0 ring-0 focus:ring-0 p-3 grow placeholder:opacity-50"
type="search" type="search"
bind:value={qry_str} bind:value={qry_str}
placeholder="Action, name, description..." placeholder="Action, name, description..." />
/> <button
<button type="submit" class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]" disabled={loading}> type="submit"
<span class="whitespace-nowrap tracking-wide">Search</span> class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]"
disabled={loading}>
<span class="whitespace-nowrap tracking-wide"
>Search</span>
</button> </button>
</form> </form>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Display Limit</span> <span
<select class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2" bind:value={limit} onchange={load_logs}> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Display Limit</span>
<select
class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2"
bind:value={limit}
onchange={load_logs}>
<option value={25}>Latest 25</option> <option value={25}>Latest 25</option>
<option value={50}>Latest 50</option> <option value={50}>Latest 50</option>
<option value={100}>Latest 100</option> <option value={100}>Latest 100</option>
@@ -103,26 +135,34 @@
{#if loading} {#if loading}
<div class="card p-8 flex justify-center items-center h-64"> <div class="card p-8 flex justify-center items-center h-64">
<div class="placeholder animate-pulse w-full h-full rounded-2xl"></div> <div class="placeholder animate-pulse w-full h-full rounded-2xl">
</div>
</div> </div>
{:else if log_li.length === 0} {:else if log_li.length === 0}
<div class="card p-12 text-center preset-tonal-surface border-2 border-dashed border-surface-500/20 rounded-2xl"> <div
class="card p-12 text-center preset-tonal-surface border-2 border-dashed border-surface-500/20 rounded-2xl">
<Activity size={48} class="mx-auto mb-4 opacity-20" /> <Activity size={48} class="mx-auto mb-4 opacity-20" />
<h3 class="h3 font-bold opacity-50">No Logs Found</h3> <h3 class="h3 font-bold opacity-50">No Logs Found</h3>
<p class="opacity-60 max-w-xs mx-auto mt-2">Try broadening your search or check another account.</p> <p class="opacity-60 max-w-xs mx-auto mt-2">
Try broadening your search or check another account.
</p>
</div> </div>
{:else} {:else}
<div class="card p-6 preset-tonal-surface shadow-xl border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 mb-6 flex items-center gap-2"> class="card p-6 preset-tonal-surface shadow-xl border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 mb-6 flex items-center gap-2">
<ListFilter size={18} class="text-secondary-500" /> <ListFilter size={18} class="text-secondary-500" />
System Events System Events
<span class="badge preset-tonal-secondary ml-auto">{log_li.length} entries shown</span> <span class="badge preset-tonal-secondary ml-auto"
>{log_li.length} entries shown</span>
</h3> </h3>
<div class="table-container"> <div class="table-container">
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr class="uppercase text-[10px] tracking-widest opacity-60"> <tr
class="uppercase text-[10px] tracking-widest opacity-60">
<th>Timestamp</th> <th>Timestamp</th>
<th>Identity</th> <th>Identity</th>
<th>Action</th> <th>Action</th>
@@ -136,11 +176,22 @@
<!-- Date/Time --> <!-- Date/Time -->
<td class="whitespace-nowrap"> <td class="whitespace-nowrap">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<Calendar size={14} class="opacity-40" /> <Calendar
size={14}
class="opacity-40" />
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-bold">{ae_util.iso_datetime_formatter(log.created_on, 'date_short')}</span> <span class="font-bold"
<span class="text-[10px] opacity-50 flex items-center gap-1"> >{ae_util.iso_datetime_formatter(
<Clock size={10} /> {ae_util.iso_datetime_formatter(log.created_on, 'time_12_short')} log.created_on,
'date_short'
)}</span>
<span
class="text-[10px] opacity-50 flex items-center gap-1">
<Clock size={10} />
{ae_util.iso_datetime_formatter(
log.created_on,
'time_12_short'
)}
</span> </span>
</div> </div>
</div> </div>
@@ -149,17 +200,28 @@
<!-- User/Person --> <!-- User/Person -->
<td> <td>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<div class="avatar preset-tonal-surface w-8 h-8 flex items-center justify-center rounded-full shadow-inner"> <div
<User size={14} class="opacity-60" /> class="avatar preset-tonal-surface w-8 h-8 flex items-center justify-center rounded-full shadow-inner">
<User
size={14}
class="opacity-60" />
</div> </div>
<div class="flex flex-col max-w-[180px]"> <div
class="flex flex-col max-w-[180px]">
{#if log.person_full_name || log.person_id_random} {#if log.person_full_name || log.person_id_random}
<span class="font-bold truncate">{log.person_full_name || 'Person'}</span> <span class="font-bold truncate"
<span class="text-[9px] opacity-40 font-mono uppercase">ID: {log.person_id_random || '--'}</span> >{log.person_full_name ||
'Person'}</span>
<span
class="text-[9px] opacity-40 font-mono uppercase"
>ID: {log.person_id_random ||
'--'}</span>
{:else if log.name} {:else if log.name}
<span class="italic opacity-70">{log.name}</span> <span class="italic opacity-70"
>{log.name}</span>
{:else} {:else}
<span class="opacity-30 italic">Unknown</span> <span class="opacity-30 italic"
>Unknown</span>
{/if} {/if}
</div> </div>
</div> </div>
@@ -168,11 +230,13 @@
<!-- Action --> <!-- Action -->
<td> <td>
<div class="flex flex-col gap-1"> <div class="flex flex-col gap-1">
<span class="badge preset-filled-surface text-[9px] font-black tracking-tighter uppercase px-2"> <span
class="badge preset-filled-surface text-[9px] font-black tracking-tighter uppercase px-2">
{log.action} {log.action}
</span> </span>
{#if log.action_with} {#if log.action_with}
<span class="text-[9px] opacity-40 font-bold uppercase ml-1 flex items-center gap-1"> <span
class="text-[9px] opacity-40 font-bold uppercase ml-1 flex items-center gap-1">
<ShieldCheck size={8} /> via {log.action_with} <ShieldCheck size={8} /> via {log.action_with}
</span> </span>
{/if} {/if}
@@ -182,17 +246,26 @@
<!-- Context --> <!-- Context -->
<td> <td>
{#if log.object_type} {#if log.object_type}
<div class="flex items-center gap-2 bg-black/5 p-2 rounded-lg border border-surface-500/10"> <div
<Tag size={12} class="text-secondary-500 shrink-0" /> class="flex items-center gap-2 bg-black/5 p-2 rounded-lg border border-surface-500/10">
<div class="flex flex-col text-[10px] truncate"> <Tag
<span class="font-bold uppercase tracking-tighter">{log.object_type}</span> size={12}
class="text-secondary-500 shrink-0" />
<div
class="flex flex-col text-[10px] truncate">
<span
class="font-bold uppercase tracking-tighter"
>{log.object_type}</span>
{#if log.external_client_id} {#if log.external_client_id}
<span class="opacity-40 font-mono truncate">{log.external_client_id}</span> <span
class="opacity-40 font-mono truncate"
>{log.external_client_id}</span>
{/if} {/if}
</div> </div>
</div> </div>
{:else} {:else}
<span class="opacity-20 italic text-xs">--</span> <span class="opacity-20 italic text-xs"
>--</span>
{/if} {/if}
</td> </td>
@@ -200,13 +273,21 @@
<td> <td>
<div class="flex flex-col gap-1 max-w-sm"> <div class="flex flex-col gap-1 max-w-sm">
{#if log.summary} {#if log.summary}
<span class="font-bold text-primary-500 leading-tight">{log.summary}</span> <span
class="font-bold text-primary-500 leading-tight"
>{log.summary}</span>
{/if} {/if}
{#if log.description} {#if log.description}
<p class="text-xs opacity-60 line-clamp-2 italic" title={log.description}>{log.description}</p> <p
class="text-xs opacity-60 line-clamp-2 italic"
title={log.description}>
{log.description}
</p>
{/if} {/if}
{#if !log.summary && !log.description} {#if !log.summary && !log.description}
<span class="italic opacity-20 text-[10px]">No detail record</span> <span
class="italic opacity-20 text-[10px]"
>No detail record</span>
{/if} {/if}
</div> </div>
</td> </td>

View File

@@ -1,50 +1,69 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { ae_loc, ae_api, slct } from '$lib/stores/ae_stores'; import { ae_loc, ae_api, slct } from '$lib/stores/ae_stores';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { Building2, ExternalLink, Globe, ListFilter, MapPin, MapPinned, Plus, Search, X } from '@lucide/svelte'; import {
import { load_ae_obj_li__address, create_ae_obj__address } from '$lib/ae_core/ae_core__address'; Building2,
import Address_form from './ae_comp__address_form.svelte'; ExternalLink,
Globe,
ListFilter,
MapPin,
MapPinned,
Plus,
Search,
X
} from '@lucide/svelte';
import {
load_ae_obj_li__address,
create_ae_obj__address
} from '$lib/ae_core/ae_core__address';
import Address_form from './ae_comp__address_form.svelte';
let address_li: any[] = $state([]); let address_li: any[] = $state([]);
let loading = $state(true); let loading = $state(true);
let show_add_form = $state(false); let show_add_form = $state(false);
let qry_str = $state(''); let qry_str = $state('');
let filtered_li: any[] = $derived( let filtered_li: any[] = $derived(
qry_str qry_str
? address_li.filter(a => ? address_li.filter(
a.city?.toLowerCase().includes(qry_str.toLowerCase()) || (a) =>
a.state_province?.toLowerCase().includes(qry_str.toLowerCase()) || a.city?.toLowerCase().includes(qry_str.toLowerCase()) ||
a.organization_name?.toLowerCase().includes(qry_str.toLowerCase()) || a.state_province
a.line_1?.toLowerCase().includes(qry_str.toLowerCase()) ?.toLowerCase()
) .includes(qry_str.toLowerCase()) ||
: address_li a.organization_name
); ?.toLowerCase()
.includes(qry_str.toLowerCase()) ||
a.line_1?.toLowerCase().includes(qry_str.toLowerCase())
)
: address_li
);
async function load_addresses() { async function load_addresses() {
if (!$ae_loc.account_id) return; if (!$ae_loc.account_id) return;
loading = true; loading = true;
address_li = await load_ae_obj_li__address({ address_li = await load_ae_obj_li__address({
api_cfg: $ae_api, api_cfg: $ae_api,
for_obj_id: $ae_loc.account_id, for_obj_id: $ae_loc.account_id,
enabled: 'all', enabled: 'all',
hidden: 'all', hidden: 'all',
log_lvl: 1 log_lvl: 1
});
loading = false;
}
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
return;
}
load_addresses();
}); });
loading = false;
}
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
return;
}
load_addresses();
});
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10"> <header
class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<div class="p-2 bg-primary-500/10 rounded-lg"> <div class="p-2 bg-primary-500/10 rounded-lg">
<MapPin size={24} class="text-primary-500" /> <MapPin size={24} class="text-primary-500" />
@@ -53,8 +72,7 @@
</div> </div>
<button <button
class="btn btn-sm preset-filled-primary font-bold shadow-lg" class="btn btn-sm preset-filled-primary font-bold shadow-lg"
onclick={() => show_add_form = !show_add_form} onclick={() => (show_add_form = !show_add_form)}>
>
{#if show_add_form} {#if show_add_form}
<X size={16} class="mr-2" /> Cancel <X size={16} class="mr-2" /> Cancel
{:else} {:else}
@@ -73,29 +91,36 @@
goto(`/core/addresses/${new_addr.address_id_random}`); goto(`/core/addresses/${new_addr.address_id_random}`);
} }
}} }}
onCancel={() => show_add_form = false} onCancel={() => (show_add_form = false)} />
/>
</div> </div>
{/if} {/if}
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10">
<div class="max-w-2xl space-y-1"> <div class="max-w-2xl space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Search Directory</span> <span
<div class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all"> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
<div class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20"> >Search Directory</span>
<div
class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all">
<div
class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20">
<Search size={18} class="opacity-50" /> <Search size={18} class="opacity-50" />
</div> </div>
<input <input
class="bg-transparent border-0 ring-0 focus:ring-0 p-3 grow placeholder:opacity-50" class="bg-transparent border-0 ring-0 focus:ring-0 p-3 grow placeholder:opacity-50"
type="search" type="search"
bind:value={qry_str} bind:value={qry_str}
placeholder="Search by city, state, organization, or street..." placeholder="Search by city, state, organization, or street..." />
/> <button
<button class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]" onclick={load_addresses} disabled={loading}> class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]"
onclick={load_addresses}
disabled={loading}>
{#if loading} {#if loading}
<span class="animate-spin text-xl"></span> <span class="animate-spin text-xl"></span>
{:else} {:else}
<span class="whitespace-nowrap tracking-wide">Refresh</span> <span class="whitespace-nowrap tracking-wide"
>Refresh</span>
{/if} {/if}
</button> </button>
</div> </div>
@@ -104,55 +129,84 @@
{#if loading} {#if loading}
<div class="card p-8 flex justify-center items-center h-64"> <div class="card p-8 flex justify-center items-center h-64">
<div class="placeholder animate-pulse w-full h-full rounded-2xl"></div> <div class="placeholder animate-pulse w-full h-full rounded-2xl">
</div>
</div> </div>
{:else if filtered_li.length === 0} {:else if filtered_li.length === 0}
<div class="card p-12 text-center preset-tonal-surface border-2 border-dashed border-surface-500/20 rounded-2xl"> <div
class="card p-12 text-center preset-tonal-surface border-2 border-dashed border-surface-500/20 rounded-2xl">
<MapPinned size={48} class="mx-auto mb-4 opacity-20" /> <MapPinned size={48} class="mx-auto mb-4 opacity-20" />
<h3 class="h3 font-bold opacity-50">No Addresses Found</h3> <h3 class="h3 font-bold opacity-50">No Addresses Found</h3>
<p class="opacity-60 max-w-xs mx-auto mt-2">Addresses associated with this account will appear here.</p> <p class="opacity-60 max-w-xs mx-auto mt-2">
Addresses associated with this account will appear here.
</p>
</div> </div>
{:else} {:else}
<div class="card p-6 preset-tonal-surface shadow-xl border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 mb-6 flex items-center gap-2"> class="card p-6 preset-tonal-surface shadow-xl border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 mb-6 flex items-center gap-2">
<ListFilter size={18} class="text-secondary-500" /> <ListFilter size={18} class="text-secondary-500" />
Linked Addresses Linked Addresses
<span class="badge preset-tonal-secondary ml-auto">{filtered_li.length} entries</span> <span class="badge preset-tonal-secondary ml-auto"
>{filtered_li.length} entries</span>
</h3> </h3>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{#each filtered_li as addr (addr.address_id_random)} {#each filtered_li as addr (addr.address_id_random)}
<div class="card p-5 space-y-4 preset-tonal-surface shadow-md border border-surface-500/10 hover:border-primary-500/30 transition-all group relative"> <div
class="card p-5 space-y-4 preset-tonal-surface shadow-md border border-surface-500/10 hover:border-primary-500/30 transition-all group relative">
<div class="absolute top-4 right-4"> <div class="absolute top-4 right-4">
<span class="badge {addr.enable ? 'preset-filled-success' : 'preset-filled-error'} text-[8px] uppercase font-bold shadow-sm"> <span
class="badge {addr.enable
? 'preset-filled-success'
: 'preset-filled-error'} text-[8px] uppercase font-bold shadow-sm">
{addr.enable ? 'Active' : 'Disabled'} {addr.enable ? 'Active' : 'Disabled'}
</span> </span>
</div> </div>
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="avatar preset-filled-primary w-10 h-10 flex items-center justify-center rounded-lg shadow-inner group-hover:scale-110 transition-transform"> <div
class="avatar preset-filled-primary w-10 h-10 flex items-center justify-center rounded-lg shadow-inner group-hover:scale-110 transition-transform">
<MapPin size={20} /> <MapPin size={20} />
</div> </div>
<div class="pr-12"> <div class="pr-12">
<p class="font-black tracking-tight truncate">{addr.city || '--'}</p> <p class="font-black tracking-tight truncate">
<p class="text-[10px] uppercase font-bold opacity-50 truncate">{addr.state_province || '--'}</p> {addr.city || '--'}
</p>
<p
class="text-[10px] uppercase font-bold opacity-50 truncate">
{addr.state_province || '--'}
</p>
</div> </div>
</div> </div>
<div class="space-y-2 text-xs opacity-70"> <div class="space-y-2 text-xs opacity-70">
{#if addr.organization_name} {#if addr.organization_name}
<div class="flex items-center gap-2 bg-black/5 p-2 rounded-lg"> <div
<Building2 size={14} class="text-primary-500 shrink-0" /> class="flex items-center gap-2 bg-black/5 p-2 rounded-lg">
<span class="truncate">{addr.organization_name}</span> <Building2
size={14}
class="text-primary-500 shrink-0" />
<span class="truncate"
>{addr.organization_name}</span>
</div> </div>
{/if} {/if}
<div class="flex items-center gap-2 bg-black/5 p-2 rounded-lg"> <div
<Globe size={14} class="text-secondary-500 shrink-0" /> class="flex items-center gap-2 bg-black/5 p-2 rounded-lg">
<span class="truncate font-mono">{addr.country_name || addr.country || '--'}</span> <Globe
size={14}
class="text-secondary-500 shrink-0" />
<span class="truncate font-mono"
>{addr.country_name ||
addr.country ||
'--'}</span>
</div> </div>
</div> </div>
<a class="btn btn-sm preset-filled-primary font-bold w-full shadow-lg group-hover:brightness-110 transition-all" href="/core/addresses/{addr.address_id_random}"> <a
class="btn btn-sm preset-filled-primary font-bold w-full shadow-lg group-hover:brightness-110 transition-all"
href="/core/addresses/{addr.address_id_random}">
View Details View Details
</a> </a>
</div> </div>

View File

@@ -1,56 +1,74 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { page } from '$app/stores'; import { page } from '$app/stores';
import { import {
load_ae_obj_id__address, load_ae_obj_id__address,
update_ae_obj__address, update_ae_obj__address,
delete_ae_obj_id__address delete_ae_obj_id__address
} from '$lib/ae_core/ae_core__address'; } from '$lib/ae_core/ae_core__address';
import { editable_fields__address } from '$lib/ae_core/ae_core__address.editable_fields'; import { editable_fields__address } from '$lib/ae_core/ae_core__address.editable_fields';
import { ae_api, ae_loc } from '$lib/stores/ae_stores'; import { ae_api, ae_loc } from '$lib/stores/ae_stores';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { Activity, ArrowLeft, Building2, Clock, Edit, Eye, Globe, Info, MapPin, MapPinned, Save, ShieldCheck, Trash2, User } from '@lucide/svelte'; import {
import Address_form from '../ae_comp__address_form.svelte'; Activity,
ArrowLeft,
Building2,
Clock,
Edit,
Eye,
Globe,
Info,
MapPin,
MapPinned,
Save,
ShieldCheck,
Trash2,
User
} from '@lucide/svelte';
import Address_form from '../ae_comp__address_form.svelte';
let address_id = $derived($page.params.address_id ?? ''); let address_id = $derived($page.params.address_id ?? '');
let address: any = $state(null); let address: any = $state(null);
let loading = $state(true); let loading = $state(true);
let is_editing = $state(false); let is_editing = $state(false);
async function load_data() { async function load_data() {
loading = true; loading = true;
address = await load_ae_obj_id__address({ address = await load_ae_obj_id__address({
api_cfg: $ae_api, api_cfg: $ae_api,
address_id, address_id,
log_lvl: 1 log_lvl: 1
});
loading = false;
}
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
return;
}
load_data();
}); });
loading = false;
}
async function handle_delete() { onMount(() => {
if (!confirm('Permanently delete this address?')) return; if (!$ae_loc.manager_access) {
await delete_ae_obj_id__address({ goto('/core');
api_cfg: $ae_api, return;
address_id,
method: 'delete',
log_lvl: 1
});
goto('/core/addresses');
} }
load_data();
});
async function handle_delete() {
if (!confirm('Permanently delete this address?')) return;
await delete_ae_obj_id__address({
api_cfg: $ae_api,
address_id,
method: 'delete',
log_lvl: 1
});
goto('/core/addresses');
}
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10 gap-4"> <header
class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10 gap-4">
<div class="flex items-center gap-4"> <div class="flex items-center gap-4">
<a class="btn btn-sm preset-tonal-surface shadow-sm" href="/core/addresses"> <a
class="btn btn-sm preset-tonal-surface shadow-sm"
href="/core/addresses">
<ArrowLeft size={16} /> <ArrowLeft size={16} />
</a> </a>
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
@@ -58,20 +76,33 @@
<MapPin size={24} class="text-primary-500" /> <MapPin size={24} class="text-primary-500" />
</div> </div>
<div> <div>
<h1 class="h2 font-black tracking-tight">{address ? `${address.city}, ${address.state_province}` : 'Loading...'}</h1> <h1 class="h2 font-black tracking-tight">
<p class="text-xs font-bold opacity-50 uppercase tracking-widest">Address Detail</p> {address
? `${address.city}, ${address.state_province}`
: 'Loading...'}
</h1>
<p
class="text-xs font-bold opacity-50 uppercase tracking-widest">
Address Detail
</p>
</div> </div>
</div> </div>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
<button class="btn btn-sm preset-tonal-secondary font-bold shadow-sm" onclick={() => is_editing = !is_editing} disabled={loading}> <button
class="btn btn-sm preset-tonal-secondary font-bold shadow-sm"
onclick={() => (is_editing = !is_editing)}
disabled={loading}>
{#if is_editing} {#if is_editing}
<Eye size={16} class="mr-2" /> View Mode <Eye size={16} class="mr-2" /> View Mode
{:else} {:else}
<Edit size={16} class="mr-2" /> Edit Mode <Edit size={16} class="mr-2" /> Edit Mode
{/if} {/if}
</button> </button>
<button class="btn btn-sm preset-tonal-error font-bold shadow-sm" onclick={handle_delete} disabled={loading}> <button
class="btn btn-sm preset-tonal-error font-bold shadow-sm"
onclick={handle_delete}
disabled={loading}>
<Trash2 size={16} class="mr-2" /> Delete <Trash2 size={16} class="mr-2" /> Delete
</button> </button>
</div> </div>
@@ -79,7 +110,8 @@
{#if loading} {#if loading}
<div class="card p-8 flex justify-center items-center h-64"> <div class="card p-8 flex justify-center items-center h-64">
<div class="placeholder animate-pulse w-full h-full rounded-2xl"></div> <div class="placeholder animate-pulse w-full h-full rounded-2xl">
</div>
</div> </div>
{:else if address} {:else if address}
{#if is_editing} {#if is_editing}
@@ -90,77 +122,120 @@
address = updated; address = updated;
is_editing = false; is_editing = false;
}} }}
onCancel={() => is_editing = false} onCancel={() => (is_editing = false)} />
/>
</div> </div>
{:else} {:else}
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 animate-fade-in"> <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 animate-fade-in">
<div class="lg:col-span-2 space-y-6"> <div class="lg:col-span-2 space-y-6">
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<MapPinned size={20} class="text-primary-500" /> <MapPinned size={20} class="text-primary-500" />
Location Information Location Information
</h3> </h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="space-y-1"> <div class="space-y-1">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<User size={10} /> Attention To <User size={10} /> Attention To
</p> </p>
<p class="font-bold">{address.attention_to || '--'}</p> <p class="font-bold">
{address.attention_to || '--'}
</p>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<Building2 size={10} /> Organization <Building2 size={10} /> Organization
</p> </p>
<p class="font-bold">{address.organization_name || '--'}</p> <p class="font-bold">
{address.organization_name || '--'}
</p>
</div> </div>
<div class="md:col-span-2 space-y-1 bg-black/5 p-4 rounded-xl border border-surface-500/10"> <div
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest">Street Address</p> class="md:col-span-2 space-y-1 bg-black/5 p-4 rounded-xl border border-surface-500/10">
<p
class="text-[10px] opacity-60 uppercase font-black tracking-widest">
Street Address
</p>
<div class="space-y-1 mt-1"> <div class="space-y-1 mt-1">
<p class="text-lg font-black tracking-tight leading-tight">{address.line_1}</p> <p
{#if address.line_2}<p class="text-lg font-black tracking-tight leading-tight opacity-75">{address.line_2}</p>{/if} class="text-lg font-black tracking-tight leading-tight">
{#if address.line_3}<p class="text-lg font-black tracking-tight leading-tight opacity-50">{address.line_3}</p>{/if} {address.line_1}
</p>
{#if address.line_2}<p
class="text-lg font-black tracking-tight leading-tight opacity-75">
{address.line_2}
</p>{/if}
{#if address.line_3}<p
class="text-lg font-black tracking-tight leading-tight opacity-50">
{address.line_3}
</p>{/if}
</div> </div>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<MapPin size={10} /> City, State/Province <MapPin size={10} /> City, State/Province
</p> </p>
<p class="font-bold">{address.city}, {address.state_province || '--'}</p> <p class="font-bold">
{address.city}, {address.state_province ||
'--'}
</p>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<Globe size={10} /> Postal Code / Country <Globe size={10} /> Postal Code / Country
</p> </p>
<p class="font-bold">{address.postal_code || '--'} / <span class="badge preset-tonal-surface">{address.country_name || address.country || '--'}</span></p> <p class="font-bold">
{address.postal_code || '--'} /
<span class="badge preset-tonal-surface"
>{address.country_name ||
address.country ||
'--'}</span>
</p>
</div> </div>
</div> </div>
</div> </div>
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Activity size={20} class="text-secondary-500" /> <Activity size={20} class="text-secondary-500" />
Technical Details Technical Details
</h3> </h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="space-y-1"> <div class="space-y-1">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<Clock size={10} /> Timezone <Clock size={10} /> Timezone
</p> </p>
<p class="font-mono">{address.timezone || '--'}</p> <p class="font-mono">
{address.timezone || '--'}
</p>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<MapPin size={10} /> Coordinates <MapPin size={10} /> Coordinates
</p> </p>
<p class="font-mono">{address.latitude || '--'}, {address.longitude || '--'}</p> <p class="font-mono">
{address.latitude || '--'}, {address.longitude ||
'--'}
</p>
</div> </div>
<div class="md:col-span-2 space-y-2"> <div class="md:col-span-2 space-y-2">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<Info size={10} /> Internal Notes <Info size={10} /> Internal Notes
</p> </p>
<div class="p-4 bg-black/5 rounded-xl border border-dashed border-surface-500/20 italic opacity-80 min-h-[80px]"> <div
{address.notes || 'No internal notes provided for this address.'} class="p-4 bg-black/5 rounded-xl border border-dashed border-surface-500/20 italic opacity-80 min-h-[80px]">
{address.notes ||
'No internal notes provided for this address.'}
</div> </div>
</div> </div>
</div> </div>
@@ -168,40 +243,77 @@
</div> </div>
<div class="space-y-6"> <div class="space-y-6">
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<ShieldCheck size={20} class="text-warning-500" /> <ShieldCheck size={20} class="text-warning-500" />
Visibility & Status Visibility & Status
</h3> </h3>
<div class="space-y-4"> <div class="space-y-4">
<div class="flex justify-between items-center p-3 bg-black/5 rounded-lg"> <div
<span class="text-sm font-bold opacity-75">Enabled</span> class="flex justify-between items-center p-3 bg-black/5 rounded-lg">
<span class="badge {address.enable ? 'preset-filled-success' : 'preset-filled-error'} px-4 py-1 shadow-sm"> <span class="text-sm font-bold opacity-75"
>Enabled</span>
<span
class="badge {address.enable
? 'preset-filled-success'
: 'preset-filled-error'} px-4 py-1 shadow-sm">
{address.enable ? 'ACTIVE' : 'DISABLED'} {address.enable ? 'ACTIVE' : 'DISABLED'}
</span> </span>
</div> </div>
<div class="flex justify-between items-center p-3 bg-black/5 rounded-lg"> <div
<span class="text-sm font-bold opacity-75">Hidden</span> class="flex justify-between items-center p-3 bg-black/5 rounded-lg">
<span class="badge {address.hide ? 'preset-filled-warning' : 'preset-filled-surface'} px-4 py-1 shadow-sm"> <span class="text-sm font-bold opacity-75"
>Hidden</span>
<span
class="badge {address.hide
? 'preset-filled-warning'
: 'preset-filled-surface'} px-4 py-1 shadow-sm">
{address.hide ? 'YES' : 'NO'} {address.hide ? 'YES' : 'NO'}
</span> </span>
</div> </div>
<div class="flex justify-between items-center p-3 bg-black/5 rounded-lg"> <div
<span class="text-sm font-bold opacity-75">Priority</span> class="flex justify-between items-center p-3 bg-black/5 rounded-lg">
<span class="badge {address.priority ? 'preset-filled-secondary' : 'preset-filled-surface'} px-4 py-1 shadow-sm"> <span class="text-sm font-bold opacity-75"
>Priority</span>
<span
class="badge {address.priority
? 'preset-filled-secondary'
: 'preset-filled-surface'} px-4 py-1 shadow-sm">
{address.priority ? 'YES' : 'NO'} {address.priority ? 'YES' : 'NO'}
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<div class="card p-5 preset-tonal-surface shadow-inner border border-surface-500/10 space-y-3"> <div
<p class="text-[10px] uppercase font-black opacity-40 tracking-widest border-b border-surface-500/20 pb-1">System Audit</p> class="card p-5 preset-tonal-surface shadow-inner border border-surface-500/10 space-y-3">
<p
class="text-[10px] uppercase font-black opacity-40 tracking-widest border-b border-surface-500/20 pb-1">
System Audit
</p>
<div class="space-y-2 text-[10px] font-mono opacity-60"> <div class="space-y-2 text-[10px] font-mono opacity-60">
<p class="flex justify-between"><span>ID:</span> <span class="text-primary-500 font-bold">{address.address_id_random}</span></p> <p class="flex justify-between">
<p class="flex justify-between"><span>Created:</span> <span>{new Date(address.created_on).toLocaleString()}</span></p> <span>ID:</span>
<span class="text-primary-500 font-bold"
>{address.address_id_random}</span>
</p>
<p class="flex justify-between">
<span>Created:</span>
<span
>{new Date(
address.created_on
).toLocaleString()}</span>
</p>
{#if address.updated_on} {#if address.updated_on}
<p class="flex justify-between"><span>Updated:</span> <span>{new Date(address.updated_on).toLocaleString()}</span></p> <p class="flex justify-between">
<span>Updated:</span>
<span
>{new Date(
address.updated_on
).toLocaleString()}</span>
</p>
{/if} {/if}
</div> </div>
</div> </div>

View File

@@ -1,128 +1,140 @@
<script lang="ts"> <script lang="ts">
/** /**
* Address Form Component * Address Form Component
* Standardized 2026-01-09 for Core UI Polish. * Standardized 2026-01-09 for Core UI Polish.
* Uses unified ae_Address type and Svelte 5 Runes. * Uses unified ae_Address type and Svelte 5 Runes.
*/ */
import { ae_api, ae_loc } from '$lib/stores/ae_stores'; import { ae_api, ae_loc } from '$lib/stores/ae_stores';
import { update_ae_obj__address, create_ae_obj__address } from '$lib/ae_core/ae_core__address'; import {
import type { ae_Address } from '$lib/types/ae_types'; update_ae_obj__address,
import { Clock, Globe, MapPin, Navigation, Save, X } from '@lucide/svelte'; create_ae_obj__address
interface Props { } from '$lib/ae_core/ae_core__address';
address?: ae_Address | null; import type { ae_Address } from '$lib/types/ae_types';
onSave?: (address: ae_Address) => void; import { Clock, Globe, MapPin, Navigation, Save, X } from '@lucide/svelte';
onCancel?: () => void; interface Props {
} address?: ae_Address | null;
onSave?: (address: ae_Address) => void;
onCancel?: () => void;
}
let { address = null, onSave, onCancel }: Props = $props(); let { address = null, onSave, onCancel }: Props = $props();
// Form State (Runes) // Form State (Runes)
let formData = $state({ let formData = $state({
attention_to: '', attention_to: '',
organization_name: '', organization_name: '',
line_1: '', line_1: '',
line_2: '', line_2: '',
line_3: '', line_3: '',
city: '', city: '',
state_province: '', state_province: '',
postal_code: '', postal_code: '',
country: '', country: '',
timezone: '', timezone: '',
latitude: '', latitude: '',
longitude: '', longitude: '',
notes: '', notes: '',
enable: true, enable: true,
hide: false, hide: false,
priority: false priority: false
}); });
// Reset form when address prop changes // Reset form when address prop changes
$effect(() => { $effect(() => {
formData.attention_to = address?.attention_to ?? ''; formData.attention_to = address?.attention_to ?? '';
formData.organization_name = address?.organization_name ?? ''; formData.organization_name = address?.organization_name ?? '';
formData.line_1 = address?.line_1 ?? ''; formData.line_1 = address?.line_1 ?? '';
formData.line_2 = address?.line_2 ?? ''; formData.line_2 = address?.line_2 ?? '';
formData.line_3 = address?.line_3 ?? ''; formData.line_3 = address?.line_3 ?? '';
formData.city = address?.city ?? ''; formData.city = address?.city ?? '';
formData.state_province = address?.state_province ?? ''; formData.state_province = address?.state_province ?? '';
formData.postal_code = address?.postal_code ?? ''; formData.postal_code = address?.postal_code ?? '';
formData.country = address?.country ?? ''; formData.country = address?.country ?? '';
formData.timezone = address?.timezone ?? ''; formData.timezone = address?.timezone ?? '';
formData.latitude = address?.latitude ?? ''; formData.latitude = address?.latitude ?? '';
formData.longitude = address?.longitude ?? ''; formData.longitude = address?.longitude ?? '';
formData.notes = address?.notes ?? ''; formData.notes = address?.notes ?? '';
formData.enable = address?.enable ?? true; formData.enable = address?.enable ?? true;
formData.hide = address?.hide ?? false; formData.hide = address?.hide ?? false;
formData.priority = address?.priority ?? false; formData.priority = address?.priority ?? false;
}); });
let is_loading = $state(false); let is_loading = $state(false);
let error_msg = $state(''); let error_msg = $state('');
async function handleSubmit(event: Event) { async function handleSubmit(event: Event) {
event.preventDefault(); event.preventDefault();
is_loading = true; is_loading = true;
error_msg = ''; error_msg = '';
// Surgical Payload // Surgical Payload
const payload: any = { ...formData }; const payload: any = { ...formData };
for (const key in payload) { for (const key in payload) {
if (typeof payload[key] === 'string' && payload[key].trim() === '') { if (typeof payload[key] === 'string' && payload[key].trim() === '') {
// line_1 and city are likely required, but we'll trim them // line_1 and city are likely required, but we'll trim them
if (key === 'line_1' || key === 'city') { if (key === 'line_1' || key === 'city') {
payload[key] = payload[key].trim(); payload[key] = payload[key].trim();
} else { } else {
payload[key] = null; payload[key] = null;
}
} }
} }
try {
let result;
if (address?.address_id_random) {
// Update existing
result = await update_ae_obj__address({
api_cfg: $ae_api,
address_id: address.address_id_random,
data_kv: payload,
log_lvl: 1
});
} else {
// Create new
result = await create_ae_obj__address({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: payload,
log_lvl: 1
});
}
if (result) {
if (onSave) onSave(result);
} else {
error_msg = 'Failed to save address record.';
}
} catch (err: any) {
error_msg = err.message || 'An error occurred while saving.';
} finally {
is_loading = false;
}
} }
try {
let result;
if (address?.address_id_random) {
// Update existing
result = await update_ae_obj__address({
api_cfg: $ae_api,
address_id: address.address_id_random,
data_kv: payload,
log_lvl: 1
});
} else {
// Create new
result = await create_ae_obj__address({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: payload,
log_lvl: 1
});
}
if (result) {
if (onSave) onSave(result);
} else {
error_msg = 'Failed to save address record.';
}
} catch (err: any) {
error_msg = err.message || 'An error occurred while saving.';
} finally {
is_loading = false;
}
}
</script> </script>
<form onsubmit={handleSubmit} class="card p-6 space-y-6 shadow-xl preset-tonal-surface"> <form
<header class="flex justify-between items-center border-b border-surface-500/30 pb-4"> onsubmit={handleSubmit}
class="card p-6 space-y-6 shadow-xl preset-tonal-surface">
<header
class="flex justify-between items-center border-b border-surface-500/30 pb-4">
<h3 class="h3 flex items-center gap-2"> <h3 class="h3 flex items-center gap-2">
<MapPin size={24} /> <MapPin size={24} />
{address ? 'Edit Address' : 'Create New Address'} {address ? 'Edit Address' : 'Create New Address'}
</h3> </h3>
<div class="flex gap-2"> <div class="flex gap-2">
{#if onCancel} {#if onCancel}
<button type="button" class="btn btn-sm preset-tonal-surface" onclick={onCancel}> <button
type="button"
class="btn btn-sm preset-tonal-surface"
onclick={onCancel}>
<X size={16} class="mr-1" /> Cancel <X size={16} class="mr-1" /> Cancel
</button> </button>
{/if} {/if}
<button type="submit" class="btn btn-sm preset-filled-primary font-bold shadow-lg" disabled={is_loading}> <button
type="submit"
class="btn btn-sm preset-filled-primary font-bold shadow-lg"
disabled={is_loading}>
{#if is_loading} {#if is_loading}
<span class="animate-spin mr-2"></span> <span class="animate-spin mr-2"></span>
{:else} {:else}
@@ -144,60 +156,130 @@
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Location Section --> <!-- Location Section -->
<fieldset class="space-y-4"> <fieldset class="space-y-4">
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">Location Details</legend> <legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>Location Details</legend>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-attention-to">Attention To / Name</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="addr-attention-to" type="text" bind:value={formData.attention_to} placeholder="John Doe" /> class="label text-xs font-bold opacity-75"
for="addr-attention-to">Attention To / Name</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="addr-attention-to"
type="text"
bind:value={formData.attention_to}
placeholder="John Doe" />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-org-name">Organization Name</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="addr-org-name" type="text" bind:value={formData.organization_name} placeholder="Acme Corp" /> class="label text-xs font-bold opacity-75"
for="addr-org-name">Organization Name</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="addr-org-name"
type="text"
bind:value={formData.organization_name}
placeholder="Acme Corp" />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-line-1">Address Line 1</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="addr-line-1" type="text" bind:value={formData.line_1} required placeholder="123 Main St" /> class="label text-xs font-bold opacity-75"
for="addr-line-1">Address Line 1</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="addr-line-1"
type="text"
bind:value={formData.line_1}
required
placeholder="123 Main St" />
</div> </div>
<div class="grid grid-cols-2 gap-2"> <div class="grid grid-cols-2 gap-2">
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-line-2">Line 2</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="addr-line-2" type="text" bind:value={formData.line_2} placeholder="Suite 100" /> class="label text-xs font-bold opacity-75"
for="addr-line-2">Line 2</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="addr-line-2"
type="text"
bind:value={formData.line_2}
placeholder="Suite 100" />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-line-3">Line 3</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="addr-line-3" type="text" bind:value={formData.line_3} placeholder="Floor 2" /> class="label text-xs font-bold opacity-75"
for="addr-line-3">Line 3</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="addr-line-3"
type="text"
bind:value={formData.line_3}
placeholder="Floor 2" />
</div> </div>
</div> </div>
</fieldset> </fieldset>
<!-- Region Section --> <!-- Region Section -->
<fieldset class="space-y-4"> <fieldset class="space-y-4">
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">Region & Code</legend> <legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>Region & Code</legend>
<div class="grid grid-cols-2 gap-2"> <div class="grid grid-cols-2 gap-2">
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-city">City</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="addr-city" type="text" bind:value={formData.city} required placeholder="Metropolis" /> class="label text-xs font-bold opacity-75"
for="addr-city">City</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="addr-city"
type="text"
bind:value={formData.city}
required
placeholder="Metropolis" />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-state">State / Province</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="addr-state" type="text" bind:value={formData.state_province} placeholder="NY" /> class="label text-xs font-bold opacity-75"
for="addr-state">State / Province</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="addr-state"
type="text"
bind:value={formData.state_province}
placeholder="NY" />
</div> </div>
</div> </div>
<div class="grid grid-cols-2 gap-2"> <div class="grid grid-cols-2 gap-2">
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-postal">Postal Code</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="addr-postal" type="text" bind:value={formData.postal_code} placeholder="12345" /> class="label text-xs font-bold opacity-75"
for="addr-postal">Postal Code</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="addr-postal"
type="text"
bind:value={formData.postal_code}
placeholder="12345" />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-country">Country (Code)</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="addr-country">Country (Code)</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Globe size={16} /></div> <div class="input-group-shim"><Globe size={16} /></div>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="addr-country" type="text" bind:value={formData.country} placeholder="USA" /> <input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="addr-country"
type="text"
bind:value={formData.country}
placeholder="USA" />
</div> </div>
</div> </div>
</div> </div>
@@ -205,29 +287,59 @@
<!-- Technical Section --> <!-- Technical Section -->
<fieldset class="space-y-4"> <fieldset class="space-y-4">
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">Technical & GIS</legend> <legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>Technical & GIS</legend>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-timezone">Timezone</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="addr-timezone">Timezone</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Clock size={16} /></div> <div class="input-group-shim"><Clock size={16} /></div>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="addr-timezone" type="text" bind:value={formData.timezone} placeholder="America/New_York" /> <input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="addr-timezone"
type="text"
bind:value={formData.timezone}
placeholder="America/New_York" />
</div> </div>
</div> </div>
<div class="grid grid-cols-2 gap-2"> <div class="grid grid-cols-2 gap-2">
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-latitude">Latitude</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
<div class="input-group-shim"><Navigation size={16} /></div> for="addr-latitude">Latitude</label>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="addr-latitude" type="text" bind:value={formData.latitude} placeholder="40.7128" /> <div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim">
<Navigation size={16} />
</div>
<input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="addr-latitude"
type="text"
bind:value={formData.latitude}
placeholder="40.7128" />
</div> </div>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-longitude">Longitude</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
<div class="input-group-shim"><Navigation size={16} /></div> for="addr-longitude">Longitude</label>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="addr-longitude" type="text" bind:value={formData.longitude} placeholder="-74.0060" /> <div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim">
<Navigation size={16} />
</div>
<input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="addr-longitude"
type="text"
bind:value={formData.longitude}
placeholder="-74.0060" />
</div> </div>
</div> </div>
</div> </div>
@@ -235,32 +347,53 @@
<!-- Status Section --> <!-- Status Section -->
<fieldset class="space-y-4"> <fieldset class="space-y-4">
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">Status</legend> <legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>Status</legend>
<div class="flex flex-wrap gap-4 pt-2"> <div class="flex flex-wrap gap-4 pt-2">
<label class="flex items-center space-x-2 cursor-pointer"> <label class="flex items-center space-x-2 cursor-pointer">
<input class="checkbox" type="checkbox" bind:checked={formData.enable} /> <input
class="checkbox"
type="checkbox"
bind:checked={formData.enable} />
<span class="text-sm font-medium">Enabled</span> <span class="text-sm font-medium">Enabled</span>
</label> </label>
<label class="flex items-center space-x-2 cursor-pointer"> <label class="flex items-center space-x-2 cursor-pointer">
<input class="checkbox" type="checkbox" bind:checked={formData.hide} /> <input
class="checkbox"
type="checkbox"
bind:checked={formData.hide} />
<span class="text-sm font-medium">Hidden</span> <span class="text-sm font-medium">Hidden</span>
</label> </label>
<label class="flex items-center space-x-2 cursor-pointer"> <label class="flex items-center space-x-2 cursor-pointer">
<input class="checkbox" type="checkbox" bind:checked={formData.priority} /> <input
class="checkbox"
type="checkbox"
bind:checked={formData.priority} />
<span class="text-sm font-medium">Priority</span> <span class="text-sm font-medium">Priority</span>
</label> </label>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="addr-notes">Internal Notes</label> <label
<textarea class="textarea preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="addr-notes" rows="2" bind:value={formData.notes} placeholder="Notes about this address..."></textarea> class="label text-xs font-bold opacity-75"
for="addr-notes">Internal Notes</label>
<textarea
class="textarea preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="addr-notes"
rows="2"
bind:value={formData.notes}
placeholder="Notes about this address..."></textarea>
</div> </div>
</fieldset> </fieldset>
</div> </div>
<footer class="flex justify-end gap-2 border-t border-surface-500/30 pt-4"> <footer class="flex justify-end gap-2 border-t border-surface-500/30 pt-4">
<button type="submit" class="btn preset-filled-primary font-bold shadow-lg w-full md:w-auto" disabled={is_loading}> <button
type="submit"
class="btn preset-filled-primary font-bold shadow-lg w-full md:w-auto"
disabled={is_loading}>
{#if is_loading} {#if is_loading}
<span class="animate-spin mr-2"></span> <span class="animate-spin mr-2"></span>
{/if} {/if}

View File

@@ -1,47 +1,56 @@
<script lang="ts"> <script lang="ts">
// Imports // Imports
// import type { key_val } from '$lib/ae_stores'; // import type { key_val } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils'; import { ae_util } from '$lib/ae_utils/ae_utils';
import { liveQuery } from 'dexie'; import { liveQuery } from 'dexie';
import { db_core } from '$lib/ae_core/db_core'; import { db_core } from '$lib/ae_core/db_core';
import { import {
ae_snip, ae_snip,
ae_loc, ae_loc,
ae_sess, ae_sess,
ae_api, ae_api,
ae_trig, ae_trig,
slct, slct,
slct_trigger slct_trigger
} from '$lib/stores/ae_stores'; } from '$lib/stores/ae_stores';
import { Building2, ListOrdered, Mail, Unlink, User, UserCheck } from '@lucide/svelte'; import {
// import { core_func } from '$lib/ae_core_functions'; Building2,
// import { events_loc, events_sess, events_slct, events_trigger, events_trig_kv } from '$lib/stores/ae_events_stores'; ListOrdered,
// import { events_func } from '$lib/ae_events/ae_events_functions'; Mail,
Unlink,
User,
UserCheck
} from '@lucide/svelte';
// import { core_func } from '$lib/ae_core_functions';
// import { events_loc, events_sess, events_slct, events_trigger, events_trig_kv } from '$lib/stores/ae_events_stores';
// import { events_func } from '$lib/ae_events/ae_events_functions';
interface Props { interface Props {
// Exports // Exports
container_class_li?: string | Array<string>; container_class_li?: string | Array<string>;
person_id_random_li?: Array<string>; person_id_random_li?: Array<string>;
allow_basic?: boolean; allow_basic?: boolean;
allow_moderator?: boolean; allow_moderator?: boolean;
show_user_fields?: boolean; show_user_fields?: boolean;
display_mode?: string; // 'default', 'compact', 'minimal', 'launcher' display_mode?: string; // 'default', 'compact', 'minimal', 'launcher'
} }
let { let {
container_class_li = [], container_class_li = [],
person_id_random_li = $bindable(['']), person_id_random_li = $bindable(['']),
allow_basic = false, allow_basic = false,
allow_moderator = false, allow_moderator = false,
show_user_fields = false, show_user_fields = false,
display_mode = 'default' display_mode = 'default'
}: Props = $props(); }: Props = $props();
// Variables // Variables
// *** Functions and Logic // *** Functions and Logic
let lq_kv__person_obj_li = $derived(liveQuery(() => db_core.person.bulkGet(person_id_random_li))); let lq_kv__person_obj_li = $derived(
liveQuery(() => db_core.person.bulkGet(person_id_random_li))
);
</script> </script>
<section class="ae_comp person_obj_tbl container {container_class_li}"> <section class="ae_comp person_obj_tbl container {container_class_li}">
@@ -53,18 +62,19 @@
{#if $lq_kv__person_obj_li.length} {#if $lq_kv__person_obj_li.length}
<span <span
class="text-3xl font-bold bg-success-100 px-4 border rounded-lg border-success-200" class="text-3xl font-bold bg-success-100 px-4 border rounded-lg border-success-200"
title="Count {$lq_kv__person_obj_li.length ?? 'None'}" title="Count {$lq_kv__person_obj_li.length ?? 'None'}">
>
<ListOrdered size="1em" class="mx-4" /> <ListOrdered size="1em" class="mx-4" />
{$lq_kv__person_obj_li.length ?? 'None'} {$lq_kv__person_obj_li.length ?? 'None'}
</span> </span>
{/if} {/if}
</h2> </h2>
<table class="table table-auto table-striped w-full text-xs lg:text-sm"> <table
class="table table-auto table-striped w-full text-xs lg:text-sm">
<thead> <thead>
<tr> <tr>
<th class="px-4 py-2">Name ({$lq_kv__person_obj_li?.length}×)</th> <th class="px-4 py-2"
>Name ({$lq_kv__person_obj_li?.length}×)</th>
<th class="px-4 py-2">Email</th> <th class="px-4 py-2">Email</th>
<th class="px-4 py-2">Affiliations</th> <th class="px-4 py-2">Affiliations</th>
{#if show_user_fields} {#if show_user_fields}
@@ -83,8 +93,7 @@
href="/core/people/{person_obj?.person_id_random}" href="/core/people/{person_obj?.person_id_random}"
class="text-blue-500 underline hover:text-blue-800" class="text-blue-500 underline hover:text-blue-800"
title="View {person_obj?.full_name ?? title="View {person_obj?.full_name ??
'no name'} (ID={person_obj?.person_id_random})" 'no name'} (ID={person_obj?.person_id_random})">
>
<!-- {@html person_obj?.full_name ?? ae_snip.html__not_set} --> <!-- {@html person_obj?.full_name ?? ae_snip.html__not_set} -->
{@html person_obj?.full_name {@html person_obj?.full_name
? person_obj?.full_name ? person_obj?.full_name
@@ -96,9 +105,9 @@
{#if person_obj?.primary_email} {#if person_obj?.primary_email}
<a <a
href="mailto:{person_obj?.primary_email}" href="mailto:{person_obj?.primary_email}"
class="text-blue-500 underline hover:text-blue-800" class="text-blue-500 underline hover:text-blue-800">
> {@html person_obj?.primary_email ??
{@html person_obj?.primary_email ?? ae_snip.html__not_set} ae_snip.html__not_set}
</a> </a>
{:else} {:else}
{@html ae_snip.html__not_set} {@html ae_snip.html__not_set}
@@ -106,26 +115,33 @@
</td> </td>
<td class="px-4 py-2"> <td class="px-4 py-2">
<Building2 size="1em" /> <Building2 size="1em" />
{@html person_obj?.affiliations ?? ae_snip.html__not_set} {@html person_obj?.affiliations ??
ae_snip.html__not_set}
</td> </td>
{#if show_user_fields} {#if show_user_fields}
<td class="px-4 py-2"> <td class="px-4 py-2">
{#if person_obj?.user_id_random} {#if person_obj?.user_id_random}
<div class="flex flex-col gap-1"> <div class="flex flex-col gap-1">
<span class="font-bold flex items-center gap-1"> <span
<UserCheck size="1em" class="text-success-500" /> class="font-bold flex items-center gap-1">
<UserCheck
size="1em"
class="text-success-500" />
<a <a
href="/core/users/{person_obj?.user_id_random}" href="/core/users/{person_obj?.user_id_random}"
class="text-blue-500 underline hover:text-blue-800" class="text-blue-500 underline hover:text-blue-800">
> {@html person_obj?.username ??
{@html person_obj?.username ?? '-- no username --'} '-- no username --'}
</a> </a>
</span> </span>
<span class="text-[10px] opacity-50 font-mono">{person_obj.user_id_random}</span> <span
class="text-[10px] opacity-50 font-mono"
>{person_obj.user_id_random}</span>
</div> </div>
{:else} {:else}
<span class="badge preset-tonal-warning"> <span
class="badge preset-tonal-warning">
<Unlink size="1em" class="mr-1" /> <Unlink size="1em" class="mr-1" />
Not Linked Not Linked
</span> </span>
@@ -133,10 +149,21 @@
</td> </td>
<td class="px-4 py-2"> <td class="px-4 py-2">
<div class="flex flex-wrap gap-1"> <div class="flex flex-wrap gap-1">
{#if person_obj?.user_super}<span class="badge preset-filled-error text-[10px]">Super</span>{/if} {#if person_obj?.user_super}<span
{#if person_obj?.user_manager}<span class="badge preset-filled-warning text-[10px]">Manager</span>{/if} class="badge preset-filled-error text-[10px]"
{#if person_obj?.user_administrator}<span class="badge preset-filled-primary text-[10px]">Admin</span>{/if} >Super</span
{#if !person_obj?.user_id_random}<span class="opacity-30">--</span>{/if} >{/if}
{#if person_obj?.user_manager}<span
class="badge preset-filled-warning text-[10px]"
>Manager</span
>{/if}
{#if person_obj?.user_administrator}<span
class="badge preset-filled-primary text-[10px]"
>Admin</span
>{/if}
{#if !person_obj?.user_id_random}<span
class="opacity-30">--</span
>{/if}
</div> </div>
</td> </td>
{/if} {/if}
@@ -161,8 +188,8 @@
</section> </section>
<style> <style>
.dim { .dim {
opacity: 0.5; opacity: 0.5;
color: #999; color: #999;
} }
</style> </style>

View File

@@ -1,50 +1,67 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { ae_loc, ae_api, slct } from '$lib/stores/ae_stores'; import { ae_loc, ae_api, slct } from '$lib/stores/ae_stores';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { Activity, Contact, ExternalLink, ListFilter, Mail, Phone, Plus, Search, ShieldCheck, User, X } from '@lucide/svelte'; import {
import { load_ae_obj_li__contact, create_ae_obj__contact } from '$lib/ae_core/ae_core__contact'; Activity,
import Contact_form from './ae_comp__contact_form.svelte'; Contact,
ExternalLink,
ListFilter,
Mail,
Phone,
Plus,
Search,
ShieldCheck,
User,
X
} from '@lucide/svelte';
import {
load_ae_obj_li__contact,
create_ae_obj__contact
} from '$lib/ae_core/ae_core__contact';
import Contact_form from './ae_comp__contact_form.svelte';
let contact_li: any[] = $state([]); let contact_li: any[] = $state([]);
let qry_str = $state(''); let qry_str = $state('');
let filtered_li: any[] = $derived( let filtered_li: any[] = $derived(
qry_str qry_str
? contact_li.filter(c => ? contact_li.filter(
c.name?.toLowerCase().includes(qry_str.toLowerCase()) || (c) =>
c.title?.toLowerCase().includes(qry_str.toLowerCase()) || c.name?.toLowerCase().includes(qry_str.toLowerCase()) ||
c.email?.toLowerCase().includes(qry_str.toLowerCase()) || c.title?.toLowerCase().includes(qry_str.toLowerCase()) ||
c.phone_office?.toLowerCase().includes(qry_str.toLowerCase()) c.email?.toLowerCase().includes(qry_str.toLowerCase()) ||
) c.phone_office?.toLowerCase().includes(qry_str.toLowerCase())
: contact_li )
); : contact_li
let loading = $state(true); );
let show_add_form = $state(false); let loading = $state(true);
let show_add_form = $state(false);
async function load_contacts() { async function load_contacts() {
if (!$ae_loc.account_id) return; if (!$ae_loc.account_id) return;
loading = true; loading = true;
contact_li = await load_ae_obj_li__contact({ contact_li = await load_ae_obj_li__contact({
api_cfg: $ae_api, api_cfg: $ae_api,
for_obj_id: $ae_loc.account_id, for_obj_id: $ae_loc.account_id,
enabled: 'all', enabled: 'all',
hidden: 'all', hidden: 'all',
log_lvl: 1 log_lvl: 1
});
loading = false;
}
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
return;
}
load_contacts();
}); });
loading = false;
}
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
return;
}
load_contacts();
});
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10"> <header
class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<div class="p-2 bg-primary-500/10 rounded-lg"> <div class="p-2 bg-primary-500/10 rounded-lg">
<Phone size={24} class="text-primary-500" /> <Phone size={24} class="text-primary-500" />
@@ -53,8 +70,7 @@
</div> </div>
<button <button
class="btn btn-sm preset-filled-primary font-bold shadow-lg" class="btn btn-sm preset-filled-primary font-bold shadow-lg"
onclick={() => show_add_form = !show_add_form} onclick={() => (show_add_form = !show_add_form)}>
>
{#if show_add_form} {#if show_add_form}
<X size={16} class="mr-2" /> Cancel <X size={16} class="mr-2" /> Cancel
{:else} {:else}
@@ -73,29 +89,36 @@
goto(`/core/contacts/${new_con.contact_id_random}`); goto(`/core/contacts/${new_con.contact_id_random}`);
} }
}} }}
onCancel={() => show_add_form = false} onCancel={() => (show_add_form = false)} />
/>
</div> </div>
{/if} {/if}
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10">
<div class="max-w-2xl space-y-1"> <div class="max-w-2xl space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Search Directory</span> <span
<div class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all"> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
<div class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20"> >Search Directory</span>
<div
class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all">
<div
class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20">
<Search size={18} class="opacity-50" /> <Search size={18} class="opacity-50" />
</div> </div>
<input <input
class="bg-transparent border-0 ring-0 focus:ring-0 p-3 grow placeholder:opacity-50" class="bg-transparent border-0 ring-0 focus:ring-0 p-3 grow placeholder:opacity-50"
type="search" type="search"
bind:value={qry_str} bind:value={qry_str}
placeholder="Search by name, title, email, or phone..." placeholder="Search by name, title, email, or phone..." />
/> <button
<button class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]" onclick={load_contacts} disabled={loading}> class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]"
onclick={load_contacts}
disabled={loading}>
{#if loading} {#if loading}
<span class="animate-spin text-xl"></span> <span class="animate-spin text-xl"></span>
{:else} {:else}
<span class="whitespace-nowrap tracking-wide">Refresh</span> <span class="whitespace-nowrap tracking-wide"
>Refresh</span>
{/if} {/if}
</button> </button>
</div> </div>
@@ -104,53 +127,82 @@
{#if loading} {#if loading}
<div class="card p-8 flex justify-center items-center h-64"> <div class="card p-8 flex justify-center items-center h-64">
<div class="placeholder animate-pulse w-full h-full rounded-2xl"></div> <div class="placeholder animate-pulse w-full h-full rounded-2xl">
</div>
</div> </div>
{:else if filtered_li.length === 0} {:else if filtered_li.length === 0}
<div class="card p-12 text-center preset-tonal-surface border-2 border-dashed border-surface-500/20 rounded-2xl"> <div
class="card p-12 text-center preset-tonal-surface border-2 border-dashed border-surface-500/20 rounded-2xl">
<Contact size={48} class="mx-auto mb-4 opacity-20" /> <Contact size={48} class="mx-auto mb-4 opacity-20" />
<h3 class="h3 font-bold opacity-50">No Contacts Found</h3> <h3 class="h3 font-bold opacity-50">No Contacts Found</h3>
<p class="opacity-60 max-w-xs mx-auto mt-2">Business and support contacts will appear here.</p> <p class="opacity-60 max-w-xs mx-auto mt-2">
Business and support contacts will appear here.
</p>
</div> </div>
{:else} {:else}
<div class="card p-6 preset-tonal-surface shadow-xl border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 mb-6 flex items-center gap-2"> class="card p-6 preset-tonal-surface shadow-xl border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 mb-6 flex items-center gap-2">
<ListFilter size={18} class="text-secondary-500" /> <ListFilter size={18} class="text-secondary-500" />
Directory Results Directory Results
<span class="badge preset-tonal-secondary ml-auto">{filtered_li.length} entries</span> <span class="badge preset-tonal-secondary ml-auto"
>{filtered_li.length} entries</span>
</h3> </h3>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{#each filtered_li as con (con.contact_id_random)} {#each filtered_li as con (con.contact_id_random)}
<div class="card p-5 space-y-4 preset-tonal-surface shadow-md border border-surface-500/10 hover:border-primary-500/30 transition-all group relative"> <div
class="card p-5 space-y-4 preset-tonal-surface shadow-md border border-surface-500/10 hover:border-primary-500/30 transition-all group relative">
<div class="absolute top-4 right-4"> <div class="absolute top-4 right-4">
<span class="badge {con.enable ? 'preset-filled-success' : 'preset-filled-error'} text-[8px] uppercase font-bold shadow-sm"> <span
class="badge {con.enable
? 'preset-filled-success'
: 'preset-filled-error'} text-[8px] uppercase font-bold shadow-sm">
{con.enable ? 'Active' : 'Disabled'} {con.enable ? 'Active' : 'Disabled'}
</span> </span>
</div> </div>
<header class="flex items-center gap-3"> <header class="flex items-center gap-3">
<div class="avatar preset-filled-primary w-12 h-12 flex items-center justify-center rounded-full shadow-inner group-hover:scale-110 transition-transform"> <div
class="avatar preset-filled-primary w-12 h-12 flex items-center justify-center rounded-full shadow-inner group-hover:scale-110 transition-transform">
<User size={24} /> <User size={24} />
</div> </div>
<div class="pr-12"> <div class="pr-12">
<p class="font-black tracking-tight truncate">{con.name || con.title || '--'}</p> <p class="font-black tracking-tight truncate">
<p class="text-[10px] uppercase font-bold opacity-50 truncate">{con.title || 'Support Contact'}</p> {con.name || con.title || '--'}
</p>
<p
class="text-[10px] uppercase font-bold opacity-50 truncate">
{con.title || 'Support Contact'}
</p>
</div> </div>
</header> </header>
<div class="space-y-2 text-xs opacity-70"> <div class="space-y-2 text-xs opacity-70">
<div class="flex items-center gap-2 bg-black/5 p-2 rounded-lg"> <div
<Mail size={14} class="text-primary-500 shrink-0" /> class="flex items-center gap-2 bg-black/5 p-2 rounded-lg">
<span class="truncate">{con.email || 'No Email'}</span> <Mail
size={14}
class="text-primary-500 shrink-0" />
<span class="truncate"
>{con.email || 'No Email'}</span>
</div> </div>
<div class="flex items-center gap-2 bg-black/5 p-2 rounded-lg"> <div
<Phone size={14} class="text-secondary-500 shrink-0" /> class="flex items-center gap-2 bg-black/5 p-2 rounded-lg">
<span class="truncate">{con.phone_office || con.phone_mobile || '--'}</span> <Phone
size={14}
class="text-secondary-500 shrink-0" />
<span class="truncate"
>{con.phone_office ||
con.phone_mobile ||
'--'}</span>
</div> </div>
</div> </div>
<a class="btn btn-sm preset-filled-primary font-bold w-full shadow-lg group-hover:brightness-110 transition-all" href="/core/contacts/{con.contact_id_random}"> <a
class="btn btn-sm preset-filled-primary font-bold w-full shadow-lg group-hover:brightness-110 transition-all"
href="/core/contacts/{con.contact_id_random}">
Manage Contact Manage Contact
</a> </a>
</div> </div>

View File

@@ -1,56 +1,75 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { page } from '$app/stores'; import { page } from '$app/stores';
import { import {
load_ae_obj_id__contact, load_ae_obj_id__contact,
update_ae_obj__contact, update_ae_obj__contact,
delete_ae_obj_id__contact delete_ae_obj_id__contact
} from '$lib/ae_core/ae_core__contact'; } from '$lib/ae_core/ae_core__contact';
import { editable_fields__contact } from '$lib/ae_core/ae_core__contact.editable_fields'; import { editable_fields__contact } from '$lib/ae_core/ae_core__contact.editable_fields';
import { ae_api, ae_loc } from '$lib/stores/ae_stores'; import { ae_api, ae_loc } from '$lib/stores/ae_stores';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { Activity, ArrowLeft, Contact, Edit, Eye, Globe, Info, Link2, Linkedin, Mail, Phone, Save, ShieldCheck, Trash2, UserRound } from '@lucide/svelte'; import {
import Contact_form from '../ae_comp__contact_form.svelte'; Activity,
ArrowLeft,
Contact,
Edit,
Eye,
Globe,
Info,
Link2,
Linkedin,
Mail,
Phone,
Save,
ShieldCheck,
Trash2,
UserRound
} from '@lucide/svelte';
import Contact_form from '../ae_comp__contact_form.svelte';
let contact_id = $derived($page.params.contact_id ?? ''); let contact_id = $derived($page.params.contact_id ?? '');
let contact: any = $state(null); let contact: any = $state(null);
let loading = $state(true); let loading = $state(true);
let is_editing = $state(false); let is_editing = $state(false);
async function load_data() { async function load_data() {
loading = true; loading = true;
contact = await load_ae_obj_id__contact({ contact = await load_ae_obj_id__contact({
api_cfg: $ae_api, api_cfg: $ae_api,
contact_id, contact_id,
log_lvl: 1 log_lvl: 1
});
loading = false;
}
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
return;
}
load_data();
}); });
loading = false;
}
async function handle_delete() { onMount(() => {
if (!confirm('Permanently delete this contact?')) return; if (!$ae_loc.manager_access) {
await delete_ae_obj_id__contact({ goto('/core');
api_cfg: $ae_api, return;
contact_id,
method: 'delete',
log_lvl: 1
});
goto('/core/contacts');
} }
load_data();
});
async function handle_delete() {
if (!confirm('Permanently delete this contact?')) return;
await delete_ae_obj_id__contact({
api_cfg: $ae_api,
contact_id,
method: 'delete',
log_lvl: 1
});
goto('/core/contacts');
}
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10 gap-4"> <header
class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10 gap-4">
<div class="flex items-center gap-4"> <div class="flex items-center gap-4">
<a class="btn btn-sm preset-tonal-surface shadow-sm" href="/core/contacts"> <a
class="btn btn-sm preset-tonal-surface shadow-sm"
href="/core/contacts">
<ArrowLeft size={16} /> <ArrowLeft size={16} />
</a> </a>
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
@@ -58,20 +77,31 @@
<UserRound size={24} class="text-primary-500" /> <UserRound size={24} class="text-primary-500" />
</div> </div>
<div> <div>
<h1 class="h2 font-black tracking-tight">{contact?.name || contact?.title || 'Loading...'}</h1> <h1 class="h2 font-black tracking-tight">
<p class="text-xs font-bold opacity-50 uppercase tracking-widest">Contact Detail</p> {contact?.name || contact?.title || 'Loading...'}
</h1>
<p
class="text-xs font-bold opacity-50 uppercase tracking-widest">
Contact Detail
</p>
</div> </div>
</div> </div>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
<button class="btn btn-sm preset-tonal-secondary font-bold shadow-sm" onclick={() => is_editing = !is_editing} disabled={loading}> <button
class="btn btn-sm preset-tonal-secondary font-bold shadow-sm"
onclick={() => (is_editing = !is_editing)}
disabled={loading}>
{#if is_editing} {#if is_editing}
<Eye size={16} class="mr-2" /> View Mode <Eye size={16} class="mr-2" /> View Mode
{:else} {:else}
<Edit size={16} class="mr-2" /> Edit Mode <Edit size={16} class="mr-2" /> Edit Mode
{/if} {/if}
</button> </button>
<button class="btn btn-sm preset-tonal-error font-bold shadow-sm" onclick={handle_delete} disabled={loading}> <button
class="btn btn-sm preset-tonal-error font-bold shadow-sm"
onclick={handle_delete}
disabled={loading}>
<Trash2 size={16} class="mr-2" /> Delete <Trash2 size={16} class="mr-2" /> Delete
</button> </button>
</div> </div>
@@ -79,7 +109,8 @@
{#if loading} {#if loading}
<div class="card p-8 flex justify-center items-center h-64"> <div class="card p-8 flex justify-center items-center h-64">
<div class="placeholder animate-pulse w-full h-full rounded-2xl"></div> <div class="placeholder animate-pulse w-full h-full rounded-2xl">
</div>
</div> </div>
{:else if contact} {:else if contact}
{#if is_editing} {#if is_editing}
@@ -90,43 +121,62 @@
contact = updated; contact = updated;
is_editing = false; is_editing = false;
}} }}
onCancel={() => is_editing = false} onCancel={() => (is_editing = false)} />
/>
</div> </div>
{:else} {:else}
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 animate-fade-in"> <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 animate-fade-in">
<div class="lg:col-span-2 space-y-6"> <div class="lg:col-span-2 space-y-6">
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Contact size={20} class="text-primary-500" /> <Contact size={20} class="text-primary-500" />
Core Information Core Information
</h3> </h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="space-y-1"> <div class="space-y-1">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<UserRound size={10} /> Full Name / Title <UserRound size={10} /> Full Name / Title
</p> </p>
<p class="text-lg font-black tracking-tight leading-tight">{contact.name || contact.title || '--'}</p> <p
class="text-lg font-black tracking-tight leading-tight">
{contact.name || contact.title || '--'}
</p>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<Activity size={10} /> Tagline / Role <Activity size={10} /> Tagline / Role
</p> </p>
<p class="font-bold">{contact.tagline || '--'}</p> <p class="font-bold">
{contact.tagline || '--'}
</p>
</div> </div>
<div class="space-y-1 bg-black/5 p-4 rounded-xl border border-surface-500/10"> <div
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> class="space-y-1 bg-black/5 p-4 rounded-xl border border-surface-500/10">
<p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<Mail size={10} /> Email Address <Mail size={10} /> Email Address
</p> </p>
<p class="font-bold text-primary-500 break-all">{contact.email || '--'}</p> <p class="font-bold text-primary-500 break-all">
{contact.email || '--'}
</p>
</div> </div>
<div class="space-y-1 bg-black/5 p-4 rounded-xl border border-surface-500/10"> <div
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> class="space-y-1 bg-black/5 p-4 rounded-xl border border-surface-500/10">
<p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<Globe size={10} /> Website <Globe size={10} /> Website
</p> </p>
{#if contact.website_url} {#if contact.website_url}
<a href={contact.website_url} target="_blank" rel="noopener noreferrer" class="font-bold text-secondary-500 hover:underline flex items-center gap-2 truncate"> <a
{contact.website_url} <Link2 size={12} /> href={contact.website_url}
target="_blank"
rel="noopener noreferrer"
class="font-bold text-secondary-500 hover:underline flex items-center gap-2 truncate">
{contact.website_url}
<Link2 size={12} />
</a> </a>
{:else} {:else}
<p class="font-bold">--</p> <p class="font-bold">--</p>
@@ -135,36 +185,52 @@
</div> </div>
</div> </div>
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Phone size={20} class="text-secondary-500" /> <Phone size={20} class="text-secondary-500" />
Communication & Social Communication & Social
</h3> </h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="space-y-1"> <div class="space-y-1">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<Phone size={10} /> Mobile Phone <Phone size={10} /> Mobile Phone
</p> </p>
<p class="font-mono font-bold">{contact.phone_mobile || contact.phone || '--'}</p> <p class="font-mono font-bold">
{contact.phone_mobile ||
contact.phone ||
'--'}
</p>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<Phone size={10} /> Office Phone <Phone size={10} /> Office Phone
</p> </p>
<p class="font-mono font-bold">{contact.phone_office || '--'}</p> <p class="font-mono font-bold">
{contact.phone_office || '--'}
</p>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<Linkedin size={10} /> LinkedIn <Linkedin size={10} /> LinkedIn
</p> </p>
<p class="font-bold truncate">{contact.linkedin_url || '--'}</p> <p class="font-bold truncate">
{contact.linkedin_url || '--'}
</p>
</div> </div>
<div class="md:col-span-2 space-y-2"> <div class="md:col-span-2 space-y-2">
<p class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1"> <p
class="text-[10px] opacity-60 uppercase font-black tracking-widest flex items-center gap-1">
<Info size={10} /> Internal Notes <Info size={10} /> Internal Notes
</p> </p>
<div class="p-4 bg-black/5 rounded-xl border border-dashed border-surface-500/20 italic opacity-80 min-h-[80px]"> <div
{contact.notes || 'No internal notes provided for this contact.'} class="p-4 bg-black/5 rounded-xl border border-dashed border-surface-500/20 italic opacity-80 min-h-[80px]">
{contact.notes ||
'No internal notes provided for this contact.'}
</div> </div>
</div> </div>
</div> </div>
@@ -172,40 +238,77 @@
</div> </div>
<div class="space-y-6"> <div class="space-y-6">
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<ShieldCheck size={20} class="text-warning-500" /> <ShieldCheck size={20} class="text-warning-500" />
Status & Flags Status & Flags
</h3> </h3>
<div class="space-y-4"> <div class="space-y-4">
<div class="flex justify-between items-center p-3 bg-black/5 rounded-lg"> <div
<span class="text-sm font-bold opacity-75">Enabled</span> class="flex justify-between items-center p-3 bg-black/5 rounded-lg">
<span class="badge {contact.enable ? 'preset-filled-success' : 'preset-filled-error'} px-4 py-1 shadow-sm"> <span class="text-sm font-bold opacity-75"
>Enabled</span>
<span
class="badge {contact.enable
? 'preset-filled-success'
: 'preset-filled-error'} px-4 py-1 shadow-sm">
{contact.enable ? 'ACTIVE' : 'DISABLED'} {contact.enable ? 'ACTIVE' : 'DISABLED'}
</span> </span>
</div> </div>
<div class="flex justify-between items-center p-3 bg-black/5 rounded-lg"> <div
<span class="text-sm font-bold opacity-75">Hidden</span> class="flex justify-between items-center p-3 bg-black/5 rounded-lg">
<span class="badge {contact.hide ? 'preset-filled-warning' : 'preset-filled-surface'} px-4 py-1 shadow-sm"> <span class="text-sm font-bold opacity-75"
>Hidden</span>
<span
class="badge {contact.hide
? 'preset-filled-warning'
: 'preset-filled-surface'} px-4 py-1 shadow-sm">
{contact.hide ? 'YES' : 'NO'} {contact.hide ? 'YES' : 'NO'}
</span> </span>
</div> </div>
<div class="flex justify-between items-center p-3 bg-black/5 rounded-lg"> <div
<span class="text-sm font-bold opacity-75">Priority</span> class="flex justify-between items-center p-3 bg-black/5 rounded-lg">
<span class="badge {contact.priority ? 'preset-filled-secondary' : 'preset-filled-surface'} px-4 py-1 shadow-sm"> <span class="text-sm font-bold opacity-75"
>Priority</span>
<span
class="badge {contact.priority
? 'preset-filled-secondary'
: 'preset-filled-surface'} px-4 py-1 shadow-sm">
{contact.priority ? 'YES' : 'NO'} {contact.priority ? 'YES' : 'NO'}
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<div class="card p-5 preset-tonal-surface shadow-inner border border-surface-500/10 space-y-3"> <div
<p class="text-[10px] uppercase font-black opacity-40 tracking-widest border-b border-surface-500/20 pb-1">System Audit</p> class="card p-5 preset-tonal-surface shadow-inner border border-surface-500/10 space-y-3">
<p
class="text-[10px] uppercase font-black opacity-40 tracking-widest border-b border-surface-500/20 pb-1">
System Audit
</p>
<div class="space-y-2 text-[10px] font-mono opacity-60"> <div class="space-y-2 text-[10px] font-mono opacity-60">
<p class="flex justify-between"><span>ID:</span> <span class="text-primary-500 font-bold">{contact.contact_id_random}</span></p> <p class="flex justify-between">
<p class="flex justify-between"><span>Created:</span> <span>{new Date(contact.created_on).toLocaleString()}</span></p> <span>ID:</span>
<span class="text-primary-500 font-bold"
>{contact.contact_id_random}</span>
</p>
<p class="flex justify-between">
<span>Created:</span>
<span
>{new Date(
contact.created_on
).toLocaleString()}</span>
</p>
{#if contact.updated_on} {#if contact.updated_on}
<p class="flex justify-between"><span>Updated:</span> <span>{new Date(contact.updated_on).toLocaleString()}</span></p> <p class="flex justify-between">
<span>Updated:</span>
<span
>{new Date(
contact.updated_on
).toLocaleString()}</span>
</p>
{/if} {/if}
</div> </div>
</div> </div>

View File

@@ -1,122 +1,144 @@
<script lang="ts"> <script lang="ts">
/** /**
* Contact Form Component * Contact Form Component
* Standardized 2026-01-09 for Core UI Polish. * Standardized 2026-01-09 for Core UI Polish.
* Uses unified ae_Contact type and Svelte 5 Runes. * Uses unified ae_Contact type and Svelte 5 Runes.
*/ */
import { ae_api, ae_loc } from '$lib/stores/ae_stores'; import { ae_api, ae_loc } from '$lib/stores/ae_stores';
import { update_ae_obj__contact, create_ae_obj__contact } from '$lib/ae_core/ae_core__contact'; import {
import type { ae_Contact } from '$lib/types/ae_types'; update_ae_obj__contact,
import { Facebook, Globe, Instagram, Linkedin, Mail, Phone, Save, UserPlus, X } from '@lucide/svelte'; create_ae_obj__contact
interface Props { } from '$lib/ae_core/ae_core__contact';
contact?: ae_Contact | null; import type { ae_Contact } from '$lib/types/ae_types';
onSave?: (contact: ae_Contact) => void; import {
onCancel?: () => void; Facebook,
} Globe,
Instagram,
Linkedin,
Mail,
Phone,
Save,
UserPlus,
X
} from '@lucide/svelte';
interface Props {
contact?: ae_Contact | null;
onSave?: (contact: ae_Contact) => void;
onCancel?: () => void;
}
let { contact = null, onSave, onCancel }: Props = $props(); let { contact = null, onSave, onCancel }: Props = $props();
// Form State (Runes) // Form State (Runes)
let formData = $state({ let formData = $state({
title: '', title: '',
tagline: '', tagline: '',
email: '', email: '',
phone_mobile: '', phone_mobile: '',
phone_office: '', phone_office: '',
website_url: '', website_url: '',
facebook_url: '', facebook_url: '',
instagram_url: '', instagram_url: '',
linkedin_url: '', linkedin_url: '',
notes: '', notes: '',
enable: true, enable: true,
hide: false, hide: false,
priority: false priority: false
}); });
// Reset form when contact prop changes // Reset form when contact prop changes
$effect(() => { $effect(() => {
formData.title = contact?.title ?? ''; formData.title = contact?.title ?? '';
formData.tagline = contact?.tagline ?? ''; formData.tagline = contact?.tagline ?? '';
formData.email = contact?.email ?? ''; formData.email = contact?.email ?? '';
formData.phone_mobile = contact?.phone_mobile ?? ''; formData.phone_mobile = contact?.phone_mobile ?? '';
formData.phone_office = contact?.phone_office ?? ''; formData.phone_office = contact?.phone_office ?? '';
formData.website_url = contact?.website_url ?? ''; formData.website_url = contact?.website_url ?? '';
formData.facebook_url = contact?.facebook_url ?? ''; formData.facebook_url = contact?.facebook_url ?? '';
formData.instagram_url = contact?.instagram_url ?? ''; formData.instagram_url = contact?.instagram_url ?? '';
formData.linkedin_url = contact?.linkedin_url ?? ''; formData.linkedin_url = contact?.linkedin_url ?? '';
formData.notes = contact?.notes ?? ''; formData.notes = contact?.notes ?? '';
formData.enable = contact?.enable ?? true; formData.enable = contact?.enable ?? true;
formData.hide = contact?.hide ?? false; formData.hide = contact?.hide ?? false;
formData.priority = contact?.priority ?? false; formData.priority = contact?.priority ?? false;
}); });
let is_loading = $state(false); let is_loading = $state(false);
let error_msg = $state(''); let error_msg = $state('');
async function handleSubmit(event: Event) { async function handleSubmit(event: Event) {
event.preventDefault(); event.preventDefault();
is_loading = true; is_loading = true;
error_msg = ''; error_msg = '';
// Surgical Payload // Surgical Payload
const payload: any = { ...formData }; const payload: any = { ...formData };
for (const key in payload) { for (const key in payload) {
if (typeof payload[key] === 'string' && payload[key].trim() === '') { if (typeof payload[key] === 'string' && payload[key].trim() === '') {
// title is likely required, but we'll trim it // title is likely required, but we'll trim it
if (key === 'title') { if (key === 'title') {
payload[key] = payload[key].trim(); payload[key] = payload[key].trim();
} else { } else {
payload[key] = null; payload[key] = null;
}
} }
} }
try {
let result;
if (contact?.contact_id_random) {
// Update existing
result = await update_ae_obj__contact({
api_cfg: $ae_api,
contact_id: contact.contact_id_random,
data_kv: payload,
log_lvl: 1
});
} else {
// Create new
result = await create_ae_obj__contact({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: payload,
log_lvl: 1
});
}
if (result) {
if (onSave) onSave(result);
} else {
error_msg = 'Failed to save contact record.';
}
} catch (err: any) {
error_msg = err.message || 'An error occurred while saving.';
} finally {
is_loading = false;
}
} }
try {
let result;
if (contact?.contact_id_random) {
// Update existing
result = await update_ae_obj__contact({
api_cfg: $ae_api,
contact_id: contact.contact_id_random,
data_kv: payload,
log_lvl: 1
});
} else {
// Create new
result = await create_ae_obj__contact({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: payload,
log_lvl: 1
});
}
if (result) {
if (onSave) onSave(result);
} else {
error_msg = 'Failed to save contact record.';
}
} catch (err: any) {
error_msg = err.message || 'An error occurred while saving.';
} finally {
is_loading = false;
}
}
</script> </script>
<form onsubmit={handleSubmit} class="card p-6 space-y-6 shadow-xl preset-tonal-surface"> <form
<header class="flex justify-between items-center border-b border-surface-500/30 pb-4"> onsubmit={handleSubmit}
class="card p-6 space-y-6 shadow-xl preset-tonal-surface">
<header
class="flex justify-between items-center border-b border-surface-500/30 pb-4">
<h3 class="h3 flex items-center gap-2"> <h3 class="h3 flex items-center gap-2">
<UserPlus size={24} /> <UserPlus size={24} />
{contact ? 'Edit Contact' : 'Create New Contact'} {contact ? 'Edit Contact' : 'Create New Contact'}
</h3> </h3>
<div class="flex gap-2"> <div class="flex gap-2">
{#if onCancel} {#if onCancel}
<button type="button" class="btn btn-sm preset-tonal-surface" onclick={onCancel}> <button
type="button"
class="btn btn-sm preset-tonal-surface"
onclick={onCancel}>
<X size={16} class="mr-1" /> Cancel <X size={16} class="mr-1" /> Cancel
</button> </button>
{/if} {/if}
<button type="submit" class="btn btn-sm preset-filled-primary font-bold shadow-lg" disabled={is_loading}> <button
type="submit"
class="btn btn-sm preset-filled-primary font-bold shadow-lg"
disabled={is_loading}>
{#if is_loading} {#if is_loading}
<span class="animate-spin mr-2"></span> <span class="animate-spin mr-2"></span>
{:else} {:else}
@@ -138,82 +160,163 @@
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Identity Section --> <!-- Identity Section -->
<fieldset class="space-y-4"> <fieldset class="space-y-4">
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">Identity & Branding</legend> <legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>Identity & Branding</legend>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="contact-title">Title / Name</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="contact-title" type="text" bind:value={formData.title} required placeholder="Business Office" /> class="label text-xs font-bold opacity-75"
for="contact-title">Title / Name</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="contact-title"
type="text"
bind:value={formData.title}
required
placeholder="Business Office" />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="contact-tagline">Tagline</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="contact-tagline" type="text" bind:value={formData.tagline} placeholder="Primary contact for business inquiries" /> class="label text-xs font-bold opacity-75"
for="contact-tagline">Tagline</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="contact-tagline"
type="text"
bind:value={formData.tagline}
placeholder="Primary contact for business inquiries" />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="contact-email">Email Address</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="contact-email">Email Address</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Mail size={16} /></div> <div class="input-group-shim"><Mail size={16} /></div>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="contact-email" type="email" bind:value={formData.email} placeholder="contact@example.com" /> <input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="contact-email"
type="email"
bind:value={formData.email}
placeholder="contact@example.com" />
</div> </div>
</div> </div>
</fieldset> </fieldset>
<!-- Communication Section --> <!-- Communication Section -->
<fieldset class="space-y-4"> <fieldset class="space-y-4">
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">Phone & Web</legend> <legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>Phone & Web</legend>
<div class="grid grid-cols-2 gap-2"> <div class="grid grid-cols-2 gap-2">
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="contact-phone-mobile">Mobile Phone</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="contact-phone-mobile">Mobile Phone</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Phone size={16} /></div> <div class="input-group-shim"><Phone size={16} /></div>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="contact-phone-mobile" type="tel" bind:value={formData.phone_mobile} placeholder="+1..." /> <input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="contact-phone-mobile"
type="tel"
bind:value={formData.phone_mobile}
placeholder="+1..." />
</div> </div>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="contact-phone-office">Office Phone</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="contact-phone-office">Office Phone</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Phone size={16} /></div> <div class="input-group-shim"><Phone size={16} /></div>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="contact-phone-office" type="tel" bind:value={formData.phone_office} placeholder="+1..." /> <input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="contact-phone-office"
type="tel"
bind:value={formData.phone_office}
placeholder="+1..." />
</div> </div>
</div> </div>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="contact-website">Website URL</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="contact-website">Website URL</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Globe size={16} /></div> <div class="input-group-shim"><Globe size={16} /></div>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="contact-website" type="url" bind:value={formData.website_url} placeholder="https://..." /> <input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="contact-website"
type="url"
bind:value={formData.website_url}
placeholder="https://..." />
</div> </div>
</div> </div>
</fieldset> </fieldset>
<!-- Social Media Section --> <!-- Social Media Section -->
<fieldset class="space-y-4"> <fieldset class="space-y-4">
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">Social Media</legend> <legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>Social Media</legend>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="contact-linkedin">LinkedIn URL</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="contact-linkedin">LinkedIn URL</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Linkedin size={16} /></div> <div class="input-group-shim"><Linkedin size={16} /></div>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="contact-linkedin" type="url" bind:value={formData.linkedin_url} placeholder="https://linkedin.com/in/..." /> <input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="contact-linkedin"
type="url"
bind:value={formData.linkedin_url}
placeholder="https://linkedin.com/in/..." />
</div> </div>
</div> </div>
<div class="grid grid-cols-2 gap-2"> <div class="grid grid-cols-2 gap-2">
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="contact-facebook">Facebook URL</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
<div class="input-group-shim"><Facebook size={16} /></div> for="contact-facebook">Facebook URL</label>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="contact-facebook" type="url" bind:value={formData.facebook_url} placeholder="https://facebook.com/..." /> <div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim">
<Facebook size={16} />
</div>
<input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="contact-facebook"
type="url"
bind:value={formData.facebook_url}
placeholder="https://facebook.com/..." />
</div> </div>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="contact-instagram">Instagram URL</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
<div class="input-group-shim"><Instagram size={16} /></div> for="contact-instagram">Instagram URL</label>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="contact-instagram" type="url" bind:value={formData.instagram_url} placeholder="https://instagram.com/..." /> <div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim">
<Instagram size={16} />
</div>
<input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="contact-instagram"
type="url"
bind:value={formData.instagram_url}
placeholder="https://instagram.com/..." />
</div> </div>
</div> </div>
</div> </div>
@@ -221,32 +324,53 @@
<!-- Status Section --> <!-- Status Section -->
<fieldset class="space-y-4"> <fieldset class="space-y-4">
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">Status</legend> <legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>Status</legend>
<div class="flex flex-wrap gap-4 pt-2"> <div class="flex flex-wrap gap-4 pt-2">
<label class="flex items-center space-x-2 cursor-pointer"> <label class="flex items-center space-x-2 cursor-pointer">
<input class="checkbox" type="checkbox" bind:checked={formData.enable} /> <input
class="checkbox"
type="checkbox"
bind:checked={formData.enable} />
<span class="text-sm font-medium">Enabled</span> <span class="text-sm font-medium">Enabled</span>
</label> </label>
<label class="flex items-center space-x-2 cursor-pointer"> <label class="flex items-center space-x-2 cursor-pointer">
<input class="checkbox" type="checkbox" bind:checked={formData.hide} /> <input
class="checkbox"
type="checkbox"
bind:checked={formData.hide} />
<span class="text-sm font-medium">Hidden</span> <span class="text-sm font-medium">Hidden</span>
</label> </label>
<label class="flex items-center space-x-2 cursor-pointer"> <label class="flex items-center space-x-2 cursor-pointer">
<input class="checkbox" type="checkbox" bind:checked={formData.priority} /> <input
class="checkbox"
type="checkbox"
bind:checked={formData.priority} />
<span class="text-sm font-medium">Priority</span> <span class="text-sm font-medium">Priority</span>
</label> </label>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="contact-notes">Internal Notes</label> <label
<textarea class="textarea preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="contact-notes" rows="2" bind:value={formData.notes} placeholder="Additional details..."></textarea> class="label text-xs font-bold opacity-75"
for="contact-notes">Internal Notes</label>
<textarea
class="textarea preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="contact-notes"
rows="2"
bind:value={formData.notes}
placeholder="Additional details..."></textarea>
</div> </div>
</fieldset> </fieldset>
</div> </div>
<footer class="flex justify-end gap-2 border-t border-surface-500/30 pt-4"> <footer class="flex justify-end gap-2 border-t border-surface-500/30 pt-4">
<button type="submit" class="btn preset-filled-primary font-bold shadow-lg w-full md:w-auto" disabled={is_loading}> <button
type="submit"
class="btn preset-filled-primary font-bold shadow-lg w-full md:w-auto"
disabled={is_loading}>
{#if is_loading} {#if is_loading}
<span class="animate-spin mr-2"></span> <span class="animate-spin mr-2"></span>
{/if} {/if}

View File

@@ -1,74 +1,99 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { ae_api, ae_loc } from '$lib/stores/ae_stores'; import { ae_api, ae_loc } from '$lib/stores/ae_stores';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { Clock, Globe, Info, Landmark, List, ListFilter, MapPin, RefreshCcw, Star } from '@lucide/svelte'; import {
import { api } from '$lib/api/api'; Clock,
Globe,
Info,
Landmark,
List,
ListFilter,
MapPin,
RefreshCcw,
Star
} from '@lucide/svelte';
import { api } from '$lib/api/api';
let loading = $state(true); let loading = $state(true);
let tz_only_priority = $state(false); let tz_only_priority = $state(false);
let lookups: any = $state({ let lookups: any = $state({
countries: [], countries: [],
time_zones: [], time_zones: [],
subdivisions: [] subdivisions: []
}); });
async function load_lookups() { async function load_lookups() {
loading = true; loading = true;
try { try {
const [countries, subdivisions, time_zones] = await Promise.all([ const [countries, subdivisions, time_zones] = await Promise.all([
api.get_ae_obj_li_for_lu({ api_cfg: $ae_api, for_lu_type: 'country', log_lvl: 1 }), api.get_ae_obj_li_for_lu({
api.get_ae_obj_li_for_lu({ api_cfg: $ae_api, for_lu_type: 'country_subdivision', log_lvl: 1 }), api_cfg: $ae_api,
api.get_ae_obj_li_for_lu({ for_lu_type: 'country',
api_cfg: $ae_api, log_lvl: 1
for_lu_type: 'time_zone', }),
only_priority: tz_only_priority, api.get_ae_obj_li_for_lu({
log_lvl: 1 api_cfg: $ae_api,
}) for_lu_type: 'country_subdivision',
]); log_lvl: 1
}),
api.get_ae_obj_li_for_lu({
api_cfg: $ae_api,
for_lu_type: 'time_zone',
only_priority: tz_only_priority,
log_lvl: 1
})
]);
console.log('Lookup Results - Countries:', countries); console.log('Lookup Results - Countries:', countries);
console.log('Lookup Results - Subdivisions:', subdivisions); console.log('Lookup Results - Subdivisions:', subdivisions);
console.log('Lookup Results - Time Zones:', time_zones); console.log('Lookup Results - Time Zones:', time_zones);
lookups.countries = countries || []; lookups.countries = countries || [];
lookups.subdivisions = subdivisions || []; lookups.subdivisions = subdivisions || [];
lookups.time_zones = time_zones || []; lookups.time_zones = time_zones || [];
} catch (error) { } catch (error) {
console.error('Failed to load lookups:', error); console.error('Failed to load lookups:', error);
} finally { } finally {
loading = false; loading = false;
}
} }
}
onMount(() => { onMount(() => {
if (!$ae_loc.manager_access) { if (!$ae_loc.manager_access) {
goto('/core'); goto('/core');
return; return;
}
load_lookups();
});
// Handle TZ priority toggle
function toggle_tz_priority() {
tz_only_priority = !tz_only_priority;
load_lookups();
} }
load_lookups();
});
// Handle TZ priority toggle
function toggle_tz_priority() {
tz_only_priority = !tz_only_priority;
load_lookups();
}
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10 gap-4"> <header
class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10 gap-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-primary-500/10 rounded-lg"> <div class="p-2 bg-primary-500/10 rounded-lg">
<List size={24} class="text-primary-500" /> <List size={24} class="text-primary-500" />
</div> </div>
<div> <div>
<h1 class="h2 font-black tracking-tight">System Lookups</h1> <h1 class="h2 font-black tracking-tight">System Lookups</h1>
<p class="text-xs font-bold opacity-50 uppercase tracking-widest">Global Reference Data</p> <p
class="text-xs font-bold opacity-50 uppercase tracking-widest">
Global Reference Data
</p>
</div> </div>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
<button class="btn btn-sm preset-filled-primary font-bold shadow-lg" onclick={load_lookups} disabled={loading}> <button
class="btn btn-sm preset-filled-primary font-bold shadow-lg"
onclick={load_lookups}
disabled={loading}>
{#if loading} {#if loading}
<RefreshCcw size={16} class="mr-2 animate-spin" /> Loading... <RefreshCcw size={16} class="mr-2 animate-spin" /> Loading...
{:else} {:else}
@@ -80,22 +105,29 @@
{#if loading && !lookups.countries.length} {#if loading && !lookups.countries.length}
<div class="card p-8 flex justify-center items-center h-64"> <div class="card p-8 flex justify-center items-center h-64">
<div class="placeholder animate-pulse w-full h-full rounded-2xl"></div> <div class="placeholder animate-pulse w-full h-full rounded-2xl">
</div>
</div> </div>
{:else} {:else}
<div class="space-y-6 animate-fade-in"> <div class="space-y-6 animate-fade-in">
<!-- 1. Countries --> <!-- 1. Countries -->
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Globe size={20} class="text-secondary-500" /> <Globe size={20} class="text-secondary-500" />
Country Reference Country Reference
<span class="badge preset-tonal-secondary ml-auto text-[10px] uppercase font-bold">{lookups.countries.length} Records</span> <span
class="badge preset-tonal-secondary ml-auto text-[10px] uppercase font-bold"
>{lookups.countries.length} Records</span>
</h3> </h3>
<div class="table-container max-h-[400px] overflow-auto border border-surface-500/10 rounded-lg"> <div
class="table-container max-h-[400px] overflow-auto border border-surface-500/10 rounded-lg">
<table class="table table-hover table-compact"> <table class="table table-hover table-compact">
<thead> <thead>
<tr class="uppercase text-[10px] tracking-widest opacity-60"> <tr
class="uppercase text-[10px] tracking-widest opacity-60">
<th>Name</th> <th>Name</th>
<th class="text-center">ISO Alpha-2</th> <th class="text-center">ISO Alpha-2</th>
</tr> </tr>
@@ -103,8 +135,13 @@
<tbody> <tbody>
{#each lookups.countries as c (c.alpha_2_code)} {#each lookups.countries as c (c.alpha_2_code)}
<tr class="transition-colors"> <tr class="transition-colors">
<td class="font-bold">{c.name || c.english_short_name}</td> <td class="font-bold"
<td class="text-center"><span class="badge preset-tonal-surface font-mono text-primary-500">{c.alpha_2_code}</span></td> >{c.name || c.english_short_name}</td>
<td class="text-center"
><span
class="badge preset-tonal-surface font-mono text-primary-500"
>{c.alpha_2_code}</span
></td>
</tr> </tr>
{/each} {/each}
</tbody> </tbody>
@@ -113,17 +150,23 @@
</div> </div>
<!-- 2. Subdivisions --> <!-- 2. Subdivisions -->
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<MapPin size={20} class="text-primary-500" /> <MapPin size={20} class="text-primary-500" />
Country Subdivisions (States/Provinces) Country Subdivisions (States/Provinces)
<span class="badge preset-tonal-secondary ml-auto text-[10px] uppercase font-bold">{lookups.subdivisions.length} Records</span> <span
class="badge preset-tonal-secondary ml-auto text-[10px] uppercase font-bold"
>{lookups.subdivisions.length} Records</span>
</h3> </h3>
<div class="table-container max-h-[500px] overflow-auto border border-surface-500/10 rounded-lg"> <div
class="table-container max-h-[500px] overflow-auto border border-surface-500/10 rounded-lg">
<table class="table table-hover table-compact"> <table class="table table-hover table-compact">
<thead> <thead>
<tr class="uppercase text-[10px] tracking-widest opacity-60"> <tr
class="uppercase text-[10px] tracking-widest opacity-60">
<th>Country</th> <th>Country</th>
<th>Name</th> <th>Name</th>
<th class="text-center">Code</th> <th class="text-center">Code</th>
@@ -132,9 +175,14 @@
<tbody> <tbody>
{#each lookups.subdivisions as s, i (i)} {#each lookups.subdivisions as s, i (i)}
<tr class="transition-colors"> <tr class="transition-colors">
<td class="opacity-60">{s.country_alpha_2_code}</td> <td class="opacity-60"
>{s.country_alpha_2_code}</td>
<td class="font-bold">{s.name}</td> <td class="font-bold">{s.name}</td>
<td class="text-center"><span class="badge preset-tonal-surface font-mono">{s.code}</span></td> <td class="text-center"
><span
class="badge preset-tonal-surface font-mono"
>{s.code}</span
></td>
</tr> </tr>
{/each} {/each}
</tbody> </tbody>
@@ -143,27 +191,40 @@
</div> </div>
<!-- 3. Time Zones --> <!-- 3. Time Zones -->
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6"> <div
<div class="flex flex-wrap justify-between items-center border-b border-surface-500/30 pb-2 gap-4"> class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-6">
<div
class="flex flex-wrap justify-between items-center border-b border-surface-500/30 pb-2 gap-4">
<h3 class="h4 font-bold flex items-center gap-2"> <h3 class="h4 font-bold flex items-center gap-2">
<Clock size={20} class="text-tertiary-500" /> <Clock size={20} class="text-tertiary-500" />
Time Zone Reference Time Zone Reference
<span class="badge preset-tonal-secondary text-[10px] uppercase font-bold">{lookups.time_zones.length} Zones</span> <span
class="badge preset-tonal-secondary text-[10px] uppercase font-bold"
>{lookups.time_zones.length} Zones</span>
</h3> </h3>
<button <button
class="btn btn-sm transition-all {tz_only_priority ? 'preset-filled-warning' : 'preset-tonal-surface'}" class="btn btn-sm transition-all {tz_only_priority
? 'preset-filled-warning'
: 'preset-tonal-surface'}"
onclick={toggle_tz_priority} onclick={toggle_tz_priority}
disabled={loading} disabled={loading}>
> <Star
<Star size={14} class="mr-2 {tz_only_priority ? 'fill-current' : ''}" /> size={14}
{tz_only_priority ? 'Showing Priority' : 'Show Only Priority'} class="mr-2 {tz_only_priority
? 'fill-current'
: ''}" />
{tz_only_priority
? 'Showing Priority'
: 'Show Only Priority'}
</button> </button>
</div> </div>
<div class="table-container max-h-[500px] overflow-auto border border-surface-500/10 rounded-lg"> <div
class="table-container max-h-[500px] overflow-auto border border-surface-500/10 rounded-lg">
<table class="table table-hover table-compact"> <table class="table table-hover table-compact">
<thead> <thead>
<tr class="uppercase text-[10px] tracking-widest opacity-60"> <tr
class="uppercase text-[10px] tracking-widest opacity-60">
<th>Zone Name</th> <th>Zone Name</th>
<th class="text-right">Offset (Hours)</th> <th class="text-right">Offset (Hours)</th>
</tr> </tr>
@@ -172,7 +233,11 @@
{#each lookups.time_zones as tz (tz.name)} {#each lookups.time_zones as tz (tz.name)}
<tr class="transition-colors"> <tr class="transition-colors">
<td class="font-bold">{tz.name}</td> <td class="font-bold">{tz.name}</td>
<td class="text-right"><span class="badge preset-tonal-surface font-mono">{tz.offset_seconds / 3600}h</span></td> <td class="text-right"
><span
class="badge preset-tonal-surface font-mono"
>{tz.offset_seconds / 3600}h</span
></td>
</tr> </tr>
{/each} {/each}
</tbody> </tbody>
@@ -181,9 +246,13 @@
</div> </div>
</div> </div>
<div class="card p-4 preset-tonal-surface border border-surface-500/10 flex items-center gap-3"> <div
class="card p-4 preset-tonal-surface border border-surface-500/10 flex items-center gap-3">
<Info size={16} class="text-primary-500" /> <Info size={16} class="text-primary-500" />
<p class="text-xs opacity-70">Lookup data is synchronized with the global system database and used for addresses, event scheduling, and localized displays.</p> <p class="text-xs opacity-70">
Lookup data is synchronized with the global system database and
used for addresses, event scheduling, and localized displays.
</p>
</div> </div>
{/if} {/if}
</div> </div>

View File

@@ -1,26 +1,27 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { ListFilter, Plus, Users, X } from '@lucide/svelte'; import { ListFilter, Plus, Users, X } from '@lucide/svelte';
import { ae_loc, ae_sess, slct, ae_api } from '$lib/stores/ae_stores'; import { ae_loc, ae_sess, slct, ae_api } from '$lib/stores/ae_stores';
import { core_func } from '$lib/ae_core/ae_core_functions'; import { core_func } from '$lib/ae_core/ae_core_functions';
import Comp_person_search from './ae_comp__person_search.svelte'; import Comp_person_search from './ae_comp__person_search.svelte';
import Comp_person_obj_tbl from '../ae_comp__person_obj_tbl.svelte'; import Comp_person_obj_tbl from '../ae_comp__person_obj_tbl.svelte';
import Person_form from './ae_comp__person_form.svelte'; import Person_form from './ae_comp__person_form.svelte';
let person_id_random_li: string[] = $state([]); let person_id_random_li: string[] = $state([]);
let show_add_form = $state(false); let show_add_form = $state(false);
onMount(() => { onMount(() => {
if (!$ae_loc.manager_access) { if (!$ae_loc.manager_access) {
goto('/core'); goto('/core');
return; return;
} }
}); });
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10"> <header
class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<div class="p-2 bg-primary-500/10 rounded-lg"> <div class="p-2 bg-primary-500/10 rounded-lg">
<Users size={24} class="text-primary-500" /> <Users size={24} class="text-primary-500" />
@@ -29,10 +30,9 @@
</div> </div>
<button <button
type="button" type="button"
onclick={() => show_add_form = !show_add_form} onclick={() => (show_add_form = !show_add_form)}
class="btn btn-sm preset-filled-primary font-bold shadow-lg" class="btn btn-sm preset-filled-primary font-bold shadow-lg"
class:hidden={!$ae_loc.edit_mode} class:hidden={!$ae_loc.edit_mode}>
>
{#if show_add_form} {#if show_add_form}
<X size={16} class="mr-2" /> Cancel <X size={16} class="mr-2" /> Cancel
{:else} {:else}
@@ -48,22 +48,25 @@
show_add_form = false; show_add_form = false;
goto(`/core/people/${new_person.person_id_random}`); goto(`/core/people/${new_person.person_id_random}`);
}} }}
onCancel={() => show_add_form = false} onCancel={() => (show_add_form = false)} />
/>
</div> </div>
{/if} {/if}
<Comp_person_search on_results={(results) => { <Comp_person_search
person_id_random_li = results.map(p => p.person_id_random); on_results={(results) => {
$ae_sess.person.show_report__person_li = true; person_id_random_li = results.map((p) => p.person_id_random);
}} /> $ae_sess.person.show_report__person_li = true;
}} />
{#if $ae_sess.person.show_report__person_li} {#if $ae_sess.person.show_report__person_li}
<div class="card p-6 preset-tonal-surface shadow-xl space-y-4 border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 preset-tonal-surface shadow-xl space-y-4 border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<ListFilter size={18} class="text-secondary-500" /> <ListFilter size={18} class="text-secondary-500" />
Search Results Search Results
<span class="badge preset-tonal-secondary ml-auto">{person_id_random_li.length} found</span> <span class="badge preset-tonal-secondary ml-auto"
>{person_id_random_li.length} found</span>
</h3> </h3>
<div class="overflow-x-auto"> <div class="overflow-x-auto">
<Comp_person_obj_tbl <Comp_person_obj_tbl

View File

@@ -1,160 +1,176 @@
<script lang="ts"> <script lang="ts">
/** @type {import('./$types').PageData} */ /** @type {import('./$types').PageData} */
// import { page } from '$app/stores'; // import { page } from '$app/stores';
// Imports // Imports
import { onMount, untrack } from 'svelte'; import { onMount, untrack } from 'svelte';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import type { key_val } from '$lib/stores/ae_stores'; import type { key_val } from '$lib/stores/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils'; import { ae_util } from '$lib/ae_utils/ae_utils';
// import { api } from '$lib/api'; // import { api } from '$lib/api';
import Element_data_store from '$lib/elements/element_data_store.svelte'; import Element_data_store from '$lib/elements/element_data_store.svelte';
import { liveQuery } from 'dexie'; import { liveQuery } from 'dexie';
// import { core_func } from '$lib/ae_core_functions'; // import { core_func } from '$lib/ae_core_functions';
import { db_core } from '$lib/ae_core/db_core'; import { db_core } from '$lib/ae_core/db_core';
// import { db_events } from "$lib/db_events"; // import { db_events } from "$lib/db_events";
import { import {
ae_snip, ae_snip,
ae_loc, ae_loc,
ae_sess, ae_sess,
ae_api, ae_api,
ae_trig, ae_trig,
slct, slct,
slct_trigger slct_trigger
} from '$lib/stores/ae_stores'; } from '$lib/stores/ae_stores';
// import { events_loc, events_sess, slct, events_trigger } from '$lib/stores/ae_events_stores'; // import { events_loc, events_sess, slct, events_trigger } from '$lib/stores/ae_events_stores';
// import { events_func } from '$lib/ae_events/ae_events_functions'; // import { events_func } from '$lib/ae_events/ae_events_functions';
import Person_view from './../../person_view.svelte'; import Person_view from './../../person_view.svelte';
import Person_form from './../ae_comp__person_form.svelte'; import Person_form from './../ae_comp__person_form.svelte';
import { load_ae_obj_li__user } from '$lib/ae_core/ae_core__user'; import { load_ae_obj_li__user } from '$lib/ae_core/ae_core__user';
import { update_ae_obj__person } from '$lib/ae_core/ae_core__person'; import { update_ae_obj__person } from '$lib/ae_core/ae_core__person';
import { qry_ae_obj_li__event } from '$lib/ae_events/ae_events__event'; import { qry_ae_obj_li__event } from '$lib/ae_events/ae_events__event';
import { qry__post } from '$lib/ae_posts/ae_posts__post'; import { qry__post } from '$lib/ae_posts/ae_posts__post';
import { qry__activity_log } from '$lib/ae_core/ae_core__activity_log'; import { qry__activity_log } from '$lib/ae_core/ae_core__activity_log';
import { Activity, ArrowLeft, Calendar, Edit, Eye, HelpCircle, History, Link, LoaderCircle, MessageSquare, ShieldCheck, Unlink, User, UserPlus, Users } from '@lucide/svelte'; import {
interface Props { Activity,
data: any; ArrowLeft,
} Calendar,
Edit,
Eye,
HelpCircle,
History,
Link,
LoaderCircle,
MessageSquare,
ShieldCheck,
Unlink,
User,
UserPlus,
Users
} from '@lucide/svelte';
interface Props {
data: any;
}
let { data }: Props = $props(); let { data }: Props = $props();
// Variables // Variables
let ae_acct = $derived(data[data.account_id]); let ae_acct = $derived(data[data.account_id]);
$effect(() => { $effect(() => {
if (!ae_acct) return; if (!ae_acct) return;
untrack(() => { untrack(() => {
$slct.account_id = data.account_id; $slct.account_id = data.account_id;
$ae_loc.url_origin = data.url.origin; $ae_loc.url_origin = data.url.origin;
$slct.person_id = ae_acct.slct.person_id; $slct.person_id = ae_acct.slct.person_id;
$slct.person_obj = ae_acct.slct.person_obj; $slct.person_obj = ae_acct.slct.person_obj;
}); });
});
let is_editing = $state(false);
let lq__person_obj = liveQuery(() => db_core.person.get($slct.person_id));
$slct.lq__person_obj = lq__person_obj;
let available_users: any[] = $state([]);
let loading_users = $state(false);
let show_link_ui = $state(false);
let related_events: any[] = $state([]);
let related_posts: any[] = $state([]);
let related_activity_logs: any[] = $state([]);
let loading_activity = $state(false);
async function load_activity() {
if (!$slct.person_id) return;
loading_activity = true;
// Load related data using search queries
const [events, posts, logs] = await Promise.all([
qry_ae_obj_li__event({
api_cfg: $ae_api,
for_obj_id: $ae_loc.account_id,
qry_person_id: $slct.person_id,
log_lvl: 1
}),
qry__post({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
qry_person_id: $slct.person_id,
log_lvl: 1
}),
qry__activity_log({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
qry_person_id: $slct.person_id,
limit: 10,
log_lvl: 1
})
]);
related_events = events || [];
related_posts = posts || [];
related_activity_logs = logs || [];
loading_activity = false;
}
async function load_unlinked_users() {
if (!$ae_loc.manager_access) return;
loading_users = true;
const all_users = await load_ae_obj_li__user({
api_cfg: $ae_api,
enabled: 'enabled',
log_lvl: 1
});
// Filter users that don't have a person_id linked
// NOTE: The backend might return person_id or person_id
available_users = all_users.filter((u) => !u.person_id && !u.person_id);
loading_users = false;
}
async function handle_link_user(user_id: string) {
if (!confirm('Link this person to this user account?')) return;
const result = await update_ae_obj__person({
api_cfg: $ae_api,
person_id: $slct.person_id,
data_kv: { user_id },
log_lvl: 1
}); });
let is_editing = $state(false); if (result) {
show_link_ui = false;
let lq__person_obj = liveQuery(() => db_core.person.get($slct.person_id)); available_users = [];
$slct.lq__person_obj = lq__person_obj;
let available_users: any[] = $state([]);
let loading_users = $state(false);
let show_link_ui = $state(false);
let related_events: any[] = $state([]);
let related_posts: any[] = $state([]);
let related_activity_logs: any[] = $state([]);
let loading_activity = $state(false);
async function load_activity() {
if (!$slct.person_id) return;
loading_activity = true;
// Load related data using search queries
const [events, posts, logs] = await Promise.all([
qry_ae_obj_li__event({
api_cfg: $ae_api,
for_obj_id: $ae_loc.account_id,
qry_person_id: $slct.person_id,
log_lvl: 1
}),
qry__post({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
qry_person_id: $slct.person_id,
log_lvl: 1
}),
qry__activity_log({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
qry_person_id: $slct.person_id,
limit: 10,
log_lvl: 1
})
]);
related_events = events || [];
related_posts = posts || [];
related_activity_logs = logs || [];
loading_activity = false;
} }
}
async function load_unlinked_users() { async function handle_unlink_user() {
if (!$ae_loc.manager_access) return; if (!confirm('Unlink this person from their user account?')) return;
loading_users = true;
const all_users = await load_ae_obj_li__user({
api_cfg: $ae_api,
enabled: 'enabled',
log_lvl: 1
});
// Filter users that don't have a person_id linked
// NOTE: The backend might return person_id or person_id
available_users = all_users.filter(u => !u.person_id && !u.person_id);
loading_users = false;
}
async function handle_link_user(user_id: string) { const result = await update_ae_obj__person({
if (!confirm('Link this person to this user account?')) return; api_cfg: $ae_api,
person_id: $slct.person_id,
const result = await update_ae_obj__person({ data_kv: { user_id: null },
api_cfg: $ae_api, log_lvl: 1
person_id: $slct.person_id,
data_kv: { user_id },
log_lvl: 1
});
if (result) {
show_link_ui = false;
available_users = [];
}
}
async function handle_unlink_user() {
if (!confirm('Unlink this person from their user account?')) return;
const result = await update_ae_obj__person({
api_cfg: $ae_api,
person_id: $slct.person_id,
data_kv: { user_id: null },
log_lvl: 1
});
}
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
return;
}
load_activity();
}); });
}
if (!$ae_loc.person) { onMount(() => {
$ae_loc.person = {}; if (!$ae_loc.manager_access) {
goto('/core');
return;
} }
$ae_loc.person.show_content__person_page_help = false; load_activity();
});
// *** Functions and Logic if (!$ae_loc.person) {
$ae_loc.person = {};
}
$ae_loc.person.show_content__person_page_help = false;
// *** Functions and Logic
</script> </script>
<svelte:head> <svelte:head>
@@ -169,11 +185,11 @@
</title> </title>
</svelte:head> </svelte:head>
<section class="ae_core__person md:container h-full mx-auto flex flex-col space-y-4 pt-0 pb-8"> <section
class="ae_core__person md:container h-full mx-auto flex flex-col space-y-4 pt-0 pb-8">
<div <div
class="core__person_view_menu {ae_snip.classes__core_menu}" class="core__person_view_menu {ae_snip.classes__core_menu}"
class:border-gray-100={!$ae_loc.person.show_content__person_page_help} class:border-gray-100={!$ae_loc.person.show_content__person_page_help}>
>
<div> <div>
<a href="/core/people" class={ae_snip.classes__core_menu__button}> <a href="/core/people" class={ae_snip.classes__core_menu__button}>
<ArrowLeft size="1em" class="mx-1" /> <ArrowLeft size="1em" class="mx-1" />
@@ -183,9 +199,8 @@
{#if $ae_loc.edit_mode} {#if $ae_loc.edit_mode}
<button <button
type="button" type="button"
onclick={() => is_editing = !is_editing} onclick={() => (is_editing = !is_editing)}
class="btn btn-sm preset-tonal-secondary mx-1" class="btn btn-sm preset-tonal-secondary mx-1">
>
{#if is_editing} {#if is_editing}
<Eye size={16} class="mr-2" /> View Mode <Eye size={16} class="mr-2" /> View Mode
{:else} {:else}
@@ -201,8 +216,7 @@
!$ae_loc.person.show_content__person_page_help; !$ae_loc.person.show_content__person_page_help;
}} }}
class={ae_snip.classes__core_menu__button} class={ae_snip.classes__core_menu__button}
title="Help and information about the person page" title="Help and information about the person page">
>
<HelpCircle size="1em" class="mx-1" /> <HelpCircle size="1em" class="mx-1" />
{#if $ae_loc.person.show_content__person_page_help} {#if $ae_loc.person.show_content__person_page_help}
Hide Hide
@@ -222,8 +236,7 @@
class_li="bg-yellow-100 p-2 rounded-md border border-yellow-200" class_li="bg-yellow-100 p-2 rounded-md border border-yellow-200"
show_edit={false} show_edit={false}
show_edit_btn={true} show_edit_btn={true}
hide={!$ae_loc.person.show_content__person_page_help} hide={!$ae_loc.person.show_content__person_page_help} />
/>
<div> <div>
<button <button
@@ -234,8 +247,7 @@
}} }}
class="btn btn-sm mx-1 preset-tonal-error border border-error-500 hover:preset-filled-error-500" class="btn btn-sm mx-1 preset-tonal-error border border-error-500 hover:preset-filled-error-500"
class:hidden={!$ae_loc.person.show_content__person_page_help} class:hidden={!$ae_loc.person.show_content__person_page_help}
title="Help and information about the session search" title="Help and information about the session search">
>
<HelpCircle size="1em" class="mx-1" /> <HelpCircle size="1em" class="mx-1" />
{#if $ae_loc.person.show_content__person_page_help} {#if $ae_loc.person.show_content__person_page_help}
Hide Hide
@@ -249,58 +261,88 @@
{#if $ae_loc.manager_access} {#if $ae_loc.manager_access}
<div class="card p-4 preset-tonal-surface space-y-4 mx-4"> <div class="card p-4 preset-tonal-surface space-y-4 mx-4">
<header class="flex justify-between items-center border-b border-surface-500/30 pb-2"> <header
class="flex justify-between items-center border-b border-surface-500/30 pb-2">
<div class="flex items-center gap-2 font-bold"> <div class="flex items-center gap-2 font-bold">
<ShieldCheck size={18} /> <ShieldCheck size={18} />
<span>User Account Linking</span> <span>User Account Linking</span>
</div> </div>
{#if $lq__person_obj?.user_id} {#if $lq__person_obj?.user_id}
<button class="btn btn-sm preset-tonal-error" onclick={handle_unlink_user}> <button
class="btn btn-sm preset-tonal-error"
onclick={handle_unlink_user}>
<Unlink size={14} class="mr-2" /> Unlink User <Unlink size={14} class="mr-2" /> Unlink User
</button> </button>
{:else} {:else}
<button <button
class="btn btn-sm preset-tonal-primary" class="btn btn-sm preset-tonal-primary"
onclick={() => { show_link_ui = !show_link_ui; if(show_link_ui) load_unlinked_users(); }} onclick={() => {
> show_link_ui = !show_link_ui;
<Link size={14} class="mr-2" /> {show_link_ui ? 'Cancel Linking' : 'Link to User'} if (show_link_ui) load_unlinked_users();
}}>
<Link size={14} class="mr-2" />
{show_link_ui ? 'Cancel Linking' : 'Link to User'}
</button> </button>
{/if} {/if}
</header> </header>
{#if $lq__person_obj?.user_id} {#if $lq__person_obj?.user_id}
<div class="flex items-center gap-4 py-2"> <div class="flex items-center gap-4 py-2">
<div class="avatar preset-filled-primary w-12 h-12 flex items-center justify-center rounded-full"> <div
class="avatar preset-filled-primary w-12 h-12 flex items-center justify-center rounded-full">
<Users size={24} /> <Users size={24} />
</div> </div>
<div> <div>
<p class="text-sm opacity-60 uppercase tracking-widest font-bold">Linked User ID</p> <p
<p class="font-mono text-lg">{$lq__person_obj.user_id}</p> class="text-sm opacity-60 uppercase tracking-widest font-bold">
<p class="text-xs opacity-60">Username: {$lq__person_obj.username || '--'}</p> Linked User ID
</p>
<p class="font-mono text-lg">
{$lq__person_obj.user_id}
</p>
<p class="text-xs opacity-60">
Username: {$lq__person_obj.username || '--'}
</p>
</div> </div>
</div> </div>
{:else if show_link_ui} {:else if show_link_ui}
<div class="space-y-4 py-2"> <div class="space-y-4 py-2">
<p class="text-sm opacity-80">Select a user account to link to this person. Only accounts without a linked person are shown.</p> <p class="text-sm opacity-80">
Select a user account to link to this person. Only
accounts without a linked person are shown.
</p>
{#if loading_users} {#if loading_users}
<div class="placeholder animate-pulse h-20 w-full"></div> <div class="placeholder animate-pulse h-20 w-full">
</div>
{:else if available_users.length === 0} {:else if available_users.length === 0}
<p class="text-center py-4 italic opacity-60 border border-dashed border-surface-500/30">No unlinked user accounts found.</p> <p
class="text-center py-4 italic opacity-60 border border-dashed border-surface-500/30">
No unlinked user accounts found.
</p>
{:else} {:else}
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2"> <div
class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2">
{#each available_users as user (user.user_id)} {#each available_users as user (user.user_id)}
<button <button
class="card p-3 preset-tonal-primary hover:preset-filled-primary text-left transition-all flex flex-col gap-1" class="card p-3 preset-tonal-primary hover:preset-filled-primary text-left transition-all flex flex-col gap-1"
onclick={() => handle_link_user(user.user_id)} onclick={() =>
> handle_link_user(user.user_id)}>
<span class="font-bold flex items-center gap-2"> <span
class="font-bold flex items-center gap-2">
<User size={14} /> <User size={14} />
{user.username} {user.username}
</span> </span>
<span class="text-xs opacity-70 truncate">{user.email}</span> <span class="text-xs opacity-70 truncate"
>{user.email}</span>
<div class="flex gap-1 mt-1"> <div class="flex gap-1 mt-1">
{#if user.super}<span class="badge preset-filled-error text-[10px]">Super</span>{/if} {#if user.super}<span
{#if user.manager}<span class="badge preset-filled-warning text-[10px]">Manager</span>{/if} class="badge preset-filled-error text-[10px]"
>Super</span
>{/if}
{#if user.manager}<span
class="badge preset-filled-warning text-[10px]"
>Manager</span
>{/if}
</div> </div>
</button> </button>
{/each} {/each}
@@ -310,14 +352,17 @@
{:else} {:else}
<div class="flex items-center gap-2 py-2 opacity-60"> <div class="flex items-center gap-2 py-2 opacity-60">
<Users size={20} /> <Users size={20} />
<p class="italic text-sm">This person is not currently linked to a user account.</p> <p class="italic text-sm">
This person is not currently linked to a user account.
</p>
</div> </div>
{/if} {/if}
</div> </div>
<!-- Activity & Content Section --> <!-- Activity & Content Section -->
<div class="card p-4 preset-tonal-surface space-y-4 mx-4"> <div class="card p-4 preset-tonal-surface space-y-4 mx-4">
<header class="flex items-center gap-2 font-bold border-b border-surface-500/30 pb-2"> <header
class="flex items-center gap-2 font-bold border-b border-surface-500/30 pb-2">
<History size={18} /> <History size={18} />
<span>Linked Activity & Content</span> <span>Linked Activity & Content</span>
</header> </header>
@@ -325,19 +370,29 @@
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Related Events --> <!-- Related Events -->
<div class="space-y-3"> <div class="space-y-3">
<h4 class="h4 flex items-center gap-2 text-sm opacity-70 uppercase tracking-wider font-bold"> <h4
class="h4 flex items-center gap-2 text-sm opacity-70 uppercase tracking-wider font-bold">
<Calendar size={16} /> Related Events <Calendar size={16} /> Related Events
</h4> </h4>
{#if loading_activity} {#if loading_activity}
<div class="placeholder animate-pulse h-20 w-full"></div> <div class="placeholder animate-pulse h-20 w-full">
</div>
{:else if related_events.length === 0} {:else if related_events.length === 0}
<p class="text-sm italic opacity-50">No related events found.</p> <p class="text-sm italic opacity-50">
No related events found.
</p>
{:else} {:else}
<div class="space-y-2"> <div class="space-y-2">
{#each related_events as ev (ev.event_id)} {#each related_events as ev (ev.event_id)}
<a href="/events/{ev.event_id}" class="card p-3 preset-tonal-surface flex flex-col gap-1 hover:preset-tonal-primary transition-all"> <a
<span class="font-bold text-sm">{ev.name}</span> href="/events/{ev.event_id}"
<span class="text-[10px] opacity-60">{new Date(ev.start_datetime).toLocaleDateString()}</span> class="card p-3 preset-tonal-surface flex flex-col gap-1 hover:preset-tonal-primary transition-all">
<span class="font-bold text-sm"
>{ev.name}</span>
<span class="text-[10px] opacity-60"
>{new Date(
ev.start_datetime
).toLocaleDateString()}</span>
</a> </a>
{/each} {/each}
</div> </div>
@@ -346,21 +401,34 @@
<!-- Related Posts --> <!-- Related Posts -->
<div class="space-y-3"> <div class="space-y-3">
<h4 class="h4 flex items-center gap-2 text-sm opacity-70 uppercase tracking-wider font-bold"> <h4
class="h4 flex items-center gap-2 text-sm opacity-70 uppercase tracking-wider font-bold">
<MessageSquare size={16} /> Related Posts <MessageSquare size={16} /> Related Posts
</h4> </h4>
{#if loading_activity} {#if loading_activity}
<div class="placeholder animate-pulse h-20 w-full"></div> <div class="placeholder animate-pulse h-20 w-full">
</div>
{:else if related_posts.length === 0} {:else if related_posts.length === 0}
<p class="text-sm italic opacity-50">No related posts found.</p> <p class="text-sm italic opacity-50">
No related posts found.
</p>
{:else} {:else}
<div class="space-y-2"> <div class="space-y-2">
{#each related_posts as post (post.post_id)} {#each related_posts as post (post.post_id)}
<a href="/idaa/bb/{post.post_id}" class="card p-3 preset-tonal-surface flex flex-col gap-1 hover:preset-tonal-primary transition-all"> <a
<span class="font-bold text-sm">{post.title}</span> href="/idaa/bb/{post.post_id}"
<div class="flex justify-between items-center text-[10px] opacity-60"> class="card p-3 preset-tonal-surface flex flex-col gap-1 hover:preset-tonal-primary transition-all">
<span>{new Date(post.created_on).toLocaleDateString()}</span> <span class="font-bold text-sm"
<span class="badge preset-tonal-surface scale-75">{post.post_comment_count || 0} comments</span> >{post.title}</span>
<div
class="flex justify-between items-center text-[10px] opacity-60">
<span
>{new Date(
post.created_on
).toLocaleDateString()}</span>
<span
class="badge preset-tonal-surface scale-75"
>{post.post_comment_count || 0} comments</span>
</div> </div>
</a> </a>
{/each} {/each}
@@ -370,27 +438,42 @@
<!-- Recent Activity --> <!-- Recent Activity -->
<div class="space-y-3"> <div class="space-y-3">
<h4 class="h4 flex items-center gap-2 text-sm opacity-70 uppercase tracking-wider font-bold"> <h4
class="h4 flex items-center gap-2 text-sm opacity-70 uppercase tracking-wider font-bold">
<Activity size={16} /> Recent Activity <Activity size={16} /> Recent Activity
</h4> </h4>
{#if loading_activity} {#if loading_activity}
<div class="placeholder animate-pulse h-20 w-full"></div> <div class="placeholder animate-pulse h-20 w-full">
</div>
{:else if related_activity_logs.length === 0} {:else if related_activity_logs.length === 0}
<p class="text-sm italic opacity-50">No recent activity logs.</p> <p class="text-sm italic opacity-50">
No recent activity logs.
</p>
{:else} {:else}
<div class="space-y-2"> <div class="space-y-2">
{#each related_activity_logs as log, index (index)} {#each related_activity_logs as log, index (index)}
<div class="card p-3 preset-tonal-surface flex flex-col gap-1"> <div
<div class="flex justify-between items-start gap-2"> class="card p-3 preset-tonal-surface flex flex-col gap-1">
<span class="badge preset-filled-surface text-[9px] uppercase tracking-tighter">{log.action}</span> <div
<span class="text-[9px] opacity-50">{new Date(log.created_on).toLocaleDateString()}</span> class="flex justify-between items-start gap-2">
<span
class="badge preset-filled-surface text-[9px] uppercase tracking-tighter"
>{log.action}</span>
<span class="text-[9px] opacity-50"
>{new Date(
log.created_on
).toLocaleDateString()}</span>
</div> </div>
{#if log.summary} {#if log.summary}
<span class="text-xs opacity-80 line-clamp-1">{log.summary}</span> <span
class="text-xs opacity-80 line-clamp-1"
>{log.summary}</span>
{/if} {/if}
</div> </div>
{/each} {/each}
<a href="/core/activity_logs?person_id={$slct.person_id}" class="btn btn-sm preset-tonal-surface w-full text-[10px]"> <a
href="/core/activity_logs?person_id={$slct.person_id}"
class="btn btn-sm preset-tonal-surface w-full text-[10px]">
View All Activity View All Activity
</a> </a>
</div> </div>
@@ -412,11 +495,9 @@
onSave={(updated) => { onSave={(updated) => {
is_editing = false; is_editing = false;
}} }}
onCancel={() => is_editing = false} onCancel={() => (is_editing = false)} />
/>
</div> </div>
{:else} {:else}
<Person_view person_id={$slct.person_id} /> <Person_view person_id={$slct.person_id} />
{/if} {/if}
</section> </section>

View File

@@ -1,147 +1,167 @@
<script lang="ts"> <script lang="ts">
/** /**
* Person Form Component * Person Form Component
* Standardized 2026-01-09 for Core UI Polish. * Standardized 2026-01-09 for Core UI Polish.
* Uses unified ae_Person type and Svelte 5 Runes. * Uses unified ae_Person type and Svelte 5 Runes.
*/ */
import { ae_api, ae_loc } from '$lib/stores/ae_stores'; import { ae_api, ae_loc } from '$lib/stores/ae_stores';
import { core_func } from '$lib/ae_core/ae_core_functions'; import { core_func } from '$lib/ae_core/ae_core_functions';
import type { ae_Person } from '$lib/types/ae_types'; import type { ae_Person } from '$lib/types/ae_types';
import { Briefcase, Building, Link, Mail, Phone, Save, Tag, User, X } from '@lucide/svelte'; import {
interface Props { Briefcase,
person?: ae_Person | null; Building,
onSave?: (person: ae_Person) => void; Link,
onCancel?: () => void; Mail,
} Phone,
Save,
Tag,
User,
X
} from '@lucide/svelte';
interface Props {
person?: ae_Person | null;
onSave?: (person: ae_Person) => void;
onCancel?: () => void;
}
let { person = null, onSave, onCancel }: Props = $props(); let { person = null, onSave, onCancel }: Props = $props();
// Form State (Runes) // Form State (Runes)
let formData = $state({ let formData = $state({
given_name: '', given_name: '',
family_name: '', family_name: '',
middle_name: '', middle_name: '',
prefix: '', prefix: '',
suffix: '', suffix: '',
nickname: '', nickname: '',
professional_title: '', professional_title: '',
affiliations: '', affiliations: '',
primary_email: '', primary_email: '',
phone: '', phone: '',
tagline: '', tagline: '',
notes: '', notes: '',
user_id_random: '', user_id_random: '',
enable: true, enable: true,
hide: false, hide: false,
priority: false priority: false
}); });
// Reset form when person prop changes // Reset form when person prop changes
$effect(() => { $effect(() => {
formData.given_name = person?.given_name ?? ''; formData.given_name = person?.given_name ?? '';
formData.family_name = person?.family_name ?? ''; formData.family_name = person?.family_name ?? '';
formData.middle_name = person?.middle_name ?? ''; formData.middle_name = person?.middle_name ?? '';
formData.prefix = (person?.prefix ?? person?.title_names) ?? ''; formData.prefix = person?.prefix ?? person?.title_names ?? '';
formData.suffix = (person?.suffix ?? person?.designations) ?? ''; formData.suffix = person?.suffix ?? person?.designations ?? '';
formData.nickname = person?.informal_name ?? ''; formData.nickname = person?.informal_name ?? '';
formData.professional_title = person?.professional_title ?? ''; formData.professional_title = person?.professional_title ?? '';
formData.affiliations = person?.affiliations ?? ''; formData.affiliations = person?.affiliations ?? '';
formData.primary_email = person?.primary_email ?? ''; formData.primary_email = person?.primary_email ?? '';
formData.phone = person?.phone ?? ''; formData.phone = person?.phone ?? '';
formData.tagline = person?.tagline ?? ''; formData.tagline = person?.tagline ?? '';
formData.notes = person?.notes ?? ''; formData.notes = person?.notes ?? '';
formData.user_id_random = person?.user_id_random ?? ''; formData.user_id_random = person?.user_id_random ?? '';
formData.enable = person?.enable ?? true; formData.enable = person?.enable ?? true;
formData.hide = person?.hide ?? false; formData.hide = person?.hide ?? false;
formData.priority = person?.priority ?? false; formData.priority = person?.priority ?? false;
}); });
let is_loading = $state(false); let is_loading = $state(false);
let error_msg = $state(''); let error_msg = $state('');
async function handleSubmit(event: Event) { async function handleSubmit(event: Event) {
event.preventDefault(); event.preventDefault();
is_loading = true; is_loading = true;
error_msg = ''; error_msg = '';
// Clean payload: Map fields and handle optional values // Clean payload: Map fields and handle optional values
const payload: any = { const payload: any = {
prefix: formData.prefix.trim() || null, prefix: formData.prefix.trim() || null,
given_name: formData.given_name.trim(), given_name: formData.given_name.trim(),
family_name: formData.family_name.trim() || null, family_name: formData.family_name.trim() || null,
middle_name: formData.middle_name.trim() || null, middle_name: formData.middle_name.trim() || null,
informal_name: formData.nickname.trim() || null, informal_name: formData.nickname.trim() || null,
// title_names: formData.prefix.trim() || null, // DO NOT USE - Scott 2026-01-09 // title_names: formData.prefix.trim() || null, // DO NOT USE - Scott 2026-01-09
designations: formData.suffix.trim() || null, designations: formData.suffix.trim() || null,
// NOTE:DO NOT USE Do note send the full_name field at this time - Scott 2026-01-09 // NOTE:DO NOT USE Do note send the full_name field at this time - Scott 2026-01-09
// full_name: `${formData.prefix ? formData.prefix + ' ' : ''}${formData.given_name} ${formData.family_name}${formData.suffix ? ', ' + formData.suffix : ''}`.trim(), // DO NOT USE - Scott 2026-01-09 // full_name: `${formData.prefix ? formData.prefix + ' ' : ''}${formData.given_name} ${formData.family_name}${formData.suffix ? ', ' + formData.suffix : ''}`.trim(), // DO NOT USE - Scott 2026-01-09
professional_title: formData.professional_title.trim() || null, professional_title: formData.professional_title.trim() || null,
affiliations: formData.affiliations.trim() || null, affiliations: formData.affiliations.trim() || null,
primary_email: formData.primary_email.trim() || null, primary_email: formData.primary_email.trim() || null,
tagline: formData.tagline.trim() || null, tagline: formData.tagline.trim() || null,
notes: formData.notes.trim() || null, notes: formData.notes.trim() || null,
user_id_random: formData.user_id_random.trim() || null, user_id_random: formData.user_id_random.trim() || null,
allow_auth_key: true, allow_auth_key: true,
enable: formData.enable, enable: formData.enable,
hide: formData.hide, hide: formData.hide,
priority: formData.priority priority: formData.priority
}; };
// Ensure strings are truly null if empty after trim // Ensure strings are truly null if empty after trim
for (const key in payload) { for (const key in payload) {
if (payload[key] === '') { if (payload[key] === '') {
if (key !== 'given_name' && key !== 'full_name') { if (key !== 'given_name' && key !== 'full_name') {
payload[key] = null; payload[key] = null;
}
} }
} }
try {
let result;
if (person?.person_id_random) {
// Update existing
result = await core_func.update_ae_obj__person({
api_cfg: $ae_api,
person_id: person.person_id_random,
data_kv: payload,
log_lvl: 1
});
} else {
// Create new
result = await core_func.create_ae_obj__person({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: payload,
log_lvl: 1
});
}
if (result) {
if (onSave) onSave(result);
} else {
error_msg = 'Failed to save person record. The server rejected the request (400).';
}
} catch (err: any) {
error_msg = err.message || 'An error occurred while saving.';
} finally {
is_loading = false;
}
} }
try {
let result;
if (person?.person_id_random) {
// Update existing
result = await core_func.update_ae_obj__person({
api_cfg: $ae_api,
person_id: person.person_id_random,
data_kv: payload,
log_lvl: 1
});
} else {
// Create new
result = await core_func.create_ae_obj__person({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: payload,
log_lvl: 1
});
}
if (result) {
if (onSave) onSave(result);
} else {
error_msg =
'Failed to save person record. The server rejected the request (400).';
}
} catch (err: any) {
error_msg = err.message || 'An error occurred while saving.';
} finally {
is_loading = false;
}
}
</script> </script>
<form onsubmit={handleSubmit} class="card p-6 space-y-6 shadow-xl preset-tonal-surface"> <form
<header class="flex justify-between items-center border-b border-surface-500/30 pb-4"> onsubmit={handleSubmit}
class="card p-6 space-y-6 shadow-xl preset-tonal-surface">
<header
class="flex justify-between items-center border-b border-surface-500/30 pb-4">
<h3 class="h3 flex items-center gap-2"> <h3 class="h3 flex items-center gap-2">
<User size={24} /> <User size={24} />
{person ? 'Edit Person' : 'Create New Person'} {person ? 'Edit Person' : 'Create New Person'}
</h3> </h3>
<div class="flex gap-2"> <div class="flex gap-2">
{#if onCancel} {#if onCancel}
<button type="button" class="btn btn-sm preset-tonal-surface" onclick={onCancel}> <button
type="button"
class="btn btn-sm preset-tonal-surface"
onclick={onCancel}>
<X size={16} class="mr-1" /> Cancel <X size={16} class="mr-1" /> Cancel
</button> </button>
{/if} {/if}
<button type="submit" class="btn btn-sm preset-filled-primary font-bold shadow-lg" disabled={is_loading}> <button
type="submit"
class="btn btn-sm preset-filled-primary font-bold shadow-lg"
disabled={is_loading}>
{#if is_loading} {#if is_loading}
<span class="animate-spin mr-2"></span> <span class="animate-spin mr-2"></span>
{:else} {:else}
@@ -163,140 +183,259 @@
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Name Section --> <!-- Name Section -->
<fieldset class="space-y-4"> <fieldset class="space-y-4">
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">Identity</legend> <legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>Identity</legend>
<div class="grid grid-cols-4 gap-2"> <div class="grid grid-cols-4 gap-2">
<div class="space-y-1 col-span-1"> <div class="space-y-1 col-span-1">
<label class="label text-xs font-bold opacity-75" for="person-prefix">Prefix</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="person-prefix" type="text" bind:value={formData.prefix} placeholder="Mr." /> class="label text-xs font-bold opacity-75"
for="person-prefix">Prefix</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="person-prefix"
type="text"
bind:value={formData.prefix}
placeholder="Mr." />
</div> </div>
<div class="space-y-1 col-span-3"> <div class="space-y-1 col-span-3">
<label class="label text-xs font-bold opacity-75" for="person-given-name">Given Name</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="person-given-name" type="text" bind:value={formData.given_name} required placeholder="Jane" /> class="label text-xs font-bold opacity-75"
for="person-given-name">Given Name</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="person-given-name"
type="text"
bind:value={formData.given_name}
required
placeholder="Jane" />
</div> </div>
</div> </div>
<div class="grid grid-cols-4 gap-2"> <div class="grid grid-cols-4 gap-2">
<div class="space-y-1 col-span-3"> <div class="space-y-1 col-span-3">
<label class="label text-xs font-bold opacity-75" for="person-family-name">Family Name</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="person-family-name" type="text" bind:value={formData.family_name} required placeholder="Doe" /> class="label text-xs font-bold opacity-75"
for="person-family-name">Family Name</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="person-family-name"
type="text"
bind:value={formData.family_name}
required
placeholder="Doe" />
</div> </div>
<div class="space-y-1 col-span-1"> <div class="space-y-1 col-span-1">
<label class="label text-xs font-bold opacity-75" for="person-suffix">Suffix</label> <label
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="person-suffix" type="text" bind:value={formData.suffix} placeholder="PhD" /> class="label text-xs font-bold opacity-75"
for="person-suffix">Suffix</label>
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="person-suffix"
type="text"
bind:value={formData.suffix}
placeholder="PhD" />
</div> </div>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="person-middle-name">Middle Name / Informal Name (Nickname)</label> <label
class="label text-xs font-bold opacity-75"
for="person-middle-name"
>Middle Name / Informal Name (Nickname)</label>
<div class="grid grid-cols-2 gap-2"> <div class="grid grid-cols-2 gap-2">
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="person-middle-name" type="text" bind:value={formData.middle_name} placeholder="Middle" /> <input
<input class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2" type="text" bind:value={formData.nickname} placeholder="Nickname" /> class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="person-middle-name"
type="text"
bind:value={formData.middle_name}
placeholder="Middle" />
<input
class="input preset-filled-surface rounded-lg placeholder-surface-400 p-2"
type="text"
bind:value={formData.nickname}
placeholder="Nickname" />
</div> </div>
</div> </div>
</fieldset> </fieldset>
<!-- Contact Section --> <!-- Contact Section -->
<fieldset class="space-y-4"> <fieldset class="space-y-4">
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">Contact Information</legend> <legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>Contact Information</legend>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="person-primary-email">Primary Email</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="person-primary-email">Primary Email</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Mail size={16} /></div> <div class="input-group-shim"><Mail size={16} /></div>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="person-primary-email" type="email" bind:value={formData.primary_email} placeholder="jane.doe@example.com" /> <input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="person-primary-email"
type="email"
bind:value={formData.primary_email}
placeholder="jane.doe@example.com" />
</div> </div>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="person-phone">Phone Number</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="person-phone">Phone Number</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Phone size={16} /></div> <div class="input-group-shim"><Phone size={16} /></div>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="person-phone" type="tel" bind:value={formData.phone} placeholder="+1 (555) 000-0000" /> <input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="person-phone"
type="tel"
bind:value={formData.phone}
placeholder="+1 (555) 000-0000" />
</div> </div>
<small class="opacity-60 text-xs px-1">(Saved only locally until Contact created)</small> <small class="opacity-60 text-xs px-1"
>(Saved only locally until Contact created)</small>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="person-tagline">Tagline</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="person-tagline">Tagline</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Tag size={16} /></div> <div class="input-group-shim"><Tag size={16} /></div>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="person-tagline" type="text" bind:value={formData.tagline} placeholder="Software Architect & Visionary" /> <input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="person-tagline"
type="text"
bind:value={formData.tagline}
placeholder="Software Architect & Visionary" />
</div> </div>
</div> </div>
</fieldset> </fieldset>
<!-- Professional Section --> <!-- Professional Section -->
<fieldset class="space-y-4"> <fieldset class="space-y-4">
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">Professional</legend> <legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>Professional</legend>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="person-professional-title">Professional Title</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="person-professional-title">Professional Title</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Briefcase size={16} /></div> <div class="input-group-shim"><Briefcase size={16} /></div>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="person-professional-title" type="text" bind:value={formData.professional_title} placeholder="Senior Engineer" /> <input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="person-professional-title"
type="text"
bind:value={formData.professional_title}
placeholder="Senior Engineer" />
</div> </div>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="person-affiliations">Affiliations</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="person-affiliations">Affiliations</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Building size={16} /></div> <div class="input-group-shim"><Building size={16} /></div>
<input class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2" id="person-affiliations" type="text" bind:value={formData.affiliations} placeholder="One Sky IT, LLC" /> <input
class="bg-transparent border-0 ring-0 focus:ring-0 placeholder-surface-400 p-2"
id="person-affiliations"
type="text"
bind:value={formData.affiliations}
placeholder="One Sky IT, LLC" />
</div> </div>
</div> </div>
</fieldset> </fieldset>
<!-- Metadata Section --> <!-- Metadata Section -->
<fieldset class="space-y-4"> <fieldset class="space-y-4">
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">Status & Flags</legend> <legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>Status & Flags</legend>
<div class="flex flex-wrap gap-4 pt-2"> <div class="flex flex-wrap gap-4 pt-2">
<label class="flex items-center space-x-2 cursor-pointer"> <label class="flex items-center space-x-2 cursor-pointer">
<input class="checkbox" type="checkbox" bind:checked={formData.enable} /> <input
class="checkbox"
type="checkbox"
bind:checked={formData.enable} />
<span class="text-sm font-medium">Enabled</span> <span class="text-sm font-medium">Enabled</span>
</label> </label>
<label class="flex items-center space-x-2 cursor-pointer"> <label class="flex items-center space-x-2 cursor-pointer">
<input class="checkbox" type="checkbox" bind:checked={formData.hide} /> <input
class="checkbox"
type="checkbox"
bind:checked={formData.hide} />
<span class="text-sm font-medium">Hidden</span> <span class="text-sm font-medium">Hidden</span>
</label> </label>
<label class="flex items-center space-x-2 cursor-pointer"> <label class="flex items-center space-x-2 cursor-pointer">
<input class="checkbox" type="checkbox" bind:checked={formData.priority} /> <input
class="checkbox"
type="checkbox"
bind:checked={formData.priority} />
<span class="text-sm font-medium">Priority</span> <span class="text-sm font-medium">Priority</span>
</label> </label>
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="person-notes">Notes (Internal)</label> <label
<textarea class="textarea preset-filled-surface rounded-lg placeholder-surface-400 p-2" id="person-notes" rows="3" bind:value={formData.notes} placeholder="Additional details..."></textarea> class="label text-xs font-bold opacity-75"
for="person-notes">Notes (Internal)</label>
<textarea
class="textarea preset-filled-surface rounded-lg placeholder-surface-400 p-2"
id="person-notes"
rows="3"
bind:value={formData.notes}
placeholder="Additional details..."></textarea>
</div> </div>
</fieldset> </fieldset>
{#if $ae_loc.manager_access} {#if $ae_loc.manager_access}
<!-- Admin/Linking Section --> <!-- Admin/Linking Section -->
<fieldset class="space-y-4 md:col-span-2 border-t border-surface-500/30 pt-4"> <fieldset
<legend class="text-sm font-bold uppercase tracking-widest opacity-60">System Linking (Managers Only)</legend> class="space-y-4 md:col-span-2 border-t border-surface-500/30 pt-4">
<legend
class="text-sm font-bold uppercase tracking-widest opacity-60"
>System Linking (Managers Only)</legend>
<div class="space-y-1 max-w-md"> <div class="space-y-1 max-w-md">
<label class="label text-xs font-bold opacity-75" for="person-user-id-random">Linked User ID (Random)</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden"> class="label text-xs font-bold opacity-75"
for="person-user-id-random"
>Linked User ID (Random)</label>
<div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-filled-surface rounded-lg overflow-hidden">
<div class="input-group-shim"><Link size={16} /></div> <div class="input-group-shim"><Link size={16} /></div>
<input <input
class="bg-transparent border-0 ring-0 focus:ring-0 font-mono placeholder-surface-400 p-2" class="bg-transparent border-0 ring-0 focus:ring-0 font-mono placeholder-surface-400 p-2"
id="person-user-id-random" id="person-user-id-random"
type="text" type="text"
bind:value={formData.user_id_random} bind:value={formData.user_id_random}
placeholder="e.g. AB12CD34" placeholder="e.g. AB12CD34" />
/>
</div> </div>
<small class="opacity-60 text-[10px] uppercase px-1 tracking-tighter">Enter the unique random ID of the user account to link to this person.</small> <small
class="opacity-60 text-[10px] uppercase px-1 tracking-tighter"
>Enter the unique random ID of the user account to link
to this person.</small>
</div> </div>
</fieldset> </fieldset>
{/if} {/if}
</div> </div>
<footer class="flex justify-end gap-2 border-t border-surface-500/30 pt-4"> <footer class="flex justify-end gap-2 border-t border-surface-500/30 pt-4">
<button type="submit" class="btn preset-filled-primary font-bold shadow-lg w-full md:w-auto" disabled={is_loading}> <button
type="submit"
class="btn preset-filled-primary font-bold shadow-lg w-full md:w-auto"
disabled={is_loading}>
{#if is_loading} {#if is_loading}
<span class="animate-spin mr-2"></span> <span class="animate-spin mr-2"></span>
{/if} {/if}

View File

@@ -1,53 +1,63 @@
<script lang="ts"> <script lang="ts">
import { Filter, Plus, Search, SearchCode, User } from '@lucide/svelte'; import { Filter, Plus, Search, SearchCode, User } from '@lucide/svelte';
import { ae_api, ae_loc, slct } from '$lib/stores/ae_stores'; import { ae_api, ae_loc, slct } from '$lib/stores/ae_stores';
import { load_ae_obj_li__person } from '$lib/ae_core/ae_core__person'; import { load_ae_obj_li__person } from '$lib/ae_core/ae_core__person';
interface Props { interface Props {
on_results: (results: any[]) => void; on_results: (results: any[]) => void;
} }
let { on_results }: Props = $props(); let { on_results }: Props = $props();
let qry_str = $state(''); let qry_str = $state('');
let loading = $state(false); let loading = $state(false);
let qry_enabled = $state('enabled'); let qry_enabled = $state('enabled');
let qry_hidden = $state('not_hidden'); let qry_hidden = $state('not_hidden');
async function handle_search() { async function handle_search() {
if (!$ae_loc.account_id) return; if (!$ae_loc.account_id) return;
loading = true; loading = true;
// V3 search logic // V3 search logic
const results = await load_ae_obj_li__person({ const results = await load_ae_obj_li__person({
api_cfg: $ae_api, api_cfg: $ae_api,
for_obj_id: $ae_loc.account_id, for_obj_id: $ae_loc.account_id,
enabled: qry_enabled as any, enabled: qry_enabled as any,
hidden: qry_hidden as any, hidden: qry_hidden as any,
// qry_str: qry_str || null, // Assuming load_ae_obj_li__person supports qry_str in the future or we use search_ae_obj // qry_str: qry_str || null, // Assuming load_ae_obj_li__person supports qry_str in the future or we use search_ae_obj
log_lvl: 1 log_lvl: 1
}); });
// Filter locally for now if needed, or update the API wrapper to support search_query // Filter locally for now if needed, or update the API wrapper to support search_query
const filtered = qry_str const filtered = qry_str
? results.filter(p => ? results.filter(
p.full_name?.toLowerCase().includes(qry_str.toLowerCase()) || (p) =>
p.primary_email?.toLowerCase().includes(qry_str.toLowerCase()) || p.full_name?.toLowerCase().includes(qry_str.toLowerCase()) ||
p.person_id_random?.toLowerCase().includes(qry_str.toLowerCase()) p.primary_email
) ?.toLowerCase()
: results; .includes(qry_str.toLowerCase()) ||
p.person_id_random
?.toLowerCase()
.includes(qry_str.toLowerCase())
)
: results;
on_results(filtered); on_results(filtered);
loading = false; loading = false;
} }
</script> </script>
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-4"> <div
class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-4">
<div class="flex flex-wrap gap-6 items-end"> <div class="flex flex-wrap gap-6 items-end">
<div class="flex-1 min-w-[280px] space-y-1"> <div class="flex-1 min-w-[280px] space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Search People</span> <span
<div class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all"> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
<div class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20"> >Search People</span>
<div
class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all">
<div
class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20">
<Search size={18} class="opacity-50" /> <Search size={18} class="opacity-50" />
</div> </div>
<input <input
@@ -55,9 +65,11 @@
type="search" type="search"
bind:value={qry_str} bind:value={qry_str}
placeholder="Search by name, email, or ID..." placeholder="Search by name, email, or ID..."
onkeydown={(e) => e.key === 'Enter' && handle_search()} onkeydown={(e) => e.key === 'Enter' && handle_search()} />
/> <button
<button class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]" onclick={handle_search} disabled={loading}> class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]"
onclick={handle_search}
disabled={loading}>
{#if loading} {#if loading}
<span class="animate-spin text-xl"></span> <span class="animate-spin text-xl"></span>
{:else} {:else}
@@ -69,8 +81,13 @@
<div class="grid grid-cols-2 gap-4"> <div class="grid grid-cols-2 gap-4">
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Account Status</span> <span
<select class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2" bind:value={qry_enabled} onchange={handle_search}> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Account Status</span>
<select
class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2"
bind:value={qry_enabled}
onchange={handle_search}>
<option value="all">All Records</option> <option value="all">All Records</option>
<option value="enabled">Enabled Only</option> <option value="enabled">Enabled Only</option>
<option value="not_enabled">Disabled Only</option> <option value="not_enabled">Disabled Only</option>
@@ -78,8 +95,13 @@
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Visibility</span> <span
<select class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2" bind:value={qry_hidden} onchange={handle_search}> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Visibility</span>
<select
class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2"
bind:value={qry_hidden}
onchange={handle_search}>
<option value="all">All Visible</option> <option value="all">All Visible</option>
<option value="not_hidden">Publicly Visible</option> <option value="not_hidden">Publicly Visible</option>
<option value="hidden">System Hidden</option> <option value="hidden">System Hidden</option>

View File

@@ -1,86 +1,112 @@
<script lang="ts"> <script lang="ts">
interface Props { interface Props {
person_id: string; person_id: string;
display_mode?: string; // 'default', 'compact', 'minimal', 'launcher' display_mode?: string; // 'default', 'compact', 'minimal', 'launcher'
log_lvl?: number; log_lvl?: number;
}
let { person_id, display_mode = 'default', log_lvl = 0 }: Props = $props();
console.log(`ae_core person_view.svelte`);
import { liveQuery } from 'dexie';
import type { key_val } from '$lib/stores/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
import Element_ae_obj_field_editor from '$lib/elements/element_ae_obj_field_editor.svelte';
import { api } from '$lib/api/api';
import { core_func } from '$lib/ae_core/ae_core_functions';
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/stores/ae_stores';
import { db_core } from '$lib/ae_core/db_core';
import {
Archive,
BookOpen,
Building2,
Check,
Eye,
EyeOff,
Fingerprint,
IdCard,
Key,
LoaderCircle,
Mail,
Save,
Star,
Tag,
ToggleLeft,
ToggleRight,
TriangleAlert,
User,
UserRound
} from '@lucide/svelte';
// import { db_events } from "$lib/db_events";
// import { events_loc, events_sess, events_slct, events_trigger } from '$lib/stores/ae_events_stores';
// import { events_func } from '$lib/ae_events/ae_events_functions';
let ae_placeholder_li: key_val = {};
let ae_promises: key_val = $state({}); // Promise<any>;
let ae_tmp: key_val = $state({});
$effect(() => {
if (log_lvl) {
console.log(`person_id:`, person_id);
} }
});
let { person_id, display_mode = 'default', log_lvl = 0 }: Props = $props(); let lq__person_obj = $derived(
liveQuery(async () => {
let results = await db_core.person.get(person_id);
return results;
})
);
console.log(`ae_core person_view.svelte`); ae_tmp.value__data_json = null;
$effect(() => {
if ($lq__person_obj?.data_json && ae_tmp.value__data_json === null) {
ae_tmp.value__data_json = JSON.stringify(
$lq__person_obj.data_json,
null,
4
);
// ae_tmp.value__data_json = JSON.parse(JSON.stringify($lq__person_obj.data_json));
// JSON.stringify(jsObj, null, 4);
}
});
import { liveQuery } from 'dexie'; ae_tmp.valid__data_json = null;
$effect(() => {
if (ae_tmp.value__data_json && ae_tmp.value__data_json.length) {
console.log(
`ae_tmp.value__data_json.length:`,
ae_tmp.value__data_json.length
);
import type { key_val } from '$lib/stores/ae_stores'; try {
import { ae_util } from '$lib/ae_utils/ae_utils'; JSON.parse(ae_tmp.value__data_json);
import Element_ae_obj_field_editor from '$lib/elements/element_ae_obj_field_editor.svelte'; ae_tmp.valid__data_json = true;
import { api } from '$lib/api/api'; } catch (e) {
ae_tmp.valid__data_json = false;
import { core_func } from '$lib/ae_core/ae_core_functions'; console.error(`JSON.parse error:`, e);
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/stores/ae_stores';
import { db_core } from '$lib/ae_core/db_core';
import { Archive, BookOpen, Building2, Check, Eye, EyeOff, Fingerprint, IdCard, Key, LoaderCircle, Mail, Save, Star, Tag, ToggleLeft, ToggleRight, TriangleAlert, User, UserRound } from '@lucide/svelte';
// import { db_events } from "$lib/db_events";
// import { events_loc, events_sess, events_slct, events_trigger } from '$lib/stores/ae_events_stores';
// import { events_func } from '$lib/ae_events/ae_events_functions';
let ae_placeholder_li: key_val = {};
let ae_promises: key_val = $state({}); // Promise<any>;
let ae_tmp: key_val = $state({});
$effect(() => {
if (log_lvl) {
console.log(`person_id:`, person_id);
} }
}); }
});
let lq__person_obj = $derived( // let tmp_agree = false;
liveQuery(async () => { // let tmp_opt_out: key_val = {
let results = await db_core.person.get(person_id); // audio: false,
return results; // video: false,
}) // transcription_and_publication: false,
); // publication_in_app: false
// };
ae_tmp.value__data_json = null;
$effect(() => {
if ($lq__person_obj?.data_json && ae_tmp.value__data_json === null) {
ae_tmp.value__data_json = JSON.stringify($lq__person_obj.data_json, null, 4);
// ae_tmp.value__data_json = JSON.parse(JSON.stringify($lq__person_obj.data_json));
// JSON.stringify(jsObj, null, 4);
}
});
ae_tmp.valid__data_json = null;
$effect(() => {
if (ae_tmp.value__data_json && ae_tmp.value__data_json.length) {
console.log(`ae_tmp.value__data_json.length:`, ae_tmp.value__data_json.length);
try {
JSON.parse(ae_tmp.value__data_json);
ae_tmp.valid__data_json = true;
} catch (e) {
ae_tmp.valid__data_json = false;
console.error(`JSON.parse error:`, e);
}
}
});
// let tmp_agree = false;
// let tmp_opt_out: key_val = {
// audio: false,
// video: false,
// transcription_and_publication: false,
// publication_in_app: false
// };
</script> </script>
{#if $lq__person_obj} {#if $lq__person_obj}
@@ -100,8 +126,12 @@
field_type={'text'} field_type={'text'}
current_value={$lq__person_obj.external_id} current_value={$lq__person_obj.external_id}
allow_null={true} allow_null={true}
on_success={() => core_func.load_ae_obj_id__person({ api_cfg: $ae_api, person_id: $lq__person_obj?.person_id_random, log_lvl: 1 })} on_success={() =>
> core_func.load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: $lq__person_obj?.person_id_random,
log_lvl: 1
})}>
<IdCard size="1em" /> <IdCard size="1em" />
External ID: External ID:
<span class="font-bold"> <span class="font-bold">
@@ -117,12 +147,17 @@
field_type={'text'} field_type={'text'}
current_value={$lq__person_obj.external_sys_id} current_value={$lq__person_obj.external_sys_id}
allow_null={true} allow_null={true}
on_success={() => core_func.load_ae_obj_id__person({ api_cfg: $ae_api, person_id: $lq__person_obj?.person_id_random, log_lvl: 1 })} on_success={() =>
> core_func.load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: $lq__person_obj?.person_id_random,
log_lvl: 1
})}>
<Fingerprint size="1em" /> <Fingerprint size="1em" />
External System ID: External System ID:
<span class="font-bold"> <span class="font-bold">
{@html $lq__person_obj.external_sys_id ?? ae_snip.html__not_set} {@html $lq__person_obj.external_sys_id ??
ae_snip.html__not_set}
</span> </span>
</Element_ae_obj_field_editor> </Element_ae_obj_field_editor>
</li> </li>
@@ -136,8 +171,12 @@
field_name={'given_name'} field_name={'given_name'}
field_type={'text'} field_type={'text'}
current_value={$lq__person_obj.given_name} current_value={$lq__person_obj.given_name}
on_success={() => core_func.load_ae_obj_id__person({ api_cfg: $ae_api, person_id: $lq__person_obj?.person_id_random, log_lvl: 1 })} on_success={() =>
> core_func.load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: $lq__person_obj?.person_id_random,
log_lvl: 1
})}>
<span class="font-bold"> <span class="font-bold">
{@html $lq__person_obj.given_name ?? ae_snip.html__not_set} {@html $lq__person_obj.given_name ?? ae_snip.html__not_set}
</span> </span>
@@ -148,8 +187,12 @@
field_name={'family_name'} field_name={'family_name'}
field_type={'text'} field_type={'text'}
current_value={$lq__person_obj.family_name} current_value={$lq__person_obj.family_name}
on_success={() => core_func.load_ae_obj_id__person({ api_cfg: $ae_api, person_id: $lq__person_obj?.person_id_random, log_lvl: 1 })} on_success={() =>
> core_func.load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: $lq__person_obj?.person_id_random,
log_lvl: 1
})}>
<span class="font-bold"> <span class="font-bold">
{@html $lq__person_obj.family_name ?? ae_snip.html__not_set} {@html $lq__person_obj.family_name ?? ae_snip.html__not_set}
</span> </span>
@@ -163,17 +206,21 @@
field_type={'text'} field_type={'text'}
current_value={$lq__person_obj.primary_email} current_value={$lq__person_obj.primary_email}
allow_null={true} allow_null={true}
on_success={() => core_func.load_ae_obj_id__person({ api_cfg: $ae_api, person_id: $lq__person_obj?.person_id_random, log_lvl: 1 })} on_success={() =>
> core_func.load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: $lq__person_obj?.person_id_random,
log_lvl: 1
})}>
<Mail size="1em" /> <Mail size="1em" />
<span class="font-bold"> <span class="font-bold">
{#if $lq__person_obj.primary_email} {#if $lq__person_obj.primary_email}
<a <a
href="mailto:{$lq__person_obj?.primary_email}" href="mailto:{$lq__person_obj?.primary_email}"
class="text-blue-500 underline hover:text-blue-800" class="text-blue-500 underline hover:text-blue-800"
title="Person's primary email address" title="Person's primary email address">
> {@html $lq__person_obj.primary_email ??
{@html $lq__person_obj.primary_email ?? 'email' + ae_snip.html__not_set} 'email' + ae_snip.html__not_set}
</a> </a>
{:else} {:else}
email {@html ae_snip.html__not_set} email {@html ae_snip.html__not_set}
@@ -189,11 +236,16 @@
field_type={'text'} field_type={'text'}
current_value={$lq__person_obj.affiliations} current_value={$lq__person_obj.affiliations}
allow_null={true} allow_null={true}
on_success={() => core_func.load_ae_obj_id__person({ api_cfg: $ae_api, person_id: $lq__person_obj?.person_id_random, log_lvl: 1 })} on_success={() =>
> core_func.load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: $lq__person_obj?.person_id_random,
log_lvl: 1
})}>
<Building2 size="1em" /> <Building2 size="1em" />
<span class="font-bold"> <span class="font-bold">
{@html $lq__person_obj.affiliations ?? 'affiliations' + ae_snip.html__not_set} {@html $lq__person_obj.affiliations ??
'affiliations' + ae_snip.html__not_set}
</span> </span>
</Element_ae_obj_field_editor> </Element_ae_obj_field_editor>
</li> </li>
@@ -205,8 +257,12 @@
field_type={'text'} field_type={'text'}
current_value={$lq__person_obj.professional_title} current_value={$lq__person_obj.professional_title}
allow_null={true} allow_null={true}
on_success={() => core_func.load_ae_obj_id__person({ api_cfg: $ae_api, person_id: $lq__person_obj?.person_id_random, log_lvl: 1 })} on_success={() =>
> core_func.load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: $lq__person_obj?.person_id_random,
log_lvl: 1
})}>
<Tag size="1em" /> <Tag size="1em" />
<span class="font-bold"> <span class="font-bold">
{@html $lq__person_obj.professional_title && {@html $lq__person_obj.professional_title &&
@@ -224,12 +280,17 @@
field_type={'text'} field_type={'text'}
current_value={$lq__person_obj.passcode} current_value={$lq__person_obj.passcode}
allow_null={true} allow_null={true}
on_success={() => core_func.load_ae_obj_id__person({ api_cfg: $ae_api, person_id: $lq__person_obj?.person_id_random, log_lvl: 1 })} on_success={() =>
> core_func.load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: $lq__person_obj?.person_id_random,
log_lvl: 1
})}>
<UserRound size="1em" /> <UserRound size="1em" />
Passcode: Passcode:
<span class="font-bold"> <span class="font-bold">
{@html $lq__person_obj.passcode ?? 'passcode' + ae_snip.html__not_set} {@html $lq__person_obj.passcode ??
'passcode' + ae_snip.html__not_set}
</span> </span>
</Element_ae_obj_field_editor> </Element_ae_obj_field_editor>
</li> </li>
@@ -237,16 +298,25 @@
<li hidden={!$ae_loc.trusted_access}> <li hidden={!$ae_loc.trusted_access}>
<!-- Show/Hide --> <!-- Show/Hide -->
{#if $ae_loc.trusted_access} {#if $ae_loc.trusted_access}
<span class="text-sm">{$lq__person_obj?.hide ? 'Hidden' : 'Not Hidden'}</span> <span class="text-sm"
>{$lq__person_obj?.hide ? 'Hidden' : 'Not Hidden'}</span>
{/if} {/if}
<button <button
type="button" type="button"
onclick={async () => { onclick={async () => {
await api.update_ae_obj({ api_cfg: $ae_api, obj_type: 'person', obj_id: $lq__person_obj?.person_id_random, fields: { hide: !$lq__person_obj?.hide } }); await api.update_ae_obj({
core_func.load_ae_obj_id__person({ api_cfg: $ae_api, person_id: $lq__person_obj?.person_id_random, log_lvl: 1 }); api_cfg: $ae_api,
obj_type: 'person',
obj_id: $lq__person_obj?.person_id_random,
fields: { hide: !$lq__person_obj?.hide }
});
core_func.load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: $lq__person_obj?.person_id_random,
log_lvl: 1
});
}} }}
class="btn btn-sm preset-tonal-warning" class="btn btn-sm preset-tonal-warning">
>
{#if $ae_loc.trusted_access} {#if $ae_loc.trusted_access}
{#if $lq__person_obj?.hide} {#if $lq__person_obj?.hide}
<Eye size="1em" class="m-1" /> Unhide? <Eye size="1em" class="m-1" /> Unhide?
@@ -261,43 +331,61 @@
<!-- Enable/Disable --> <!-- Enable/Disable -->
{#if $ae_loc.trusted_access} {#if $ae_loc.trusted_access}
<span class="text-sm">{$lq__person_obj?.enable ? 'Enabled' : 'Disabled'}</span> <span class="text-sm"
>{$lq__person_obj?.enable ? 'Enabled' : 'Disabled'}</span>
{/if} {/if}
<button <button
type="button" type="button"
onclick={async () => { onclick={async () => {
await api.update_ae_obj({ api_cfg: $ae_api, obj_type: 'person', obj_id: $lq__person_obj?.person_id_random, fields: { enable: !$lq__person_obj?.enable } }); await api.update_ae_obj({
core_func.load_ae_obj_id__person({ api_cfg: $ae_api, person_id: $lq__person_obj?.person_id_random, log_lvl: 1 }); api_cfg: $ae_api,
obj_type: 'person',
obj_id: $lq__person_obj?.person_id_random,
fields: { enable: !$lq__person_obj?.enable }
});
core_func.load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: $lq__person_obj?.person_id_random,
log_lvl: 1
});
}} }}
class="btn btn-sm preset-tonal-warning" class="btn btn-sm preset-tonal-warning">
>
{#if $ae_loc.trusted_access} {#if $ae_loc.trusted_access}
{#if $lq__person_obj?.enable} {#if $lq__person_obj?.enable}
<ToggleRight size="1em" class="m-1" /> Disable? <ToggleRight size="1em" class="m-1" /> Disable?
{:else} {:else}
<ToggleLeft size="1em" class="m-1" /> Enable? <ToggleLeft size="1em" class="m-1" /> Enable?
{/if} {/if}
{:else if $lq__person_obj?.enable}
<ToggleRight size="1em" class="m-1" /> Disable
{:else} {:else}
{#if $lq__person_obj?.enable} <ToggleLeft size="1em" class="m-1" /> Enable
<ToggleRight size="1em" class="m-1" /> Disable
{:else}
<ToggleLeft size="1em" class="m-1" /> Enable
{/if}
{/if} {/if}
</button> </button>
<!-- Priority/Not --> <!-- Priority/Not -->
{#if $ae_loc.trusted_access} {#if $ae_loc.trusted_access}
<span class="text-sm">{$lq__person_obj?.priority ? 'Priority' : 'Not Priority'}</span> <span class="text-sm"
>{$lq__person_obj?.priority
? 'Priority'
: 'Not Priority'}</span>
{/if} {/if}
<button <button
type="button" type="button"
onclick={async () => { onclick={async () => {
await api.update_ae_obj({ api_cfg: $ae_api, obj_type: 'person', obj_id: $lq__person_obj?.person_id_random, fields: { priority: !$lq__person_obj?.priority } }); await api.update_ae_obj({
core_func.load_ae_obj_id__person({ api_cfg: $ae_api, person_id: $lq__person_obj?.person_id_random, log_lvl: 1 }); api_cfg: $ae_api,
obj_type: 'person',
obj_id: $lq__person_obj?.person_id_random,
fields: { priority: !$lq__person_obj?.priority }
});
core_func.load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: $lq__person_obj?.person_id_random,
log_lvl: 1
});
}} }}
class="btn btn-sm preset-tonal-warning" class="btn btn-sm preset-tonal-warning">
>
<Star size="1em" class="m-1" /> <Star size="1em" class="m-1" />
{#if $ae_loc.trusted_access} {#if $ae_loc.trusted_access}
{$lq__person_obj?.priority ? 'Not Priority?' : 'Priority?'} {$lq__person_obj?.priority ? 'Not Priority?' : 'Priority?'}
@@ -308,21 +396,38 @@
<!-- Allow Auth Key/Not --> <!-- Allow Auth Key/Not -->
{#if $ae_loc.trusted_access} {#if $ae_loc.trusted_access}
<span class="text-sm">{$lq__person_obj?.allow_auth_key ? 'Allow Auth Key' : 'Not Allow Auth Key'}</span> <span class="text-sm"
>{$lq__person_obj?.allow_auth_key
? 'Allow Auth Key'
: 'Not Allow Auth Key'}</span>
{/if} {/if}
<button <button
type="button" type="button"
onclick={async () => { onclick={async () => {
await api.update_ae_obj({ api_cfg: $ae_api, obj_type: 'person', obj_id: $lq__person_obj?.person_id_random, fields: { allow_auth_key: !$lq__person_obj?.allow_auth_key } }); await api.update_ae_obj({
core_func.load_ae_obj_id__person({ api_cfg: $ae_api, person_id: $lq__person_obj?.person_id_random, log_lvl: 1 }); api_cfg: $ae_api,
obj_type: 'person',
obj_id: $lq__person_obj?.person_id_random,
fields: {
allow_auth_key: !$lq__person_obj?.allow_auth_key
}
});
core_func.load_ae_obj_id__person({
api_cfg: $ae_api,
person_id: $lq__person_obj?.person_id_random,
log_lvl: 1
});
}} }}
class="btn btn-sm preset-tonal-warning" class="btn btn-sm preset-tonal-warning">
>
<Key size="1em" class="m-1" /> <Key size="1em" class="m-1" />
{#if $ae_loc.trusted_access} {#if $ae_loc.trusted_access}
{$lq__person_obj?.allow_auth_key ? 'Not Allow Auth Key?' : 'Allow Auth Key?'} {$lq__person_obj?.allow_auth_key
? 'Not Allow Auth Key?'
: 'Allow Auth Key?'}
{:else} {:else}
{$lq__person_obj?.allow_auth_key ? 'Not Allow Auth Key' : 'Allow Auth Key'} {$lq__person_obj?.allow_auth_key
? 'Not Allow Auth Key'
: 'Allow Auth Key'}
{/if} {/if}
</button> </button>
</li> </li>
@@ -332,7 +437,9 @@
<label for="person__data_json" class="label"> <label for="person__data_json" class="label">
<BookOpen size="1em" /> <BookOpen size="1em" />
Person JSON Data Person JSON Data
<span class="text-sm text-gray-500"> (no character limit) </span> <span class="text-sm text-gray-500">
(no character limit)
</span>
</label> </label>
<textarea <textarea
@@ -348,8 +455,7 @@
rows="8" rows="8"
cols="70" cols="70"
bind:value={ae_tmp.value__data_json} bind:value={ae_tmp.value__data_json}
placeholder="Enter data_json here" placeholder="Enter data_json here"></textarea>
></textarea>
<!-- {/if} --> <!-- {/if} -->
</div> </div>
@@ -393,8 +499,7 @@
// console.log(update_result); // console.log(update_result);
// return update_result; // return update_result;
}); });
}} }}>
>
{#await ae_promises.update__person_obj} {#await ae_promises.update__person_obj}
<LoaderCircle size="1em" class="animate-spin mx-1" /> <LoaderCircle size="1em" class="animate-spin mx-1" />
{:then} {:then}

View File

@@ -1,99 +1,127 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { load_ae_obj_li__site, create_ae_obj__site } from '$lib/ae_core/ae_core__site'; import {
import { ae_api, ae_loc, slct } from '$lib/stores/ae_stores'; load_ae_obj_li__site,
import { goto } from '$app/navigation'; create_ae_obj__site
import { Calendar, ExternalLink, Globe, ListFilter, Plus, RefreshCcw, Search, ShieldCheck, X } from '@lucide/svelte'; } from '$lib/ae_core/ae_core__site';
let site_li: any[] = $state([]); import { ae_api, ae_loc, slct } from '$lib/stores/ae_stores';
let loading = $state(true); import { goto } from '$app/navigation';
let qry_enabled = $state('all'); import {
let qry_hidden = $state('all'); Calendar,
let qry_str = $state(''); ExternalLink,
Globe,
ListFilter,
Plus,
RefreshCcw,
Search,
ShieldCheck,
X
} from '@lucide/svelte';
let site_li: any[] = $state([]);
let loading = $state(true);
let qry_enabled = $state('all');
let qry_hidden = $state('all');
let qry_str = $state('');
let filtered_li = $derived( let filtered_li = $derived(
qry_str qry_str
? site_li.filter(s => ? site_li.filter(
s.name?.toLowerCase().includes(qry_str.toLowerCase()) || (s) =>
s.code?.toLowerCase().includes(qry_str.toLowerCase()) s.name?.toLowerCase().includes(qry_str.toLowerCase()) ||
) s.code?.toLowerCase().includes(qry_str.toLowerCase())
: site_li )
); : site_li
);
async function load_sites() { async function load_sites() {
if (!$ae_loc.account_id) return; if (!$ae_loc.account_id) return;
loading = true; loading = true;
site_li = await load_ae_obj_li__site({ site_li = await load_ae_obj_li__site({
api_cfg: $ae_api, api_cfg: $ae_api,
for_obj_id: $ae_loc.account_id, for_obj_id: $ae_loc.account_id,
enabled: qry_enabled as any, enabled: qry_enabled as any,
hidden: qry_hidden as any, hidden: qry_hidden as any,
log_lvl: 1 log_lvl: 1
}); });
loading = false; loading = false;
} }
onMount(() => { onMount(() => {
load_sites(); load_sites();
});
async function handle_add_site() {
const name = prompt('Enter new site name:');
if (!name) return;
const code = prompt('Enter site code (optional):');
const new_site = await create_ae_obj__site({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: {
name,
code: code || undefined,
enable: true
},
log_lvl: 1
}); });
async function handle_add_site() { if (new_site) {
const name = prompt('Enter new site name:'); load_sites();
if (!name) return;
const code = prompt('Enter site code (optional):');
const new_site = await create_ae_obj__site({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: {
name,
code: code || undefined,
enable: true
},
log_lvl: 1
});
if (new_site) {
load_sites();
}
} }
}
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10 gap-4"> <header
class="flex flex-wrap justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10 gap-4">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="p-2 bg-primary-500/10 rounded-lg"> <div class="p-2 bg-primary-500/10 rounded-lg">
<Globe size={24} class="text-primary-500" /> <Globe size={24} class="text-primary-500" />
</div> </div>
<div> <div>
<h1 class="h2 font-black tracking-tight">Site Management</h1> <h1 class="h2 font-black tracking-tight">Site Management</h1>
<p class="text-xs font-bold opacity-50 uppercase tracking-widest">Digital Properties & Domains</p> <p
class="text-xs font-bold opacity-50 uppercase tracking-widest">
Digital Properties & Domains
</p>
</div> </div>
</div> </div>
<button class="btn btn-sm preset-filled-primary font-bold shadow-lg" onclick={handle_add_site}> <button
class="btn btn-sm preset-filled-primary font-bold shadow-lg"
onclick={handle_add_site}>
<Plus size={16} class="mr-2" /> Add Site <Plus size={16} class="mr-2" /> Add Site
</button> </button>
</header> </header>
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-4"> <div
class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-4">
<div class="flex flex-wrap gap-6 items-end"> <div class="flex flex-wrap gap-6 items-end">
<div class="flex-1 min-w-[280px] space-y-1"> <div class="flex-1 min-w-[280px] space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Search Sites</span> <span
<div class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all"> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
<div class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20"> >Search Sites</span>
<div
class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all">
<div
class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20">
<Search size={18} class="opacity-50" /> <Search size={18} class="opacity-50" />
</div> </div>
<input <input
class="bg-transparent border-0 ring-0 focus:ring-0 p-3 grow placeholder:opacity-50" class="bg-transparent border-0 ring-0 focus:ring-0 p-3 grow placeholder:opacity-50"
type="search" type="search"
bind:value={qry_str} bind:value={qry_str}
placeholder="Search by name or code..." placeholder="Search by name or code..." />
/> <button
<button class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]" onclick={load_sites} disabled={loading}> class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]"
onclick={load_sites}
disabled={loading}>
{#if loading} {#if loading}
<span class="animate-spin text-xl"></span> <span class="animate-spin text-xl"></span>
{:else} {:else}
<span class="whitespace-nowrap tracking-wide">Refresh</span> <span class="whitespace-nowrap tracking-wide"
>Refresh</span>
{/if} {/if}
</button> </button>
</div> </div>
@@ -101,8 +129,13 @@
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Status</span> <span
<select class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2" bind:value={qry_enabled} onchange={load_sites}> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Status</span>
<select
class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2"
bind:value={qry_enabled}
onchange={load_sites}>
<option value="all">All Statuses</option> <option value="all">All Statuses</option>
<option value="enabled">Enabled Only</option> <option value="enabled">Enabled Only</option>
<option value="not_enabled">Disabled Only</option> <option value="not_enabled">Disabled Only</option>
@@ -110,8 +143,13 @@
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Visibility</span> <span
<select class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2" bind:value={qry_hidden} onchange={load_sites}> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Visibility</span>
<select
class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2"
bind:value={qry_hidden}
onchange={load_sites}>
<option value="all">All Visibility</option> <option value="all">All Visibility</option>
<option value="not_hidden">Not Hidden Only</option> <option value="not_hidden">Not Hidden Only</option>
<option value="hidden">Hidden Only</option> <option value="hidden">Hidden Only</option>
@@ -123,56 +161,88 @@
{#if loading} {#if loading}
<div class="card p-8 flex justify-center items-center h-64"> <div class="card p-8 flex justify-center items-center h-64">
<div class="placeholder animate-pulse w-full h-full rounded-2xl"></div> <div class="placeholder animate-pulse w-full h-full rounded-2xl">
</div>
</div> </div>
{:else if filtered_li.length === 0} {:else if filtered_li.length === 0}
<div class="card p-12 text-center preset-tonal-surface border-2 border-dashed border-surface-500/20 rounded-2xl"> <div
class="card p-12 text-center preset-tonal-surface border-2 border-dashed border-surface-500/20 rounded-2xl">
<Globe size={48} class="mx-auto mb-4 opacity-20" /> <Globe size={48} class="mx-auto mb-4 opacity-20" />
<h3 class="h3 font-bold opacity-50">No Sites Found</h3> <h3 class="h3 font-bold opacity-50">No Sites Found</h3>
<p class="opacity-60 max-w-xs mx-auto mt-2">Sites for this account will appear here. Add your first site to get started.</p> <p class="opacity-60 max-w-xs mx-auto mt-2">
Sites for this account will appear here. Add your first site to
get started.
</p>
</div> </div>
{:else} {:else}
<div class="card p-6 preset-tonal-surface shadow-xl border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 mb-6 flex items-center gap-2"> class="card p-6 preset-tonal-surface shadow-xl border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 mb-6 flex items-center gap-2">
<ListFilter size={18} class="text-secondary-500" /> <ListFilter size={18} class="text-secondary-500" />
Linked Properties Linked Properties
<span class="badge preset-tonal-secondary ml-auto">{filtered_li.length} found</span> <span class="badge preset-tonal-secondary ml-auto"
>{filtered_li.length} found</span>
</h3> </h3>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{#each filtered_li as site (site.site_id_random)} {#each filtered_li as site (site.site_id_random)}
<div class="card p-5 space-y-4 preset-tonal-surface shadow-md border border-surface-500/10 hover:border-primary-500/30 transition-all group relative"> <div
class="card p-5 space-y-4 preset-tonal-surface shadow-md border border-surface-500/10 hover:border-primary-500/30 transition-all group relative">
<div class="absolute top-4 right-4 flex gap-1"> <div class="absolute top-4 right-4 flex gap-1">
{#if site.hide} {#if site.hide}
<span class="badge preset-filled-warning text-[8px] uppercase font-bold shadow-sm">Hidden</span> <span
class="badge preset-filled-warning text-[8px] uppercase font-bold shadow-sm"
>Hidden</span>
{/if} {/if}
<span class="badge {site.enable ? 'preset-filled-success' : 'preset-filled-error'} text-[8px] uppercase font-bold shadow-sm"> <span
class="badge {site.enable
? 'preset-filled-success'
: 'preset-filled-error'} text-[8px] uppercase font-bold shadow-sm">
{site.enable ? 'Active' : 'Disabled'} {site.enable ? 'Active' : 'Disabled'}
</span> </span>
</div> </div>
<header class="flex items-center gap-3"> <header class="flex items-center gap-3">
<div class="avatar preset-filled-primary w-12 h-12 flex items-center justify-center rounded-lg shadow-inner group-hover:scale-110 transition-transform"> <div
class="avatar preset-filled-primary w-12 h-12 flex items-center justify-center rounded-lg shadow-inner group-hover:scale-110 transition-transform">
<Globe size={24} /> <Globe size={24} />
</div> </div>
<div class="pr-12"> <div class="pr-12">
<p class="font-black tracking-tight truncate">{site.name}</p> <p class="font-black tracking-tight truncate">
<p class="text-[10px] uppercase font-bold opacity-50 font-mono tracking-tighter">Code: {site.code || '--'}</p> {site.name}
</p>
<p
class="text-[10px] uppercase font-bold opacity-50 font-mono tracking-tighter">
Code: {site.code || '--'}
</p>
</div> </div>
</header> </header>
<div class="space-y-2 text-xs opacity-70"> <div class="space-y-2 text-xs opacity-70">
<div class="flex items-center gap-2 bg-black/5 p-2 rounded-lg"> <div
<Calendar size={14} class="text-primary-500 shrink-0" /> class="flex items-center gap-2 bg-black/5 p-2 rounded-lg">
<span>Created: {new Date(site.created_on).toLocaleDateString()}</span> <Calendar
size={14}
class="text-primary-500 shrink-0" />
<span
>Created: {new Date(
site.created_on
).toLocaleDateString()}</span>
</div> </div>
<div class="flex items-center gap-2 bg-black/5 p-2 rounded-lg"> <div
<ShieldCheck size={14} class="text-secondary-500 shrink-0" /> class="flex items-center gap-2 bg-black/5 p-2 rounded-lg">
<span class="font-mono truncate">{site.site_id_random}</span> <ShieldCheck
size={14}
class="text-secondary-500 shrink-0" />
<span class="font-mono truncate"
>{site.site_id_random}</span>
</div> </div>
</div> </div>
<a class="btn btn-sm preset-filled-primary font-bold w-full shadow-lg group-hover:brightness-110 transition-all" href="/core/sites/{site.site_id_random}"> <a
class="btn btn-sm preset-filled-primary font-bold w-full shadow-lg group-hover:brightness-110 transition-all"
href="/core/sites/{site.site_id_random}">
Manage Site Manage Site
</a> </a>
</div> </div>

View File

@@ -1,125 +1,145 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { page } from '$app/stores'; import { page } from '$app/stores';
import { import {
load_ae_obj_id__site, load_ae_obj_id__site,
update_ae_obj__site, update_ae_obj__site,
delete_ae_obj_id__site, delete_ae_obj_id__site,
load_ae_obj_li__site_domain, load_ae_obj_li__site_domain,
create_ae_obj__site_domain, create_ae_obj__site_domain,
update_ae_obj__site_domain, update_ae_obj__site_domain,
delete_ae_obj_id__site_domain delete_ae_obj_id__site_domain
} from '$lib/ae_core/ae_core__site'; } from '$lib/ae_core/ae_core__site';
import { editable_fields__site } from '$lib/ae_core/ae_core__site.editable_fields'; import { editable_fields__site } from '$lib/ae_core/ae_core__site.editable_fields';
import { editable_fields__site_domain } from '$lib/ae_core/ae_core__site_domain.editable_fields'; import { editable_fields__site_domain } from '$lib/ae_core/ae_core__site_domain.editable_fields';
import { ae_api, ae_loc } from '$lib/stores/ae_stores'; import { ae_api, ae_loc } from '$lib/stores/ae_stores';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { Activity, ArrowLeft, Database, ExternalLink, Globe, Info, Key, Plus, Save, Settings, Trash2 } from '@lucide/svelte'; import {
import AE_Comp_Site_Config_Editor from '$lib/ae_core/ae_comp__site_config_editor.svelte'; Activity,
ArrowLeft,
Database,
ExternalLink,
Globe,
Info,
Key,
Plus,
Save,
Settings,
Trash2
} from '@lucide/svelte';
import AE_Comp_Site_Config_Editor from '$lib/ae_core/ae_comp__site_config_editor.svelte';
let site_id = $derived($page.params.site_id ?? ''); let site_id = $derived($page.params.site_id ?? '');
let site: any = $state(null); let site: any = $state(null);
let domain_li: any[] = $state([]); let domain_li: any[] = $state([]);
let loading = $state(true); let loading = $state(true);
let saving = $state(false); let saving = $state(false);
async function load_data() { async function load_data() {
loading = true; loading = true;
site = await load_ae_obj_id__site({ site = await load_ae_obj_id__site({
api_cfg: $ae_api, api_cfg: $ae_api,
site_id, site_id,
log_lvl: 1 log_lvl: 1
}); });
domain_li = await load_ae_obj_li__site_domain({ domain_li = await load_ae_obj_li__site_domain({
api_cfg: $ae_api, api_cfg: $ae_api,
site_id, site_id,
enabled: 'all', enabled: 'all',
hidden: 'all', hidden: 'all',
log_lvl: 1 log_lvl: 1
}); });
loading = false; loading = false;
}
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
return;
} }
load_data();
});
onMount(() => { async function handle_save_site() {
if (!$ae_loc.manager_access) { saving = true;
goto('/core'); const data_kv: any = {};
return; editable_fields__site.forEach((field) => {
if (site[field] !== undefined) {
data_kv[field] = site[field];
} }
load_data();
}); });
async function handle_save_site() { // Ensure cfg_json is included explicitly
saving = true; data_kv.cfg_json = site.cfg_json;
const data_kv: any = {};
editable_fields__site.forEach(field => {
if (site[field] !== undefined) {
data_kv[field] = site[field];
}
});
// Ensure cfg_json is included explicitly await update_ae_obj__site({
data_kv.cfg_json = site.cfg_json; api_cfg: $ae_api,
site_id,
data_kv,
log_lvl: 1
});
saving = false;
}
await update_ae_obj__site({ async function handle_add_domain() {
api_cfg: $ae_api, const fqdn = prompt('Enter new domain (e.g. example.com):');
site_id, if (!fqdn) return;
data_kv,
log_lvl: 1
});
saving = false;
}
async function handle_add_domain() { await create_ae_obj__site_domain({
const fqdn = prompt('Enter new domain (e.g. example.com):'); api_cfg: $ae_api,
if (!fqdn) return; site_id,
data_kv: { fqdn, enable: true },
log_lvl: 1
});
load_data();
}
await create_ae_obj__site_domain({ async function handle_toggle_domain(dom: any) {
api_cfg: $ae_api, await update_ae_obj__site_domain({
site_id, api_cfg: $ae_api,
data_kv: { fqdn, enable: true }, site_id,
log_lvl: 1 site_domain_id: dom.site_domain_id_random,
}); data_kv: { enable: !dom.enable },
load_data(); log_lvl: 1
} });
load_data();
}
async function handle_toggle_domain(dom: any) { async function handle_delete_domain(dom: any) {
await update_ae_obj__site_domain({ if (!confirm(`Remove domain ${dom.fqdn}?`)) return;
api_cfg: $ae_api, await delete_ae_obj_id__site_domain({
site_id, api_cfg: $ae_api,
site_domain_id: dom.site_domain_id_random, site_id,
data_kv: { enable: !dom.enable }, site_domain_id: dom.site_domain_id_random,
log_lvl: 1 method: 'delete',
}); log_lvl: 1
load_data(); });
} load_data();
}
async function handle_delete_domain(dom: any) {
if (!confirm(`Remove domain ${dom.fqdn}?`)) return;
await delete_ae_obj_id__site_domain({
api_cfg: $ae_api,
site_id,
site_domain_id: dom.site_domain_id_random,
method: 'delete',
log_lvl: 1
});
load_data();
}
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10"> <header
class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10">
<div class="flex items-center gap-4"> <div class="flex items-center gap-4">
<a class="btn btn-sm preset-tonal-surface shadow-sm" href="/core/sites"> <a
class="btn btn-sm preset-tonal-surface shadow-sm"
href="/core/sites">
<ArrowLeft size={16} /> <ArrowLeft size={16} />
</a> </a>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<div class="p-2 bg-primary-500/10 rounded-lg"> <div class="p-2 bg-primary-500/10 rounded-lg">
<Globe size={24} class="text-primary-500" /> <Globe size={24} class="text-primary-500" />
</div> </div>
<h1 class="h2 font-black tracking-tight">{site?.name ?? 'Loading...'}</h1> <h1 class="h2 font-black tracking-tight">
{site?.name ?? 'Loading...'}
</h1>
</div> </div>
</div> </div>
<button class="btn btn-sm preset-filled-primary font-bold shadow-lg" onclick={handle_save_site} disabled={loading || saving}> <button
class="btn btn-sm preset-filled-primary font-bold shadow-lg"
onclick={handle_save_site}
disabled={loading || saving}>
{#if saving} {#if saving}
<span class="animate-spin mr-2"></span> <span class="animate-spin mr-2"></span>
{:else} {:else}
@@ -131,60 +151,98 @@
{#if loading} {#if loading}
<div class="card p-8 flex justify-center items-center h-64"> <div class="card p-8 flex justify-center items-center h-64">
<div class="placeholder animate-pulse w-full h-full rounded-2xl"></div> <div class="placeholder animate-pulse w-full h-full rounded-2xl">
</div>
</div> </div>
{:else if site} {:else if site}
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6"> <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Site Config --> <!-- Site Config -->
<div class="lg:col-span-2 space-y-6"> <div class="lg:col-span-2 space-y-6">
<div class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Settings size={18} class="text-primary-500" /> Site Configuration <Settings size={18} class="text-primary-500" /> Site Configuration
</h3> </h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Site Name</span> <span
<input class="input preset-filled-surface rounded-lg p-3" type="text" bind:value={site.name} /> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Site Name</span>
<input
class="input preset-filled-surface rounded-lg p-3"
type="text"
bind:value={site.name} />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Site Code</span> <span
<input class="input preset-filled-surface rounded-lg font-mono p-3" type="text" bind:value={site.code} /> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Site Code</span>
<input
class="input preset-filled-surface rounded-lg font-mono p-3"
type="text"
bind:value={site.code} />
</div> </div>
<div class="space-y-1 md:col-span-2"> <div class="space-y-1 md:col-span-2">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Tagline</span> <span
<input class="input preset-filled-surface rounded-lg p-3" type="text" bind:value={site.tagline} /> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Tagline</span>
<input
class="input preset-filled-surface rounded-lg p-3"
type="text"
bind:value={site.tagline} />
</div> </div>
<div class="space-y-1 md:col-span-2"> <div class="space-y-1 md:col-span-2">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Description</span> <span
<textarea class="textarea preset-filled-surface rounded-lg p-3" rows="2" bind:value={site.description}></textarea> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Description</span>
<textarea
class="textarea preset-filled-surface rounded-lg p-3"
rows="2"
bind:value={site.description}></textarea>
</div> </div>
</div> </div>
</div> </div>
<!-- Advanced Site JSON Config --> <!-- Advanced Site JSON Config -->
<div class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10">
<Database size={18} class="text-warning-500" /> Site Settings (cfg_json) <h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Database size={18} class="text-warning-500" /> Site Settings
(cfg_json)
</h3> </h3>
<AE_Comp_Site_Config_Editor <AE_Comp_Site_Config_Editor
bind:cfg_json={site.cfg_json} bind:cfg_json={site.cfg_json}
on_save={handle_save_site} on_save={handle_save_site} />
/>
</div> </div>
<div class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Key size={18} class="text-secondary-500" /> Access Control <Key size={18} class="text-secondary-500" /> Access Control
</h3> </h3>
<div class="flex flex-col gap-4"> <div class="flex flex-col gap-4">
<label class="flex items-center space-x-2 cursor-pointer group"> <label
<input class="checkbox" type="checkbox" bind:checked={site.restrict_access} /> class="flex items-center space-x-2 cursor-pointer group">
<span class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity">Restrict Access</span> <input
class="checkbox"
type="checkbox"
bind:checked={site.restrict_access} />
<span
class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity"
>Restrict Access</span>
</label> </label>
{#if site.restrict_access} {#if site.restrict_access}
<div class="space-y-1 max-w-md animate-fade-in"> <div class="space-y-1 max-w-md animate-fade-in">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Access Key</span> <span
<input class="input preset-filled-surface rounded-lg font-mono p-3" type="text" bind:value={site.access_key} /> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Access Key</span>
<input
class="input preset-filled-surface rounded-lg font-mono p-3"
type="text"
bind:value={site.access_key} />
</div> </div>
{/if} {/if}
</div> </div>
@@ -193,38 +251,67 @@
<!-- Domains Management --> <!-- Domains Management -->
<div class="space-y-6"> <div class="space-y-6">
<div class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<header class="flex justify-between items-center border-b border-surface-500/30 pb-2"> class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10">
<header
class="flex justify-between items-center border-b border-surface-500/30 pb-2">
<h3 class="h4 font-bold flex items-center gap-2"> <h3 class="h4 font-bold flex items-center gap-2">
<Globe size={18} class="text-tertiary-500" /> Site Domains <Globe size={18} class="text-tertiary-500" /> Site Domains
</h3> </h3>
<button class="btn btn-icon btn-sm preset-filled-secondary shadow-md" onclick={handle_add_domain} title="Add Domain"> <button
class="btn btn-icon btn-sm preset-filled-secondary shadow-md"
onclick={handle_add_domain}
title="Add Domain">
<Plus size={14} /> <Plus size={14} />
</button> </button>
</header> </header>
{#if domain_li.length === 0} {#if domain_li.length === 0}
<p class="text-sm opacity-60 text-center py-8 bg-surface-500/5 rounded-lg border-2 border-dashed border-surface-500/20">No domains configured.</p> <p
class="text-sm opacity-60 text-center py-8 bg-surface-500/5 rounded-lg border-2 border-dashed border-surface-500/20">
No domains configured.
</p>
{:else} {:else}
<div class="space-y-3"> <div class="space-y-3">
{#each domain_li as dom (dom.site_domain_id_random)} {#each domain_li as dom (dom.site_domain_id_random)}
<div class="card p-3 preset-tonal-surface shadow-sm border border-surface-500/10 flex justify-between items-center group"> <div
class="card p-3 preset-tonal-surface shadow-sm border border-surface-500/10 flex justify-between items-center group">
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-bold text-sm flex items-center gap-1"> <span
class="font-bold text-sm flex items-center gap-1">
{dom.fqdn} {dom.fqdn}
<a href="https://{dom.fqdn}" target="_blank" rel="noopener noreferrer" class="opacity-30 group-hover:opacity-100 transition-opacity"> <a
href="https://{dom.fqdn}"
target="_blank"
rel="noopener noreferrer"
class="opacity-30 group-hover:opacity-100 transition-opacity">
<ExternalLink size={12} /> <ExternalLink size={12} />
</a> </a>
</span> </span>
<span class="text-[10px] uppercase font-bold tracking-tighter opacity-50"> <span
Key: <code class="text-primary-500">{dom.access_key || '--'}</code> &bull; {dom.enable ? 'Active' : 'Disabled'} class="text-[10px] uppercase font-bold tracking-tighter opacity-50">
Key: <code class="text-primary-500"
>{dom.access_key || '--'}</code>
&bull; {dom.enable
? 'Active'
: 'Disabled'}
</span> </span>
</div> </div>
<div class="flex gap-1"> <div class="flex gap-1">
<button class="btn btn-icon btn-sm {dom.enable ? 'preset-tonal-success' : 'preset-tonal-error'}" onclick={() => handle_toggle_domain(dom)} title="Toggle Active"> <button
class="btn btn-icon btn-sm {dom.enable
? 'preset-tonal-success'
: 'preset-tonal-error'}"
onclick={() =>
handle_toggle_domain(dom)}
title="Toggle Active">
<Save size={14} /> <Save size={14} />
</button> </button>
<button class="btn btn-icon btn-sm preset-tonal-error" onclick={() => handle_delete_domain(dom)} title="Delete Domain"> <button
class="btn btn-icon btn-sm preset-tonal-error"
onclick={() =>
handle_delete_domain(dom)}
title="Delete Domain">
<Trash2 size={14} /> <Trash2 size={14} />
</button> </button>
</div> </div>
@@ -234,18 +321,32 @@
{/if} {/if}
</div> </div>
<div class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Activity size={18} class="text-error-500" /> System Status <Activity size={18} class="text-error-500" /> System Status
</h3> </h3>
<div class="space-y-4 py-2"> <div class="space-y-4 py-2">
<label class="flex items-center space-x-3 cursor-pointer group"> <label
<input class="checkbox" type="checkbox" bind:checked={site.enable} /> class="flex items-center space-x-3 cursor-pointer group">
<span class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity">Site Enabled</span> <input
class="checkbox"
type="checkbox"
bind:checked={site.enable} />
<span
class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity"
>Site Enabled</span>
</label> </label>
<label class="flex items-center space-x-3 cursor-pointer group"> <label
<input class="checkbox" type="checkbox" bind:checked={site.hide} /> class="flex items-center space-x-3 cursor-pointer group">
<span class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity">Hidden from Public</span> <input
class="checkbox"
type="checkbox"
bind:checked={site.hide} />
<span
class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity"
>Hidden from Public</span>
</label> </label>
</div> </div>
</div> </div>

View File

@@ -1,75 +1,94 @@
<script lang="ts"> <script lang="ts">
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { load_ae_obj_li__user, create_ae_obj__user } from '$lib/ae_core/ae_core__user'; import {
import { ae_api, ae_loc } from '$lib/stores/ae_stores'; load_ae_obj_li__user,
import { goto } from '$app/navigation'; create_ae_obj__user
import { Activity, Fingerprint, Globe, Landmark, ListFilter, Mail, Plus, Search, ShieldCheck, User, X } from '@lucide/svelte'; } from '$lib/ae_core/ae_core__user';
let user_li: any[] = $state([]); import { ae_api, ae_loc } from '$lib/stores/ae_stores';
let loading = $state(true); import { goto } from '$app/navigation';
let qry_str = $state(''); import {
let qry_enabled = $state('all'); Activity,
let qry_account_scope = $state('all'); // 'all', 'account', 'global' Fingerprint,
let show_add_form = $state(false); Globe,
Landmark,
ListFilter,
Mail,
Plus,
Search,
ShieldCheck,
User,
X
} from '@lucide/svelte';
let user_li: any[] = $state([]);
let loading = $state(true);
let qry_str = $state('');
let qry_enabled = $state('all');
let qry_account_scope = $state('all'); // 'all', 'account', 'global'
let show_add_form = $state(false);
async function load_users() { async function load_users() {
loading = true; loading = true;
let for_obj_id: string | null = $ae_loc.account_id; let for_obj_id: string | null = $ae_loc.account_id;
let include_global = true; let include_global = true;
if (qry_account_scope === 'account') { if (qry_account_scope === 'account') {
include_global = false; include_global = false;
} else if (qry_account_scope === 'global') { } else if (qry_account_scope === 'global') {
for_obj_id = null; for_obj_id = null;
include_global = true; // This will trigger the (account_id IS NULL) logic in the search if no qry_str include_global = true; // This will trigger the (account_id IS NULL) logic in the search if no qry_str
}
user_li = await load_ae_obj_li__user({
api_cfg: $ae_api,
for_obj_id: for_obj_id,
include_global: include_global,
qry_str: qry_str || null,
enabled: qry_enabled as any,
log_lvl: 1
});
loading = false;
} }
onMount(() => { user_li = await load_ae_obj_li__user({
if (!$ae_loc.manager_access) { api_cfg: $ae_api,
goto('/core'); for_obj_id: for_obj_id,
return; include_global: include_global,
} qry_str: qry_str || null,
load_users(); enabled: qry_enabled as any,
log_lvl: 1
}); });
loading = false;
}
async function handle_add_user() { onMount(() => {
const username = prompt('Enter new username:'); if (!$ae_loc.manager_access) {
if (!username) return; goto('/core');
const email = prompt('Enter email address:'); return;
// Link to account if scope is 'account' or 'all', otherwise create global user
const account_id = qry_account_scope === 'global' ? undefined : $ae_loc.account_id;
await create_ae_obj__user({
api_cfg: $ae_api,
account_id: account_id,
data_kv: { username, email, enable: true },
log_lvl: 1
});
load_users();
} }
load_users();
});
async function handle_add_user() {
const username = prompt('Enter new username:');
if (!username) return;
const email = prompt('Enter email address:');
// Link to account if scope is 'account' or 'all', otherwise create global user
const account_id =
qry_account_scope === 'global' ? undefined : $ae_loc.account_id;
await create_ae_obj__user({
api_cfg: $ae_api,
account_id: account_id,
data_kv: { username, email, enable: true },
log_lvl: 1
});
load_users();
}
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10"> <header
class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<div class="p-2 bg-primary-500/10 rounded-lg"> <div class="p-2 bg-primary-500/10 rounded-lg">
<ShieldCheck size={24} class="text-primary-500" /> <ShieldCheck size={24} class="text-primary-500" />
</div> </div>
<h1 class="h2 font-black tracking-tight">User Management</h1> <h1 class="h2 font-black tracking-tight">User Management</h1>
</div> </div>
<button class="btn btn-sm preset-filled-primary font-bold shadow-lg" onclick={() => show_add_form = !show_add_form}> <button
class="btn btn-sm preset-filled-primary font-bold shadow-lg"
onclick={() => (show_add_form = !show_add_form)}>
{#if show_add_form} {#if show_add_form}
<X size={16} class="mr-2" /> Cancel <X size={16} class="mr-2" /> Cancel
{:else} {:else}
@@ -78,12 +97,17 @@
</button> </button>
</header> </header>
<div class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-4"> <div
class="card p-6 shadow-xl preset-tonal-surface border border-surface-500/10 space-y-4">
<div class="flex flex-wrap gap-6 items-end"> <div class="flex flex-wrap gap-6 items-end">
<div class="flex-1 min-w-[280px] space-y-1"> <div class="flex-1 min-w-[280px] space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Search Users</span> <span
<div class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all"> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
<div class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20"> >Search Users</span>
<div
class="flex bg-surface-200-700-token rounded-lg overflow-hidden border border-surface-500/20 shadow-inner group focus-within:ring-2 focus-within:ring-primary-500/50 transition-all">
<div
class="flex items-center justify-center px-4 bg-surface-300-600-token border-r border-surface-500/20">
<Search size={18} class="opacity-50" /> <Search size={18} class="opacity-50" />
</div> </div>
<input <input
@@ -91,13 +115,16 @@
type="search" type="search"
bind:value={qry_str} bind:value={qry_str}
placeholder="Search username or email..." placeholder="Search username or email..."
onkeydown={(e) => e.key === 'Enter' && load_users()} onkeydown={(e) => e.key === 'Enter' && load_users()} />
/> <button
<button class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]" onclick={load_users} disabled={loading}> class="preset-filled-primary font-bold px-10 py-3 hover:brightness-110 transition-all border-l border-surface-500/20 flex items-center justify-center min-w-[100px]"
onclick={load_users}
disabled={loading}>
{#if loading} {#if loading}
<span class="animate-spin text-xl"></span> <span class="animate-spin text-xl"></span>
{:else} {:else}
<span class="whitespace-nowrap tracking-wide">Go</span> <span class="whitespace-nowrap tracking-wide"
>Go</span>
{/if} {/if}
</button> </button>
</div> </div>
@@ -105,8 +132,13 @@
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Scope</span> <span
<select class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2" bind:value={qry_account_scope} onchange={load_users}> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Scope</span>
<select
class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2"
bind:value={qry_account_scope}
onchange={load_users}>
<option value="all">All (Current + Global)</option> <option value="all">All (Current + Global)</option>
<option value="account">Account Only</option> <option value="account">Account Only</option>
<option value="global">Global Only</option> <option value="global">Global Only</option>
@@ -114,8 +146,13 @@
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<span class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1">Status</span> <span
<select class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2" bind:value={qry_enabled} onchange={load_users}> class="label block text-xs font-bold opacity-75 uppercase tracking-wider ml-1"
>Status</span>
<select
class="select preset-filled-surface rounded-lg text-sm border border-surface-500/20 p-2"
bind:value={qry_enabled}
onchange={load_users}>
<option value="all">All</option> <option value="all">All</option>
<option value="enabled">Enabled</option> <option value="enabled">Enabled</option>
<option value="not_enabled">Disabled</option> <option value="not_enabled">Disabled</option>
@@ -127,47 +164,67 @@
{#if loading} {#if loading}
<div class="card p-8 flex justify-center items-center h-64"> <div class="card p-8 flex justify-center items-center h-64">
<div class="placeholder animate-pulse w-full h-full rounded-2xl"></div> <div class="placeholder animate-pulse w-full h-full rounded-2xl">
</div>
</div> </div>
{:else if user_li.length === 0} {:else if user_li.length === 0}
<div class="card p-12 text-center preset-tonal-surface border-2 border-dashed border-surface-500/20 rounded-2xl"> <div
class="card p-12 text-center preset-tonal-surface border-2 border-dashed border-surface-500/20 rounded-2xl">
<Fingerprint size={48} class="mx-auto mb-4 opacity-20" /> <Fingerprint size={48} class="mx-auto mb-4 opacity-20" />
<h3 class="h3 font-bold opacity-50">No Users Found</h3> <h3 class="h3 font-bold opacity-50">No Users Found</h3>
<p class="opacity-60 max-w-xs mx-auto mt-2">Try adjusting your search or scope filters.</p> <p class="opacity-60 max-w-xs mx-auto mt-2">
Try adjusting your search or scope filters.
</p>
</div> </div>
{:else} {:else}
<div class="card p-6 preset-tonal-surface shadow-xl border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 mb-6 flex items-center gap-2"> class="card p-6 preset-tonal-surface shadow-xl border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 mb-6 flex items-center gap-2">
<ListFilter size={18} class="text-secondary-500" /> <ListFilter size={18} class="text-secondary-500" />
Directory Results Directory Results
<span class="badge preset-tonal-secondary ml-auto">{user_li.length} found</span> <span class="badge preset-tonal-secondary ml-auto"
>{user_li.length} found</span>
</h3> </h3>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{#each user_li as user (user.user_id_random)} {#each user_li as user (user.user_id_random)}
<div class="card p-5 space-y-4 preset-tonal-surface shadow-md border border-surface-500/10 hover:border-primary-500/30 transition-all group"> <div
class="card p-5 space-y-4 preset-tonal-surface shadow-md border border-surface-500/10 hover:border-primary-500/30 transition-all group">
<header class="flex justify-between items-start"> <header class="flex justify-between items-start">
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="avatar preset-filled-primary w-12 h-12 flex items-center justify-center rounded-full shadow-inner group-hover:scale-110 transition-transform"> <div
class="avatar preset-filled-primary w-12 h-12 flex items-center justify-center rounded-full shadow-inner group-hover:scale-110 transition-transform">
<User size={24} /> <User size={24} />
</div> </div>
<div> <div>
<p class="font-black tracking-tight">{user.username}</p> <p class="font-black tracking-tight">
<p class="text-[10px] uppercase font-bold opacity-50">{user.name || 'No Display Name'}</p> {user.username}
</p>
<p
class="text-[10px] uppercase font-bold opacity-50">
{user.name || 'No Display Name'}
</p>
</div> </div>
</div> </div>
<div class="flex flex-col items-end gap-1"> <div class="flex flex-col items-end gap-1">
{#if user.super} {#if user.super}
<span class="badge preset-filled-error text-[8px] uppercase font-bold">Super</span> <span
class="badge preset-filled-error text-[8px] uppercase font-bold"
>Super</span>
{:else if user.manager} {:else if user.manager}
<span class="badge preset-filled-warning text-[8px] uppercase font-bold">Manager</span> <span
class="badge preset-filled-warning text-[8px] uppercase font-bold"
>Manager</span>
{/if} {/if}
{#if !user.account_id && !user.account_id_random} {#if !user.account_id && !user.account_id_random}
<span class="badge preset-tonal-secondary text-[8px] uppercase font-bold flex items-center gap-1"> <span
class="badge preset-tonal-secondary text-[8px] uppercase font-bold flex items-center gap-1">
<Globe size={8} /> Global <Globe size={8} /> Global
</span> </span>
{:else} {:else}
<span class="badge preset-tonal-primary text-[8px] uppercase font-bold flex items-center gap-1"> <span
class="badge preset-tonal-primary text-[8px] uppercase font-bold flex items-center gap-1">
<Landmark size={8} /> Account <Landmark size={8} /> Account
</span> </span>
{/if} {/if}
@@ -175,17 +232,25 @@
</header> </header>
<div class="space-y-2"> <div class="space-y-2">
<div class="flex items-center gap-2 text-xs opacity-70 bg-black/5 p-2 rounded-lg"> <div
class="flex items-center gap-2 text-xs opacity-70 bg-black/5 p-2 rounded-lg">
<Mail size={14} class="text-primary-500" /> <Mail size={14} class="text-primary-500" />
<span class="truncate">{user.email || '--'}</span> <span class="truncate"
>{user.email || '--'}</span>
</div> </div>
<div class="flex items-center gap-2 text-xs opacity-70 bg-black/5 p-2 rounded-lg"> <div
<Activity size={14} class="text-secondary-500" /> class="flex items-center gap-2 text-xs opacity-70 bg-black/5 p-2 rounded-lg">
<span class="font-mono">{user.user_id_random}</span> <Activity
size={14}
class="text-secondary-500" />
<span class="font-mono"
>{user.user_id_random}</span>
</div> </div>
</div> </div>
<a class="btn btn-sm preset-filled-primary font-bold w-full shadow-lg group-hover:brightness-110 transition-all" href="/core/users/{user.user_id_random}"> <a
class="btn btn-sm preset-filled-primary font-bold w-full shadow-lg group-hover:brightness-110 transition-all"
href="/core/users/{user.user_id_random}">
Manage User Manage User
</a> </a>
</div> </div>

View File

@@ -1,87 +1,120 @@
<script lang="ts"> <script lang="ts">
import { onMount, untrack } from 'svelte'; import { onMount, untrack } from 'svelte';
import { ae_loc, ae_api } from '$lib/stores/ae_stores'; import { ae_loc, ae_api } from '$lib/stores/ae_stores';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { update_ae_obj__user, delete_ae_obj_id__user } from '$lib/ae_core/ae_core__user'; import {
import { editable_fields__user } from '$lib/ae_core/ae_core__user.editable_fields'; update_ae_obj__user,
import { Activity, ArrowLeft, CircleCheck, CircleX, Clock, Fingerprint, Key, Lock, Mail, Save, Settings, ShieldCheck, Trash2, User as UserIcon } from '@lucide/svelte'; delete_ae_obj_id__user
interface Props { } from '$lib/ae_core/ae_core__user';
data: any; import { editable_fields__user } from '$lib/ae_core/ae_core__user.editable_fields';
import {
Activity,
ArrowLeft,
CircleCheck,
CircleX,
Clock,
Fingerprint,
Key,
Lock,
Mail,
Save,
Settings,
ShieldCheck,
Trash2,
User as UserIcon
} from '@lucide/svelte';
interface Props {
data: any;
}
let { data }: Props = $props();
let user = $state(untrack(() => data.user));
let saving = $state(false);
$effect(() => {
user = data.user;
});
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
} }
});
let { data }: Props = $props(); async function handle_save() {
let user = $state(untrack(() => data.user)); saving = true;
let saving = $state(false); const data_kv: any = {};
editable_fields__user.forEach((field) => {
$effect(() => { if (user[field] !== undefined) {
user = data.user; data_kv[field] = user[field];
});
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
} }
}); });
async function handle_save() { const result = await update_ae_obj__user({
saving = true; api_cfg: $ae_api,
const data_kv: any = {}; user_id: user.user_id_random,
editable_fields__user.forEach(field => { data_kv,
if (user[field] !== undefined) { log_lvl: 1
data_kv[field] = user[field]; });
}
});
const result = await update_ae_obj__user({ if (result) {
api_cfg: $ae_api, alert('User updated successfully');
user_id: user.user_id_random,
data_kv,
log_lvl: 1
});
if (result) {
alert('User updated successfully');
}
saving = false;
} }
saving = false;
}
async function handle_delete() { async function handle_delete() {
if (!confirm('Are you sure you want to disable this user account?')) return; if (!confirm('Are you sure you want to disable this user account?')) return;
const result = await delete_ae_obj_id__user({ const result = await delete_ae_obj_id__user({
api_cfg: $ae_api, api_cfg: $ae_api,
user_id: user.user_id_random, user_id: user.user_id_random,
method: 'disable', method: 'disable',
log_lvl: 1 log_lvl: 1
}); });
if (result) { if (result) {
goto('/core/users'); goto('/core/users');
}
} }
}
</script> </script>
<div class="container mx-auto p-4 space-y-6"> <div class="container mx-auto p-4 space-y-6">
<header class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10"> <header
class="flex justify-between items-center bg-surface-50-900-token p-4 rounded-xl shadow-lg border border-surface-500/10">
<div class="flex items-center gap-4"> <div class="flex items-center gap-4">
<a class="btn btn-sm preset-tonal-surface shadow-sm" href="/core/users"> <a
class="btn btn-sm preset-tonal-surface shadow-sm"
href="/core/users">
<ArrowLeft size={16} /> <ArrowLeft size={16} />
</a> </a>
<div class="flex items-center gap-3"> <div class="flex items-center gap-3">
<div class="avatar preset-filled-primary w-12 h-12 flex items-center justify-center rounded-full shadow-inner"> <div
class="avatar preset-filled-primary w-12 h-12 flex items-center justify-center rounded-full shadow-inner">
<UserIcon size={24} /> <UserIcon size={24} />
</div> </div>
<div> <div>
<h1 class="h2 font-black tracking-tight">{user.username}</h1> <h1 class="h2 font-black tracking-tight">
<p class="text-[10px] uppercase font-bold tracking-widest opacity-50">UID: {user.user_id_random}</p> {user.username}
</h1>
<p
class="text-[10px] uppercase font-bold tracking-widest opacity-50">
UID: {user.user_id_random}
</p>
</div> </div>
</div> </div>
</div> </div>
<div class="flex gap-2"> <div class="flex gap-2">
<button class="btn btn-sm preset-filled-error font-bold shadow-lg" onclick={handle_delete} disabled={saving}> <button
class="btn btn-sm preset-filled-error font-bold shadow-lg"
onclick={handle_delete}
disabled={saving}>
<Trash2 size={16} class="mr-2" /> Disable <Trash2 size={16} class="mr-2" /> Disable
</button> </button>
<button class="btn btn-sm preset-filled-primary font-bold shadow-lg" onclick={handle_save} disabled={saving}> <button
class="btn btn-sm preset-filled-primary font-bold shadow-lg"
onclick={handle_save}
disabled={saving}>
{#if saving} {#if saving}
<span class="animate-spin mr-2"></span> <span class="animate-spin mr-2"></span>
{:else} {:else}
@@ -95,61 +128,123 @@
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6"> <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Main Info --> <!-- Main Info -->
<div class="lg:col-span-2 space-y-6"> <div class="lg:col-span-2 space-y-6">
<div class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<UserIcon size={18} class="text-primary-500" /> Basic Profile <UserIcon size={18} class="text-primary-500" /> Basic Profile
</h3> </h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="user-display-name">Display Name</label> <label
<input class="input preset-filled-surface rounded-lg p-2" id="user-display-name" type="text" bind:value={user.name} placeholder="Full Name" /> class="label text-xs font-bold opacity-75"
for="user-display-name">Display Name</label>
<input
class="input preset-filled-surface rounded-lg p-2"
id="user-display-name"
type="text"
bind:value={user.name}
placeholder="Full Name" />
</div> </div>
<div class="space-y-1"> <div class="space-y-1">
<label class="label text-xs font-bold opacity-75" for="user-email">Email Address</label> <label
<input class="input preset-filled-surface rounded-lg p-2" id="user-email" type="email" bind:value={user.email} /> class="label text-xs font-bold opacity-75"
for="user-email">Email Address</label>
<input
class="input preset-filled-surface rounded-lg p-2"
id="user-email"
type="email"
bind:value={user.email} />
</div> </div>
<div class="space-y-1 md:col-span-2"> <div class="space-y-1 md:col-span-2">
<label class="label text-xs font-bold opacity-75" for="user-username">Username</label> <label
<div class="input-group input-group-divider grid-cols-[auto_1fr] preset-tonal-surface rounded-lg overflow-hidden border border-surface-500/20"> class="label text-xs font-bold opacity-75"
<div class="input-group-shim !pl-4 !pr-0"><Fingerprint size={16} /></div> for="user-username">Username</label>
<input class="bg-transparent border-0 ring-0 focus:ring-0 font-mono opacity-60 p-2" id="user-username" type="text" bind:value={user.username} disabled /> <div
class="input-group input-group-divider grid-cols-[auto_1fr] preset-tonal-surface rounded-lg overflow-hidden border border-surface-500/20">
<div class="input-group-shim !pl-4 !pr-0">
<Fingerprint size={16} />
</div>
<input
class="bg-transparent border-0 ring-0 focus:ring-0 font-mono opacity-60 p-2"
id="user-username"
type="text"
bind:value={user.username}
disabled />
</div> </div>
<p class="text-[10px] opacity-50 mt-1 italic uppercase tracking-tighter">Username changes are currently restricted.</p> <p
class="text-[10px] opacity-50 mt-1 italic uppercase tracking-tighter">
Username changes are currently restricted.
</p>
</div> </div>
</div> </div>
</div> </div>
<div class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<ShieldCheck size={18} class="text-secondary-500" /> System Permissions <ShieldCheck size={18} class="text-secondary-500" /> System Permissions
</h3> </h3>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4"> <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<label class="flex items-center space-x-3 card p-4 preset-tonal-error cursor-pointer border border-error-500/20 hover:preset-filled-error transition-all group"> <label
<input class="checkbox" type="checkbox" bind:checked={user.super} /> class="flex items-center space-x-3 card p-4 preset-tonal-error cursor-pointer border border-error-500/20 hover:preset-filled-error transition-all group">
<input
class="checkbox"
type="checkbox"
bind:checked={user.super} />
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-black uppercase text-xs tracking-widest">Super User</span> <span
<span class="text-[10px] opacity-70 group-hover:opacity-100">Full system override access</span> class="font-black uppercase text-xs tracking-widest"
>Super User</span>
<span
class="text-[10px] opacity-70 group-hover:opacity-100"
>Full system override access</span>
</div> </div>
</label> </label>
<label class="flex items-center space-x-3 card p-4 preset-tonal-warning cursor-pointer border border-warning-500/20 hover:preset-filled-warning transition-all group"> <label
<input class="checkbox" type="checkbox" bind:checked={user.manager} /> class="flex items-center space-x-3 card p-4 preset-tonal-warning cursor-pointer border border-warning-500/20 hover:preset-filled-warning transition-all group">
<input
class="checkbox"
type="checkbox"
bind:checked={user.manager} />
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-black uppercase text-xs tracking-widest">Manager</span> <span
<span class="text-[10px] opacity-70 group-hover:opacity-100">Global account & user management</span> class="font-black uppercase text-xs tracking-widest"
>Manager</span>
<span
class="text-[10px] opacity-70 group-hover:opacity-100"
>Global account & user management</span>
</div> </div>
</label> </label>
<label class="flex items-center space-x-3 card p-4 preset-tonal-primary cursor-pointer border border-primary-500/20 hover:preset-filled-primary transition-all group"> <label
<input class="checkbox" type="checkbox" bind:checked={user.administrator} /> class="flex items-center space-x-3 card p-4 preset-tonal-primary cursor-pointer border border-primary-500/20 hover:preset-filled-primary transition-all group">
<input
class="checkbox"
type="checkbox"
bind:checked={user.administrator} />
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-black uppercase text-xs tracking-widest">Administrator</span> <span
<span class="text-[10px] opacity-70 group-hover:opacity-100">Account-level administrative access</span> class="font-black uppercase text-xs tracking-widest"
>Administrator</span>
<span
class="text-[10px] opacity-70 group-hover:opacity-100"
>Account-level administrative access</span>
</div> </div>
</label> </label>
<label class="flex items-center space-x-3 card p-4 preset-tonal-secondary cursor-pointer border border-secondary-500/20 hover:preset-filled-secondary transition-all group"> <label
<input class="checkbox" type="checkbox" bind:checked={user.verified} /> class="flex items-center space-x-3 card p-4 preset-tonal-secondary cursor-pointer border border-secondary-500/20 hover:preset-filled-secondary transition-all group">
<input
class="checkbox"
type="checkbox"
bind:checked={user.verified} />
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-black uppercase text-xs tracking-widest">Verified User</span> <span
<span class="text-[10px] opacity-70 group-hover:opacity-100">Identity confirmed by staff</span> class="font-black uppercase text-xs tracking-widest"
>Verified User</span>
<span
class="text-[10px] opacity-70 group-hover:opacity-100"
>Identity confirmed by staff</span>
</div> </div>
</label> </label>
</div> </div>
@@ -158,63 +253,105 @@
<!-- Sidebar / Meta --> <!-- Sidebar / Meta -->
<div class="space-y-6"> <div class="space-y-6">
<div class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Activity size={18} class="text-tertiary-500" /> Account Status <Activity size={18} class="text-tertiary-500" /> Account Status
</h3> </h3>
<div class="space-y-4 py-2"> <div class="space-y-4 py-2">
<label class="flex items-center space-x-3 cursor-pointer group"> <label
<input class="checkbox" type="checkbox" bind:checked={user.enable} /> class="flex items-center space-x-3 cursor-pointer group">
<span class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity">Login Enabled</span> <input
class="checkbox"
type="checkbox"
bind:checked={user.enable} />
<span
class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity"
>Login Enabled</span>
</label> </label>
<label class="flex items-center space-x-3 cursor-pointer group"> <label
<input class="checkbox" type="checkbox" bind:checked={user.hide} /> class="flex items-center space-x-3 cursor-pointer group">
<span class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity">Hidden from Lists</span> <input
class="checkbox"
type="checkbox"
bind:checked={user.hide} />
<span
class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity"
>Hidden from Lists</span>
</label> </label>
<label class="flex items-center space-x-3 cursor-pointer group"> <label
<input class="checkbox" type="checkbox" bind:checked={user.allow_auth_key} /> class="flex items-center space-x-3 cursor-pointer group">
<span class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity">Allow Email Auth Key</span> <input
class="checkbox"
type="checkbox"
bind:checked={user.allow_auth_key} />
<span
class="text-sm font-bold opacity-70 group-hover:opacity-100 transition-opacity"
>Allow Email Auth Key</span>
</label> </label>
</div> </div>
</div> </div>
<div class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Lock size={18} class="text-surface-500" /> Linking Info <Lock size={18} class="text-surface-500" /> Linking Info
</h3> </h3>
<div class="space-y-3 text-xs"> <div class="space-y-3 text-xs">
<div class="flex justify-between items-center p-2 bg-black/5 rounded-lg"> <div
<span class="font-bold opacity-50 uppercase tracking-tighter">Linked Person</span> class="flex justify-between items-center p-2 bg-black/5 rounded-lg">
<span
class="font-bold opacity-50 uppercase tracking-tighter"
>Linked Person</span>
<span class="font-mono font-bold"> <span class="font-mono font-bold">
{#if user.person_id_random} {#if user.person_id_random}
<a href="/core/people/{user.person_id_random}" class="text-primary-500 hover:underline"> <a
href="/core/people/{user.person_id_random}"
class="text-primary-500 hover:underline">
{user.person_id_random} {user.person_id_random}
</a> </a>
{:else} {:else}
<span class="italic text-error-500">Unlinked</span> <span class="italic text-error-500"
>Unlinked</span>
{/if} {/if}
</span> </span>
</div> </div>
<div class="flex justify-between items-center p-2 bg-black/5 rounded-lg"> <div
<span class="font-bold opacity-50 uppercase tracking-tighter">Account Context</span> class="flex justify-between items-center p-2 bg-black/5 rounded-lg">
<span class="font-mono font-bold">{user.account_id_random || '--'}</span> <span
class="font-bold opacity-50 uppercase tracking-tighter"
>Account Context</span>
<span class="font-mono font-bold"
>{user.account_id_random || '--'}</span>
</div> </div>
</div> </div>
</div> </div>
<div class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10"> <div
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2"> class="card p-6 space-y-4 shadow-xl preset-tonal-surface border border-surface-500/10">
<h3
class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
<Clock size={18} class="text-surface-500" /> Timestamps <Clock size={18} class="text-surface-500" /> Timestamps
</h3> </h3>
<div class="space-y-3 text-[10px] uppercase font-bold tracking-wider"> <div
class="space-y-3 text-[10px] uppercase font-bold tracking-wider">
<div class="flex flex-col gap-1 opacity-60"> <div class="flex flex-col gap-1 opacity-60">
<span>Created On</span> <span>Created On</span>
<span class="text-xs text-surface-900 dark:text-surface-100">{new Date(user.created_on).toLocaleString()}</span> <span
class="text-xs text-surface-900 dark:text-surface-100"
>{new Date(user.created_on).toLocaleString()}</span>
</div> </div>
{#if user.updated_on} {#if user.updated_on}
<div class="flex flex-col gap-1 opacity-60 border-t border-surface-500/10 pt-2"> <div
class="flex flex-col gap-1 opacity-60 border-t border-surface-500/10 pt-2">
<span>Last Updated</span> <span>Last Updated</span>
<span class="text-xs text-surface-900 dark:text-surface-100">{new Date(user.updated_on).toLocaleString()}</span> <span
class="text-xs text-surface-900 dark:text-surface-100"
>{new Date(
user.updated_on
).toLocaleString()}</span>
</div> </div>
{/if} {/if}
</div> </div>

View File

@@ -1,133 +1,133 @@
<script lang="ts"> <script lang="ts">
/** @type {import('./$types').LayoutProps} */ /** @type {import('./$types').LayoutProps} */
let log_lvl: number = $state(0); let log_lvl: number = $state(0);
// *** Import Svelte specific // *** Import Svelte specific
import { untrack } from 'svelte'; import { untrack } from 'svelte';
// import { browser } from '$app/environment'; // import { browser } from '$app/environment';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
// *** Import other supporting libraries // *** Import other supporting libraries
// import * as icons from '@lucide/svelte'; // import * as icons from '@lucide/svelte';
import { import {
Brain, Brain,
House, House,
Library, Library,
RefreshCw, RefreshCw,
Satellite, Satellite,
ArrowUp, ArrowUp,
ArrowDown ArrowDown
} from '@lucide/svelte'; } from '@lucide/svelte';
// *** Import Aether specific variables and functions // *** Import Aether specific variables and functions
import type { key_val } from '$lib/stores/ae_stores'; import type { key_val } from '$lib/stores/ae_stores';
import { ae_loc, ae_sess, ae_api, slct } from '$lib/stores/ae_stores'; import { ae_loc, ae_sess, ae_api, slct } from '$lib/stores/ae_stores';
import Element_data_store from '$lib/elements/element_data_store.svelte'; import Element_data_store from '$lib/elements/element_data_store.svelte';
import { import {
events_loc, events_loc,
events_sess, events_sess,
events_slct, events_slct,
events_trigger, events_trigger,
events_trig_kv events_trig_kv
} from '$lib/stores/ae_events_stores'; } from '$lib/stores/ae_events_stores';
interface Props { interface Props {
/** @type {import('./$types').LayoutData} */ /** @type {import('./$types').LayoutData} */
data: any; data: any;
children?: import('svelte').Snippet; children?: import('svelte').Snippet;
} }
let { data, children }: Props = $props(); let { data, children }: Props = $props();
// Use effects for store initializations to prevent render-phase updates // Use effects for store initializations to prevent render-phase updates
$effect(() => { $effect(() => {
untrack(() => {
$events_loc.qry__enabled = 'enabled';
$events_loc.qry__hidden = 'not_hidden';
$events_loc.qry__limit = 15;
$events_loc.qry__offset = 0;
});
});
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
let ae_acct = $derived(data[data.account_id]);
$effect(() => {
if (ae_acct) {
untrack(() => { untrack(() => {
$events_loc.qry__enabled = 'enabled'; $events_slct.event_id = ae_acct.slct.event_id;
$events_loc.qry__hidden = 'not_hidden'; $events_slct.event_obj_li = ae_acct.slct.event_obj_li;
$events_loc.qry__limit = 15;
$events_loc.qry__offset = 0;
}); });
});
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
let ae_acct = $derived(data[data.account_id]);
$effect(() => {
if (ae_acct) {
untrack(() => {
$events_slct.event_id = ae_acct.slct.event_id;
$events_slct.event_obj_li = ae_acct.slct.event_obj_li;
});
}
});
let ae_promises: key_val = {};
let nav_y_height = $state(0);
let box: any;
let xLeft = $state(0);
let xScroll = $state(0);
let xWidth = $state(0);
let yTop = $state(0);
let yScroll = $state(0);
let yHeight = $state(0);
let scroll_x = $state(0);
let scroll_y = $state(0);
function parse_scroll() {
// console.log(`parse_scroll() called`);
xLeft = box.scrollLeft;
xScroll = box.scrollWidth;
xWidth = box.clientWidth;
yTop = box.scrollTop;
yHeight = box.clientHeight;
yScroll = box.scrollHeight;
// console.log(`parse_scroll() called: ${yTop}`);
} }
});
function scroll_container() { let ae_promises: key_val = {};
return (
document.getElementById('ae_main_content') ||
document.documentElement ||
document.body
);
}
function clear_idb() { let nav_y_height = $state(0);
indexedDB.deleteDatabase('ae_archives_db'); // Archives module
indexedDB.deleteDatabase('ae_core_db');
indexedDB.deleteDatabase('ae_events_db'); // Events module
indexedDB.deleteDatabase('ae_journals_db'); // Journals module
indexedDB.deleteDatabase('ae_posts_db'); // Posts module
indexedDB.deleteDatabase('ae_sponsorships_db'); // Sponsorships module
}
function clear_local() { let box: any;
// localStorage.removeItem('ae_loc'); let xLeft = $state(0);
// localStorage.removeItem('ae_idaa_loc'); let xScroll = $state(0);
// localStorage.removeItem('ae_journals_loc'); let xWidth = $state(0);
// localStorage.removeItem('ae_events_loc'); let yTop = $state(0);
let yScroll = $state(0);
let yHeight = $state(0);
$ae_loc.allow_access = false; let scroll_x = $state(0);
$ae_loc.authenticated_access = false; let scroll_y = $state(0);
$ae_loc.edit_mode = false;
// $ae_loc.ver = ''; function parse_scroll() {
// console.log(`parse_scroll() called`);
xLeft = box.scrollLeft;
xScroll = box.scrollWidth;
xWidth = box.clientWidth;
yTop = box.scrollTop;
yHeight = box.clientHeight;
yScroll = box.scrollHeight;
// console.log(`parse_scroll() called: ${yTop}`);
}
localStorage.clear(); function scroll_container() {
// window.localStorage.clear(); return (
} document.getElementById('ae_main_content') ||
document.documentElement ||
document.body
);
}
function clear_sess() { function clear_idb() {
// sessionStorage.removeItem('ae_sess'); indexedDB.deleteDatabase('ae_archives_db'); // Archives module
// sessionStorage.removeItem('ae_idaa_sess'); indexedDB.deleteDatabase('ae_core_db');
// sessionStorage.removeItem('ae_journals_sess'); indexedDB.deleteDatabase('ae_events_db'); // Events module
// sessionStorage.removeItem('ae_events_sess'); indexedDB.deleteDatabase('ae_journals_db'); // Journals module
indexedDB.deleteDatabase('ae_posts_db'); // Posts module
indexedDB.deleteDatabase('ae_sponsorships_db'); // Sponsorships module
}
sessionStorage.clear(); function clear_local() {
} // localStorage.removeItem('ae_loc');
// localStorage.removeItem('ae_idaa_loc');
// localStorage.removeItem('ae_journals_loc');
// localStorage.removeItem('ae_events_loc');
$ae_loc.allow_access = false;
$ae_loc.authenticated_access = false;
$ae_loc.edit_mode = false;
// $ae_loc.ver = '';
localStorage.clear();
// window.localStorage.clear();
}
function clear_sess() {
// sessionStorage.removeItem('ae_sess');
// sessionStorage.removeItem('ae_idaa_sess');
// sessionStorage.removeItem('ae_journals_sess');
// sessionStorage.removeItem('ae_events_sess');
sessionStorage.clear();
}
</script> </script>
<svelte:head> <svelte:head>
@@ -137,15 +137,15 @@
</svelte:head> </svelte:head>
{#if $events_loc?.ver && $events_loc?.ver !== $events_sess?.ver} {#if $events_loc?.ver && $events_loc?.ver !== $events_sess?.ver}
<div class="fixed inset-0 bg-pink-100/80 z-40"> <div class="fixed inset-0 z-40 bg-pink-100/80">
<button <button
type="button" type="button"
class=" class="
fixed top-16 left-0 right-0 z-50 p-4 m-8 sm:mx-16 md:mx-32 btn btn-lg preset-tonal-warning hover:preset-filled-success-200-800 border-warning-300 dark:border-warning-700 fixed top-16 right-0
btn btn-lg rounded-2xl left-0 z-50 m-8
preset-tonal-warning hover:preset-filled-success-200-800 rounded-2xl border-4
border-4 border-warning-300 dark:border-warning-700 p-4 transition-all sm:mx-16
transition-all md:mx-32
" "
onclick={async () => { onclick={async () => {
// Clear the IndexedDB // Clear the IndexedDB
@@ -171,17 +171,22 @@
location.reload(); location.reload();
}} }}
title="A new version of One Sky IT's Aether Events module is available. Click to reload the page and use the latest version." title="A new version of One Sky IT's Aether Events module is available. Click to reload the page and use the latest version.">
> <RefreshCw
<RefreshCw size="1em" class="animate-spin shrink-0" aria-hidden="true" /> size="1em"
<span class="m-4 sm:mx-8 text-wrap"> class="shrink-0 animate-spin"
aria-hidden="true" />
<span class="m-4 text-wrap sm:mx-8">
New Events Module Version Available!<br /> New Events Module Version Available!<br />
Click to Reload<br /> Click to Reload<br />
<div class="italic text-base"> <div class="text-base italic">
You may need to sign in again. You may need to sign in again.
</div> </div>
</span> </span>
<RefreshCw size="1em" class="animate-spin shrink-0" aria-hidden="true" /> <RefreshCw
size="1em"
class="shrink-0 animate-spin"
aria-hidden="true" />
<!-- <span class="text-xs"> <!-- <span class="text-xs">
$events_loc.ver=${$events_loc?.ver}<br> $events_loc.ver=${$events_loc?.ver}<br>
@@ -202,59 +207,54 @@
class:iframe={$ae_loc?.iframe} class:iframe={$ae_loc?.iframe}
class=" class="
ae_events ae_events
min-h-full h-full min-w-full w-full max-w-7xl container m-auto flex h-full min-h-full
overflow-auto container w-full max-w-7xl
flex flex-col gap-1 min-w-full flex-col gap-1
m-auto overflow-auto
bg-gray-50 dark:bg-gray-900 bg-gray-50 text-gray-800
text-gray-800 dark:text-gray-200 dark:bg-gray-900 dark:text-gray-200
" ">
>
{#if !$ae_sess?.disable_sys_nav && !$ae_loc?.iframe} {#if !$ae_sess?.disable_sys_nav && !$ae_loc?.iframe}
<nav <nav
bind:clientHeight={nav_y_height} bind:clientHeight={nav_y_height}
class:hidden={yTop > 600} class:hidden={yTop > 600}
class:opacity-0={yTop > 250} class:opacity-0={yTop > 250}
class=" class="
submenu submenu
print:hidden absolute
z-20 top-0
hover:opacity-100 right-0
absolute top-0 left-0 right-0 left-0 z-20 m-auto flex
w-full max-w-7xl min-h-12 w-full
min-h-12 md:min-h-20 max-w-7xl flex-col
p-1 px-2 pb-2 m-auto items-center justify-between gap-1 rounded-b-lg
flex flex-col sm:flex-row sm:flex-wrap border-b-2 bg-gray-200 p-1 px-2
items-center justify-between pb-2 transition-all
gap-1 duration-1000
border-b-2 rounded-b-lg hover:opacity-100 sm:flex-row
bg-gray-200 dark:bg-gray-800 sm:flex-wrap md:min-h-20
transition-all duration-1000 dark:bg-gray-800 print:hidden
" ">
>
<span class="justify-self-start"> <span class="justify-self-start">
<!-- Be sure to explain what &AElig; (Aether) means in the title text or similar! --> <!-- Be sure to explain what &AElig; (Aether) means in the title text or similar! -->
<Satellite <Satellite
size="1.5em" size="1.5em"
class="mx-1 inline-block text-gray-500" class="mx-1 inline-block text-gray-500" />
/>
<abbr title="Aether - Events Module"> Æ Events </abbr> <abbr title="Aether - Events Module"> Æ Events </abbr>
</span> </span>
{#if !$ae_sess?.disable_sys_header} {#if !$ae_sess?.disable_sys_header}
<Element_data_store <Element_data_store
ds_code="hub__site__appshell_header" ds_code="hub__site__appshell_header"
ds_type="html" ds_type="html" />
/>
{/if} {/if}
<a <a
href="/" href="/"
class="btn btn-sm preset-tonal-surface border border-surface-500 hover:preset-filled-success-500" class="btn btn-sm preset-tonal-surface border-surface-500 hover:preset-filled-success-500 border">
>
<House /> <House />
<span class="hidden md:inline"> Home </span> <span class="hidden md:inline"> Home </span>
</a> </a>
@@ -264,20 +264,27 @@
<section <section
class:iframe={$ae_loc?.iframe} class:iframe={$ae_loc?.iframe}
class:pt-0={!!$ae_sess?.disable_sys_nav || $ae_loc?.iframe} class:pt-0={!!$ae_sess?.disable_sys_nav || $ae_loc?.iframe}
class:pt-12={!$ae_sess?.disable_sys_nav && nav_y_height > 0 && nav_y_height <= 50} class:pt-12={!$ae_sess?.disable_sys_nav &&
class:pt-20={!$ae_sess?.disable_sys_nav && nav_y_height > 50 && nav_y_height <= 100} nav_y_height > 0 &&
class:pt-32={!$ae_sess?.disable_sys_nav && nav_y_height > 100 && nav_y_height <= 150} nav_y_height <= 50}
class:pt-40={!$ae_sess?.disable_sys_nav && nav_y_height > 150 && nav_y_height <= 200} class:pt-20={!$ae_sess?.disable_sys_nav &&
nav_y_height > 50 &&
nav_y_height <= 100}
class:pt-32={!$ae_sess?.disable_sys_nav &&
nav_y_height > 100 &&
nav_y_height <= 150}
class:pt-40={!$ae_sess?.disable_sys_nav &&
nav_y_height > 150 &&
nav_y_height <= 200}
class=" class="
main_content main_content
grow flex
px-1 md:px-2 lg:px-4 grow flex-col items-center
pb-[25vh]
flex flex-col gap-1
items-center
justify-start justify-start
" gap-1 px-1 pb-[25vh]
> md:px-2
lg:px-4
">
<!-- Page Route Content --> <!-- Page Route Content -->
{@render children?.()} {@render children?.()}
</section> </section>
@@ -285,14 +292,13 @@
<div <div
class:hidden={yTop < 500} class:hidden={yTop < 500}
class=" class="
print:hidden fixed
z-20 right-1
hover:opacity-100 bottom-40
fixed bottom-40 right-1 z-20 flex flex-col
flex flex-col gap-1 items-end justify-end items-end justify-end gap-1 hover:opacity-100 print:hidden
" ">
>
<!-- Scroll to top button --> <!-- Scroll to top button -->
<button <button
type="button" type="button"
@@ -317,8 +323,7 @@
window.parent.postMessage({ scroll_to: 0 }, '*'); // This should be window.parent.postMessage({ scroll_to: 0 }, '*'); // This should be
}} }}
title="Scroll to top" title="Scroll to top">
>
<ArrowUp size="1em" aria-hidden="true" /> <ArrowUp size="1em" aria-hidden="true" />
Scroll to Top Scroll to Top
</button> </button>
@@ -346,8 +351,7 @@
window.parent.postMessage({ scroll_to: scroll_y }, '*'); window.parent.postMessage({ scroll_to: scroll_y }, '*');
}} }}
title="Scroll to bottom" title="Scroll to bottom">
>
<ArrowDown size="1em" aria-hidden="true" /> <ArrowDown size="1em" aria-hidden="true" />
Scroll to Bottom Scroll to Bottom
<!-- yTop={yTop} yScroll={yScroll} yHeight={yHeight} scroll_y={scroll_y} scrollTop={scroll_container().scrollTop} total={scroll_container().scrollTop + yHeight} --> <!-- yTop={yTop} yScroll={yScroll} yHeight={yHeight} scroll_y={scroll_y} scrollTop={scroll_container().scrollTop} total={scroll_container().scrollTop + yHeight} -->
@@ -360,32 +364,30 @@
class:opacity-80={yTop < 250} class:opacity-80={yTop < 250}
class:opacity-0={yTop > 250} class:opacity-0={yTop > 250}
class=" class="
footer print:hidden z-20 footer absolute right-0
hover:opacity-100 bottom-0
absolute bottom-0 left-0 right-0 left-0 z-20 m-auto flex
w-full max-w-7xl w-full max-w-7xl
p-1 m-auto flex-row flex-wrap
flex flex-row flex-wrap items-center justify-between gap-1
items-center justify-between rounded-t-lg border-t-2
sm:flex-row md:items-center md:justify-between border-gray-200 bg-gray-200 p-1
gap-1 text-xs
border-t-2 border-gray-200 dark:border-gray-600 transition-all duration-1000 hover:text-base
rounded-t-lg hover:opacity-100
bg-gray-200 dark:bg-gray-800 sm:flex-row md:items-center
text-xs hover:text-base md:justify-between dark:border-gray-600
transition-all duration-1000 dark:bg-gray-800 print:hidden
" "
class:ae_debug={$ae_loc.debug} class:ae_debug={$ae_loc.debug}>
>
<Element_data_store <Element_data_store
ds_code="hub__site__appshell_footer" ds_code="hub__site__appshell_footer"
ds_type="html" ds_type="html"
class_li="grow flex flex-row justify-between" class_li="grow flex flex-row justify-between" />
/>
</footer> </footer>
{/if} {/if}
</div> </div>