domma-cms 1.60.0 → 1.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/admin/index.html +7 -1
- package/admin/js/app.js +2 -2
- package/admin/js/lib/ai-assist.js +1 -1
- package/admin/js/templates/ai-assist-builders.html +29 -0
- package/admin/js/templates/docs/usage-chat.html +5 -2
- package/admin/js/views/ai-assist-builders.js +1 -0
- package/admin/js/views/ai-assist-settings.js +1 -1
- package/admin/js/views/index.js +1 -1
- package/admin/js/views/login.js +1 -1
- package/docs/DommaFeatures.md +1 -1
- package/docs/plugin-development.md +26 -0
- package/package.json +1 -1
- package/server/routes/api/admin-assistant.js +11 -3
- package/server/routes/api/auth.js +4 -1
- package/server/routes/api/theme.js +2 -6
- package/server/server.js +2 -1
- package/server/services/aiAssist.js +67 -0
- package/server/services/chat/ai.js +1 -1
- package/server/services/hooks.js +1 -1
- package/server/services/plugins.js +9 -1
- package/server/services/themeSettings.js +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.61.0] - 2026-11-11
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- **AI chat answers see up to 48,000 characters of Knowledge** (was 16,000), so a full Knowledge base of around 80 entries reaches AI Assist instead of only the most used third. Needs the matching Manager change; until then the Manager trims at 24,000.
|
|
8
|
+
- **AI Assist lives under Data.** Its side-menu entry now starts in the Data folder (it was Tools > Communication); a place an admin chose for it still wins.
|
|
9
|
+
- **Builders in AI Assist.** A new **Builders** tab lists the AI chats of the site's builders - the Site Builder's conversations and the Tool Builder's builds - with who started each and when; click one to carry on in its builder. Each person sees only the builders, and the chats, they could open in the builder itself. Builders opt in with plugin.json `admin.aiAssist` (see docs/plugin-development.md, "AI Assist: listing your AI chats"); only the plugin's own screen and API are accepted.
|
|
10
|
+
- The admin opens light while it loads, instead of dark until the site's admin theme is applied. Domma's own start-up theme (Charcoal Dark, or a theme remembered from the public site) no longer overrides it.
|
|
11
|
+
- Sign-in and password-reset screens honour the saved admin theme, including custom theme colours, fonts and matching logo variants, instead of forcing Charcoal Dark. Only the selected theme presentation is exposed before sign-in.
|
|
12
|
+
- When the saved theme cannot be read (an older site or a failed request), the sign-in screen falls back to Charcoal Light, matching the admin's light start while it loads.
|
|
13
|
+
|
|
3
14
|
## [1.60.0] - 2026-11-11
|
|
4
15
|
|
|
5
16
|
- **AI Assist owns every chat.** On a site with AI Assist (Pro), chats are answered in its own screen, **AI Assist** (Tools > Communication), with **Chats**, **Knowledge** and **Settings** tabs; it takes the Chats entry's place in the side menu. **Settings** holds what AI answers know and the rules they keep (About the business, Rules) and the admin assistant, which move there from Site Settings. Launchers stay launchers. A site without AI Assist keeps Content > Chats exactly as before; links to either lead to whichever the site has, and chat notifications link there too.
|
package/admin/index.html
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<link rel="stylesheet" href="/admin/css/calculator.css">
|
|
32
32
|
<link rel="stylesheet" href="/admin/css/admin-assistant.css?v=20261110-admin-assistant">
|
|
33
33
|
</head>
|
|
34
|
-
<body class="dm-cloaked dm-theme-charcoal-
|
|
34
|
+
<body class="dm-cloaked dm-theme-charcoal-light dashboard-layout">
|
|
35
35
|
|
|
36
36
|
<!-- Top Bar -->
|
|
37
37
|
<header id="admin-topbar">
|
|
@@ -64,6 +64,12 @@
|
|
|
64
64
|
</main>
|
|
65
65
|
</div>
|
|
66
66
|
|
|
67
|
+
<!-- Domma (and the copy inside domma-tools) would otherwise apply its default
|
|
68
|
+
theme, Charcoal Dark, or a remembered public-site choice on DOMContentLoaded.
|
|
69
|
+
The body's own class (light) stays until the saved admin theme is applied
|
|
70
|
+
(lib/admin-theme.js, views/login.js). -->
|
|
71
|
+
<script>window.DommaOptions = Object.assign({}, window.DommaOptions, {theme: false});</script>
|
|
72
|
+
|
|
67
73
|
<!-- DOMPurify - must load before DommaJS -->
|
|
68
74
|
<script src="/public/js/vendor/dompurify/purify.min.js?v=3.4.17"></script>
|
|
69
75
|
|
package/admin/js/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{wireNotificationMenu as ct}from"./lib/topbar-notifications.js";import{installSmoothCarets as pt}from"./lib/smooth-caret.js";import{viewLoaders as mt}from"./views/index.js";import{createLazyViews as dt}from"./lib/lazy-views.js";import{withPluginChrome as J}from"./lib/plugin-chrome.js";import{api as r,getUser as W,isAuthenticated as m,logout as ut,sendToLogin as ht}from"./api.js";import{claimDrafts as wt}from"./lib/draft-owner.js";import{isAuthScreen as P,loginHashFor as gt}from"./lib/login-arrange.js";import{installHttpInterceptor as ft}from"./http-interceptor.js";import{installResizableSlideovers as vt}from"./lib/slideover-resizable.js";import{installActivityThrobber as bt}from"./lib/activity-throbber.js";import{installUpdateNotice as Ct,renderCmsVersion as St}from"./lib/update-notice.js";import{renderFrameworkVersions as Y,wireAccountMenu as Mt}from"./lib/topbar-account.js";import{refreshTopbarProject as H}from"./lib/topbar-project.js";import{CONFINED_CLASS as yt,isConfined as Dt,isPathAllowed as N,redirectFor as At}from"./lib/admin-scope.js";import{deliverDesktop as Et,desktopActive as Q,notificationSettings as X}from"./lib/desktop-notify.js";import{chatToastsOpen as Pt,closeChatToasts as Nt,deliverChatToasts as kt,settleChatToasts as jt}from"./lib/chat-toast.js";import{aiAssistReroute as Rt,launcherChatsFor as It}from"./lib/ai-assist.js";import{onPresence as Tt,setAvailable as Z,startPresence as Lt,stopPresence as tt}from"./lib/chat-presence.js";import{avatarUrl as Ut,installAccountAvatar as $t}from"./lib/avatar.js";import{installCalculator as xt}from"./lib/calculator.js";import{installAdminAssistant as Bt}from"./lib/admin-assistant.js";import{installAdminLaunchers as Ft}from"./lib/admin-launchers.js";import{takeOverviewPass as Ot,withDashboardStrip as et}from"./lib/dashboards-strip.js";import{installHotkeys as Vt}from"./lib/hotkeys-ui.js";import{applyAdminBrand as at}from"./lib/admin-brand.js";import{installRouterCatchUp as _t}from"./lib/router-catch-up.js";import{installSidebarDrawer as Kt}from"./lib/sidebar-drawer.js";$(()=>{pt(document),ft(),xt(),Bt(),Ft(),Ct(),bt(),vt(),Kt(),(async()=>{const{applyAdminTheme:t,refreshAdminTheme:o}=await import("./lib/admin-theme.js");m()?await o(r,{init:!0}):t({dommaTheme:"charcoal-dark"},{init:!0})})();let l=null,f=null,p="/",v=!1,w=null,d=null,u=!0,b=!1,C=null;function k(t){if(T[t])return E.toast(`${T[t]} is switched off on this site.`,{type:"info"}),"/";const[o,e]=t.split("?"),a=new URLSearchParams(e||"").get("tab");if(o==="/settings"&&["favicon","pageNavigation","breadcrumbs","motion","search"].includes(a))return`/appearance?tab=${a}`;if(t.split("?")[0]==="/my-dashboard")return"/dashboards";const i=Rt(t,C);if(i&&N(l,i.split("?")[0]))return i;const s=It(t);if(s&&!N(l,o)&&N(l,s.split("?")[0]))return s;const n=I[t]||At(l,t);return n||(!u&&o==="/system/notifications"?l?.home||"/":(t.split("?")[0]||"/")==="/"&&p&&p!=="/"&&!Ot()?I[p]||p:null)}function j(){document.body.classList.toggle(yt,Dt(l))}const I={},T={};R.use(async(t,o,e)=>{if(P(t.path))return e();if(!m()){ht();return}const a=k(t.path);if(a){R.navigate(a);return}e()});async function y(){try{const t=await r.get("/auth/permissions");l=t.adminScope||null,j(),f=t.adminBrand||null,at(f),p=t.adminHome||"/",Y(t.versions||{});const o=t.permissions||[];return v=N(l,"/settings")&&o.some(e=>e==="settings"||e.startsWith("settings.")),w=o.some(e=>e==="notifications"||e.startsWith("notifications.")),d=t.adminPortal||null,u=t.notificationsScreen!==!1,b=o.includes("chats")||o.includes("chats.reply"),o}catch{return l=null,j(),p="/",f||at(null),v=!1,w=null,d=null,u=!0,b=!1,[]}}document.addEventListener("dm:admin-home-changed",()=>{y()});let L=null,U=!1;document.addEventListener("dm:sidebar-rebuild",()=>{if(H(r),L){U=!0;return}L=(async()=>{do{U=!1;try{await x(await y())}catch{}}while(U)})().finally(()=>{L=null})});async function x(t){const{applyAdminPortal:o}=await import("./lib/admin-portal.js");if(await o(d),d)return;const{renderAdminSidebar:e}=await import("./lib/sidebar-renderer.js");await e({mount:"#admin-sidebar",permissions:t,adminScope:l,brand:f,notificationsScreen:u})}M.subscribe("router:afterChange",({to:t})=>{P(t.path)&&(g&&(clearInterval(g),g=null),l=null,j(),p="/",v=!1,w=null,u=!0,b=!1,d&&(d=null,import("./lib/admin-portal.js").then(o=>o.applyAdminPortal(null))))});const it=[{path:"/",view:"dashboard",title:"Dashboard - Domma CMS"},{path:"/dashboards",view:"dashboards",title:"Dashboards - Domma CMS"},{path:"/my-dashboard",view:"dashboards",title:"Dashboards - Domma CMS"},{path:"/pages",view:"pages",title:"Pages - Domma CMS"},{path:"/pages/new",view:"pageEditor",title:"New Page - Domma CMS"},{path:"/pages/edit/*",view:"pageEditor",title:"Edit Page - Domma CMS"},{path:"/media",view:"media",title:"Media - Domma CMS"},{path:"/menus",view:"menus",title:"Menus - Domma CMS"},{path:"/context-menus",view:"contextMenus",title:"Context Menus - Domma CMS"},{path:"/context-menus/new",view:"contextMenuEditor",title:"New Context Menu - Domma CMS"},{path:"/context-menus/edit/:slug",view:"contextMenuEditor",title:"Edit Context Menu - Domma CMS"},{path:"/launchers",view:"launchers",title:"Launchers - Domma CMS"},{path:"/menus/new",view:"menuEditor",title:"New Menu - Domma CMS"},{path:"/menus/edit/:slug",view:"menuEditor",title:"Edit Menu - Domma CMS"},{path:"/menu-locations",view:"menuLocations",title:"Menu Locations - Domma CMS"},{path:"/navigation",view:"menusRedirect",title:"Menus - Domma CMS"},{path:"/layouts",view:"layouts",title:"Layouts - Domma CMS"},{path:"/appearance",view:"appearance",title:"Appearance - Domma CMS"},{path:"/footer",view:"footer",title:"Footer - Domma CMS"},{path:"/settings",view:"settings",title:"Settings - Domma CMS"},{path:"/theme",view:"theme",title:"Theme - Domma CMS"},{path:"/users",view:"users",title:"Users - Domma CMS"},{path:"/users/new",view:"userEditor",title:"New User - Domma CMS"},{path:"/users/edit/:id",view:"userEditor",title:"Edit User - Domma CMS"},{path:"/plugins",view:"plugins",title:"Plugins - Domma CMS"},{path:"/plugins/code/:name",view:"pluginCode",title:"Plugin Code - Domma CMS"},{path:"/documentation",view:"documentation",title:"Usage - Domma CMS"},{path:"/tutorials",view:"tutorials",title:"Tutorials - Domma CMS"},{path:"/tutorials/crud",view:"tutorialCrud",title:"Building a CRUD App - Domma CMS"},{path:"/tutorials/editor",view:"tutorialEditor",title:"The Editor - Domma CMS"},{path:"/tutorials/plugin",view:"tutorialPlugin",title:"Writing a Tool - Domma CMS"},{path:"/tutorials/forms",view:"tutorialForms",title:"Form Follow-Up - Domma CMS"},{path:"/docs/components",view:"componentsReference",title:"Components Reference - Domma CMS"},{path:"/docs/components-howto",view:"componentsHowto",title:"Components How-To - Domma CMS"},{path:"/docs/components-walkthrough",view:"componentsWalkthrough",title:"Components Walkthrough - Domma CMS"},{path:"/docs/components-rules",view:"componentsRules",title:"Components Rules - Domma CMS"},{path:"/docs/usage/pages",view:"usagePages",title:"Pages - Usage - Domma CMS"},{path:"/docs/usage/media",view:"usageMedia",title:"Media - Usage - Domma CMS"},{path:"/docs/usage/navigation",view:"usageNavigation",title:"Navigation - Usage - Domma CMS"},{path:"/docs/usage/dconfig",view:"usageDconfig",title:"DConfig - Usage - Domma CMS"},{path:"/docs/usage/shortcodes",view:"usageShortcodes",title:"Shortcodes - Usage - Domma CMS"},{path:"/docs/usage/site-settings",view:"usageSiteSettings",title:"Site Settings - Usage - Domma CMS"},{path:"/docs/usage/plugins",view:"usagePlugins",title:"Plugins - Usage - Domma CMS"},{path:"/docs/usage/users-roles",view:"usageUsersRoles",title:"Users & Roles - Usage - Domma CMS"},{path:"/docs/usage/views",view:"usageViews",title:"Views - Usage - Domma CMS"},{path:"/docs/usage/actions",view:"usageActions",title:"Actions - Usage - Domma CMS"},{path:"/docs/usage/cta-shortcode",view:"usageCtaShortcode",title:"CTA Shortcode - Usage - Domma CMS"},{path:"/docs/usage/editions",view:"usageEditions",title:"Editions & Licences - Usage - Domma CMS"},{path:"/docs/usage/collections",view:"usageCollections",title:"Collections & Forms - Usage - Domma CMS"},{path:"/docs/usage/blocks",view:"usageBlocks",title:"Blocks - Usage - Domma CMS"},{path:"/docs/usage/tools",view:"usageTools",title:"Built-in Tools - Usage - Domma CMS"},{path:"/docs/usage/dashboard",view:"usageDashboard",title:"Dashboard - Usage - Domma CMS"},{path:"/docs/usage/search-engines",view:"usageSearchEngines",title:"Search Engines & AI - Usage - Domma CMS"},{path:"/docs/usage/launchers",view:"usageLaunchers",title:"Launchers - Usage - Domma CMS"},{path:"/docs/usage/chat",view:"usageChat",title:"Chat & Knowledge - Usage - Domma CMS"},{path:"/docs/plugins",view:"pluginGuides",title:"Plugin Guides - Domma CMS"},{path:"/docs/plugins/*",view:"pluginGuide",title:"Plugin Guide - Domma CMS"},{path:"/docs/api/authentication",view:"apiRefAuthentication",title:"Authentication - API - Domma CMS"},{path:"/docs/api/pages",view:"apiRefPages",title:"Pages - API - Domma CMS"},{path:"/docs/api/settings",view:"apiRefSettings",title:"Settings - API - Domma CMS"},{path:"/docs/api/layouts",view:"apiRefLayouts",title:"Layouts - API - Domma CMS"},{path:"/docs/api/navigation",view:"apiRefNavigation",title:"Navigation - API - Domma CMS"},{path:"/docs/api/media",view:"apiRefMedia",title:"Media - API - Domma CMS"},{path:"/docs/api/users",view:"apiRefUsers",title:"Users - API - Domma CMS"},{path:"/docs/api/plugins",view:"apiRefPlugins",title:"Plugins - API - Domma CMS"},{path:"/docs/api/collections",view:"apiRefCollections",title:"Collections - API - Domma CMS"},{path:"/docs/api/views",view:"apiRefViews",title:"Views API - Domma CMS"},{path:"/docs/api/actions",view:"apiRefActions",title:"Actions API - Domma CMS"},{path:"/docs/api/forms",view:"apiRefForms",title:"Forms API - Domma CMS"},{path:"/docs/api/scaffold",view:"apiRefScaffold",title:"Scaffold API - Domma CMS"},{path:"/docs/api/external",view:"apiRefExternal",title:"External API & Tokens - Domma CMS"},{path:"/docs/api/content",view:"apiRefContent",title:"Content API - Domma CMS"},{path:"/docs/api/builder",view:"apiRefBuilder",title:"API Builder - Domma CMS"},{path:"/api-reference",view:"apiReference",title:"API Reference - Domma CMS"},{path:"/collections",view:"collections",title:"Collections - Domma CMS"},{path:"/collections/new",view:"collectionEditor",title:"New Collection - Domma CMS"},{path:"/collections/edit/:slug",view:"collectionEditor",title:"Edit Collection - Domma CMS"},{path:"/collections/:slug/entries",view:"collectionEntries",title:"Entries - Domma CMS"},{path:"/forms",view:"forms",title:"Forms - Domma CMS"},{path:"/forms/new",view:"formEditor",title:"New Form - Domma CMS"},{path:"/forms/edit/:slug",view:"formEditor",title:"Edit Form - Domma CMS"},{path:"/forms/:slug/submissions",view:"formSubmissions",title:"Submissions - Domma CMS"},{path:"/views",view:"viewsList",title:"Views - Domma CMS"},{path:"/views/new",view:"viewEditor",title:"New View - Domma CMS"},{path:"/views/edit/:slug",view:"viewEditor",title:"Edit View - Domma CMS"},{path:"/views/:slug/preview",view:"viewPreview",title:"View Preview - Domma CMS"},{path:"/actions",view:"actionsList",title:"Actions - Domma CMS"},{path:"/actions/new",view:"actionEditor",title:"New Action - Domma CMS"},{path:"/actions/edit/:slug",view:"actionEditor",title:"Edit Action - Domma CMS"},{path:"/pro/docs",view:"proDocs",title:"Pro Documentation - Domma CMS"},{path:"/blocks",view:"blocks",title:"Blocks - Domma CMS"},{path:"/blocks/new",view:"pageEditor",title:"New Block - Domma CMS"},{path:"/blocks/edit/:name",view:"pageEditor",title:"Edit Block - Domma CMS"},{path:"/components",view:"components",title:"Components - Domma CMS"},{path:"/components/new",view:"pageEditor",title:"New Component - Domma CMS"},{path:"/components/edit/:name",view:"pageEditor",title:"Edit Component - Domma CMS"},{path:"/my-profile",view:"myProfile",title:"My Profile - Domma CMS"},{path:"/roles",view:"roles",title:"Roles & Permissions - Domma CMS"},{path:"/roles/edit/:id",view:"roleEditor",title:"Edit Role - Domma CMS"},{path:"/effects",view:"effects",title:"Effects - Domma CMS"},{path:"/search",view:"search",title:"Search - Domma CMS"},{path:"/content-api",view:"contentApi",title:"Content API - Domma CMS"},{path:"/launchers/chats",view:"chats",title:"Chats - Domma CMS"},{path:"/launchers/chats/:id",view:"chats",title:"Chats - Domma CMS"},{path:"/launchers/knowledge",view:"chatKnowledge",title:"Chat Knowledge - Domma CMS"},{path:"/ai-assist",view:"aiAssistChats",title:"AI Assist - Domma CMS"},{path:"/ai-assist/chats",view:"aiAssistChats",title:"AI Assist - Domma CMS"},{path:"/ai-assist/chats/:id",view:"aiAssistChats",title:"AI Assist - Domma CMS"},{path:"/ai-assist/knowledge",view:"aiAssistKnowledge",title:"AI Assist Knowledge - Domma CMS"},{path:"/ai-assist/settings",view:"aiAssistSettings",title:"AI Assist Settings - Domma CMS"},{path:"/notes",view:"notes",title:"Notes - Domma CMS"},{path:"/todo",view:"todo",title:"Todo - Domma CMS"},{path:"/calculator",view:"calculator",title:"Calculator - Domma CMS"},{path:"/analytics",view:"analytics",title:"Analytics - Domma CMS"},{path:"/seo",view:"seo",title:"SEO - Domma CMS"},{path:"/seo/:tab",view:"seo",title:"SEO - Domma CMS"},{path:"/wordpress-import",view:"wordpressImport",title:"Import a site - Domma CMS"},{path:"/contacts",view:"contacts",title:"Contacts - Domma CMS"},{path:"/calls/new",view:"callNew",title:"Call now - Domma CMS"},{path:"/system/notifications",view:"notifications",title:"Notifications - Domma CMS"},{path:"/api-tokens",view:"apiTokens",title:"API Tokens - Domma CMS"},{path:"/api-endpoints",view:"apiEndpoints",title:"API Builder - Domma CMS"},{path:"/api-endpoints/new",view:"apiEndpointEditor",title:"New API Endpoint - Domma CMS"},{path:"/api-endpoints/edit/:id",view:"apiEndpointEditor",title:"Edit API Endpoint - Domma CMS"},{path:"/projects",view:"projects",title:"Projects - Domma CMS"},{path:"/projects/new",view:"projects",title:"New Project - Domma CMS"},{path:"/projects/edit/:slug",view:"projects",title:"Edit Project - Domma CMS"},{path:"/projects/:slug/settings",view:"projectSettings",title:"Project settings - Domma CMS"},{path:"/projects/:slug/pages",view:"pages",title:"Project pages - Domma CMS"},{path:"/projects/:slug/collections",view:"collections",title:"Project collections - Domma CMS"},{path:"/projects/:slug/forms",view:"forms",title:"Project forms - Domma CMS"},{path:"/projects/:slug/actions",view:"actionsList",title:"Project actions - Domma CMS"},{path:"/projects/:slug/menus",view:"menus",title:"Project menus - Domma CMS"},{path:"/projects/:slug/blocks",view:"blocks",title:"Project blocks - Domma CMS"},{path:"/projects/:slug/components",view:"components",title:"Project components - Domma CMS"},{path:"/projects/:slug/views",view:"viewsList",title:"Project views - Domma CMS"},{path:"/projects/:slug/roles",view:"roles",title:"Project roles - Domma CMS"},{path:"/projects/:slug/users",view:"users",title:"Project users - Domma CMS"},{path:"/projects/:slug/apis",view:"apiEndpoints",title:"Project APIs - Domma CMS"},{path:"/projects/:slug",view:"projectDetail",title:"Project - Domma CMS"},{path:"/login",view:"login",title:"Sign in - Domma CMS",onEnter:()=>{$("#admin-sidebar").hide(),$("#admin-topbar").hide(),tt(),Nt()}},{path:"/reset-password",view:"login",title:"Reset Password - Domma CMS",onEnter:()=>{$("#admin-sidebar").hide(),$("#admin-topbar").hide()}}];M.subscribe("router:afterChange",async({to:t,from:o})=>{if(!P(t.path)){if($("#admin-sidebar").show(),$("#admin-topbar").show(),P(o?.path)){$("#topbar-user-name").remove(),import("./lib/admin-theme.js").then(i=>i.refreshAdminTheme(r)),await O();const e=await y(),a=k(t.path);if(a&&R.navigate(a),x(e),X.read().signInToasts)try{const i=await r.system.notifications.list().catch(()=>[]),s=(Array.isArray(i)?i:[]).filter(n=>n.unread&&["warning","critical"].includes(n.data?.severity)).slice(0,3);for(const n of s){const c=h(n.data?.title||""),K=h((n.data?.body||"").slice(0,120));E.toast(`${c} - ${K}`,{type:n.data?.severity==="critical"?"error":"warning",duration:0})}}catch{}}G()}}),M.subscribe("router:afterChange",()=>{setTimeout(()=>{$(".btn-primary, .btn-danger").length&&Domma.effects.reveal(".btn-primary, .btn-danger",{animation:"fade",stagger:40,duration:300})},50)});const ot=["#field-project","#menu-project","#collection-project","#endpoint-project","#action-project","#view-project","#block-project","#component-project","#role-project",'[name="project"]','[name="ownedByProject"]'];function st(t){return/^\/(pages|menus|context-menus|collections|forms|actions|views|blocks|components|users|roles|api-endpoints)\/(new|edit\/)/.test(t)}M.subscribe("router:afterChange",({to:t})=>{const o=t?String(t.path).split("?")[0]:"";if(!t||!st(o))return;const a=new URLSearchParams(location.hash.split("?")[1]||"").get("project");if(!a||!/\/new$/.test(o))return;let i=0;const s=60,n=1500,c=()=>{i+=s;for(const K of ot){const A=document.querySelector(K);if(!A)continue;if(Array.from(A.options||[]).find(lt=>lt.value===a)){A.value=a,A.dispatchEvent(new Event("change",{bubbles:!0}));return}}i<n&&setTimeout(c,s)};setTimeout(c,s)});const q="cms_card_states",B=S.get(q)||{};M.subscribe("router:afterChange",()=>{setTimeout(()=>{$("#view-container .card-collapsible").each(function(){const t=$(this).find(".card-header h2, .card-header h3").first().text().trim();t&&B[t]==="collapsed"&&$(this).addClass("card-collapsed")})},200)}),$("#view-container").on("click",".card-collapsible .card-header",function(t){if($(t.target).closest("button, a").length)return;const o=$(this).closest(".card");o.toggleClass("card-collapsed");const e=$(this).find("h2, h3").first().text().trim();e&&(B[e]=o.hasClass("card-collapsed")?"collapsed":"open",S.set(q,B))}),Vt(),document.addEventListener("keydown",t=>{if(!(t.ctrlKey||t.metaKey)||t.key!=="s"||window.location.hash.startsWith("#/login")||window.location.hash.startsWith("#/reset-password"))return;const o=document.querySelector("#view-container .view-header button.btn-primary");o&&(t.preventDefault(),o.click())});const D=dt(),z=D.views,nt={notes:{displayName:"Notes",icon:"edit-3"},todo:{displayName:"Todo",icon:"check-square"},calculator:{displayName:"Calculator",icon:"calculator"},analytics:{displayName:"Analytics",icon:"chart-bar"},seo:{displayName:"SEO",icon:"search"},wordpressImport:{displayName:"Import a site",icon:"download"},contacts:{displayName:"Contacts",icon:"users"},projects:{displayName:"Projects",icon:"folder"},pages:{displayName:"Pages",icon:"file-text"},media:{displayName:"Media",icon:"image"},menus:{displayName:"Site menus",icon:"menu"},contextMenus:{displayName:"Context Menus",icon:"menu"},launchers:{displayName:"Launchers",icon:"rocket"},theme:{displayName:"Theme",icon:"droplet"},collections:{displayName:"Collections",icon:"database"},forms:{displayName:"Forms",icon:"layout"},viewsList:{displayName:"Views",icon:"eye"},actionsList:{displayName:"Actions",icon:"zap"},apiEndpoints:{displayName:"API Builder",icon:"code"},blocks:{displayName:"Blocks",icon:"box"},components:{displayName:"Components",icon:"component"},notifications:{displayName:"Notifications",icon:"bell"},roles:{displayName:"Roles",icon:"shield"},users:{displayName:"Users",icon:"users"},appearance:{displayName:"Appearance",icon:"layout"},footer:{displayName:"Footer",icon:"panel-bottom"},settings:{displayName:"Site Settings",icon:"settings"},effects:{displayName:"Effects",icon:"sparkles"},layouts:{displayName:"Layouts",icon:"layout"},plugins:{displayName:"Marketplace",icon:"store"},myProfile:{displayName:"My Profile",icon:"user"},apiTokens:{displayName:"API Tokens",icon:"key"},search:{displayName:"Search",icon:"search"},contentApi:{displayName:"Content API",icon:"file-text"},chats:{displayName:"Chats",icon:"message-circle"},dashboard:{displayName:"Dashboard",icon:"home"},dashboards:{displayName:"Dashboards",icon:"home"},pageEditor:{displayName:"Pages",section:"Edit",icon:"file-text"},menuEditor:{displayName:"Site menus",section:"Edit",icon:"menu"},menuLocations:{displayName:"Site menus",section:"Locations",icon:"map-pin"},contextMenuEditor:{displayName:"Context Menus",section:"Edit",icon:"menu"},collectionEditor:{displayName:"Collections",section:"Edit",icon:"database"},collectionEntries:{displayName:"Collections",section:"Entries",icon:"database"},formEditor:{displayName:"Forms",section:"Edit",icon:"layout"},formSubmissions:{displayName:"Forms",section:"Submissions",icon:"inbox"},viewEditor:{displayName:"Views",section:"Edit",icon:"eye"},viewPreview:{displayName:"Views",section:"Preview",icon:"eye"},actionEditor:{displayName:"Actions",section:"Edit",icon:"zap"},apiEndpointEditor:{displayName:"API Builder",section:"Edit",icon:"code"},roleEditor:{displayName:"Roles",section:"Edit",icon:"shield"},userEditor:{displayName:"Users",section:"Edit",icon:"users"},projectDetail:{displayName:"Projects",section:"Overview",icon:"folder"},projectSettings:{displayName:"Projects",section:"Settings",icon:"folder"},pluginCode:{displayName:"Marketplace",section:"Code",icon:"code"},chatKnowledge:{displayName:"Chats",section:"Knowledge",icon:"book-open"},aiAssistChats:{displayName:"AI Assist",section:"Chats",icon:"sparkles",licence:"Pro"},aiAssistKnowledge:{displayName:"AI Assist",section:"Knowledge",icon:"sparkles",licence:"Pro"},aiAssistSettings:{displayName:"AI Assist",section:"Settings",icon:"sparkles",licence:"Pro"}};for(const[t,o]of Object.entries(mt))D.register(t,async()=>{let e=await o();const a=nt[t];return a&&(e=J(e,{plugin:t,licence:"Built in",...a})),t==="dashboard"?et(e):e});R.use(async(t,o,e)=>{try{await D.load(t.view)}catch(a){console.error("[admin] Screen failed to load",a),z[t.view]={template:'<p role="alert">This screen could not load. Reload the page to try again.</p>'}}e()});const F=[...it];async function O(){if(m()){C=await r.get("/ai-assist").catch(()=>C);try{const t=await r.plugins.adminConfig(),o=new Set(F.map(e=>e.path));for(const e of t.routes||[])o.has(e.path)||F.push(e);for(const[e,a]of Object.entries(t.views||{})){const i=(t.meta||{})[e];D.register(e,async()=>{const n=(await import(`/plugins/${a.entry}`))[a.exportName];if(!n)throw new Error(`Missing plugin screen: ${e}`);const c=J(n,i);return e==="dashboard"?et(c):c},JSON.stringify([a,i]))}for(const[e,{route:a}]of Object.entries(t.takeovers||{}))a&&(I[`/${e}`]=a);t.mediaPicker&&(globalThis[Symbol.for("domma.media-picker")]=t.mediaPicker);for(const[e,{enabled:a,displayName:i}]of Object.entries(t.tools||{}))a===!1&&(T[`/${e}`]=i);for(const{id:e,href:a}of t.css||[])if(!document.getElementById(e)){const i=document.createElement("link");i.id=e,i.rel="stylesheet",i.href=a,document.head.appendChild(i)}}catch{}}}function G(){const t=W();if(!t)return;if($("#topbar-user-name").length){H(r);return}const e={"super-admin":"Super Admin",admin:"Admin",user:"User"}[t.role]||t.role,a=Ut(t);$("#topbar-user").get(0).innerHTML=`
|
|
1
|
+
import{wireNotificationMenu as ct}from"./lib/topbar-notifications.js";import{installSmoothCarets as pt}from"./lib/smooth-caret.js";import{viewLoaders as mt}from"./views/index.js";import{createLazyViews as dt}from"./lib/lazy-views.js";import{withPluginChrome as J}from"./lib/plugin-chrome.js";import{api as r,getUser as W,isAuthenticated as m,logout as ut,sendToLogin as ht}from"./api.js";import{claimDrafts as wt}from"./lib/draft-owner.js";import{isAuthScreen as P,loginHashFor as gt}from"./lib/login-arrange.js";import{installHttpInterceptor as ft}from"./http-interceptor.js";import{installResizableSlideovers as vt}from"./lib/slideover-resizable.js";import{installActivityThrobber as bt}from"./lib/activity-throbber.js";import{installUpdateNotice as Ct,renderCmsVersion as St}from"./lib/update-notice.js";import{renderFrameworkVersions as Y,wireAccountMenu as Mt}from"./lib/topbar-account.js";import{refreshTopbarProject as H}from"./lib/topbar-project.js";import{CONFINED_CLASS as yt,isConfined as Dt,isPathAllowed as N,redirectFor as At}from"./lib/admin-scope.js";import{deliverDesktop as Et,desktopActive as Q,notificationSettings as X}from"./lib/desktop-notify.js";import{chatToastsOpen as Pt,closeChatToasts as Nt,deliverChatToasts as kt,settleChatToasts as jt}from"./lib/chat-toast.js";import{aiAssistReroute as Rt,launcherChatsFor as It,rememberAiAssistState as Tt}from"./lib/ai-assist.js";import{onPresence as Lt,setAvailable as Z,startPresence as Ut,stopPresence as tt}from"./lib/chat-presence.js";import{avatarUrl as $t,installAccountAvatar as xt}from"./lib/avatar.js";import{installCalculator as Bt}from"./lib/calculator.js";import{installAdminAssistant as Ft}from"./lib/admin-assistant.js";import{installAdminLaunchers as Ot}from"./lib/admin-launchers.js";import{takeOverviewPass as Vt,withDashboardStrip as et}from"./lib/dashboards-strip.js";import{installHotkeys as _t}from"./lib/hotkeys-ui.js";import{applyAdminBrand as at}from"./lib/admin-brand.js";import{installRouterCatchUp as Kt}from"./lib/router-catch-up.js";import{installSidebarDrawer as Wt}from"./lib/sidebar-drawer.js";$(()=>{pt(document),ft(),Bt(),Ft(),Ot(),Ct(),bt(),vt(),Wt(),(async()=>{const{refreshAdminTheme:t}=await import("./lib/admin-theme.js");m()&&await t(r,{init:!0})})();let l=null,v=null,p="/",b=!1,w=null,d=null,u=!0,C=!1,g=null;function k(t){if(T[t])return E.toast(`${T[t]} is switched off on this site.`,{type:"info"}),"/";const[o,e]=t.split("?"),a=new URLSearchParams(e||"").get("tab");if(o==="/settings"&&["favicon","pageNavigation","breadcrumbs","motion","search"].includes(a))return`/appearance?tab=${a}`;if(t.split("?")[0]==="/my-dashboard")return"/dashboards";const i=Rt(t,g);if(i&&N(l,i.split("?")[0]))return i;const s=It(t);if(s&&!N(l,o)&&N(l,s.split("?")[0]))return s;const n=I[t]||At(l,t);return n||(!u&&o==="/system/notifications"?l?.home||"/":(t.split("?")[0]||"/")==="/"&&p&&p!=="/"&&!Vt()?I[p]||p:null)}function j(){document.body.classList.toggle(yt,Dt(l))}const I={},T={};R.use(async(t,o,e)=>{if(P(t.path))return e();if(!m()){ht();return}const a=k(t.path);if(a){R.navigate(a);return}e()});async function y(){try{const t=await r.get("/auth/permissions");l=t.adminScope||null,j(),v=t.adminBrand||null,at(v),p=t.adminHome||"/",Y(t.versions||{});const o=t.permissions||[];return b=N(l,"/settings")&&o.some(e=>e==="settings"||e.startsWith("settings.")),w=o.some(e=>e==="notifications"||e.startsWith("notifications.")),d=t.adminPortal||null,u=t.notificationsScreen!==!1,C=o.includes("chats")||o.includes("chats.reply"),o}catch{return l=null,j(),p="/",v||at(null),b=!1,w=null,d=null,u=!0,C=!1,[]}}document.addEventListener("dm:admin-home-changed",()=>{y()});let L=null,U=!1;document.addEventListener("dm:sidebar-rebuild",()=>{if(H(r),L){U=!0;return}L=(async()=>{do{U=!1;try{await x(await y())}catch{}}while(U)})().finally(()=>{L=null})});async function x(t){const{applyAdminPortal:o}=await import("./lib/admin-portal.js");if(await o(d),d)return;const{renderAdminSidebar:e}=await import("./lib/sidebar-renderer.js");await e({mount:"#admin-sidebar",permissions:t,adminScope:l,brand:v,notificationsScreen:u})}M.subscribe("router:afterChange",({to:t})=>{P(t.path)&&(f&&(clearInterval(f),f=null),l=null,j(),p="/",b=!1,w=null,u=!0,C=!1,d&&(d=null,import("./lib/admin-portal.js").then(o=>o.applyAdminPortal(null))))});const it=[{path:"/",view:"dashboard",title:"Dashboard - Domma CMS"},{path:"/dashboards",view:"dashboards",title:"Dashboards - Domma CMS"},{path:"/my-dashboard",view:"dashboards",title:"Dashboards - Domma CMS"},{path:"/pages",view:"pages",title:"Pages - Domma CMS"},{path:"/pages/new",view:"pageEditor",title:"New Page - Domma CMS"},{path:"/pages/edit/*",view:"pageEditor",title:"Edit Page - Domma CMS"},{path:"/media",view:"media",title:"Media - Domma CMS"},{path:"/menus",view:"menus",title:"Menus - Domma CMS"},{path:"/context-menus",view:"contextMenus",title:"Context Menus - Domma CMS"},{path:"/context-menus/new",view:"contextMenuEditor",title:"New Context Menu - Domma CMS"},{path:"/context-menus/edit/:slug",view:"contextMenuEditor",title:"Edit Context Menu - Domma CMS"},{path:"/launchers",view:"launchers",title:"Launchers - Domma CMS"},{path:"/menus/new",view:"menuEditor",title:"New Menu - Domma CMS"},{path:"/menus/edit/:slug",view:"menuEditor",title:"Edit Menu - Domma CMS"},{path:"/menu-locations",view:"menuLocations",title:"Menu Locations - Domma CMS"},{path:"/navigation",view:"menusRedirect",title:"Menus - Domma CMS"},{path:"/layouts",view:"layouts",title:"Layouts - Domma CMS"},{path:"/appearance",view:"appearance",title:"Appearance - Domma CMS"},{path:"/footer",view:"footer",title:"Footer - Domma CMS"},{path:"/settings",view:"settings",title:"Settings - Domma CMS"},{path:"/theme",view:"theme",title:"Theme - Domma CMS"},{path:"/users",view:"users",title:"Users - Domma CMS"},{path:"/users/new",view:"userEditor",title:"New User - Domma CMS"},{path:"/users/edit/:id",view:"userEditor",title:"Edit User - Domma CMS"},{path:"/plugins",view:"plugins",title:"Plugins - Domma CMS"},{path:"/plugins/code/:name",view:"pluginCode",title:"Plugin Code - Domma CMS"},{path:"/documentation",view:"documentation",title:"Usage - Domma CMS"},{path:"/tutorials",view:"tutorials",title:"Tutorials - Domma CMS"},{path:"/tutorials/crud",view:"tutorialCrud",title:"Building a CRUD App - Domma CMS"},{path:"/tutorials/editor",view:"tutorialEditor",title:"The Editor - Domma CMS"},{path:"/tutorials/plugin",view:"tutorialPlugin",title:"Writing a Tool - Domma CMS"},{path:"/tutorials/forms",view:"tutorialForms",title:"Form Follow-Up - Domma CMS"},{path:"/docs/components",view:"componentsReference",title:"Components Reference - Domma CMS"},{path:"/docs/components-howto",view:"componentsHowto",title:"Components How-To - Domma CMS"},{path:"/docs/components-walkthrough",view:"componentsWalkthrough",title:"Components Walkthrough - Domma CMS"},{path:"/docs/components-rules",view:"componentsRules",title:"Components Rules - Domma CMS"},{path:"/docs/usage/pages",view:"usagePages",title:"Pages - Usage - Domma CMS"},{path:"/docs/usage/media",view:"usageMedia",title:"Media - Usage - Domma CMS"},{path:"/docs/usage/navigation",view:"usageNavigation",title:"Navigation - Usage - Domma CMS"},{path:"/docs/usage/dconfig",view:"usageDconfig",title:"DConfig - Usage - Domma CMS"},{path:"/docs/usage/shortcodes",view:"usageShortcodes",title:"Shortcodes - Usage - Domma CMS"},{path:"/docs/usage/site-settings",view:"usageSiteSettings",title:"Site Settings - Usage - Domma CMS"},{path:"/docs/usage/plugins",view:"usagePlugins",title:"Plugins - Usage - Domma CMS"},{path:"/docs/usage/users-roles",view:"usageUsersRoles",title:"Users & Roles - Usage - Domma CMS"},{path:"/docs/usage/views",view:"usageViews",title:"Views - Usage - Domma CMS"},{path:"/docs/usage/actions",view:"usageActions",title:"Actions - Usage - Domma CMS"},{path:"/docs/usage/cta-shortcode",view:"usageCtaShortcode",title:"CTA Shortcode - Usage - Domma CMS"},{path:"/docs/usage/editions",view:"usageEditions",title:"Editions & Licences - Usage - Domma CMS"},{path:"/docs/usage/collections",view:"usageCollections",title:"Collections & Forms - Usage - Domma CMS"},{path:"/docs/usage/blocks",view:"usageBlocks",title:"Blocks - Usage - Domma CMS"},{path:"/docs/usage/tools",view:"usageTools",title:"Built-in Tools - Usage - Domma CMS"},{path:"/docs/usage/dashboard",view:"usageDashboard",title:"Dashboard - Usage - Domma CMS"},{path:"/docs/usage/search-engines",view:"usageSearchEngines",title:"Search Engines & AI - Usage - Domma CMS"},{path:"/docs/usage/launchers",view:"usageLaunchers",title:"Launchers - Usage - Domma CMS"},{path:"/docs/usage/chat",view:"usageChat",title:"Chat & Knowledge - Usage - Domma CMS"},{path:"/docs/plugins",view:"pluginGuides",title:"Plugin Guides - Domma CMS"},{path:"/docs/plugins/*",view:"pluginGuide",title:"Plugin Guide - Domma CMS"},{path:"/docs/api/authentication",view:"apiRefAuthentication",title:"Authentication - API - Domma CMS"},{path:"/docs/api/pages",view:"apiRefPages",title:"Pages - API - Domma CMS"},{path:"/docs/api/settings",view:"apiRefSettings",title:"Settings - API - Domma CMS"},{path:"/docs/api/layouts",view:"apiRefLayouts",title:"Layouts - API - Domma CMS"},{path:"/docs/api/navigation",view:"apiRefNavigation",title:"Navigation - API - Domma CMS"},{path:"/docs/api/media",view:"apiRefMedia",title:"Media - API - Domma CMS"},{path:"/docs/api/users",view:"apiRefUsers",title:"Users - API - Domma CMS"},{path:"/docs/api/plugins",view:"apiRefPlugins",title:"Plugins - API - Domma CMS"},{path:"/docs/api/collections",view:"apiRefCollections",title:"Collections - API - Domma CMS"},{path:"/docs/api/views",view:"apiRefViews",title:"Views API - Domma CMS"},{path:"/docs/api/actions",view:"apiRefActions",title:"Actions API - Domma CMS"},{path:"/docs/api/forms",view:"apiRefForms",title:"Forms API - Domma CMS"},{path:"/docs/api/scaffold",view:"apiRefScaffold",title:"Scaffold API - Domma CMS"},{path:"/docs/api/external",view:"apiRefExternal",title:"External API & Tokens - Domma CMS"},{path:"/docs/api/content",view:"apiRefContent",title:"Content API - Domma CMS"},{path:"/docs/api/builder",view:"apiRefBuilder",title:"API Builder - Domma CMS"},{path:"/api-reference",view:"apiReference",title:"API Reference - Domma CMS"},{path:"/collections",view:"collections",title:"Collections - Domma CMS"},{path:"/collections/new",view:"collectionEditor",title:"New Collection - Domma CMS"},{path:"/collections/edit/:slug",view:"collectionEditor",title:"Edit Collection - Domma CMS"},{path:"/collections/:slug/entries",view:"collectionEntries",title:"Entries - Domma CMS"},{path:"/forms",view:"forms",title:"Forms - Domma CMS"},{path:"/forms/new",view:"formEditor",title:"New Form - Domma CMS"},{path:"/forms/edit/:slug",view:"formEditor",title:"Edit Form - Domma CMS"},{path:"/forms/:slug/submissions",view:"formSubmissions",title:"Submissions - Domma CMS"},{path:"/views",view:"viewsList",title:"Views - Domma CMS"},{path:"/views/new",view:"viewEditor",title:"New View - Domma CMS"},{path:"/views/edit/:slug",view:"viewEditor",title:"Edit View - Domma CMS"},{path:"/views/:slug/preview",view:"viewPreview",title:"View Preview - Domma CMS"},{path:"/actions",view:"actionsList",title:"Actions - Domma CMS"},{path:"/actions/new",view:"actionEditor",title:"New Action - Domma CMS"},{path:"/actions/edit/:slug",view:"actionEditor",title:"Edit Action - Domma CMS"},{path:"/pro/docs",view:"proDocs",title:"Pro Documentation - Domma CMS"},{path:"/blocks",view:"blocks",title:"Blocks - Domma CMS"},{path:"/blocks/new",view:"pageEditor",title:"New Block - Domma CMS"},{path:"/blocks/edit/:name",view:"pageEditor",title:"Edit Block - Domma CMS"},{path:"/components",view:"components",title:"Components - Domma CMS"},{path:"/components/new",view:"pageEditor",title:"New Component - Domma CMS"},{path:"/components/edit/:name",view:"pageEditor",title:"Edit Component - Domma CMS"},{path:"/my-profile",view:"myProfile",title:"My Profile - Domma CMS"},{path:"/roles",view:"roles",title:"Roles & Permissions - Domma CMS"},{path:"/roles/edit/:id",view:"roleEditor",title:"Edit Role - Domma CMS"},{path:"/effects",view:"effects",title:"Effects - Domma CMS"},{path:"/search",view:"search",title:"Search - Domma CMS"},{path:"/content-api",view:"contentApi",title:"Content API - Domma CMS"},{path:"/launchers/chats",view:"chats",title:"Chats - Domma CMS"},{path:"/launchers/chats/:id",view:"chats",title:"Chats - Domma CMS"},{path:"/launchers/knowledge",view:"chatKnowledge",title:"Chat Knowledge - Domma CMS"},{path:"/ai-assist",view:"aiAssistChats",title:"AI Assist - Domma CMS"},{path:"/ai-assist/chats",view:"aiAssistChats",title:"AI Assist - Domma CMS"},{path:"/ai-assist/chats/:id",view:"aiAssistChats",title:"AI Assist - Domma CMS"},{path:"/ai-assist/knowledge",view:"aiAssistKnowledge",title:"AI Assist Knowledge - Domma CMS"},{path:"/ai-assist/settings",view:"aiAssistSettings",title:"AI Assist Settings - Domma CMS"},{path:"/ai-assist/builders",view:"aiAssistBuilders",title:"AI Assist Builders - Domma CMS"},{path:"/notes",view:"notes",title:"Notes - Domma CMS"},{path:"/todo",view:"todo",title:"Todo - Domma CMS"},{path:"/calculator",view:"calculator",title:"Calculator - Domma CMS"},{path:"/analytics",view:"analytics",title:"Analytics - Domma CMS"},{path:"/seo",view:"seo",title:"SEO - Domma CMS"},{path:"/seo/:tab",view:"seo",title:"SEO - Domma CMS"},{path:"/wordpress-import",view:"wordpressImport",title:"Import a site - Domma CMS"},{path:"/contacts",view:"contacts",title:"Contacts - Domma CMS"},{path:"/calls/new",view:"callNew",title:"Call now - Domma CMS"},{path:"/system/notifications",view:"notifications",title:"Notifications - Domma CMS"},{path:"/api-tokens",view:"apiTokens",title:"API Tokens - Domma CMS"},{path:"/api-endpoints",view:"apiEndpoints",title:"API Builder - Domma CMS"},{path:"/api-endpoints/new",view:"apiEndpointEditor",title:"New API Endpoint - Domma CMS"},{path:"/api-endpoints/edit/:id",view:"apiEndpointEditor",title:"Edit API Endpoint - Domma CMS"},{path:"/projects",view:"projects",title:"Projects - Domma CMS"},{path:"/projects/new",view:"projects",title:"New Project - Domma CMS"},{path:"/projects/edit/:slug",view:"projects",title:"Edit Project - Domma CMS"},{path:"/projects/:slug/settings",view:"projectSettings",title:"Project settings - Domma CMS"},{path:"/projects/:slug/pages",view:"pages",title:"Project pages - Domma CMS"},{path:"/projects/:slug/collections",view:"collections",title:"Project collections - Domma CMS"},{path:"/projects/:slug/forms",view:"forms",title:"Project forms - Domma CMS"},{path:"/projects/:slug/actions",view:"actionsList",title:"Project actions - Domma CMS"},{path:"/projects/:slug/menus",view:"menus",title:"Project menus - Domma CMS"},{path:"/projects/:slug/blocks",view:"blocks",title:"Project blocks - Domma CMS"},{path:"/projects/:slug/components",view:"components",title:"Project components - Domma CMS"},{path:"/projects/:slug/views",view:"viewsList",title:"Project views - Domma CMS"},{path:"/projects/:slug/roles",view:"roles",title:"Project roles - Domma CMS"},{path:"/projects/:slug/users",view:"users",title:"Project users - Domma CMS"},{path:"/projects/:slug/apis",view:"apiEndpoints",title:"Project APIs - Domma CMS"},{path:"/projects/:slug",view:"projectDetail",title:"Project - Domma CMS"},{path:"/login",view:"login",title:"Sign in - Domma CMS",onEnter:()=>{$("#admin-sidebar").hide(),$("#admin-topbar").hide(),tt(),Nt()}},{path:"/reset-password",view:"login",title:"Reset Password - Domma CMS",onEnter:()=>{$("#admin-sidebar").hide(),$("#admin-topbar").hide()}}];M.subscribe("router:afterChange",async({to:t,from:o})=>{if(!P(t.path)){if($("#admin-sidebar").show(),$("#admin-topbar").show(),P(o?.path)){$("#topbar-user-name").remove(),import("./lib/admin-theme.js").then(i=>i.refreshAdminTheme(r)),await O();const e=await y(),a=k(t.path);if(a&&R.navigate(a),x(e),X.read().signInToasts)try{const i=await r.system.notifications.list().catch(()=>[]),s=(Array.isArray(i)?i:[]).filter(n=>n.unread&&["warning","critical"].includes(n.data?.severity)).slice(0,3);for(const n of s){const c=h(n.data?.title||""),K=h((n.data?.body||"").slice(0,120));E.toast(`${c} - ${K}`,{type:n.data?.severity==="critical"?"error":"warning",duration:0})}}catch{}}G()}}),M.subscribe("router:afterChange",()=>{setTimeout(()=>{$(".btn-primary, .btn-danger").length&&Domma.effects.reveal(".btn-primary, .btn-danger",{animation:"fade",stagger:40,duration:300})},50)});const ot=["#field-project","#menu-project","#collection-project","#endpoint-project","#action-project","#view-project","#block-project","#component-project","#role-project",'[name="project"]','[name="ownedByProject"]'];function st(t){return/^\/(pages|menus|context-menus|collections|forms|actions|views|blocks|components|users|roles|api-endpoints)\/(new|edit\/)/.test(t)}M.subscribe("router:afterChange",({to:t})=>{const o=t?String(t.path).split("?")[0]:"";if(!t||!st(o))return;const a=new URLSearchParams(location.hash.split("?")[1]||"").get("project");if(!a||!/\/new$/.test(o))return;let i=0;const s=60,n=1500,c=()=>{i+=s;for(const K of ot){const A=document.querySelector(K);if(!A)continue;if(Array.from(A.options||[]).find(lt=>lt.value===a)){A.value=a,A.dispatchEvent(new Event("change",{bubbles:!0}));return}}i<n&&setTimeout(c,s)};setTimeout(c,s)});const q="cms_card_states",B=S.get(q)||{};M.subscribe("router:afterChange",()=>{setTimeout(()=>{$("#view-container .card-collapsible").each(function(){const t=$(this).find(".card-header h2, .card-header h3").first().text().trim();t&&B[t]==="collapsed"&&$(this).addClass("card-collapsed")})},200)}),$("#view-container").on("click",".card-collapsible .card-header",function(t){if($(t.target).closest("button, a").length)return;const o=$(this).closest(".card");o.toggleClass("card-collapsed");const e=$(this).find("h2, h3").first().text().trim();e&&(B[e]=o.hasClass("card-collapsed")?"collapsed":"open",S.set(q,B))}),_t(),document.addEventListener("keydown",t=>{if(!(t.ctrlKey||t.metaKey)||t.key!=="s"||window.location.hash.startsWith("#/login")||window.location.hash.startsWith("#/reset-password"))return;const o=document.querySelector("#view-container .view-header button.btn-primary");o&&(t.preventDefault(),o.click())});const D=dt(),z=D.views,nt={notes:{displayName:"Notes",icon:"edit-3"},todo:{displayName:"Todo",icon:"check-square"},calculator:{displayName:"Calculator",icon:"calculator"},analytics:{displayName:"Analytics",icon:"chart-bar"},seo:{displayName:"SEO",icon:"search"},wordpressImport:{displayName:"Import a site",icon:"download"},contacts:{displayName:"Contacts",icon:"users"},projects:{displayName:"Projects",icon:"folder"},pages:{displayName:"Pages",icon:"file-text"},media:{displayName:"Media",icon:"image"},menus:{displayName:"Site menus",icon:"menu"},contextMenus:{displayName:"Context Menus",icon:"menu"},launchers:{displayName:"Launchers",icon:"rocket"},theme:{displayName:"Theme",icon:"droplet"},collections:{displayName:"Collections",icon:"database"},forms:{displayName:"Forms",icon:"layout"},viewsList:{displayName:"Views",icon:"eye"},actionsList:{displayName:"Actions",icon:"zap"},apiEndpoints:{displayName:"API Builder",icon:"code"},blocks:{displayName:"Blocks",icon:"box"},components:{displayName:"Components",icon:"component"},notifications:{displayName:"Notifications",icon:"bell"},roles:{displayName:"Roles",icon:"shield"},users:{displayName:"Users",icon:"users"},appearance:{displayName:"Appearance",icon:"layout"},footer:{displayName:"Footer",icon:"panel-bottom"},settings:{displayName:"Site Settings",icon:"settings"},effects:{displayName:"Effects",icon:"sparkles"},layouts:{displayName:"Layouts",icon:"layout"},plugins:{displayName:"Marketplace",icon:"store"},myProfile:{displayName:"My Profile",icon:"user"},apiTokens:{displayName:"API Tokens",icon:"key"},search:{displayName:"Search",icon:"search"},contentApi:{displayName:"Content API",icon:"file-text"},chats:{displayName:"Chats",icon:"message-circle"},dashboard:{displayName:"Dashboard",icon:"home"},dashboards:{displayName:"Dashboards",icon:"home"},pageEditor:{displayName:"Pages",section:"Edit",icon:"file-text"},menuEditor:{displayName:"Site menus",section:"Edit",icon:"menu"},menuLocations:{displayName:"Site menus",section:"Locations",icon:"map-pin"},contextMenuEditor:{displayName:"Context Menus",section:"Edit",icon:"menu"},collectionEditor:{displayName:"Collections",section:"Edit",icon:"database"},collectionEntries:{displayName:"Collections",section:"Entries",icon:"database"},formEditor:{displayName:"Forms",section:"Edit",icon:"layout"},formSubmissions:{displayName:"Forms",section:"Submissions",icon:"inbox"},viewEditor:{displayName:"Views",section:"Edit",icon:"eye"},viewPreview:{displayName:"Views",section:"Preview",icon:"eye"},actionEditor:{displayName:"Actions",section:"Edit",icon:"zap"},apiEndpointEditor:{displayName:"API Builder",section:"Edit",icon:"code"},roleEditor:{displayName:"Roles",section:"Edit",icon:"shield"},userEditor:{displayName:"Users",section:"Edit",icon:"users"},projectDetail:{displayName:"Projects",section:"Overview",icon:"folder"},projectSettings:{displayName:"Projects",section:"Settings",icon:"folder"},pluginCode:{displayName:"Marketplace",section:"Code",icon:"code"},chatKnowledge:{displayName:"Chats",section:"Knowledge",icon:"book-open"},aiAssistChats:{displayName:"AI Assist",section:"Chats",icon:"sparkles",licence:"Pro"},aiAssistKnowledge:{displayName:"AI Assist",section:"Knowledge",icon:"sparkles",licence:"Pro"},aiAssistSettings:{displayName:"AI Assist",section:"Settings",icon:"sparkles",licence:"Pro"},aiAssistBuilders:{displayName:"AI Assist",section:"Builders",icon:"sparkles",licence:"Pro"}};for(const[t,o]of Object.entries(mt))D.register(t,async()=>{let e=await o();const a=nt[t];return a&&(e=J(e,{plugin:t,licence:"Built in",...a})),t==="dashboard"?et(e):e});R.use(async(t,o,e)=>{try{await D.load(t.view)}catch(a){console.error("[admin] Screen failed to load",a),z[t.view]={template:'<p role="alert">This screen could not load. Reload the page to try again.</p>'}}e()});const F=[...it];async function O(){if(m()){g=await r.get("/ai-assist").catch(()=>g),Tt(g);try{const t=await r.plugins.adminConfig(),o=new Set(F.map(e=>e.path));for(const e of t.routes||[])o.has(e.path)||F.push(e);for(const[e,a]of Object.entries(t.views||{})){const i=(t.meta||{})[e];D.register(e,async()=>{const n=(await import(`/plugins/${a.entry}`))[a.exportName];if(!n)throw new Error(`Missing plugin screen: ${e}`);const c=J(n,i);return e==="dashboard"?et(c):c},JSON.stringify([a,i]))}for(const[e,{route:a}]of Object.entries(t.takeovers||{}))a&&(I[`/${e}`]=a);t.mediaPicker&&(globalThis[Symbol.for("domma.media-picker")]=t.mediaPicker);for(const[e,{enabled:a,displayName:i}]of Object.entries(t.tools||{}))a===!1&&(T[`/${e}`]=i);for(const{id:e,href:a}of t.css||[])if(!document.getElementById(e)){const i=document.createElement("link");i.id=e,i.rel="stylesheet",i.href=a,document.head.appendChild(i)}}catch{}}}function G(){const t=W();if(!t)return;if($("#topbar-user-name").length){H(r);return}const e={"super-admin":"Super Admin",admin:"Admin",user:"User"}[t.role]||t.role,a=$t(t);$("#topbar-user").get(0).innerHTML=`
|
|
2
2
|
<a id="topbar-project" class="topbar-action-link topbar-project" hidden>
|
|
3
3
|
<span data-icon="folder"></span>
|
|
4
4
|
<span id="topbar-project-name" class="topbar-project-name"></span>
|
|
@@ -56,4 +56,4 @@ import{wireNotificationMenu as ct}from"./lib/topbar-notifications.js";import{ins
|
|
|
56
56
|
</a>
|
|
57
57
|
</div>
|
|
58
58
|
</div>
|
|
59
|
-
`;const i=$("#topbar-settings").get(0);i&&(i.hidden=!
|
|
59
|
+
`;const i=$("#topbar-settings").get(0);i&&(i.hidden=!b),$("#topbar-logout-btn").on("click",s=>{s.preventDefault(),tt({leaving:!0}),ut()}),Domma.icons.scan("#admin-topbar"),E.tooltip("#topbar-actions [data-tooltip]",{placement:"bottom"}),Mt(t),ct({refreshBadge:_,canRead:()=>w!==!1,own:()=>!u}),xt(t),rt(t),Y(),St(),H(r),_(),f||(f=setInterval(_,3e4))}function rt(t){const o=C&&g?.chats!==!1;Ut({userId:t.id,canReply:o,post:i=>r.post("/chats/presence",i)});const e=document.getElementById("topbar-presence"),a=document.getElementById("topbar-available");!e||!a||e.dataset.wired||(e.dataset.wired="1",e.addEventListener("click",()=>Z(e.getAttribute("aria-pressed")!=="true")),a.addEventListener("change",()=>Z(a.checked)),Lt(({available:i,canReply:s})=>{e.hidden=!s,a.closest("label").hidden=!s,e.setAttribute("aria-pressed",String(i)),e.classList.toggle("is-available",i),e.setAttribute("aria-label",i?"Available for chats - switch to away":"Away from chats - switch to available"),e.querySelector(".topbar-presence-label").textContent=i?"Available":"Away",a.checked=i}))}function h(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}let f=null,V=null;async function _(){if(!(!m()||w===!1))try{const{count:t}=await r.system.notifications.unreadCount(),o=$("#topbar-bell-badge");t>0?o.text(t>99?"99+":String(t)).removeAttr("hidden"):o.attr("hidden","").text("");const e=X.read().chatToasts&&t>0&&(V===null||t>V);V=t;const a=Pt();if(t>0&&(Q()||e)||a){const i=await r.system.notifications.list().catch(()=>null);if(!i)return;t>0&&Q()&&Et(i),e&&kt(i),a&&jt(i)}}catch{}}(async()=>{if(!m()&&!window.location.hash.startsWith("#/reset-password"))window.location.hash.startsWith("#/login")||(window.location.hash=gt(window.location.hash));else{wt(W()?.id);const a=W(),[i]=await Promise.all([a?y():Promise.resolve([]),O()]);if(a){const s=(window.location.hash||"#/").slice(1)||"/",n=k(s);n&&(window.location.hash=`#${n}`),x(i).catch(c=>console.error("[admin] Sidebar failed to load",c)),G()}}const t=R._extractParams.bind(R);R._extractParams=function(a,i){const s=i.indexOf("?");if(s!==-1&&(i=i.slice(0,s)),a.endsWith("/*")){const n=a.slice(0,-2);return i.startsWith(n+"/")?{}:null}return t(a,i)};const o=R._renderNotFound.bind(R);let e="";R._renderNotFound=async function(a){return m()&&e!==a&&(e=a,await O(),R._matchRoute(a).route)?(e="",R._handleRouteChange()):(e="",m()&&$("#admin-sidebar").get(0)?.style.display==="none"?(E.toast("That link goes nowhere - here is your home page.",{type:"warning"}),R.navigate("/")):o(a))},Kt(R),R.init({container:"#view-container",routes:F,views:z,default:"/",transitions:{enter:"fadeIn",leave:"fadeOut",duration:150}})})()});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AI_ASSIST_BASE="/ai-assist",LAUNCHER_BASE="/launchers",AI_ASSIST_TABS=Object.freeze([{key:"chats",label:"Chats",icon:"message-circle",chats:!0},{key:"knowledge",label:"Knowledge",icon:"book-open",chats:!0},{key:"settings",label:"Settings",icon:"settings",chats:!1}]);export function aiAssistReroute(
|
|
1
|
+
export const AI_ASSIST_BASE="/ai-assist",LAUNCHER_BASE="/launchers",AI_ASSIST_TABS=Object.freeze([{key:"chats",label:"Chats",icon:"message-circle",chats:!0},{key:"knowledge",label:"Knowledge",icon:"book-open",chats:!0},{key:"builders",label:"Builders",icon:"sparkles",builders:!0},{key:"settings",label:"Settings",icon:"settings",chats:!1}]);let u=null;export function rememberAiAssistState(s){u=s&&typeof s=="object"?s:null}export const aiAssistState=()=>u;export function aiAssistReroute(s,n){if(!n||typeof s!="string")return null;const[i,t]=s.split("?"),e=t?`?${t}`:"",r=n.chats!==!1,c=i.match(/^\/(launchers|ai-assist)(?:\/(chats|knowledge|settings|builders))?(\/[^/]+)?\/?$/);if(!c)return null;const[,l,a,o=""]=c;return l==="launchers"?!a||a==="settings"||a==="builders"?null:n.on?`${AI_ASSIST_BASE}/${a}${o}${e}`:null:n.on?a?a==="builders"?Array.isArray(n.builders)&&n.builders.length?null:`${AI_ASSIST_BASE}/${r?"chats":"settings"}`:!r&&a!=="settings"?`${AI_ASSIST_BASE}/settings`:null:`${AI_ASSIST_BASE}/${r?"chats":"settings"}`:r&&(a==="chats"||a==="knowledge")?`${LAUNCHER_BASE}/${a}${o}${e}`:r?`${LAUNCHER_BASE}/chats`:"/"}export function launcherChatsFor(s){const n=String(s||"").match(/^\/ai-assist\/(chats|knowledge)(\/[^/?]+)?\/?(\?.*)?$/);return n?`${LAUNCHER_BASE}/${n[1]}${n[2]||""}${n[3]||""}`:null}export function builderChatRows(s,n){const i=Array.isArray(s?.items)?s.items:Array.isArray(s?.conversations)?s.conversations:Array.isArray(s?.builds)?s.builds:[],t=(e,r=120)=>typeof e=="string"?e.trim().slice(0,r):"";return i.map(e=>{const r=t(e?.id,100)||t(e?.plugin,100);return r?{id:r,title:t(e.title)||t(e.displayName)||t(e.plugin)||"Untitled",when:t(e.updatedAt,40)||t(e.createdAt,40),who:t(e.startedBy,80)||t(e.by,80)||t(e.userName,80),status:t(e.status,40),href:`${n.url}?open=${encodeURIComponent(r)}`}:null}).filter(Boolean).sort((e,r)=>r.when.localeCompare(e.when))}export function chatsBaseFor(s){return/^#\/ai-assist\b/.test(String(s||""))?`#${AI_ASSIST_BASE}`:`#${LAUNCHER_BASE}`}export function aiAssistTabs(s,{chats:n=!0,builders:i=!1}={}){return AI_ASSIST_TABS.filter(t=>(n||!t.chats)&&(i||!t.builders)).map(t=>({...t,href:`#${AI_ASSIST_BASE}/${t.key}`,active:t.key===s}))}export function mountAiAssistTabs(s,n,i={}){if(!s||chatsBaseFor(location.hash)!==`#${AI_ASSIST_BASE}`)return null;const t=s.querySelector(".dm-plugin-body")||s;t.querySelector(":scope > .ai-assist-tabs")?.remove();const e=document.createElement("nav");e.className="ai-assist-tabs",e.setAttribute("aria-label","AI Assist");const r=aiAssistState(),c={chats:r?.chats!==!1,builders:!!r?.builders?.length,...i};for(const l of aiAssistTabs(n,c)){const a=document.createElement("a");a.className=`ai-assist-tab${l.active?" is-active":""}`,a.href=l.href,l.active&&a.setAttribute("aria-current","page");const o=document.createElement("span");o.dataset.icon=l.icon,o.dataset.iconSize="14",o.setAttribute("aria-hidden","true"),a.append(o,document.createTextNode(` ${l.label}`)),e.append(a)}return t.prepend(e),globalThis.I?.scan?.(e),e}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!-- AI Assist › Builders. Bound with M.applyBindings - see admin/js/views/ai-assist-builders.js,
|
|
2
|
+
which also inserts the row template (the router renders a templateUrl through _.render, eating any {{…}}). -->
|
|
3
|
+
<div class="aib">
|
|
4
|
+
<div class="aib-note dm-loading-slot" data-bind-hidden="!loading.value">Loading…</div>
|
|
5
|
+
<p class="aib-intro" hidden data-bind-hidden="loading.value">
|
|
6
|
+
The AI chats in your builders. Click one to carry on with it in its builder.
|
|
7
|
+
<span data-help-title="Builders"
|
|
8
|
+
data-help="Each builder keeps its own chats - the Site Builder its conversations, the Tool Builder one chat per Tool. You see the ones you could open in that builder yourself. Right-click a chat (or its ⋮) to open it, or open the builder to start a new one."></span>
|
|
9
|
+
</p>
|
|
10
|
+
<p class="aib-note" hidden data-bind-hidden="loading.value || groups.value.length">No builders on this site.</p>
|
|
11
|
+
<div class="aib-groups" hidden data-bind-hidden="loading.value"></div>
|
|
12
|
+
</div>
|
|
13
|
+
<style>
|
|
14
|
+
.aib { display: grid; gap: 1rem; max-width: 1000px; }
|
|
15
|
+
.aib [hidden] { display: none !important; }
|
|
16
|
+
.aib-note, .aib-intro { margin: 0; color: var(--dm-text-muted); font-size: var(--dm-text-sm); }
|
|
17
|
+
.aib-groups { display: grid; gap: 1rem; }
|
|
18
|
+
.aib-group { padding: 1rem 1.25rem; display: grid; gap: .5rem; }
|
|
19
|
+
.aib-head { display: flex; align-items: center; gap: .5rem; }
|
|
20
|
+
.aib-head h3 { margin: 0; font-size: 1rem; flex: 1; }
|
|
21
|
+
.aib-list { display: grid; gap: .25rem; }
|
|
22
|
+
.aib-row { display: grid; grid-template-columns: 1fr auto auto; gap: .75rem; align-items: center; padding: .5rem .6rem;
|
|
23
|
+
border: 1px solid var(--dm-border); border-radius: var(--dm-radius-md); cursor: pointer; }
|
|
24
|
+
.aib-row:hover, .aib-row:focus-visible { border-color: var(--dm-primary); outline: none; }
|
|
25
|
+
.aib-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
26
|
+
.aib-meta { color: var(--dm-text-muted); font-size: var(--dm-text-sm); }
|
|
27
|
+
.aib-kebab { background: none; border: 0; color: var(--dm-text-muted); cursor: pointer; padding: 0 .25rem; }
|
|
28
|
+
.aib-chip { font-size: .75rem; padding: .05rem .5rem; border-radius: 9999px; border: 1px solid var(--dm-border); color: var(--dm-text-muted); }
|
|
29
|
+
</style>
|
|
@@ -69,10 +69,13 @@
|
|
|
69
69
|
about something else, such as a help chat in the admin.</p>
|
|
70
70
|
|
|
71
71
|
<h3>Answering visitors: Chats</h3>
|
|
72
|
-
<p>On a site with <strong>AI Assist</strong> (Pro), every chat is answered in <strong>AI Assist</strong> (
|
|
73
|
-
|
|
72
|
+
<p>On a site with <strong>AI Assist</strong> (Pro), every chat is answered in <strong>AI Assist</strong> (in Data): its <strong>Chats</strong>, <strong>Knowledge</strong>, <strong>Builders</strong> and
|
|
73
|
+
<strong>Settings</strong> tabs. Launchers stay
|
|
74
74
|
launchers - a chat launcher only hands its chats over. Without AI Assist the same inbox is <strong>Content >
|
|
75
75
|
Chats</strong>, and old links to either lead to whichever the site has.</p>
|
|
76
|
+
<p>AI Assist's <strong>Builders</strong> tab lists the AI chats of the site's builders - the Site Builder's
|
|
77
|
+
conversations and the Tool Builder's builds - newest first, with who started each. Click one to carry on in its
|
|
78
|
+
builder. You see only the builders, and the chats, you could open in the builder yourself.</p>
|
|
76
79
|
<p>The inbox Its sidebar badge counts the chats that need you: a visitor
|
|
77
80
|
<strong>Waiting</strong> for a person (a live dot; red after five minutes), a <strong>Message left</strong> when
|
|
78
81
|
nobody was available, and chats with new messages since your reply. Waiting chats are listed first, the longest
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{apiRequest as L}from"../api.js";import{helpPopovers as B}from"../lib/help-popover.js";import{SHAPES as j,whileLoading as D}from"../lib/loading.js";import{openMenuAt as $,viewLifetime as N}from"../lib/tool-kit.js";import{fmtDateTime as P}from"../lib/dates.js";import{builderChatRows as R,mountAiAssistTabs as T,rememberAiAssistState as K}from"../lib/ai-assist.js";const U=/^#\/ai-assist\/builders\b/,d=N(U);async function z(s){try{const n=await L(s.list.replace(/^\/api(?=\/)/,""));return{builder:s,rows:R(n,s),error:""}}catch(n){const i=String(n?.message||"");return{builder:s,rows:[],error:/403|permission|not allowed/i.test(i)?"Not available to you.":"Could not load its chats just now."}}}function o(s,n,i){const l=document.createElement(s);return n&&(l.className=n),i!==void 0&&(l.textContent=i),l}export const aiAssistBuildersView={templateUrl:"/admin/js/templates/ai-assist-builders.html",async onMount(s){d.reset();const n=s.get(0),i=n.querySelector(".aib")||n;let l=!1;d.add(()=>{l=!0});const x=()=>!l&&i.isConnected,w=M.observable(!0),y=M.observable([]),O=M.applyBindings({loading:w,groups:y},i);d.add(()=>O.dispose()),d.add(B(i,{position:"bottom"}));let u=[];try{u=await D(i.querySelector(".dm-loading-slot"),(async()=>{const e=await L("/ai-assist");return K(e),Promise.all((e?.builders||[]).map(z))})(),j.rows)}catch{u=[]}if(!x())return;T(n,"builders");const r=i.querySelector(".aib-groups");r.replaceChildren();const p=new Map;for(const e of u){const t=o("section","card aib-group"),c=o("div","aib-head"),f=o("span");f.dataset.icon="sparkles",f.dataset.iconSize="16";const v=o("a","btn btn-sm btn-outline",`Open ${e.builder.label}`);v.href=e.builder.url,c.append(f,o("h3","",e.builder.label),v),t.append(c),e.error?t.append(o("p","aib-note",e.error)):e.rows.length||t.append(o("p","aib-note","No chats yet. Open the builder to start one."));const A=o("div","aib-list");for(const a of e.rows){const S=`${e.builder.plugin}:${a.id}`;p.set(S,{row:a,builder:e.builder});const b=o("div","aib-row");b.tabIndex=0,b.dataset.key=S,b.setAttribute("role","link");const C=o("div");C.append(o("div","aib-title",a.title),o("div","aib-meta",[a.when?P(a.when):"",a.who].filter(Boolean).join(" \xB7 ")));const h=o("button","aib-kebab","\u22EE");h.type="button",h.setAttribute("aria-label",`Actions for ${a.title}`),b.append(C,a.status?o("span","aib-chip",a.status):o("span"),h),A.append(b)}t.append(A),r.append(t)}y.value=u,w.value=!1;const m=e=>{const t=p.get(e);t&&(location.hash=t.row.href)},g=e=>{const t=e.target.closest(".aib-kebab");if(t){$(t);return}const c=e.target.closest(".aib-row");c&&m(c.dataset.key)},k=e=>{const t=e.target.closest(".aib-row");t&&(e.key==="Enter"&&(e.preventDefault(),m(t.dataset.key)),e.key==="F10"&&e.shiftKey&&(e.preventDefault(),$(t)))};r.addEventListener("click",g),r.addEventListener("keydown",k),d.add(()=>{r.removeEventListener("click",g),r.removeEventListener("keydown",k)});const q=E.contextMenu?.(r,{cursor:"glyph",match:".aib-row",inherit:!1,density:"compact",items:e=>{const t=p.get(e?.dataset?.key);return t?[{header:t.row.title},{label:`Open in ${t.builder.label}`,icon:"external-link",action:()=>m(e.dataset.key)},{label:`Open ${t.builder.label}`,icon:"sparkles",action:()=>{location.hash=t.builder.url}}]:[]}});d.add(()=>q?.destroy?.()),I.scan(i)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{apiRequest as l}from"../api.js";import{addBannerAction as z}from"../lib/plugin-chrome.js";import{helpPopovers as G}from"../lib/help-popover.js";import{SHAPES as Q,whileLoading as X}from"../lib/loading.js";import{mountAiAssistTabs as x}from"../lib/ai-assist.js";import{characterOptions as Z,checkForm as P,formFromSettings as T,LIMITS as K,payloadFromForm as N,snapshot as k}from"../lib/ai-assist-settings-arrange.js";import{CHARACTERS as _}from"../../../public/js/characters.mjs";const C=/^\/ai-assist\/settings(\?.*)?$/;let n=null,U=!1;function ee(){U||!window.R?.use||(U=!0,R.use((r,i,o)=>!(C.test(i?.path||"")&&!C.test(r?.path||""))||!n?.dirty()?o():E.confirm("You have unsaved AI Assist settings. Leave anyway?").then(c=>{c?o():history.replaceState(null,"","#/ai-assist/settings")})),M.subscribe("router:afterChange",({to:r}={})=>{if(n&&!C.test(r?.path||"")){const i=n;n=null,i.dispose()}}))}export const aiAssistSettingsView={templateUrl:"/admin/js/templates/ai-assist-settings.html",async onMount(r){if(ee(),n){const e=n;n=null,e.dispose()}const i=[],o=e=>(i.push(e),e);let p=!1;const c=r.get(0),a=c.querySelector(".aia")||c,m=()=>!p&&a.isConnected;x(c,"settings"
|
|
1
|
+
import{apiRequest as l}from"../api.js";import{addBannerAction as z}from"../lib/plugin-chrome.js";import{helpPopovers as G}from"../lib/help-popover.js";import{SHAPES as Q,whileLoading as X}from"../lib/loading.js";import{mountAiAssistTabs as x}from"../lib/ai-assist.js";import{characterOptions as Z,checkForm as P,formFromSettings as T,LIMITS as K,payloadFromForm as N,snapshot as k}from"../lib/ai-assist-settings-arrange.js";import{CHARACTERS as _}from"../../../public/js/characters.mjs";const C=/^\/ai-assist\/settings(\?.*)?$/;let n=null,U=!1;function ee(){U||!window.R?.use||(U=!0,R.use((r,i,o)=>!(C.test(i?.path||"")&&!C.test(r?.path||""))||!n?.dirty()?o():E.confirm("You have unsaved AI Assist settings. Leave anyway?").then(c=>{c?o():history.replaceState(null,"","#/ai-assist/settings")})),M.subscribe("router:afterChange",({to:r}={})=>{if(n&&!C.test(r?.path||"")){const i=n;n=null,i.dispose()}}))}export const aiAssistSettingsView={templateUrl:"/admin/js/templates/ai-assist-settings.html",async onMount(r){if(ee(),n){const e=n;n=null,e.dispose()}const i=[],o=e=>(i.push(e),e);let p=!1;const c=r.get(0),a=c.querySelector(".aia")||c,m=()=>!p&&a.isConnected;x(c,"settings");const O=M.observable(!0);let u={},f=[],v={chats:!0};try{[u,f,v]=await X(a.querySelector(".dm-loading-slot"),Promise.all([l("/settings"),l("/auth/permissions").then(e=>e.permissions||[]).catch(()=>[]),l("/ai-assist").catch(()=>({chats:!0}))]),Q.rows)}catch(e){if(!m())return;a.querySelector(".dm-loading-slot").textContent=`Could not load the settings: ${e.message||e}`;return}if(!m())return;const h=f.includes("settings")||f.includes("settings.update");v?.chats===!1&&x(c,"settings",{chats:!1});const g=M.observable(T(u)),A=g.peek(),s=Object.fromEntries(Object.entries(A).map(([e,t])=>[e,M.observable(t)])),y=()=>Object.fromEntries(Object.entries(s).map(([e,t])=>[e,t.peek()])),j=()=>Object.fromEntries(Object.entries(s).map(([e,t])=>[e,t.value])),L=M.observable(k(A)),d=M.observable(!1),b=M.computed(()=>k(j())!==L.value),B=M.computed(()=>P(j())),D=M.computed(()=>`${s.aiContext.value.length} / ${K.context}`),H=M.computed(()=>`${s.aiRules.value.length} / ${K.rules}`),F=a.querySelector("#aia-admin-character");for(const e of Z(_))F.append(new Option(e.label,e.value));F.value=s.adminCharacter.peek();async function w(){if(d.peek()||!h)return;const e=P(y());if(e){E.toast(e,{type:"error"});return}d.value=!0;try{await l("/settings",{method:"PUT",body:JSON.stringify(N(y()))});const t=await l("/settings").catch(()=>({...u,...N(y())}));if(!m())return;u=t;const S=T(t);for(const[W,Y]of Object.entries(S))s[W].value=Y;g.value=S,L.value=k(S),window.dispatchEvent(new Event("admin-assistant:settings")),E.toast("AI Assist settings saved",{type:"success"})}catch(t){E.toast(`Not saved: ${t.message||t}`,{type:"error"})}finally{d.value=!1}}function V(){for(const[e,t]of Object.entries(g.peek()))s[e].value=t}O.value=!1;const J=M.applyBindings({...s,loading:O,dirty:b,saving:d,problem:B,contextCount:D,rulesCount:H,canEdit:h,chatsOn:v?.chats!==!1},a,{methods:{save:()=>w(),discard:()=>V()}});o(()=>J.dispose()),o(G(a,{position:"bottom"})),h&&z(r,{id:"ai-assist-save",icon:"save",title:"Save (Ctrl+S)",onClick:()=>w()});const $=e=>{!(e.ctrlKey||e.metaKey)||e.key!=="s"||(e.preventDefault(),e.stopImmediatePropagation(),w())};document.addEventListener("keydown",$,!0),o(()=>document.removeEventListener("keydown",$,!0));const q=e=>{b.peek()&&(e.preventDefault(),e.returnValue="")};window.addEventListener("beforeunload",q),o(()=>window.removeEventListener("beforeunload",q)),n={dirty:()=>b.peek(),dispose(){p=!0,i.splice(0).reverse().forEach(e=>{try{e()}catch{}})}},I.scan(a)}};
|
package/admin/js/views/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const i={templateUrl:"",async onMount(){location.hash="#/menus"}};export const viewLoaders={projects:()=>import("./projects.js").then(e=>e.projectsView),projectDetail:()=>import("./project-detail.js").then(e=>e.projectDetailView),projectSettings:()=>import("./project-settings.js").then(e=>e.projectSettingsView),apiTokens:()=>import("./api-tokens.js").then(e=>e.apiTokensView),apiEndpoints:()=>import("./api-endpoints.js").then(e=>e.apiEndpointsView),apiEndpointEditor:()=>import("./api-endpoint-editor.js").then(e=>e.apiEndpointEditorView),dashboard:()=>import("./dashboard.js").then(e=>e.dashboardView),dashboards:()=>import("./dashboards.js").then(e=>e.dashboardsView),pages:()=>import("./pages.js").then(e=>e.pagesView),pageEditor:()=>import("./page-editor.js").then(e=>e.pageEditorView),appearance:()=>import("./appearance.js").then(e=>e.appearanceView),footer:()=>import("./footer.js").then(e=>e.footerView),settings:()=>import("./settings.js").then(e=>e.settingsView),theme:()=>import("./theme.js").then(e=>e.themeView),layouts:()=>import("./layouts.js").then(e=>e.layoutsView),media:()=>import("./media.js").then(e=>e.mediaView),login:()=>import("./login.js").then(e=>e.loginView),users:()=>import("./users.js").then(e=>e.usersView),userEditor:()=>import("./user-editor.js").then(e=>e.userEditorView),plugins:()=>import("./plugins.js").then(e=>e.pluginsView),pluginCode:()=>import("./plugin-code.js").then(e=>e.pluginCodeView),documentation:()=>import("./documentation.js").then(e=>e.documentationView),tutorials:()=>import("./tutorials.js").then(e=>e.tutorialsView),apiReference:()=>import("./api-reference.js").then(e=>e.apiReferenceView),collections:()=>import("./collections.js").then(e=>e.collectionsView),collectionEditor:()=>import("./collection-editor.js").then(e=>e.collectionEditorView),collectionEntries:()=>import("./collection-entries.js").then(e=>e.collectionEntriesView),forms:()=>import("./forms.js").then(e=>e.formsView),formEditor:()=>import("./form-editor.js").then(e=>e.formEditorView),formSubmissions:()=>import("./form-submissions.js").then(e=>e.formSubmissionsView),viewsList:()=>import("./views-list.js").then(e=>e.viewsListView),viewEditor:()=>import("./view-editor.js").then(e=>e.viewEditorView),viewPreview:()=>import("./view-preview.js").then(e=>e.viewPreviewView),actionsList:()=>import("./actions-list.js").then(e=>e.actionsListView),actionEditor:()=>import("./action-editor.js").then(e=>e.actionEditorView),proDocs:()=>import("./pro-docs.js").then(e=>e.proDocsView),blocks:()=>import("./blocks.js").then(e=>e.blocksView),components:()=>import("./components.js").then(e=>e.componentsView),myProfile:()=>import("./my-profile.js").then(e=>e.myProfileView),roles:()=>import("./roles.js").then(e=>e.rolesView),roleEditor:()=>import("./role-editor.js").then(e=>e.roleEditorView),effects:()=>import("./effects.js").then(e=>e.effectsView),search:()=>import("./search.js").then(e=>e.searchView),contentApi:()=>import("./content-api.js").then(e=>e.contentApiView),notes:()=>import("./notes.js").then(e=>e.notesView),chats:()=>import("./chats.js").then(e=>e.chatsView),chatKnowledge:()=>import("./chat-knowledge.js").then(e=>e.chatKnowledgeView),aiAssistChats:()=>import("./chats.js").then(e=>e.chatsView),aiAssistKnowledge:()=>import("./chat-knowledge.js").then(e=>e.chatKnowledgeView),aiAssistSettings:()=>import("./ai-assist-settings.js").then(e=>e.aiAssistSettingsView),todo:()=>import("./todo.js").then(e=>e.todoView),calculator:()=>import("../lib/calculator.js").then(e=>e.calculatorView),analytics:()=>import("./analytics.js").then(e=>e.analyticsView),seo:()=>import("./seo.js").then(e=>e.seoView),wordpressImport:()=>import("./wordpress-import.js").then(e=>e.wordpressImportView),contacts:()=>import("./contacts.js").then(e=>e.contactsView),callNew:()=>import("./call-new.js").then(e=>e.callNewView),notifications:()=>import("./notifications.js").then(e=>e.notificationsView),menus:()=>import("./menus.js").then(e=>e.menusView),contextMenus:()=>import("./context-menus.js").then(e=>e.contextMenusView),launchers:()=>import("./launchers.js").then(e=>e.launchersView),contextMenuEditor:()=>import("./context-menu-editor.js").then(e=>e.contextMenuEditorView),menuEditor:()=>import("./menu-editor.js").then(e=>e.menuEditorView),menuLocations:()=>import("./menu-locations.js").then(e=>e.menuLocationsView),menusRedirect:async()=>i,pluginGuides:()=>import("./plugin-guides.js").then(e=>e.pluginGuidesView),pluginGuide:()=>import("./plugin-guides.js").then(e=>e.pluginGuideView)};for(const e of["tutorialCrud","tutorialPlugin","tutorialEditor","tutorialForms","componentsReference","componentsHowto","componentsWalkthrough","componentsRules","usagePages","usageMedia","usageNavigation","usageDconfig","usageShortcodes","usageSiteSettings","usagePlugins","usageUsersRoles","usageViews","usageActions","usageCtaShortcode","usageEditions","usageCollections","usageBlocks","usageTools","usageDashboard","usageSearchEngines","usageLaunchers","usageChat","apiRefAuthentication","apiRefPages","apiRefSettings","apiRefLayouts","apiRefNavigation","apiRefMedia","apiRefUsers","apiRefPlugins","apiRefCollections","apiRefViews","apiRefActions","apiRefForms","apiRefScaffold","apiRefExternal","apiRefContent","apiRefBuilder"])viewLoaders[e]=()=>import("./doc-pages.js").then(t=>t.docViews[e]);
|
|
1
|
+
const i={templateUrl:"",async onMount(){location.hash="#/menus"}};export const viewLoaders={projects:()=>import("./projects.js").then(e=>e.projectsView),projectDetail:()=>import("./project-detail.js").then(e=>e.projectDetailView),projectSettings:()=>import("./project-settings.js").then(e=>e.projectSettingsView),apiTokens:()=>import("./api-tokens.js").then(e=>e.apiTokensView),apiEndpoints:()=>import("./api-endpoints.js").then(e=>e.apiEndpointsView),apiEndpointEditor:()=>import("./api-endpoint-editor.js").then(e=>e.apiEndpointEditorView),dashboard:()=>import("./dashboard.js").then(e=>e.dashboardView),dashboards:()=>import("./dashboards.js").then(e=>e.dashboardsView),pages:()=>import("./pages.js").then(e=>e.pagesView),pageEditor:()=>import("./page-editor.js").then(e=>e.pageEditorView),appearance:()=>import("./appearance.js").then(e=>e.appearanceView),footer:()=>import("./footer.js").then(e=>e.footerView),settings:()=>import("./settings.js").then(e=>e.settingsView),theme:()=>import("./theme.js").then(e=>e.themeView),layouts:()=>import("./layouts.js").then(e=>e.layoutsView),media:()=>import("./media.js").then(e=>e.mediaView),login:()=>import("./login.js").then(e=>e.loginView),users:()=>import("./users.js").then(e=>e.usersView),userEditor:()=>import("./user-editor.js").then(e=>e.userEditorView),plugins:()=>import("./plugins.js").then(e=>e.pluginsView),pluginCode:()=>import("./plugin-code.js").then(e=>e.pluginCodeView),documentation:()=>import("./documentation.js").then(e=>e.documentationView),tutorials:()=>import("./tutorials.js").then(e=>e.tutorialsView),apiReference:()=>import("./api-reference.js").then(e=>e.apiReferenceView),collections:()=>import("./collections.js").then(e=>e.collectionsView),collectionEditor:()=>import("./collection-editor.js").then(e=>e.collectionEditorView),collectionEntries:()=>import("./collection-entries.js").then(e=>e.collectionEntriesView),forms:()=>import("./forms.js").then(e=>e.formsView),formEditor:()=>import("./form-editor.js").then(e=>e.formEditorView),formSubmissions:()=>import("./form-submissions.js").then(e=>e.formSubmissionsView),viewsList:()=>import("./views-list.js").then(e=>e.viewsListView),viewEditor:()=>import("./view-editor.js").then(e=>e.viewEditorView),viewPreview:()=>import("./view-preview.js").then(e=>e.viewPreviewView),actionsList:()=>import("./actions-list.js").then(e=>e.actionsListView),actionEditor:()=>import("./action-editor.js").then(e=>e.actionEditorView),proDocs:()=>import("./pro-docs.js").then(e=>e.proDocsView),blocks:()=>import("./blocks.js").then(e=>e.blocksView),components:()=>import("./components.js").then(e=>e.componentsView),myProfile:()=>import("./my-profile.js").then(e=>e.myProfileView),roles:()=>import("./roles.js").then(e=>e.rolesView),roleEditor:()=>import("./role-editor.js").then(e=>e.roleEditorView),effects:()=>import("./effects.js").then(e=>e.effectsView),search:()=>import("./search.js").then(e=>e.searchView),contentApi:()=>import("./content-api.js").then(e=>e.contentApiView),notes:()=>import("./notes.js").then(e=>e.notesView),chats:()=>import("./chats.js").then(e=>e.chatsView),chatKnowledge:()=>import("./chat-knowledge.js").then(e=>e.chatKnowledgeView),aiAssistChats:()=>import("./chats.js").then(e=>e.chatsView),aiAssistKnowledge:()=>import("./chat-knowledge.js").then(e=>e.chatKnowledgeView),aiAssistSettings:()=>import("./ai-assist-settings.js").then(e=>e.aiAssistSettingsView),aiAssistBuilders:()=>import("./ai-assist-builders.js").then(e=>e.aiAssistBuildersView),todo:()=>import("./todo.js").then(e=>e.todoView),calculator:()=>import("../lib/calculator.js").then(e=>e.calculatorView),analytics:()=>import("./analytics.js").then(e=>e.analyticsView),seo:()=>import("./seo.js").then(e=>e.seoView),wordpressImport:()=>import("./wordpress-import.js").then(e=>e.wordpressImportView),contacts:()=>import("./contacts.js").then(e=>e.contactsView),callNew:()=>import("./call-new.js").then(e=>e.callNewView),notifications:()=>import("./notifications.js").then(e=>e.notificationsView),menus:()=>import("./menus.js").then(e=>e.menusView),contextMenus:()=>import("./context-menus.js").then(e=>e.contextMenusView),launchers:()=>import("./launchers.js").then(e=>e.launchersView),contextMenuEditor:()=>import("./context-menu-editor.js").then(e=>e.contextMenuEditorView),menuEditor:()=>import("./menu-editor.js").then(e=>e.menuEditorView),menuLocations:()=>import("./menu-locations.js").then(e=>e.menuLocationsView),menusRedirect:async()=>i,pluginGuides:()=>import("./plugin-guides.js").then(e=>e.pluginGuidesView),pluginGuide:()=>import("./plugin-guides.js").then(e=>e.pluginGuideView)};for(const e of["tutorialCrud","tutorialPlugin","tutorialEditor","tutorialForms","componentsReference","componentsHowto","componentsWalkthrough","componentsRules","usagePages","usageMedia","usageNavigation","usageDconfig","usageShortcodes","usageSiteSettings","usagePlugins","usageUsersRoles","usageViews","usageActions","usageCtaShortcode","usageEditions","usageCollections","usageBlocks","usageTools","usageDashboard","usageSearchEngines","usageLaunchers","usageChat","apiRefAuthentication","apiRefPages","apiRefSettings","apiRefLayouts","apiRefNavigation","apiRefMedia","apiRefUsers","apiRefPlugins","apiRefCollections","apiRefViews","apiRefActions","apiRefForms","apiRefScaffold","apiRefExternal","apiRefContent","apiRefBuilder"])viewLoaders[e]=()=>import("./doc-pages.js").then(t=>t.docViews[e]);
|
package/admin/js/views/login.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{api as l,isAuthenticated as A,setAuthData as f,takePendingLogout as D}from"../api.js";import{themesInDisplayOrder as O}from"../lib/themes.js";import{enhancePasswordFields as b}from"../lib/password-field.js";import{challengeText as g,loginBrandFromStatus as S,minutesText as j,passwordVerdict as z,readLoginHash as H,resetTokenFrom as N}from"../lib/login-arrange.js";import{viewLifetime as V}from"../lib/tool-kit.js";import{applyAdminBrand as W}from"../lib/admin-brand.js";import{isDarkAdminTheme as Y}from"../lib/theme-aware-logo.js";const K={name:{type:"string",required:!0,minLength:2,label:"Full Name",formConfig:{placeholder:"Your name",autocomplete:"name"}},email:{type:"email",required:!0,label:"Email Address",formConfig:{placeholder:"admin@example.com",autocomplete:"email"}},password:{type:"password",required:!0,minLength:8,label:"Password",formConfig:{placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",autocomplete:"new-password",tooltip:"Minimum 8 characters"}}},U={email:{type:"email",required:!0,label:"Email Address",formConfig:{placeholder:"you@example.com",autocomplete:"email"}},password:{type:"password",required:!0,label:"Password",formConfig:{placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",autocomplete:"current-password"}}},G={email:{type:"email",required:!0,label:"Email Address",formConfig:{placeholder:"you@example.com",autocomplete:"email"}}},J={password:{type:"password",required:!0,minLength:8,label:"New Password",formConfig:{placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",autocomplete:"new-password"}},confirmPassword:{type:"password",required:!0,label:"Confirm Password",formConfig:{placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",autocomplete:"new-password"}}};let T=Promise.resolve();function Q(){let e;T=new Promise(o=>{e=o});const t=M.subscribe("router:afterChange",()=>{a(),e()}),a=()=>{typeof t=="function"&&t()};setTimeout(()=>{a(),e()},1500)}function y(e){T.then(()=>R.navigate(e))}const m=V(/^#\/(login|reset-password)(\?|$)/);function X(){const e=M.observable(null),t=M.observable("code"),a=M.observable(S()),o=M.observable("");return{step:M.observable(""),siteTitle:M.observable("Domma CMS"),brand:a,brandTheme:o,brandLogo:M.computed(()=>{o.value;const r=a.value;return Y()?r.logoDark||r.logo:r.logo||r.logoDark}),notice:M.observable(""),byEmail:M.observable(!0),expiresIn:M.observable(""),obTitle:M.observable(""),obTagline:M.observable(""),obSiteError:M.observable(""),obSiteSaving:M.observable(!1),themes:O(),theme:M.observable("charcoal-dark"),obThemeError:M.observable(""),obThemeSaving:M.observable(!1),chChallenge:e,chMode:t,chTitle:M.computed(()=>e.value?.title||"One more step"),chLabel:M.computed(()=>g(e.value,t.value).label),chHelp:M.computed(()=>g(e.value,t.value).help),chInputMode:M.computed(()=>g(e.value,t.value).inputMode),chImage:M.computed(()=>e.value?.image||""),chSecret:M.computed(()=>e.value?.secret||""),chCanTrust:M.computed(()=>e.value?.trust===!0),chCanRecover:M.computed(()=>e.value?.recovery===!0),chCode:M.observable(""),chTrust:M.observable(!1),chError:M.observable(""),chBusy:M.observable(!1),resetEmail:M.observable(""),resetExpiry:M.observable(""),resetLines:M.observable([])}}function w(e,t={}){e.byEmail.value=t.resetByEmail!==!1,e.expiresIn.value=t.resetExpiresIn||"";const a=S(t);e.brand.value=a,e.siteTitle.value=a.title,W(a)}export const loginView={templateUrl:"/admin/js/templates/login.html",async onMount(e){m.reset(),Q();const t=D(),a=window.location.hash,{next:o,expired:r}=H(a);if(A()){y(a.startsWith("#/reset-password")?"/":o);return}const n=e.get(0).querySelector(".login-wrap")||e.get(0),u=X(),c={state:u,root:n,next:o,token:"",email:"",pw:{problems:[],asked:0,timer:null}},p=M.applyBindings(u,n,{methods:Z(c)});if(m.add(()=>p.dispose()),m.add(()=>clearTimeout(c.pw.timer)),m.add(M.effect(()=>{u.step.value;const s=u.brand.value;requestAnimationFrame(()=>{if(!n.isConnected)return;const d=n.querySelector(".login-brand-icon"),i=I.render(s.icon,{size:32})||I.render("layout",{size:32});d&&i&&d.replaceChildren(i),I.scan(n)})})),m.add(Domma.theme.onChange(()=>{u.brandTheme.value=Domma.theme.get()})),a.startsWith("#/reset-password")){await ae(c,N(a));return}let h=!1;const v=E.loader(e.get(0),{type:"dots"});try{const s=await l.auth.setupStatus();h=s.needsSetup,w(u,s)}catch{E.toast("Could not reach the server.",{type:"error"})}finally{v.destroy()}h?(u.step.value="setup",_(c)):(u.step.value="login",k(c),r&&!t&&(u.notice.value="Your session ended - sign in again to carry on where you were."))}};function Z(e){const{state:t}=e,a=o=>r=>{r?.preventDefault?.(),o()};return{skipSite:a(()=>{t.step.value="onboarding-theme"}),saveSite:()=>$(t),pickTheme:o=>{t.theme.value=o},skipTheme:a(()=>{t.step.value="onboarding-done"}),saveTheme:()=>ee(t),backToLogin:a(()=>{t.step.value="login"}),forgot:a(()=>{const o=String(e.root.querySelector('#login-form-container input[type="email"]')?.value||"").trim();t.step.value="forgot",q(e,o)}),toggleRecovery:a(()=>C(t,t.chMode.value==="code"?"recovery":"code")),copySecret:async()=>{try{await navigator.clipboard.writeText(String(t.chSecret.value).replace(/\s+/g,"")),E.toast("Key copied.",{type:"success"})}catch{E.toast("Could not copy - select the key and copy it.",{type:"warning"})}},verify:o=>{o?.preventDefault?.(),te(e)},newLink:a(async()=>{try{w(t,await l.auth.setupStatus())}catch{}t.step.value="forgot",q(e)}),signInAfterReset:a(()=>{t.step.value="login",k(e,{email:e.email})})}}function _(e){F.render("#setup-form-container",K,{},{layout:"stacked",submitText:"Create admin account",onSubmit:async t=>{try{const a=await l.auth.setup(t);f(a),e.state.step.value="onboarding-site"}catch(a){return E.toast(a.message||"Setup failed. Please try again.",{type:"error"}),!1}}}),b(e.root.querySelector("#setup-form-container"))}async function $(e){e.obSiteError.value="";const t=e.obTitle.value.trim(),a=e.obTagline.value.trim();e.obSiteSaving.value=!0;try{const o=await l.settings.get();await l.settings.save({...o,title:t||o.title,tagline:a||o.tagline,brand:{...o.brand||{},text:t||o.brand?.text||o.title},seo:{...o.seo||{},defaultTitle:t||o.seo&&o.seo.defaultTitle}}),e.step.value="onboarding-theme"}catch(o){e.obSiteError.value=o.message||"Could not save site details."}finally{e.obSiteSaving.value=!1}}async function ee(e){e.obThemeError.value="",e.obThemeSaving.value=!0;try{await l.theme.save({theme:e.theme.value||"charcoal-dark"}),e.step.value="onboarding-done"}catch(t){e.obThemeError.value=t.message||"Could not save theme."}finally{e.obThemeSaving.value=!1}}function k(e,{email:t=""}={}){F.render("#login-form-container",U,t?{email:t}:{},{layout:"stacked",submitText:"Sign in",onSubmit:async a=>{try{const o=await l.auth.login(a);if(o?.challenge&&o.ticket)return x(e,o),!1;f(o),y(e.next)}catch(o){return E.toast(o.message||"Invalid credentials. Please try again.",{type:"error"}),!1}}}),b(e.root.querySelector("#login-form-container"))}function x(e,{challenge:t,ticket:a}){const{state:o}=e;e.ticket=a,o.chChallenge.value=t||{},o.chTrust.value=!1,C(o,"code"),o.step.value="challenge"}function C(e,t){e.chMode.value=t,e.chCode.value="",e.chError.value="",setTimeout(()=>document.getElementById("challenge-code")?.focus(),0)}async function te(e){const{state:t}=e;t.chBusy.value=!0;try{const a=await l.auth.verifyLogin({ticket:e.ticket,response:String(t.chCode.value||"").trim(),mode:t.chMode.value,trust:t.chTrust.value===!0});if(a?.challenge&&a.ticket){x(e,a);return}f(a),y(e.next)}catch(a){const o=a.message||"That did not match.";t.chError.value=o,/sign in again/i.test(o)&&setTimeout(()=>{t.step.value="login"},1800)}finally{t.chBusy.value=!1}}function q(e,t=""){const{state:a}=e;a.byEmail.value&&F.render("#forgot-form-container",G,t?{email:t}:{},{layout:"stacked",submitText:"Send reset link",onSubmit:async o=>{try{const r=await l.auth.forgotPassword(o.email);r?.expiresIn&&(a.expiresIn.value=r.expiresIn)}catch{}a.step.value="forgot-success"}})}async function ae(e,t){const{state:a}=e;if(!t){a.step.value="reset-invalid";return}const o=E.loader(e.root,{type:"dots"});let r;l.auth.setupStatus().then(n=>w(a,n)).catch(()=>{});try{r=await l.auth.checkReset(t)}catch{a.step.value="reset-invalid";return}finally{o.destroy()}e.token=t,e.email=r.email||"",a.resetEmail.value=e.email,a.resetExpiry.value=j(r.minutesLeft),a.step.value="reset",oe(e)}function oe(e){const{state:t,token:a,email:o,pw:r}=e,n=e.root.querySelector("#reset-form-container"),u=()=>({password:String(n.querySelector('input[name="password"]')?.value||""),confirm:String(n.querySelector('input[name="confirmPassword"]')?.value||"")}),c=()=>{const{password:s,confirm:d}=u(),i=z({password:s,confirm:d,problems:r.problems}),L=[...i.messages,...i.mismatch?["The two passwords do not match yet."]:[]];return t.resetLines.value=s?L.map((P,B)=>({id:B,text:P})):[],i},p=async()=>{const{password:s}=u(),d=++r.asked;if(s.length<8){r.problems=[],c();return}try{const i=await l.auth.checkReset(a,s);d===r.asked&&(r.problems=i.problems||[])}catch(i){if(i.body?.expired){t.step.value="reset-invalid";return}}d===r.asked&&c()};F.render("#reset-form-container",J,{},{layout:"stacked",submitText:"Set new password",onSubmit:async s=>{await p();const d=c();if(!d.ok)return E.toast(d.mismatch?"The passwords do not match.":"That password does not meet the rules below.",{type:"error"}),!1;try{await l.auth.resetPassword(a,s.password),history.replaceState(null,"","#/reset-password"),t.step.value="reset-done"}catch(i){return i.body?.expired?(t.step.value="reset-invalid",!1):(r.problems=i.body?.problems||[],c(),E.toast(i.message||"The password was not changed.",{type:"error"}),!1)}}});const h=n.querySelector("form")||n;if(o){const s=document.createElement("input");s.type="email",s.name="username",s.autocomplete="username",s.value=o,s.readOnly=!0,s.hidden=!0,h.prepend(s)}b(n);const v=s=>{s.target.matches?.('input[type="password"], input[name="password"], input[name="confirmPassword"]')&&(s.target.name==="password"&&(r.problems=[]),c(),clearTimeout(r.timer),s.target.name==="password"&&(r.timer=setTimeout(p,400)))};n.addEventListener("input",v),m.add(()=>n.removeEventListener("input",v))}
|
|
1
|
+
import{api as u,isAuthenticated as D,setAuthData as f,takePendingLogout as O}from"../api.js";import{themesInDisplayOrder as j}from"../lib/themes.js";import{enhancePasswordFields as b}from"../lib/password-field.js";import{challengeText as g,loginBrandFromStatus as S,minutesText as z,passwordVerdict as H,readLoginHash as N,resetTokenFrom as V}from"../lib/login-arrange.js";import{viewLifetime as W}from"../lib/tool-kit.js";import{applyAdminBrand as Y}from"../lib/admin-brand.js";import{isDarkAdminTheme as K}from"../lib/theme-aware-logo.js";import{applyAdminTheme as T}from"../lib/admin-theme.js";const U={name:{type:"string",required:!0,minLength:2,label:"Full Name",formConfig:{placeholder:"Your name",autocomplete:"name"}},email:{type:"email",required:!0,label:"Email Address",formConfig:{placeholder:"admin@example.com",autocomplete:"email"}},password:{type:"password",required:!0,minLength:8,label:"Password",formConfig:{placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",autocomplete:"new-password",tooltip:"Minimum 8 characters"}}},G={email:{type:"email",required:!0,label:"Email Address",formConfig:{placeholder:"you@example.com",autocomplete:"email"}},password:{type:"password",required:!0,label:"Password",formConfig:{placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",autocomplete:"current-password"}}},J={email:{type:"email",required:!0,label:"Email Address",formConfig:{placeholder:"you@example.com",autocomplete:"email"}}},Q={password:{type:"password",required:!0,minLength:8,label:"New Password",formConfig:{placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",autocomplete:"new-password"}},confirmPassword:{type:"password",required:!0,label:"Confirm Password",formConfig:{placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",autocomplete:"new-password"}}};let k=Promise.resolve();function X(){let e;k=new Promise(o=>{e=o});const t=M.subscribe("router:afterChange",()=>{a(),e()}),a=()=>{typeof t=="function"&&t()};setTimeout(()=>{a(),e()},1500)}function y(e){k.then(()=>R.navigate(e))}const d=W(/^#\/(login|reset-password)(\?|$)/);function Z(){const e=M.observable(null),t=M.observable("code"),a=M.observable(S()),o=M.observable("");return{step:M.observable(""),siteTitle:M.observable("Domma CMS"),brand:a,brandTheme:o,brandLogo:M.computed(()=>{o.value;const r=a.value;return K()?r.logoDark||r.logo:r.logo||r.logoDark}),notice:M.observable(""),byEmail:M.observable(!0),expiresIn:M.observable(""),obTitle:M.observable(""),obTagline:M.observable(""),obSiteError:M.observable(""),obSiteSaving:M.observable(!1),themes:j(),theme:M.observable("charcoal-dark"),obThemeError:M.observable(""),obThemeSaving:M.observable(!1),chChallenge:e,chMode:t,chTitle:M.computed(()=>e.value?.title||"One more step"),chLabel:M.computed(()=>g(e.value,t.value).label),chHelp:M.computed(()=>g(e.value,t.value).help),chInputMode:M.computed(()=>g(e.value,t.value).inputMode),chImage:M.computed(()=>e.value?.image||""),chSecret:M.computed(()=>e.value?.secret||""),chCanTrust:M.computed(()=>e.value?.trust===!0),chCanRecover:M.computed(()=>e.value?.recovery===!0),chCode:M.observable(""),chTrust:M.observable(!1),chError:M.observable(""),chBusy:M.observable(!1),resetEmail:M.observable(""),resetExpiry:M.observable(""),resetLines:M.observable([])}}function w(e,t={}){T(t.adminTheme||{dommaTheme:"charcoal-light"}),e.byEmail.value=t.resetByEmail!==!1,e.expiresIn.value=t.resetExpiresIn||"";const a=S(t);e.brand.value=a,e.siteTitle.value=a.title,Y(a)}export const loginView={templateUrl:"/admin/js/templates/login.html",async onMount(e){d.reset(),X();const t=O(),a=window.location.hash,{next:o,expired:r}=N(a);if(D()){y(a.startsWith("#/reset-password")?"/":o);return}const i=e.get(0).querySelector(".login-wrap")||e.get(0),l=Z(),c={state:l,root:i,next:o,token:"",email:"",pw:{problems:[],asked:0,timer:null}},p=M.applyBindings(l,i,{methods:_(c)});if(d.add(()=>p.dispose()),d.add(()=>clearTimeout(c.pw.timer)),d.add(M.effect(()=>{l.step.value;const s=l.brand.value;requestAnimationFrame(()=>{if(!i.isConnected)return;const m=i.querySelector(".login-brand-icon"),n=I.render(s.icon,{size:32})||I.render("layout",{size:32});m&&n&&m.replaceChildren(n),I.scan(i)})})),d.add(Domma.theme.onChange(()=>{l.brandTheme.value=Domma.theme.get()})),a.startsWith("#/reset-password")){try{w(l,await u.auth.setupStatus())}catch{T({dommaTheme:"charcoal-light"})}await oe(c,V(a));return}let h=!1;const v=E.loader(e.get(0),{type:"dots"});try{const s=await u.auth.setupStatus();h=s.needsSetup,w(l,s)}catch{E.toast("Could not reach the server.",{type:"error"})}finally{v.destroy()}h?(l.step.value="setup",$(c)):(l.step.value="login",x(c),r&&!t&&(l.notice.value="Your session ended - sign in again to carry on where you were."))}};function _(e){const{state:t}=e,a=o=>r=>{r?.preventDefault?.(),o()};return{skipSite:a(()=>{t.step.value="onboarding-theme"}),saveSite:()=>ee(t),pickTheme:o=>{t.theme.value=o},skipTheme:a(()=>{t.step.value="onboarding-done"}),saveTheme:()=>te(t),backToLogin:a(()=>{t.step.value="login"}),forgot:a(()=>{const o=String(e.root.querySelector('#login-form-container input[type="email"]')?.value||"").trim();t.step.value="forgot",L(e,o)}),toggleRecovery:a(()=>q(t,t.chMode.value==="code"?"recovery":"code")),copySecret:async()=>{try{await navigator.clipboard.writeText(String(t.chSecret.value).replace(/\s+/g,"")),E.toast("Key copied.",{type:"success"})}catch{E.toast("Could not copy - select the key and copy it.",{type:"warning"})}},verify:o=>{o?.preventDefault?.(),ae(e)},newLink:a(async()=>{try{w(t,await u.auth.setupStatus())}catch{}t.step.value="forgot",L(e)}),signInAfterReset:a(()=>{t.step.value="login",x(e,{email:e.email})})}}function $(e){F.render("#setup-form-container",U,{},{layout:"stacked",submitText:"Create admin account",onSubmit:async t=>{try{const a=await u.auth.setup(t);f(a),e.state.step.value="onboarding-site"}catch(a){return E.toast(a.message||"Setup failed. Please try again.",{type:"error"}),!1}}}),b(e.root.querySelector("#setup-form-container"))}async function ee(e){e.obSiteError.value="";const t=e.obTitle.value.trim(),a=e.obTagline.value.trim();e.obSiteSaving.value=!0;try{const o=await u.settings.get();await u.settings.save({...o,title:t||o.title,tagline:a||o.tagline,brand:{...o.brand||{},text:t||o.brand?.text||o.title},seo:{...o.seo||{},defaultTitle:t||o.seo&&o.seo.defaultTitle}}),e.step.value="onboarding-theme"}catch(o){e.obSiteError.value=o.message||"Could not save site details."}finally{e.obSiteSaving.value=!1}}async function te(e){e.obThemeError.value="",e.obThemeSaving.value=!0;try{await u.theme.save({theme:e.theme.value||"charcoal-dark"}),e.step.value="onboarding-done"}catch(t){e.obThemeError.value=t.message||"Could not save theme."}finally{e.obThemeSaving.value=!1}}function x(e,{email:t=""}={}){F.render("#login-form-container",G,t?{email:t}:{},{layout:"stacked",submitText:"Sign in",onSubmit:async a=>{try{const o=await u.auth.login(a);if(o?.challenge&&o.ticket)return C(e,o),!1;f(o),y(e.next)}catch(o){return E.toast(o.message||"Invalid credentials. Please try again.",{type:"error"}),!1}}}),b(e.root.querySelector("#login-form-container"))}function C(e,{challenge:t,ticket:a}){const{state:o}=e;e.ticket=a,o.chChallenge.value=t||{},o.chTrust.value=!1,q(o,"code"),o.step.value="challenge"}function q(e,t){e.chMode.value=t,e.chCode.value="",e.chError.value="",setTimeout(()=>document.getElementById("challenge-code")?.focus(),0)}async function ae(e){const{state:t}=e;t.chBusy.value=!0;try{const a=await u.auth.verifyLogin({ticket:e.ticket,response:String(t.chCode.value||"").trim(),mode:t.chMode.value,trust:t.chTrust.value===!0});if(a?.challenge&&a.ticket){C(e,a);return}f(a),y(e.next)}catch(a){const o=a.message||"That did not match.";t.chError.value=o,/sign in again/i.test(o)&&setTimeout(()=>{t.step.value="login"},1800)}finally{t.chBusy.value=!1}}function L(e,t=""){const{state:a}=e;a.byEmail.value&&F.render("#forgot-form-container",J,t?{email:t}:{},{layout:"stacked",submitText:"Send reset link",onSubmit:async o=>{try{const r=await u.auth.forgotPassword(o.email);r?.expiresIn&&(a.expiresIn.value=r.expiresIn)}catch{}a.step.value="forgot-success"}})}async function oe(e,t){const{state:a}=e;if(!t){a.step.value="reset-invalid";return}const o=E.loader(e.root,{type:"dots"});let r;try{r=await u.auth.checkReset(t)}catch{a.step.value="reset-invalid";return}finally{o.destroy()}e.token=t,e.email=r.email||"",a.resetEmail.value=e.email,a.resetExpiry.value=z(r.minutesLeft),a.step.value="reset",re(e)}function re(e){const{state:t,token:a,email:o,pw:r}=e,i=e.root.querySelector("#reset-form-container"),l=()=>({password:String(i.querySelector('input[name="password"]')?.value||""),confirm:String(i.querySelector('input[name="confirmPassword"]')?.value||"")}),c=()=>{const{password:s,confirm:m}=l(),n=H({password:s,confirm:m,problems:r.problems}),P=[...n.messages,...n.mismatch?["The two passwords do not match yet."]:[]];return t.resetLines.value=s?P.map((B,A)=>({id:A,text:B})):[],n},p=async()=>{const{password:s}=l(),m=++r.asked;if(s.length<8){r.problems=[],c();return}try{const n=await u.auth.checkReset(a,s);m===r.asked&&(r.problems=n.problems||[])}catch(n){if(n.body?.expired){t.step.value="reset-invalid";return}}m===r.asked&&c()};F.render("#reset-form-container",Q,{},{layout:"stacked",submitText:"Set new password",onSubmit:async s=>{await p();const m=c();if(!m.ok)return E.toast(m.mismatch?"The passwords do not match.":"That password does not meet the rules below.",{type:"error"}),!1;try{await u.auth.resetPassword(a,s.password),history.replaceState(null,"","#/reset-password"),t.step.value="reset-done"}catch(n){return n.body?.expired?(t.step.value="reset-invalid",!1):(r.problems=n.body?.problems||[],c(),E.toast(n.message||"The password was not changed.",{type:"error"}),!1)}}});const h=i.querySelector("form")||i;if(o){const s=document.createElement("input");s.type="email",s.name="username",s.autocomplete="username",s.value=o,s.readOnly=!0,s.hidden=!0,h.prepend(s)}b(i);const v=s=>{s.target.matches?.('input[type="password"], input[name="password"], input[name="confirmPassword"]')&&(s.target.name==="password"&&(r.problems=[]),c(),clearTimeout(r.timer),s.target.name==="password"&&(r.timer=setTimeout(p,400)))};i.addEventListener("input",v),d.add(()=>i.removeEventListener("input",v))}
|
package/docs/DommaFeatures.md
CHANGED
|
@@ -1241,7 +1241,7 @@ The four Tools below were plugins until 0.67.0 and are now part of the CMS. They
|
|
|
1241
1241
|
- Admin: **Content > Chats** (`#/launchers/chats`, `#/launchers/chats/:id`) - the inbox, waiting first, the live thread (3s poll), replies with per-chat drafts, end/delete/email in a context menu, Available switch, settings cog; sidebar badge `/api/chats/_count` (live while someone waits, red after 5 minutes). **Chats > Knowledge** (`#/launchers/knowledge`) - entries with an editor slideover (question, other ways of asking, keywords, Markdown answer, up to five buttons, on/off), Try the bot with scores, and the Unanswered list (Make an entry, add to the closest entry, dismiss). Visitor panel `public/js/launcher-chat.mjs` `mountChat(container, {launcherId, title, chat})` + `public/css/launcher-chat.css`, domma-reactive.
|
|
1242
1242
|
- Permission `chats` (`read`, `reply`, `manage`) in the Tools group; Admin is granted it once. All of it is behind the Launchers switch.
|
|
1243
1243
|
- AI Assist (unreleased): the paid `ai-assist` Tool (Pro plan) calls `hooks.enableAiAssist()` (`services/aiAssist.js`, paid + closedSource only, off when the Tool is disabled). Without it `aiAvailable()` is false (chat config says `ai: false`, nothing is asked) and the admin assistant is unavailable (`requestAdminAnswer` 403). `GET /api/launchers/items` says `aiAssist`, and the launcher editor notes under AI answers when it is off. The Manager checks the `ai-assist` licence (no longer the Site Builder's).
|
|
1244
|
-
- Della's AI answers (unreleased; Pro plan, hosted sites): when the matcher says `none`, `services/chat/ai.js` `aiAnswer()` asks the Manager (`MANAGER_URL` + `FLEET_TOKEN`, `POST /api/fleet/launcher-chat`; on dcm the in-process registry `Symbol.for('domma.launcher-chat')`) with the site's name, `assistantBrief()` (site.json `assistant.context`/`rules` from Site Settings > General > AI assistant, plus the launcher's `chat.aiContext`/`aiRules`), the enabled non-sample Knowledge (most used first,
|
|
1244
|
+
- Della's AI answers (unreleased; Pro plan, hosted sites): when the matcher says `none`, `services/chat/ai.js` `aiAnswer()` asks the Manager (`MANAGER_URL` + `FLEET_TOKEN`, `POST /api/fleet/launcher-chat`; on dcm the in-process registry `Symbol.for('domma.launcher-chat')`) with the site's name, `assistantBrief()` (site.json `assistant.context`/`rules` from Site Settings > General > AI assistant, plus the launcher's `chat.aiContext`/`aiRules`), the enabled non-sample Knowledge (most used first, 48,000 characters), the last 10 visitor/bot messages and the question. A non-empty answer is stored as a bot message with `ai: true` (`misses` reset); empty or refused falls back to the usual "do not know". The question is still logged as unanswered. A 403 (no licence) backs off 10 minutes, a 429 (month used) 30 minutes, anything else 1 minute. Per launcher `chat.ai` (default on), `chat.aiUseSite` (default on; off = the launcher's own context only - the site's rules always apply), `chat.aiMaxPerChat` (20; `aiCount` on the session); the default bot name is now Della. A character's chat is called by the character's name, or by `chat.characterName` when set (admin: **Call her** under Use Della) - `characterChat()` in `public/js/characters.mjs` - so Della can be "Dash" on one launcher with her own artwork. Packs in `CHARACTERS`: dot, daisy, della, dash (Job Board) and remy (health care, Regimen; unreleased), each a 3x2 atlas in `public/images/characters/<id>-poses.png`. `aiContext`/`aiRules` never reach the page (`publicLauncher`). `/api/chat/config` says `ai` so the panel can say Della is an AI assistant. Manager side: `plugins/site-manager/services/launcherChatRoutes.js` (fleet token, the `ai-site-builder` licence, 2,000 answers per site per month counting "do not know", 4 at once) and `tools/launcher-chat` (Claude Haiku 5.5, low effort; fixed cached system prompt, then the owner's context and rules as a second system block; the visitor's words only in the user message; `LAUNCHER_CHAT_ANTHROPIC_KEY` read by the job alone).
|
|
1245
1245
|
- Saved chats (unreleased): preset `chat-saved` (in `CHAT_PRESET_SLUGS`, `chats.manage` through the generic API, kept out of site repos) - a copy of a chat with `note`, `outcome` (to look at / looking into it / done), visitor, page, dates, who saved it, `transcript` (plain text) and `messages`. `POST /api/chats/:id/save` (reply), `GET /api/chats/saved` and `/saved/:sid` (read), `PUT /saved/:sid` (reply; note, outcome), `DELETE /saved/:sid` (manage); at most 2,000 per site. Chats inbox: a **Saved** tab, the context-menu item **Save for a closer look…**, and an outcome/note bar on an open saved chat (`services/chat/saved.js`, `arrangeSaved()`).
|
|
1246
1246
|
- Visitor panel look (unreleased): bot and staff avatars, runs of messages grouped (name on the first, avatar on the last), gradient visitor bubbles, soft chips for links and choices, a rounded composer with the send button inside, messages easing in (still for reduced motion), and in a launcher panel the bot's avatar (with a dot while someone answers) and the status under the title. Panel 400 x 600. Per-chat branding: `chat.accent` / `chat.accentText` (a theme token or hex, `launcherColour`) and `chat.avatar` (a site address only, `launcherAvatar()`), in the page's chat block and `/api/chat/config`; the panel sets `--chat-accent` / `--chat-accent-text` on itself (`launcherChatAccentCss()`: a hex accent with no text colour gets black or white by contrast, a token its `--dm-<token>-text`), and the bot's picture replaces its initial in the heading, the typing row and its messages.
|
|
1247
1247
|
- Chat window and extras (unreleased): `chat.size` sm/md/lg/custom + `width`/`height` (`launcherChatBox()`; desktop only, clamped 300-720 x 380-900 and to the window), `chat.resizable` (a grip in the corner opposite the disc; size kept per launcher in the browser, `launcher-chat-size:<id>`, double-click resets), `chat.starters` (up to 4 buttons under the greeting; a tap within 1.7s of opening waits out the anti-bot window), `chat.personButton` below/header (an icon with a tooltip before the close button), greeting placeholders `{greeting}` `{timeofday}` `{day}` `{date}` `{time}` `{botname}` `{site}`, `chat.times` time/datetime/none on each message (`fillGreeting()`, the visitor's clock, text only), and `chat.keepDays` (0 = the site's `retentionDays`; the hourly tidy-up reads each launcher's).
|
|
@@ -764,6 +764,32 @@ nothing was stored (an end-form set not to record) - treat that as not sent. An
|
|
|
764
764
|
`meta.updatedAt` with `meta.createdAt` if the answers must be as sent. When the person's data is erased, use
|
|
765
765
|
`removeFormEntry`, and `formEntriesBy(form, userId)` for the entries they sent but your plugin never used. Feature-detect an older core: `import('../../server/services/formContext.js').catch(() => null)`.
|
|
766
766
|
|
|
767
|
+
## AI Assist: listing your AI chats
|
|
768
|
+
|
|
769
|
+
A Tool with its own AI chats (the Site Builder's conversations, the Tool Builder's builds) can list them on
|
|
770
|
+
**AI Assist › Builders**, so a site with AI Assist has every AI chat in one place. Declare it in `plugin.json`:
|
|
771
|
+
|
|
772
|
+
```json
|
|
773
|
+
"admin": {
|
|
774
|
+
"aiAssist": {
|
|
775
|
+
"label": "Site Builder",
|
|
776
|
+
"url": "#/plugins/ai-site-builder",
|
|
777
|
+
"list": "/api/plugins/ai-site-builder/conversations",
|
|
778
|
+
"permission": "ai-builder",
|
|
779
|
+
"character": "dot"
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
- `url` must be your own screen (`#/plugins/<name>...`) and `list` your own API (`/api/plugins/<name>/...`, no
|
|
785
|
+
query); anything else is skipped at load with a warning.
|
|
786
|
+
- The tab shows your entry only to people holding `permission` (the resource or any of its actions) whose admin
|
|
787
|
+
scope covers `url`, and reads `list` with **their** token - your route decides what each person sees.
|
|
788
|
+
- `list` answers `{items: [{id, title, updatedAt, status, startedBy}]}` (`{conversations}` and `{builds}` with the
|
|
789
|
+
same fields, or `plugin`/`displayName` for id/title, are read too).
|
|
790
|
+
- A chat opens at `<url>?open=<id>`: read `open` from `location.hash` when your view mounts and open that chat.
|
|
791
|
+
- Older engines ignore the block, so it is safe to ship before the engine has it.
|
|
792
|
+
|
|
767
793
|
## Dashboard widgets
|
|
768
794
|
|
|
769
795
|
With **Dashboard Pro**, admins build their own Dashboard from widgets the Tools offer. A widget ships
|
package/package.json
CHANGED
|
@@ -3,14 +3,22 @@ import {authenticate as defaultAuthenticate} from '../../middleware/auth.js';
|
|
|
3
3
|
import {getConfig} from '../../config.js';
|
|
4
4
|
import {siteAssistant} from '../../services/assistant.js';
|
|
5
5
|
import {adminAssistantConfig, adminAssistantContext, requestAdminAnswer} from '../../services/adminAssistant.js';
|
|
6
|
-
import {chatsHome, isAiAssist} from '../../services/aiAssist.js';
|
|
6
|
+
import {aiAssistBuildersFor, chatsHome, isAiAssist} from '../../services/aiAssist.js';
|
|
7
|
+
import {adminAccessFor} from '../../services/adminAccess.js';
|
|
8
|
+
import {covers} from '../../services/pluginScope.js';
|
|
7
9
|
import {isToolEnabled} from '../../services/tools.js';
|
|
8
10
|
|
|
9
11
|
export async function adminAssistantRoutes(fastify, {authenticate = defaultAuthenticate, contextFor = adminAssistantContext, settings = adminAssistantConfig, answer = requestAdminAnswer,
|
|
10
|
-
aiAssist = isAiAssist, chatsOn = () => isToolEnabled('launchers')} = {}) {
|
|
12
|
+
aiAssist = isAiAssist, chatsOn = () => isToolEnabled('launchers'), accessFor = adminAccessFor} = {}) {
|
|
11
13
|
const guard = {preHandler: [authenticate]};
|
|
12
14
|
// Whether this site has AI Assist (Pro) - the admin's screen, routes and pop-ups follow it.
|
|
13
|
-
|
|
15
|
+
// `builders`: the other Tools' AI chats this viewer may open (their own APIs still decide what is listed).
|
|
16
|
+
fastify.get('/ai-assist', guard, async (request) => {
|
|
17
|
+
const on = aiAssist() === true;
|
|
18
|
+
let builders = [];
|
|
19
|
+
if (on) { try { builders = aiAssistBuildersFor(accessFor(request.user), covers); } catch { builders = []; } }
|
|
20
|
+
return {on, chats: chatsOn() === true, chatsHome: chatsHome(), builders};
|
|
21
|
+
});
|
|
14
22
|
fastify.get('/admin-assistant/config', guard, async request => {
|
|
15
23
|
const cfg = settings();
|
|
16
24
|
if (!cfg.enabled) return {enabled: false};
|
|
@@ -27,6 +27,7 @@ import {getMenu} from '../../services/menus.js';
|
|
|
27
27
|
import {resolveAdminHome} from '../../services/adminHome.js';
|
|
28
28
|
import {adminAccessFor} from '../../services/adminAccess.js';
|
|
29
29
|
import {adminBrandFor} from '../../services/adminBrand.js';
|
|
30
|
+
import {adminThemePresentation, loadThemeConfig} from '../../services/themeSettings.js';
|
|
30
31
|
import {seesNotificationsScreen} from '../../services/adminPortal.js';
|
|
31
32
|
import {getAdminPortal} from '../../services/plugins.js';
|
|
32
33
|
import {authenticate, checkVisibility} from '../../middleware/auth.js';
|
|
@@ -80,7 +81,9 @@ export async function authRoutes(fastify) {
|
|
|
80
81
|
fastify.get('/auth/setup-status', async () => {
|
|
81
82
|
const count = await countUsers();
|
|
82
83
|
const site = getConfig('site') || {};
|
|
83
|
-
|
|
84
|
+
const theme = await loadThemeConfig();
|
|
85
|
+
return {needsSetup: count === 0, siteTitle: String(site.title || ''), adminBrand: adminBrandFor(site),
|
|
86
|
+
adminTheme: adminThemePresentation(theme.adminTheme, theme), resetByEmail: isSmtpConfigured(site.smtp),
|
|
84
87
|
resetExpiresIn: resetLifetime().text};
|
|
85
88
|
});
|
|
86
89
|
|
|
@@ -20,11 +20,10 @@ import {
|
|
|
20
20
|
requirePermission as defaultRequirePermission
|
|
21
21
|
} from '../../middleware/auth.js';
|
|
22
22
|
import {
|
|
23
|
-
|
|
23
|
+
adminThemePresentation,
|
|
24
24
|
compileOverrideCss,
|
|
25
25
|
getThemeTokenMap,
|
|
26
26
|
listCustomThemes,
|
|
27
|
-
resolveThemeClasses,
|
|
28
27
|
listThemeIds,
|
|
29
28
|
listThemeTokens,
|
|
30
29
|
loadThemeConfig,
|
|
@@ -121,10 +120,7 @@ export async function themeRoutes(fastify, opts = {}) {
|
|
|
121
120
|
if (reply.sent) return reply;
|
|
122
121
|
}
|
|
123
122
|
const id = asked || saved;
|
|
124
|
-
|
|
125
|
-
return {theme: id, dommaTheme, customClass, css: customClass ? compileCustomThemeCss([id]) : '',
|
|
126
|
-
font: {family: cfg.font?.adminFamily || '', stylesheet: cfg.font?.stylesheet || ''},
|
|
127
|
-
sidebar: cfg.adminSidebar !== false};
|
|
123
|
+
return adminThemePresentation(id, cfg);
|
|
128
124
|
});
|
|
129
125
|
|
|
130
126
|
/*
|
package/server/server.js
CHANGED
|
@@ -784,7 +784,8 @@ await registerPlugins(app);
|
|
|
784
784
|
const {isAiAssist} = await import('./services/aiAssist.js');
|
|
785
785
|
if (isAiAssist()) {
|
|
786
786
|
const url = isToolEnabled('launchers') ? '#/ai-assist/chats' : '#/ai-assist/settings';
|
|
787
|
-
|
|
787
|
+
// Under Data by default; an admin's own placement in the menu still wins.
|
|
788
|
+
registerSidebarItem({folder: 'data', item: {source: 'Built in', text: 'AI Assist', url, icon: 'sparkles', permission: isToolEnabled('launchers') ? 'chats' : 'settings',
|
|
788
789
|
...(isToolEnabled('launchers') && {countUrl: '/api/chats/_count'})}});
|
|
789
790
|
hideSidebarUrl('#/launchers/chats', url);
|
|
790
791
|
}
|
|
@@ -50,7 +50,74 @@ export function chatsHome() {
|
|
|
50
50
|
return isAiAssist() ? AI_ASSIST_CHATS : LAUNCHER_CHATS;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
// Builders: AI chats of other Tools, listed on AI Assist's Builders tab
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* plugin name -> its builder entry. A plugin declares one in plugin.json:
|
|
59
|
+
*
|
|
60
|
+
* "admin": {"aiAssist": {"label": "Site Builder", "url": "#/plugins/ai-site-builder",
|
|
61
|
+
* "list": "/api/plugins/ai-site-builder/conversations", "permission": "ai-builder",
|
|
62
|
+
* "character": "dot"}}
|
|
63
|
+
*
|
|
64
|
+
* `url` must be the plugin's own admin screen and `list` its own API: AI Assist only
|
|
65
|
+
* links to the plugin and reads its list with the viewer's own token, so the plugin's
|
|
66
|
+
* routes still decide what each person sees. Registered by the loader for enabled plugins.
|
|
67
|
+
*/
|
|
68
|
+
const builders = new Map();
|
|
69
|
+
const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* What is wrong with a plugin's `admin.aiAssist` block, or ''.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} plugin - the manifest name
|
|
75
|
+
* @param {object} block
|
|
76
|
+
*/
|
|
77
|
+
export function aiAssistBuilderProblem(plugin, block) {
|
|
78
|
+
if (!SLUG.test(String(plugin || ''))) return 'invalid plugin name';
|
|
79
|
+
if (!block || typeof block !== 'object' || Array.isArray(block)) return 'admin.aiAssist must be an object';
|
|
80
|
+
const own = (re) => new RegExp(re.replace('<p>', plugin.replace(/-/g, '\\-')));
|
|
81
|
+
if (typeof block.label !== 'string' || !block.label.trim() || block.label.length > 40) return 'label must be text of up to 40 characters';
|
|
82
|
+
if (typeof block.url !== 'string' || !own('^#/plugins/<p>(/[a-z0-9-]+)*$').test(block.url)) return `url must be this plugin's own screen (#/plugins/${plugin}...)`;
|
|
83
|
+
if (typeof block.list !== 'string' || !own('^/api/plugins/<p>(/[a-z0-9-]+)+$').test(block.list)) return `list must be this plugin's own API (/api/plugins/${plugin}/...)`;
|
|
84
|
+
if (typeof block.permission !== 'string' || !/^[a-z0-9][a-z0-9.-]{0,79}$/.test(block.permission)) return 'permission is required';
|
|
85
|
+
if (block.character !== undefined && (typeof block.character !== 'string' || !SLUG.test(block.character))) return 'character must be a character id';
|
|
86
|
+
return '';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Register a loaded plugin's builder entry; returns the problem ('' when registered). */
|
|
90
|
+
export function registerAiAssistBuilder(plugin, block) {
|
|
91
|
+
const problem = aiAssistBuilderProblem(plugin, block);
|
|
92
|
+
if (problem) return problem;
|
|
93
|
+
builders.set(plugin, {plugin, label: block.label.trim(), url: block.url, list: block.list, permission: block.permission,
|
|
94
|
+
...(block.character ? {character: block.character} : {})});
|
|
95
|
+
return '';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The plugin was switched off: its chats leave the Builders tab at once, not at the next restart. */
|
|
99
|
+
export function unregisterAiAssistBuilder(plugin) {
|
|
100
|
+
return builders.delete(String(plugin || ''));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The builders this viewer may open: they hold the entry's permission (the resource or
|
|
105
|
+
* any action of it), and a confined user's admin scope covers its screen.
|
|
106
|
+
*
|
|
107
|
+
* @param {{permissions: string[], adminScope?: {allow?: string[]}|null}} access - services/adminAccess.js adminAccessFor()
|
|
108
|
+
* @param {(prefix: string, path: string) => boolean} covers - services/pluginScope.js covers()
|
|
109
|
+
*/
|
|
110
|
+
export function aiAssistBuildersFor(access, covers) {
|
|
111
|
+
const perms = access?.permissions || [];
|
|
112
|
+
const holds = (p) => perms.includes(p) || perms.some(x => x.startsWith(`${p}.`)) || perms.includes(p.split('.')[0]);
|
|
113
|
+
const scope = access?.adminScope;
|
|
114
|
+
const inScope = (url) => !scope || (scope.allow || []).some(prefix => covers(prefix, url.slice(1)));
|
|
115
|
+
return [...builders.values()].filter(b => holds(b.permission) && inScope(b.url))
|
|
116
|
+
.map(({plugin, label, url, list, character}) => ({plugin, label, url, list, ...(character ? {character} : {})}));
|
|
117
|
+
}
|
|
118
|
+
|
|
53
119
|
/** Tests only: forget every owner. */
|
|
54
120
|
export function _resetAiAssistForTests() {
|
|
55
121
|
owners.clear();
|
|
122
|
+
builders.clear();
|
|
56
123
|
}
|
|
@@ -22,7 +22,7 @@ const REGISTRY = Symbol.for('domma.launcher-chat');
|
|
|
22
22
|
/** What a visitor will wait for an answer. */
|
|
23
23
|
const ASK_MS = 25_000;
|
|
24
24
|
/** Knowledge and chat sent at most: a reply is a few sentences, the prompt need not be a book. */
|
|
25
|
-
export const KNOWLEDGE_CHARS =
|
|
25
|
+
export const KNOWLEDGE_CHARS = 48_000;
|
|
26
26
|
export const HISTORY_MESSAGES = 10;
|
|
27
27
|
/** After the Manager says no (no licence, the month's answers used), ask again only after this. */
|
|
28
28
|
const BACKOFF_MS = {403: 10 * 60_000, 429: 30 * 60_000, other: 60_000};
|
package/server/services/hooks.js
CHANGED
|
@@ -99,7 +99,7 @@ const _registeredSidebarItems = [];
|
|
|
99
99
|
*/
|
|
100
100
|
const TOOL_GROUPS = new Map(Object.entries({
|
|
101
101
|
Productivity: ['#/notes', '#/todo', '#/calculator', '#/plugins/calendar', '#/plugins/waypoint-pro', '#/plugins/sheets'],
|
|
102
|
-
Communication: ['#/
|
|
102
|
+
Communication: ['#/contacts', '#/plugins/contacts-pro', '#/plugins/mail-reader', '#/plugins/email-pro', '#/plugins/messages'],
|
|
103
103
|
Marketing: ['#/analytics', '#/seo', '#/plugins/analytics-pro/dashboard', '#/plugins/social', '#/plugins/feedback', '#/plugins/surveys', '#/plugins/campaigns-pro', '#/plugins/ecards'],
|
|
104
104
|
Publishing: ['#/plugins/blog', '#/plugins/blog-pro', '#/plugins/docs', '#/plugins/theme-roller', '#/plugins/wiki', '#/plugins/wiki-pro', '#/plugins/scraper', '#/plugins/scraper-pro'],
|
|
105
105
|
Business: ['#/plugins/shopping-cart', '#/plugins/booking', '#/plugins/booking-pro', '#/plugins/invoice', '#/job-board', '#/plugins/garage', '#/plugins/takeaway', '#/plugins/support', '#/plugins/onboard-pro'],
|
|
@@ -43,7 +43,7 @@ import {disableInstantCalls, enableInstantCalls, grantInstantCallsOnce} from './
|
|
|
43
43
|
import {claimHosts} from './hostClaims.js';
|
|
44
44
|
import {pluginSafeFetch} from './outbound.js';
|
|
45
45
|
import {disableDashboardPro, enableDashboardPro, registerWidget, unregisterWidgetsFrom} from './widgets.js';
|
|
46
|
-
import {disableAiAssist, enableAiAssist} from './aiAssist.js';
|
|
46
|
+
import {disableAiAssist, enableAiAssist, registerAiAssistBuilder, unregisterAiAssistBuilder} from './aiAssist.js';
|
|
47
47
|
import {createCollection, getCollection, updateCollection} from './collections.js';
|
|
48
48
|
import * as defaultRolesService from './roles.js';
|
|
49
49
|
import {getAdminScope, normaliseAdminScope} from './roles.js';
|
|
@@ -624,6 +624,13 @@ export async function registerPlugins(fastify) {
|
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
626
|
|
|
627
|
+
// AI Assist's Builders tab (services/aiAssist.js): this plugin's AI chats, linked
|
|
628
|
+
// from there. Only its own screen and API are accepted.
|
|
629
|
+
if (manifest.admin?.aiAssist) {
|
|
630
|
+
const problem = registerAiAssistBuilder(manifest.name, manifest.admin.aiAssist);
|
|
631
|
+
if (problem) fastify.log.warn(`[plugins] admin.aiAssist for "${manifest.name}" skipped: ${problem}`);
|
|
632
|
+
}
|
|
633
|
+
|
|
627
634
|
// Dashboard widgets the manifest offers (services/widgets.js) - drawn by the admin
|
|
628
635
|
// from their `kind` and `dataUrl`, so a Tool needs no code to have one.
|
|
629
636
|
for (const def of manifest.admin?.widgets || []) {
|
|
@@ -1172,6 +1179,7 @@ export async function runLifecycleHook(name, hook, fastify) {
|
|
|
1172
1179
|
disableInstantCalls(name);
|
|
1173
1180
|
disableDashboardPro(name);
|
|
1174
1181
|
disableAiAssist(name);
|
|
1182
|
+
unregisterAiAssistBuilder(name);
|
|
1175
1183
|
unregisterWidgetsFrom(name);
|
|
1176
1184
|
unregisterContactAccess(name);
|
|
1177
1185
|
unregisterDirectMessenger(name);
|
|
@@ -368,6 +368,17 @@ export function compileCustomThemeCss(ids = null) {
|
|
|
368
368
|
.join('\n\n');
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
/** Presentation shared by authenticated admin and anonymous sign-in screens.
|
|
372
|
+
* Callers choose the id; sign-in exposes only the saved admin theme.
|
|
373
|
+
*/
|
|
374
|
+
export function adminThemePresentation(id, cfg = {}) {
|
|
375
|
+
const theme = id || cfg.adminTheme || DEFAULT_THEME;
|
|
376
|
+
const {dommaTheme, customClass} = resolveThemeClasses(theme, cfg);
|
|
377
|
+
return {theme, dommaTheme, customClass, css: customClass ? compileCustomThemeCss([theme]) : '',
|
|
378
|
+
font: {family: cfg.font?.adminFamily || '', stylesheet: cfg.font?.stylesheet || ''},
|
|
379
|
+
sidebar: cfg.adminSidebar !== false};
|
|
380
|
+
}
|
|
381
|
+
|
|
371
382
|
/**
|
|
372
383
|
* The page-head `<style>` for the custom themes a page can show, or ''. Only
|
|
373
384
|
* those: every theme a Roller keeps is ~250 tokens, and an unused draft's
|