Migrate Event Badges to V3 and implement Core Management pages
- Completed V3 migration for Event Badge CRUD operations - Implemented User module V3 logic and editable fields - Created management routes for Accounts, Sites, Users, and Lookups - Updated Site Domain logic to use 'fqdn' and show 'access_key' - Modernized Core Dashboard with navigation cards - Restored Dexie User table definition
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
// import { liveQuery } from "dexie";
|
||||
import { core_func } from '$lib/ae_core/ae_core_functions';
|
||||
import { Building, Globe, Users, ShieldCheck, List, Plus } from 'lucide-svelte';
|
||||
// import { db_core } from "$lib/db_core";
|
||||
// import { db_events } from "$lib/db_events";
|
||||
import {
|
||||
@@ -45,128 +46,127 @@
|
||||
// let search_submit_results: Promise<any>|key_val;
|
||||
</script>
|
||||
|
||||
<section class="ae_core md:container mx-auto">
|
||||
<h2 class="h3">Æ Core for {$ae_loc.account_name ?? 'Æ loading...'}</h2>
|
||||
<section class="ae_core md:container mx-auto p-4 space-y-6">
|
||||
<header class="flex justify-between items-center border-b border-surface-500/30 pb-4">
|
||||
<h2 class="h2">Æ Core Management</h2>
|
||||
<div class="text-right">
|
||||
<p class="text-sm opacity-60">Active Account</p>
|
||||
<p class="font-bold">{$ae_loc.account_name ?? 'Loading...'}</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
console.log('Edit the POC person for the session.');
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
<!-- Account Management Card -->
|
||||
<div class="card p-4 space-y-4 variant-soft-primary">
|
||||
<div class="flex items-center gap-2">
|
||||
<Building size={20} />
|
||||
<h3 class="h4">Accounts</h3>
|
||||
</div>
|
||||
<p class="text-sm opacity-80 text-balance">Manage client accounts and high-level system settings.</p>
|
||||
<button class="btn variant-filled-primary w-full" onclick={() => goto('/core/accounts')}>
|
||||
Manage Accounts
|
||||
</button>
|
||||
</div>
|
||||
|
||||
// let params = {
|
||||
// qry__limit: $ae_loc.person.qry_limit__people,
|
||||
// }
|
||||
<!-- Site Management Card -->
|
||||
<div class="card p-4 space-y-4 variant-soft-secondary">
|
||||
<div class="flex items-center gap-2">
|
||||
<Globe size={20} />
|
||||
<h3 class="h4">Sites</h3>
|
||||
</div>
|
||||
<p class="text-sm opacity-80 text-balance">Configure sites and domains associated with the active account.</p>
|
||||
<button class="btn variant-filled-secondary w-full" onclick={() => goto('/core/sites')}>
|
||||
Manage Sites
|
||||
</button>
|
||||
</div>
|
||||
|
||||
// $slct.person_obj_li = await core_func.load_ae_obj_li__person({api_cfg: $ae_api, account_id: $slct.account_id, params: params});
|
||||
<!-- User Management Card -->
|
||||
<div class="card p-4 space-y-4 variant-soft-error">
|
||||
<div class="flex items-center gap-2">
|
||||
<ShieldCheck size={20} />
|
||||
<h3 class="h4">Users</h3>
|
||||
</div>
|
||||
<p class="text-sm opacity-80 text-balance">Manage system access, permissions, and user credentials.</p>
|
||||
<button class="btn variant-filled-error w-full" onclick={() => goto('/core/users')}>
|
||||
Manage Users
|
||||
</button>
|
||||
</div>
|
||||
|
||||
let person_results = core_func
|
||||
.load_ae_obj_li__person({
|
||||
api_cfg: $ae_api,
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: $slct.account_id,
|
||||
limit: $ae_loc.person.qry_limit__people,
|
||||
// params: params,
|
||||
log_lvl: 1
|
||||
})
|
||||
.then(function (load_results) {
|
||||
console.log(`Loaded person_obj_li:`, load_results);
|
||||
|
||||
// We need to make this ready for the select option list. Convert the list to a key value pair with the person_id_random as the key. We also need to set the option text value to: full_name (primary_email)
|
||||
if (load_results) {
|
||||
$slct.person_id_random_li = load_results;
|
||||
|
||||
person_id_random_li = [];
|
||||
|
||||
let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
|
||||
|
||||
for (let i = 0; i < $slct.person_id_random_li.length; i++) {
|
||||
let person_obj = $slct.person_id_random_li[i];
|
||||
let person_id_random = person_obj.person_id_random;
|
||||
tmp_li.push(person_id_random);
|
||||
<!-- Person Management Card -->
|
||||
<div class="card p-4 space-y-4 variant-soft-warning">
|
||||
<div class="flex items-center gap-2">
|
||||
<Users size={20} />
|
||||
<h3 class="h4">People</h3>
|
||||
</div>
|
||||
<p class="text-sm opacity-80 text-balance">View and manage person records and their associated user accounts.</p>
|
||||
<div class="flex gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
let person_results = core_func
|
||||
.load_ae_obj_li__person({
|
||||
api_cfg: $ae_api,
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: $slct.account_id,
|
||||
limit: $ae_loc.person.qry_limit__people,
|
||||
log_lvl: 1
|
||||
})
|
||||
.then(function (load_results) {
|
||||
if (load_results) {
|
||||
$slct.person_id_random_li = load_results;
|
||||
person_id_random_li = load_results.map((p: any) => p.person_id_random);
|
||||
}
|
||||
return load_results;
|
||||
})
|
||||
.finally(() => {
|
||||
$ae_sess.person.show_report__person_li = true;
|
||||
});
|
||||
}}
|
||||
class="btn variant-filled-warning flex-1"
|
||||
>
|
||||
List People
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onclick={async () => {
|
||||
if (!confirm(`Add a new person to ${$ae_loc.account_name}?`)) return;
|
||||
let person_data = {
|
||||
account_id_random: $slct.account_id,
|
||||
source_code: 'manual:SK-core',
|
||||
given_name: 'New',
|
||||
family_name: 'Person',
|
||||
enable: true
|
||||
};
|
||||
let new_person_obj = await core_func.create_ae_obj__person({
|
||||
api_cfg: $ae_api,
|
||||
data_kv: person_data,
|
||||
log_lvl: 1
|
||||
});
|
||||
if (new_person_obj && confirm(`Person created. View details?`)) {
|
||||
goto(`/core/person/${new_person_obj.person_id_random}`);
|
||||
}
|
||||
person_id_random_li = tmp_li;
|
||||
}}
|
||||
class="btn variant-filled-warning btn-icon"
|
||||
class:hidden={!$ae_loc.edit_mode}
|
||||
>
|
||||
<Plus size={16} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
// $slct.person_id_random_li = load_results.map((person_obj) => person_obj.person_id_random);
|
||||
// let person_obj_li = load_results;
|
||||
// let person_obj_kv = {};
|
||||
// person_obj_kv[''] = '-- Select a person --';
|
||||
// person_obj_li.forEach((person_obj) => {
|
||||
// let option_text = `${person_obj.full_name} (${person_obj.primary_email})`;
|
||||
// person_obj_kv[person_obj.person_id_random] = option_text;
|
||||
// });
|
||||
// $slct.person_obj_kv = person_obj_kv;
|
||||
}
|
||||
// $slct.person_obj_kv = $slct.person_obj_kv;
|
||||
// console.log(`$slct.person_obj_kv = `, $slct.person_obj_kv);
|
||||
<!-- Lookups Card -->
|
||||
<div class="card p-4 space-y-4 variant-soft-surface">
|
||||
<div class="flex items-center gap-2">
|
||||
<List size={20} />
|
||||
<h3 class="h4">Lookups</h3>
|
||||
</div>
|
||||
<p class="text-sm opacity-80 text-balance">View system lookup tables (countries, time zones, etc).</p>
|
||||
<button class="btn variant-filled-surface w-full" onclick={() => goto('/core/lookups')}>
|
||||
View Lookups
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
return load_results;
|
||||
})
|
||||
.finally(() => {
|
||||
console.log(`person_id_random_li:`, person_id_random_li);
|
||||
$ae_sess.person.show_report__person_li = true;
|
||||
});
|
||||
}}
|
||||
class="btn btn-sm preset-tonal-warning hover:preset-tonal-warning border border-warning-500"
|
||||
>
|
||||
<span class="fas fa-user mx-1"></span>
|
||||
List People
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick={async () => {
|
||||
console.log('Add Person');
|
||||
if (
|
||||
!confirm(
|
||||
`Add a new person to the account?\n${$ae_loc.account_name}\nID: ${$slct.account_id}`
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
let person_data = {
|
||||
account_id_random: $slct.account_id,
|
||||
// user_id_random: user_obj.user_id_random,
|
||||
source_code: 'manual:SK-core',
|
||||
given_name: 'New',
|
||||
family_name: 'Person',
|
||||
// professional_title: 'Temp Prof Title',
|
||||
// affiliations: 'Temp Org',
|
||||
// primary_email: 'tmp+person@oneskyit.com',
|
||||
// allow_auth_key: false,
|
||||
auth_key: Math.floor(Math.random() * 90000000) + 10000000,
|
||||
// Random number between 100000 and 999999
|
||||
passcode: Math.floor(Math.random() * 900000) + 100000,
|
||||
enable: true
|
||||
};
|
||||
|
||||
let new_person_obj = await core_func.create_ae_obj__person({
|
||||
api_cfg: $ae_api,
|
||||
// user_id: $ae_loc.user_id,
|
||||
data_kv: person_data,
|
||||
log_lvl: 1
|
||||
});
|
||||
|
||||
console.log('new_person_obj:', new_person_obj);
|
||||
|
||||
if (
|
||||
confirm(
|
||||
`Person created:\n${new_person_obj.full_name} (${new_person_obj.primary_email ?? 'no email'})\nID: ${new_person_obj.person_id_random}\n\nView this person?`
|
||||
)
|
||||
) {
|
||||
// window.location.reload();
|
||||
// invalidateAll();
|
||||
goto(`/core/person/${new_person_obj.person_id_random}`, { replaceState: true });
|
||||
// pushState(`/core/person/${new_person_obj.person_id_random}`, { replace: true });
|
||||
// replaceState(`/core/person/${new_person_obj.person_id_random}`);
|
||||
}
|
||||
}}
|
||||
class:hidden={!$ae_loc.edit_mode}
|
||||
class="btn btn-sm preset-tonal-warning hover:preset-filled-warning-500"
|
||||
>
|
||||
<span class="fas fa-plus mx-1"></span>
|
||||
Add Person
|
||||
</button>
|
||||
|
||||
<!-- Show people for this account -->
|
||||
{#if $ae_sess.person.show_report__person_li && person_id_random_li?.length > 0}
|
||||
|
||||
Reference in New Issue
Block a user