domma-cms 1.55.1 → 1.57.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 +10 -0
- package/admin/css/admin.css +1 -1
- package/admin/js/app.js +5 -5
- package/admin/js/lib/admin-assistant.js +1 -1
- package/admin/js/lib/admin-portal-arrange.js +1 -0
- package/admin/js/lib/admin-portal.js +1 -0
- package/admin/js/lib/sidebar-renderer.js +6 -6
- package/admin/js/lib/topbar-notifications.js +7 -7
- package/admin/js/templates/docs/usage-launchers.html +1 -1
- package/admin/js/templates/docs/usage-users-roles.html +8 -0
- package/admin/js/templates/settings.html +1 -1
- package/docs/DommaFeatures.md +4 -1
- package/docs/remy-character.md +16 -0
- package/package.json +1 -1
- package/public/images/characters/remy-poses.png +0 -0
- package/public/js/builder-character.mjs +1 -1
- package/public/js/character-view.mjs +1 -1
- package/public/js/characters.mjs +1 -1
- package/public/js/launcher-chat.mjs +1 -1
- package/public/js/launchers.mjs +2 -2
- package/server/routes/api/auth.js +9 -2
- package/server/services/adminPortal.js +72 -0
- package/server/services/launchers.js +1 -1
- package/server/services/plugins.js +15 -0
package/admin/js/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{wireNotificationMenu as X}from"./lib/topbar-notifications.js";import{installSmoothCarets as Z}from"./lib/smooth-caret.js";import{viewLoaders as tt}from"./views/index.js";import{createLazyViews as et}from"./lib/lazy-views.js";import{withPluginChrome as W}from"./lib/plugin-chrome.js";import{api as r,getUser as B,isAuthenticated as p,logout as at,sendToLogin as it}from"./api.js";import{claimDrafts as ot}from"./lib/draft-owner.js";import{isAuthScreen as C,loginHashFor as st}from"./lib/login-arrange.js";import{installHttpInterceptor as nt}from"./http-interceptor.js";import{installResizableSlideovers as rt}from"./lib/slideover-resizable.js";import{installActivityThrobber as lt}from"./lib/activity-throbber.js";import{installUpdateNotice as ct,renderCmsVersion as mt}from"./lib/update-notice.js";import{renderFrameworkVersions as H,wireAccountMenu as pt}from"./lib/topbar-account.js";import{refreshTopbarProject as F}from"./lib/topbar-project.js";import{CONFINED_CLASS as dt,isConfined as ut,isPathAllowed as ht,redirectFor as wt}from"./lib/admin-scope.js";import{deliverDesktop as gt,desktopActive as ft,notificationSettings as vt}from"./lib/desktop-notify.js";import{avatarUrl as bt,installAccountAvatar as Ct}from"./lib/avatar.js";import{installCalculator as St}from"./lib/calculator.js";import{installAdminAssistant as Mt}from"./lib/admin-assistant.js";import{installAdminLaunchers as Dt}from"./lib/admin-launchers.js";import{takeOverviewPass as yt,withDashboardStrip as K}from"./lib/dashboards-strip.js";import{installHotkeys as Et}from"./lib/hotkeys-ui.js";import{applyAdminBrand as q}from"./lib/admin-brand.js";import{installRouterCatchUp as Nt}from"./lib/router-catch-up.js";import{installSidebarDrawer as Pt}from"./lib/sidebar-drawer.js";$(()=>{Z(document),nt(),St(),Mt(),Dt(),ct(),lt(),rt(),Pt(),(async()=>{const{applyAdminTheme:t,refreshAdminTheme:i}=await import("./lib/admin-theme.js");p()?await i(r,{init:!0}):t({dommaTheme:"charcoal-dark"},{init:!0})})();let c=null,w=null,m="/",g=!1,u=null;function D(t){if(P[t])return E.toast(`${P[t]} is switched off on this site.`,{type:"info"}),"/";const[i,e]=t.split("?"),a=new URLSearchParams(e||"").get("tab");if(i==="/settings"&&["favicon","pageNavigation","breadcrumbs","motion","search"].includes(a))return`/appearance?tab=${a}`;if(t.split("?")[0]==="/my-dashboard")return"/dashboards";const o=N[t]||wt(c,t);return o||((t.split("?")[0]||"/")==="/"&&m&&m!=="/"&&!yt()?N[m]||m:null)}function y(){document.body.classList.toggle(dt,ut(c))}const N={},P={};R.use(async(t,i,e)=>{if(C(t.path))return e();if(!p()){it();return}const a=D(t.path);if(a){R.navigate(a);return}e()});async function f(){try{const t=await r.get("/auth/permissions");c=t.adminScope||null,y(),w=t.adminBrand||null,q(w),m=t.adminHome||"/",H(t.versions||{});const i=t.permissions||[];return g=ht(c,"/settings")&&i.some(e=>e==="settings"||e.startsWith("settings.")),u=i.some(e=>e==="notifications"||e.startsWith("notifications.")),i}catch{return c=null,y(),m="/",w||q(null),g=!1,u=null,[]}}document.addEventListener("dm:admin-home-changed",()=>{f()});let A=null,j=!1;document.addEventListener("dm:sidebar-rebuild",()=>{if(F(r),A){j=!0;return}A=(async()=>{do{j=!1;try{await k(await f())}catch{}}while(j)})().finally(()=>{A=null})});async function k(t){const{renderAdminSidebar:i}=await import("./lib/sidebar-renderer.js");await i({mount:"#admin-sidebar",permissions:t,adminScope:c,brand:w})}M.subscribe("router:afterChange",({to:t})=>{C(t.path)&&(h&&(clearInterval(h),h=null),c=null,y(),m="/",g=!1,u=null)});const z=[{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:"/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()}},{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:i})=>{if(!C(t.path)){if($("#admin-sidebar").show(),$("#admin-topbar").show(),C(i?.path)){$("#topbar-user-name").remove(),import("./lib/admin-theme.js").then(o=>o.refreshAdminTheme(r)),await U();const e=await f(),a=D(t.path);if(a&&R.navigate(a),k(e),vt.read().signInToasts)try{const o=await r.system.notifications.list().catch(()=>[]),n=(Array.isArray(o)?o:[]).filter(s=>s.unread&&["warning","critical"].includes(s.data?.severity)).slice(0,3);for(const s of n){const l=d(s.data?.title||""),x=d((s.data?.body||"").slice(0,120));E.toast(`${l} - ${x}`,{type:s.data?.severity==="critical"?"error":"warning",duration:0})}}catch{}}_()}}),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 G=["#field-project","#menu-project","#collection-project","#endpoint-project","#action-project","#view-project","#block-project","#component-project","#role-project",'[name="project"]','[name="ownedByProject"]'];function J(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 i=t?String(t.path).split("?")[0]:"";if(!t||!J(i))return;const a=new URLSearchParams(location.hash.split("?")[1]||"").get("project");if(!a||!/\/new$/.test(i))return;let o=0;const n=60,s=1500,l=()=>{o+=n;for(const x of G){const b=document.querySelector(x);if(!b)continue;if(Array.from(b.options||[]).find(Q=>Q.value===a)){b.value=a,b.dispatchEvent(new Event("change",{bubbles:!0}));return}}o<s&&setTimeout(l,n)};setTimeout(l,n)});const O="cms_card_states",I=S.get(O)||{};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&&I[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 i=$(this).closest(".card");i.toggleClass("card-collapsed");const e=$(this).find("h2, h3").first().text().trim();e&&(I[e]=i.hasClass("card-collapsed")?"collapsed":"open",S.set(O,I))}),Et(),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 i=document.querySelector("#view-container .view-header button.btn-primary");i&&(t.preventDefault(),i.click())});const v=et(),V=v.views,Y={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"}};for(const[t,i]of Object.entries(tt))v.register(t,async()=>{let e=await i();const a=Y[t];return a&&(e=W(e,{plugin:t,licence:"Built in",...a})),t==="dashboard"?K(e):e});R.use(async(t,i,e)=>{try{await v.load(t.view)}catch(a){console.error("[admin] Screen failed to load",a),V[t.view]={template:'<p role="alert">This screen could not load. Reload the page to try again.</p>'}}e()});const T=[...z];async function U(){if(p())try{const t=await r.plugins.adminConfig(),i=new Set(T.map(e=>e.path));for(const e of t.routes||[])i.has(e.path)||T.push(e);for(const[e,a]of Object.entries(t.views||{})){const o=(t.meta||{})[e];v.register(e,async()=>{const s=(await import(`/plugins/${a.entry}`))[a.exportName];if(!s)throw new Error(`Missing plugin screen: ${e}`);const l=W(s,o);return e==="dashboard"?K(l):l},JSON.stringify([a,o]))}for(const[e,{route:a}]of Object.entries(t.takeovers||{}))a&&(N[`/${e}`]=a);t.mediaPicker&&(globalThis[Symbol.for("domma.media-picker")]=t.mediaPicker);for(const[e,{enabled:a,displayName:o}]of Object.entries(t.tools||{}))a===!1&&(P[`/${e}`]=o);for(const{id:e,href:a}of t.css||[])if(!document.getElementById(e)){const o=document.createElement("link");o.id=e,o.rel="stylesheet",o.href=a,document.head.appendChild(o)}}catch{}}function _(){const t=B();if(!t)return;if($("#topbar-user-name").length){F(r);return}const e={"super-admin":"Super Admin",admin:"Admin",user:"User"}[t.role]||t.role,a=bt(t);$("#topbar-user").get(0).innerHTML=`
|
|
1
|
+
import{wireNotificationMenu as tt}from"./lib/topbar-notifications.js";import{installSmoothCarets as et}from"./lib/smooth-caret.js";import{viewLoaders as at}from"./views/index.js";import{createLazyViews as it}from"./lib/lazy-views.js";import{withPluginChrome as K}from"./lib/plugin-chrome.js";import{api as r,getUser as O,isAuthenticated as p,logout as ot,sendToLogin as st}from"./api.js";import{claimDrafts as nt}from"./lib/draft-owner.js";import{isAuthScreen as y,loginHashFor as rt}from"./lib/login-arrange.js";import{installHttpInterceptor as lt}from"./http-interceptor.js";import{installResizableSlideovers as ct}from"./lib/slideover-resizable.js";import{installActivityThrobber as mt}from"./lib/activity-throbber.js";import{installUpdateNotice as pt,renderCmsVersion as dt}from"./lib/update-notice.js";import{renderFrameworkVersions as q,wireAccountMenu as ut}from"./lib/topbar-account.js";import{refreshTopbarProject as V}from"./lib/topbar-project.js";import{CONFINED_CLASS as ht,isConfined as wt,isPathAllowed as gt,redirectFor as ft}from"./lib/admin-scope.js";import{deliverDesktop as vt,desktopActive as bt,notificationSettings as St}from"./lib/desktop-notify.js";import{avatarUrl as Ct,installAccountAvatar as Mt}from"./lib/avatar.js";import{installCalculator as Dt}from"./lib/calculator.js";import{installAdminAssistant as yt}from"./lib/admin-assistant.js";import{installAdminLaunchers as Et}from"./lib/admin-launchers.js";import{takeOverviewPass as Nt,withDashboardStrip as z}from"./lib/dashboards-strip.js";import{installHotkeys as Pt}from"./lib/hotkeys-ui.js";import{applyAdminBrand as G}from"./lib/admin-brand.js";import{installRouterCatchUp as At}from"./lib/router-catch-up.js";import{installSidebarDrawer as jt}from"./lib/sidebar-drawer.js";$(()=>{et(document),lt(),Dt(),yt(),Et(),pt(),mt(),ct(),jt(),(async()=>{const{applyAdminTheme:t,refreshAdminTheme:i}=await import("./lib/admin-theme.js");p()?await i(r,{init:!0}):t({dommaTheme:"charcoal-dark"},{init:!0})})();let c=null,f=null,m="/",v=!1,w=null,d=null,u=!0;function N(t){if(j[t])return E.toast(`${j[t]} is switched off on this site.`,{type:"info"}),"/";const[i,e]=t.split("?"),a=new URLSearchParams(e||"").get("tab");if(i==="/settings"&&["favicon","pageNavigation","breadcrumbs","motion","search"].includes(a))return`/appearance?tab=${a}`;if(t.split("?")[0]==="/my-dashboard")return"/dashboards";const o=A[t]||ft(c,t);return o||(!u&&i==="/system/notifications"?c?.home||"/":(t.split("?")[0]||"/")==="/"&&m&&m!=="/"&&!Nt()?A[m]||m:null)}function P(){document.body.classList.toggle(ht,wt(c))}const A={},j={};R.use(async(t,i,e)=>{if(y(t.path))return e();if(!p()){st();return}const a=N(t.path);if(a){R.navigate(a);return}e()});async function b(){try{const t=await r.get("/auth/permissions");c=t.adminScope||null,P(),f=t.adminBrand||null,G(f),m=t.adminHome||"/",q(t.versions||{});const i=t.permissions||[];return v=gt(c,"/settings")&&i.some(e=>e==="settings"||e.startsWith("settings.")),w=i.some(e=>e==="notifications"||e.startsWith("notifications.")),d=t.adminPortal||null,u=t.notificationsScreen!==!1,i}catch{return c=null,P(),m="/",f||G(null),v=!1,w=null,d=null,u=!0,[]}}document.addEventListener("dm:admin-home-changed",()=>{b()});let k=null,I=!1;document.addEventListener("dm:sidebar-rebuild",()=>{if(V(r),k){I=!0;return}k=(async()=>{do{I=!1;try{await T(await b())}catch{}}while(I)})().finally(()=>{k=null})});async function T(t){const{applyAdminPortal:i}=await import("./lib/admin-portal.js");if(await i(d),d)return;const{renderAdminSidebar:e}=await import("./lib/sidebar-renderer.js");await e({mount:"#admin-sidebar",permissions:t,adminScope:c,brand:f,notificationsScreen:u})}M.subscribe("router:afterChange",({to:t})=>{y(t.path)&&(g&&(clearInterval(g),g=null),c=null,P(),m="/",v=!1,w=null,u=!0,d&&(d=null,import("./lib/admin-portal.js").then(i=>i.applyAdminPortal(null))))});const J=[{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:"/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()}},{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:i})=>{if(!y(t.path)){if($("#admin-sidebar").show(),$("#admin-topbar").show(),y(i?.path)){$("#topbar-user-name").remove(),import("./lib/admin-theme.js").then(o=>o.refreshAdminTheme(r)),await x();const e=await b(),a=N(t.path);if(a&&R.navigate(a),T(e),St.read().signInToasts)try{const o=await r.system.notifications.list().catch(()=>[]),n=(Array.isArray(o)?o:[]).filter(s=>s.unread&&["warning","critical"].includes(s.data?.severity)).slice(0,3);for(const s of n){const l=h(s.data?.title||""),F=h((s.data?.body||"").slice(0,120));E.toast(`${l} - ${F}`,{type:s.data?.severity==="critical"?"error":"warning",duration:0})}}catch{}}H()}}),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 Y=["#field-project","#menu-project","#collection-project","#endpoint-project","#action-project","#view-project","#block-project","#component-project","#role-project",'[name="project"]','[name="ownedByProject"]'];function Q(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 i=t?String(t.path).split("?")[0]:"";if(!t||!Q(i))return;const a=new URLSearchParams(location.hash.split("?")[1]||"").get("project");if(!a||!/\/new$/.test(i))return;let o=0;const n=60,s=1500,l=()=>{o+=n;for(const F of Y){const D=document.querySelector(F);if(!D)continue;if(Array.from(D.options||[]).find(Z=>Z.value===a)){D.value=a,D.dispatchEvent(new Event("change",{bubbles:!0}));return}}o<s&&setTimeout(l,n)};setTimeout(l,n)});const _="cms_card_states",U=S.get(_)||{};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&&U[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 i=$(this).closest(".card");i.toggleClass("card-collapsed");const e=$(this).find("h2, h3").first().text().trim();e&&(U[e]=i.hasClass("card-collapsed")?"collapsed":"open",S.set(_,U))}),Pt(),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 i=document.querySelector("#view-container .view-header button.btn-primary");i&&(t.preventDefault(),i.click())});const C=it(),W=C.views,X={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"}};for(const[t,i]of Object.entries(at))C.register(t,async()=>{let e=await i();const a=X[t];return a&&(e=K(e,{plugin:t,licence:"Built in",...a})),t==="dashboard"?z(e):e});R.use(async(t,i,e)=>{try{await C.load(t.view)}catch(a){console.error("[admin] Screen failed to load",a),W[t.view]={template:'<p role="alert">This screen could not load. Reload the page to try again.</p>'}}e()});const L=[...J];async function x(){if(p())try{const t=await r.plugins.adminConfig(),i=new Set(L.map(e=>e.path));for(const e of t.routes||[])i.has(e.path)||L.push(e);for(const[e,a]of Object.entries(t.views||{})){const o=(t.meta||{})[e];C.register(e,async()=>{const s=(await import(`/plugins/${a.entry}`))[a.exportName];if(!s)throw new Error(`Missing plugin screen: ${e}`);const l=K(s,o);return e==="dashboard"?z(l):l},JSON.stringify([a,o]))}for(const[e,{route:a}]of Object.entries(t.takeovers||{}))a&&(A[`/${e}`]=a);t.mediaPicker&&(globalThis[Symbol.for("domma.media-picker")]=t.mediaPicker);for(const[e,{enabled:a,displayName:o}]of Object.entries(t.tools||{}))a===!1&&(j[`/${e}`]=o);for(const{id:e,href:a}of t.css||[])if(!document.getElementById(e)){const o=document.createElement("link");o.id=e,o.rel="stylesheet",o.href=a,document.head.appendChild(o)}}catch{}}function H(){const t=O();if(!t)return;if($("#topbar-user-name").length){V(r);return}const e={"super-admin":"Super Admin",admin:"Admin",user:"User"}[t.role]||t.role,a=Ct(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>
|
|
@@ -33,9 +33,9 @@ import{wireNotificationMenu as X}from"./lib/topbar-notifications.js";import{inst
|
|
|
33
33
|
</button>
|
|
34
34
|
<div id="topbar-account-menu" class="topbar-account-menu" hidden>
|
|
35
35
|
<div class="topbar-account-identity">
|
|
36
|
-
${a?`<img id="topbar-avatar" class="topbar-avatar" src="${
|
|
37
|
-
<span id="topbar-user-name" class="topbar-user-name">${
|
|
38
|
-
<span class="topbar-role-badge topbar-role-badge--${
|
|
36
|
+
${a?`<img id="topbar-avatar" class="topbar-avatar" src="${h(a)}" alt="">`:""}
|
|
37
|
+
<span id="topbar-user-name" class="topbar-user-name">${h(t.name)}</span>
|
|
38
|
+
<span class="topbar-role-badge topbar-role-badge--${h(t.role)}">${h(e)}</span>
|
|
39
39
|
</div>
|
|
40
40
|
<a href="#/my-profile" class="topbar-action-link" data-tooltip="My Profile" data-tooltip-placement="bottom">
|
|
41
41
|
<span data-icon="user"></span>
|
|
@@ -51,4 +51,4 @@ import{wireNotificationMenu as X}from"./lib/topbar-notifications.js";import{inst
|
|
|
51
51
|
</a>
|
|
52
52
|
</div>
|
|
53
53
|
</div>
|
|
54
|
-
`;const o=$("#topbar-settings").get(0);o&&(o.hidden=!
|
|
54
|
+
`;const o=$("#topbar-settings").get(0);o&&(o.hidden=!v),$("#topbar-logout-btn").on("click",n=>{n.preventDefault(),ot()}),Domma.icons.scan("#admin-topbar"),E.tooltip("#topbar-actions [data-tooltip]",{placement:"bottom"}),ut(t),tt({refreshBadge:B,canRead:()=>w!==!1,own:()=>!u}),Mt(t),q(),dt(),V(r),B(),g||(g=setInterval(B,6e4))}function h(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}let g=null;async function B(){if(!(!p()||w===!1))try{const{count:t}=await r.system.notifications.unreadCount(),i=$("#topbar-bell-badge");t>0?i.text(t>99?"99+":String(t)).removeAttr("hidden"):i.attr("hidden","").text(""),t>0&&bt()&&vt(await r.system.notifications.list().catch(()=>[]))}catch{}}(async()=>{if(!p()&&!window.location.hash.startsWith("#/reset-password"))window.location.hash.startsWith("#/login")||(window.location.hash=rt(window.location.hash));else{nt(O()?.id);const a=O(),[o]=await Promise.all([a?b():Promise.resolve([]),x()]);if(a){const n=(window.location.hash||"#/").slice(1)||"/",s=N(n);s&&(window.location.hash=`#${s}`),T(o).catch(l=>console.error("[admin] Sidebar failed to load",l)),H()}}const t=R._extractParams.bind(R);R._extractParams=function(a,o){const n=o.indexOf("?");if(n!==-1&&(o=o.slice(0,n)),a.endsWith("/*")){const s=a.slice(0,-2);return o.startsWith(s+"/")?{}:null}return t(a,o)};const i=R._renderNotFound.bind(R);let e="";R._renderNotFound=async function(a){return p()&&e!==a&&(e=a,await x(),R._matchRoute(a).route)?(e="",R._handleRouteChange()):(e="",p()&&$("#admin-sidebar").get(0)?.style.display==="none"?(E.toast("That link goes nowhere - here is your home page.",{type:"warning"}),R.navigate("/")):i(a))},At(R),R.init({container:"#view-container",routes:L,views:W,default:"/",transitions:{enter:"fadeIn",leave:"fadeOut",duration:150}})})()});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{api as $,getUser as x,isAuthenticated as k}from"../api.js";import{onceClosed as T}from"./tool-kit.js";import{mountCharacter as H}from"/public/js/character-view.mjs?v=20261111-
|
|
1
|
+
import{api as $,getUser as x,isAuthenticated as k}from"../api.js";import{onceClosed as T}from"./tool-kit.js";import{mountCharacter as H}from"/public/js/character-view.mjs?v=20261111-remy-character";export function installAdminAssistant(){let v=null,u=0,w=0,s=null,t=null,i=null,h=null;const l=M.observable([]),g=M.observable(""),m=M.observable(!1),d=M.observable(""),A=()=>location.hash.slice(1).split("?")[0]||"/",C=()=>/^#\/(login|reset-password)(\?|\/|$)/.test(location.hash);function p(){u++,i?.element?.querySelector(".admin-assistant-panel")?.replaceChildren(),i?.close(!0),i=null,h?.destroy(),h=null,t?.remove(),t=null,l.value=[],g.value="",m.value=!1,d.value=""}async function I(){const a=g.peek().trim();if(!a||a.length>1e3||m.peek())return;const n=v,e=u,o=l.peek().slice(-10).map(c=>({from:c.from,text:c.text.slice(0,1e3)}));g.value="",d.value="",m.value=!0,l.value=[...l.peek(),{from:"visitor",text:a}].slice(-30);try{const c=await $.post("/admin-assistant/ask",{question:a,history:o,route:A()});if(u!==e||x()?.id!==n||!k())return;l.value=[...l.peek(),{from:"bot",text:c.answer}].slice(-30)}catch(c){u===e&&x()?.id===n&&(d.value=c.message||"Could not get an answer.")}finally{u===e&&(m.value=!1)}}function N(){if(!s?.enabled||!t)return;if(i){i.open();return}const a=s.name.replace(/[&<>"']/g,r=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[r]),n=E.slideover({title:`Ask ${a}`,size:"md",position:"right"}),e=document.createElement("div");e.className="admin-assistant-panel",e.innerHTML=`<p class="text-muted">Help and drafts for the current tool. You choose what to copy and save.</p>
|
|
2
2
|
<div class="admin-assistant-messages" role="log" aria-live="polite" aria-label="Assistant conversation"></div>
|
|
3
3
|
<p role="status" data-bind-hidden="!busy.value">Thinking...</p>
|
|
4
4
|
<p class="text-danger" role="alert" data-bind-text="error.value"></p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const NOTIFICATIONS_SCREEN="#/system/notifications";const s=/^#\/[a-z0-9/_-]*$/i,c=/^[a-z0-9-]{1,40}$/,l=new Set(["info","danger"]);export function withoutUrl(i,o){return(Array.isArray(i)?i:[]).flatMap(e=>{if(!e||typeof e!="object")return[];if(e.url===o)return[];if(!Array.isArray(e.items))return[e];const r=withoutUrl(e.items,o);return!r.length&&e.items.length&&!e.url?[]:[{...e,items:r}]})}export function portalSections(i){const o=Array.isArray(i)?i:Array.isArray(i?.items)?i.items:[],e=new Set;return o.flatMap(r=>{const t=typeof r?.text=="string"?r.text.replace(/\s+/g," ").trim().slice(0,40):"",n=typeof r?.url=="string"?r.url.trim():"";return!t||!s.test(n)||e.has(n)?[]:(e.add(n),[{text:t,url:n,...c.test(r.icon||"")&&{icon:r.icon},items:[]}])}).slice(0,16)}export function portalCounts(i){const o=Array.isArray(i)?i:Array.isArray(i?.items)?i.items:[],e={};for(const r of o){const t=typeof r?.url=="string"?r.url.trim():"",n=Number(r?.count);if(!s.test(t)||!Number.isInteger(n)||n<=0)continue;const a=typeof r.label=="string"&&r.label.trim()?r.label.trim().slice(0,80):`${n} in ${r.text||"this section"}`;e[t]={count:Math.min(n,9999),label:a,tone:l.has(r.tone)?r.tone:"info"}}return e}export function activeSection(i,o){const e=String(o||"").split("?")[0];let r=null;for(const{url:t}of i||[])(e===t||e.startsWith(t+"/"))&&(!r||t.length>r.length)&&(r=t);return r}export function ownNotifications(i,o=20){const e=(t,n)=>typeof t=="string"?t.replace(/\s+/g," ").trim().slice(0,n):"",r=t=>typeof t=="string"&&(s.test(t.split("?")[0])||/^https?:\/\/\S+$/i.test(t))?t:null;return(Array.isArray(i)?i:[]).filter(t=>t&&t.id).map(t=>({id:String(t.id),title:e(t.data?.title,140)||"Notification",body:e(t.data?.body,200),unread:!!t.unread,link:r(t.data?.link),at:typeof t.data?.createdAt=="string"?t.data.createdAt:typeof t.createdAt=="string"?t.createdAt:""})).sort((t,n)=>n.at>t.at?1:n.at<t.at?-1:0).slice(0,o)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{renderTopbarNavigation as w,updateTopbarCounts as y}from"./topbar-navigation.js";import{activeSection as b,portalCounts as m,portalSections as f}from"./admin-portal-arrange.js";export const PORTAL_CLASS="dm-admin-portal";const p=6e4,S=1e4;let r=null;function g(){const t=document.getElementById("topbar-navigation");if(!t||!r)return;const e=b(r.sections,location.hash);for(const n of t.querySelectorAll("a.topbar-nav-link"))n.dataset.url===e?n.setAttribute("aria-current","page"):n.removeAttribute("aria-current")}function u(t){const e=()=>document.getElementById("topbar-navigation"),{sections:n}=t,o=h(t.counts);let i=n.length;const c=()=>{const s=i<n.length?[...n.slice(0,i),{text:"More",key:"portal-more",icon:"menu",items:n.slice(i)}]:n;w(s,{counts:o})};for(c();i>1&&e()&&e().scrollWidth>e().clientWidth+1;)i--,c();g()}function h(t){return Object.fromEntries(Object.entries(t||{}).map(([e,n])=>[e,{...n,aggregate:!0}]))}async function v(t){return t.nav?H.get(t.nav):{items:[]}}export async function applyAdminPortal(t){const e=t?JSON.stringify(t):null;if(r&&r.key===e)return a(!0);if(E(),document.body.classList.toggle(PORTAL_CLASS,!!t),!t)return;const n=new AbortController;r={portal:t,key:e,sections:[],counts:{},timer:null,controller:n,last:0};const o=r;let i;try{i=await v(t)}catch{i=null}if(r!==o)return;const c=f(i);o.sections=c.length?c:[{text:t.title,url:`#${t.home}`,items:[]}],o.last=Date.now(),o.counts=m(i),u(o);const{signal:s}=n;let d=null;window.addEventListener("resize",()=>{clearTimeout(d),d=setTimeout(()=>{r===o&&u(o)},150)},{signal:s}),window.addEventListener("hashchange",()=>{g(),a(!1)},{signal:s});let l=null;window.addEventListener("dm:sidebar-count",()=>{clearTimeout(l),l=setTimeout(()=>a(!0),1e3)},{signal:s}),s.addEventListener("abort",()=>clearTimeout(l)),document.addEventListener("visibilitychange",()=>{document.hidden||a(!1)},{signal:s}),o.timer=setInterval(()=>{document.hidden||a(!0)},p)}async function a(t){const e=r;if(!e||!t&&Date.now()-e.last<S)return;e.last=Date.now();let n;try{n=await v(e.portal)}catch{return}if(r!==e)return;const o=f(n);e.counts=m(n),o.length&&JSON.stringify(o)!==JSON.stringify(e.sections)?(e.sections=o,u(e)):y(h(e.counts),{replace:!0})}function E(){r&&(r.controller.abort(),clearInterval(r.timer),r=null)}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{syncThemeAwareLogos as
|
|
2
|
-
<summary${
|
|
1
|
+
import{syncThemeAwareLogos as Ce}from"./theme-aware-logo.js";import{api as g,getUser as k,isAuthenticated as qe}from"../api.js";import{createRequestQueue as Ae}from"./background-requests.js";import{requestSidebarCounts as Fe}from"./sidebar-counts.js";import{beginSidebarCounts as Le,publishSidebarCount as Ee}from"./sidebar-count-cache.js";import{isConfined as Oe,isPathAllowed as je}from"./admin-scope.js";import{NOTIFICATIONS_SCREEN as Te,withoutUrl as Me}from"./admin-portal-arrange.js";import{cleanNotify as Ne,noticeFromCount as Be}from"./sidebar-notify.js";import{colourToCss as ne,applyFloat as He,applyHighlight as Re,itemHighlightAttrs as Ie}from"/public/js/menu-decor.mjs?v=20261109-current-query";import{arrangeSidebar as Pe,sidebarStateKey as se,canAny as V,confinedTree as _e}from"./sidebar-grouping.js";import{arrangeButtonMarkup as Ue,canArrange as ze,startArrange as De}from"./sidebar-arrange.js";import{collapseButtonMarkup as We,wireSidebarSize as Ke,COLLAPSED_WIDTH as Ve}from"./sidebar-size.js";import{FREQUENT_MAX as oe,addFrequent as Xe,frequentFolder as Ze,moveFrequent as ie,readFrequent as Z,readFrequentHidden as Je,removeFrequent as Ye,saveFrequent as Ge,syncFrequent as Qe,writeFrequent as et,writeFrequentHidden as ae}from"./sidebar-frequent.js";import{hotkeyFor as re,hotkeyTitle as tt,setHotkeyTree as nt}from"./hotkeys-ui.js";import{hotkeyLabel as st}from"./hotkeys.js";function p(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const ot=[{text:"Dashboard",url:"#/",icon:"home"},{text:"Site menus",url:"#/menus",icon:"menu",permission:"menus"}];async function it(e){if(!V(e,"projects"))return[];let n=[];try{n=await g.projects.listWithCounts()}catch{return[]}if(!Array.isArray(n))return[];const t=[{key:"pages",text:"Pages",icon:"file-text",path:"/pages"},{key:"collections",text:"Collections",icon:"database",path:"/collections"},{key:"forms",text:"Forms",icon:"layout",path:"/forms"},{key:"actions",text:"Actions",icon:"zap",path:"/actions"},{key:"menus",text:"Site menus",icon:"menu",path:"/menus"},{key:"blocks",text:"Blocks",icon:"box",path:"/blocks"},{key:"components",text:"Components",icon:"component",path:"/components"},{key:"views",text:"Views",icon:"eye",path:"/views"},{key:"roles",text:"Roles",icon:"shield",path:"/roles"},{key:"users",text:"Users",icon:"users",path:"/users"},{key:"apis",text:"APIs",icon:"code",path:"/apis"}];return n.map(s=>{const o="#/projects/"+encodeURIComponent(s.slug),d=s.counts||{},r=[{text:"Overview",url:o,icon:s.icon||"folder"}];for(const a of t){const c=Number(d[a.key])||0;c<=0||r.push({text:`${a.text} (${c})`,url:o+a.path,icon:a.icon})}r.push({text:"Settings",url:o+"/settings",icon:"settings"});const u=s.enabled===!1;return{text:s.name||s.slug,key:`project.${s.slug}`,icon:s.icon||"folder",items:r,...u&&{colour:"neutral",badge:{text:"off"}}}})}function at(e,n){for(const t of e)if(!t.hidden&&(t.key==="projects"||!t.key&&(t.text||"").toLowerCase()==="projects")){t.items=Array.isArray(t.items)?t.items.slice():[],t.items.push(...n);return}}function le(e,n){const t=de.includes(n.tone)?n.tone:"info",s=n.label||String(n.count);n.details?I.set(e,n.details):I.delete(e);const i=!n.inventory&&O.some(o=>o.url===e&&!o.inventory)?" data-live":"";return`<span class="sidebar-badge sidebar-badge--${t}" data-count-for="${p(e)}"${i} data-badge-label="${p(s)}" aria-label="${p(s)}">${p(String(n.count))}</span>`}function ce(e){for(const n of e.querySelectorAll("details")){const t=n.querySelector(":scope > summary");if(!t)continue;let s=0,i=!1;const o=[];for(const c of n.querySelectorAll(":scope > .sidebar-children .sidebar-badge[data-live]")){const f=Number(c.textContent)||0;f&&(s+=f,i||(i=c.classList.contains("sidebar-badge--danger")),o.push({text:c.closest("a")?.querySelector(".sidebar-text")?.textContent.trim()??"",meta:c.dataset.badgeLabel,tone:c.classList.contains("sidebar-badge--danger")?"danger":void 0}))}const d=`folder:${n.dataset.stateKey||t.textContent.trim()}`;let r=t.querySelector(":scope > .sidebar-badge--sum");if(!s){r?.remove(),I.delete(d);continue}r||(r=document.createElement("span"),t.querySelector(".sidebar-text")?.after(r));const u=t.querySelector(".sidebar-text")?.textContent.trim()||"This folder",a=o.map(c=>`${c.text}: ${c.meta}`).join(" \xB7 ");r.className=`sidebar-badge sidebar-badge--sum sidebar-badge--${i?"danger":"info"}`,r.dataset.countFor=d,r.dataset.badgeLabel=a,r.setAttribute("aria-label",a),r.textContent=String(s),I.set(d,{title:u,items:o})}}const I=new Map;function rt(e,n){if(!e.url||!n)return"";const t=n[e.url];return!t||!(t.count>0)&&!t.showZero?"":le(e.url,t)}const de=["info","attention","danger","live"],lt={"#/pages":["page","pages"],"#/media":["file in the media library","files in the media library"],"#/menus":["menu","menus"],"#/context-menus":["context menu","context menus"],"#/theme":["element override in the theme","element overrides in the theme"],"#/collections":["collection","collections"],"#/forms":["form","forms"],"#/views":["view","views"],"#/actions":["action","actions"],"#/blocks":["block","blocks"],"#/components":["component","components"],"#/users":["user","users"],"#/plugins":["plugin installed","plugins installed"],"#/system/notifications":["unread notification","unread notifications"]};function X(e,{fallbackLabel:n="",tone:t="info"}={}){const s=Number(typeof e=="object"&&e!==null?e.count:e);if(!Number.isFinite(s)||s<0)return null;const i=typeof e?.label=="string"&&e.label||(n?`${s} - ${n}`:String(s)),o={count:Math.round(s),label:i,tone:de.includes(e?.tone)?e.tone:t};e?.details&&typeof e.details=="object"&&(o.details=e.details),e?.inventory===!0&&(o.inventory=!0),e?.showZero===!0&&(o.showZero=!0);const d=Ne(e?.notify);return d&&(o.notify=d),o}function ue(e,n,t=null,{inFrequent:s=!1}={}){if(e&&e.type==="separator")return'<hr class="sidebar-divider">';if(e&&e.type==="theme-switcher")return"";if(e&&e.type==="spacer"){const y=["xs","sm","md","lg","xl","flex"].includes(e.size)?e.size:"md";return`<div class="sidebar-spacer sidebar-spacer--${p(y)}" aria-hidden="true"></div>`}const i=String(e.text||"?").trim().charAt(0).toUpperCase()||"?",o=e.icon?`<span data-icon="${p(e.icon)}"></span>`:`<span class="sidebar-initial" aria-hidden="true">${p(i)}</span>`,d=p(e.text||""),r=e.url?p(e.url):"",u=Array.isArray(e.items)&&e.items.length>0,a=e.colour?ne(e.colour):"",c=Ie(e),f=[c.hover&&` data-menu-item-hover="${p(c.hover)}"`,c.active&&` data-menu-item-active="${p(c.active)}"`].filter(Boolean).join(""),m=[a&&`color:${p(a)}`,c.accent&&`--dm-menu-highlight:${p(c.accent)}`].filter(Boolean).join(";"),b=m?` style="${m}"`:"",q=e.url?tt(e.url,e.text||"",{inFrequent:s}):"",C=q?` title="${p(q)}"`:"";let L="";if(e.badge&&e.badge.text!=null&&e.badge.text!==""){const y=e.badge.variant?ne(e.badge.variant):"";L=`<span class="dm-menu-badge"${y?` style="background:${p(y)};color:var(--dm-text-inverse,#fff)"`:""}>${p(String(e.badge.text))}</span>`}if(e.frequent&&e.empty){const y=se(e,t),A=S.get(y)!==!1;return`<details data-state-key="${p(y)}"${A?" open":""} data-frequent data-frequent-empty>
|
|
2
|
+
<summary${b}>${o} <span class="sidebar-text">${d}</span></summary>
|
|
3
3
|
<div class="sidebar-children"><p class="sidebar-frequent-empty">Right-click any Tool and choose <strong>Add to Frequent</strong> to keep it here.</p></div>
|
|
4
|
-
</details>`}if(
|
|
5
|
-
<summary${
|
|
6
|
-
<div class="sidebar-children">${
|
|
7
|
-
</details>`}return`<a href="${i}" class="sidebar-link" data-url="${i}"${v}${f}${q}>${r} <span class="sidebar-text">${u}</span>${it(e,n)}${A}</a>`}async function rt(e=[],n=[],t=null){const o=g=>g.then(C=>Array.isArray(C)?C.length:Array.isArray(C?.entries)?C.entries.length:0).catch(()=>0),s=fe(e,t),r=new Set(s.map(g=>g.url)),u={pages:"#/pages",media:"#/media",menus:"#/menus","context-menus":"#/context-menus",theme:"#/theme",collections:"#/collections",forms:"#/forms",views:"#/views",actions:"#/actions",blocks:"#/blocks",components:"#/components",users:"#/users",plugins:"#/plugins",notifications:"#/system/notifications"},i=(g,C)=>W(n,g)&&!r.has(u[g])?C():Promise.resolve(0),[c,d,l,f,h,v,k,q,A,y,F,L,P,O]=await Promise.all([i("pages",()=>o(b.pages.list())),i("media",()=>o(b.media.list())),i("menus",()=>o(b.menus.list())),i("context-menus",()=>o(b.contextMenus.list())),i("theme",()=>b.theme.get().then(g=>(g?.overrides||[]).length).catch(()=>0)),i("collections",()=>o(b.collections.list())),i("forms",()=>o(b.forms.list())),i("views",()=>o(b.views.list())),i("actions",()=>o(b.actions.list())),i("blocks",()=>o(b.blocks.list())),i("components",()=>o(b.components.list())),i("users",()=>o(b.users.list())),i("plugins",()=>o(b.plugins.list())),i("notifications",()=>b.system?.notifications?.unreadCount?.().then(g=>g?.count??0).catch(()=>0)??Promise.resolve(0))]),D=await pe(s),V={"#/pages":c,"#/media":d,"#/menus":l,"#/context-menus":f,"#/theme":h,"#/collections":v,"#/forms":k,"#/views":q,"#/actions":A,"#/blocks":y,"#/components":F,"#/users":L,"#/plugins":P,"#/system/notifications":O},_={};for(const[g,C]of Object.entries(V)){if(r.has(g))continue;const[T,X]=at[g]??["item","items"],U=K(C);U&&(_[g]={...U,label:`${U.count} ${U.count===1?T:X}`})}return{..._,...D}}let j=[];const lt="dm:sidebar-count",ct=6e4,dt=Ae(4);function fe(e=[],n=null){const t=[],o=s=>{if(s&&!(n&&typeof s.url=="string"&&s.url.startsWith("#/")&&!Oe(n,s.url.slice(1)))){s.url&&typeof s.countUrl=="string"&&s.countUrl&&t.push({url:s.url,countUrl:s.countUrl,text:s.text||"",countLabel:s.countLabel||"",inventory:s.inventory===!0});for(const r of[...s.children||[],...s.items||[]])o(r)}};for(const s of e??[])o(s?.item??s);return t}async function me(e,{priority:n=!1}={}){try{const t=new Date,o=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,s=e.countUrl+(e.countUrl.includes("?")?"&":"?")+`today=${o}`,r=w()?.id,u=await dt(()=>!Ce()||w()?.id!==r?null:H.get(s,{priority:"low"}),{key:JSON.stringify([r,s]),priority:n});return K(u,{fallbackLabel:e.countLabel||e.text})}catch{return null}}function J(e,n,t){Ee(n,t),t?.notify&&Te(w()?.id??null,n,t.notify);const o=[...e.querySelectorAll("a.sidebar-link")].filter(s=>s.dataset.url===n);if(o.length){for(const s of o){const r=s.querySelector(".sidebar-badge[data-count-for]");if(!t||!(t.count>0)&&!t.showZero)r?.remove();else{const u=document.createRange();u.selectNodeContents(s);const i=u.createContextualFragment(le(n,t)).firstElementChild;r?r.replaceWith(i):s.querySelector(".sidebar-text")?.after(i)}}Y.set(n,t),ce(e)}}const Y=new Map;async function pe(e){const n=await Fe(e,{legacy:async t=>{const o=await Promise.all(t.map(async s=>[s.url,await me(s)]));return Object.fromEntries(o)}});return Object.fromEntries(e.map(t=>[t.url,n[t.url]==null?null:K(n[t.url],{fallbackLabel:t.countLabel||t.text})]))}async function G(e,n=null){const t=w()?.id,o=j;try{const s=n?{[n]:await me(j.find(r=>r.url===n),{priority:!0})}:await pe(j);if(w()?.id!==t||j!==o)return;for(const[r,u]of Object.entries(s)){const i=Y.get(r);JSON.stringify(i??null)!==JSON.stringify(u)&&J(e,r,u)}}catch{}}function ut(e){e.dataset.liveCounts||(e.dataset.liveCounts="1",window.addEventListener(lt,n=>{const t=n.detail||{};if(t.url)if(t.count!==void 0){const o=j.find(s=>s.url===t.url);J(e,t.url,K(t,{fallbackLabel:o?.countLabel||o?.text||""}))}else G(e,t.url)}),setInterval(()=>{!document.hidden&&document.body.contains(e)&&G(e)},ct),document.addEventListener("visibilitychange",()=>{document.hidden||G(e)}),ft(e))}function he(e,n,t){const o=(u,i,c)=>{const d=document.createElement(u);return i&&(d.className=i),c!=null&&(d.textContent=String(c)),d};if(!t){e.textContent=n;return}e.appendChild(o("strong","dm-badge-pop-title",t.title||n)),(t.rows?.length||!t.items?.length)&&e.appendChild(o("p","dm-badge-pop-sub",n));const s=Array.isArray(t.rows)?t.rows.slice(0,6):[];if(s.length){const u=o("dl","dm-badge-pop-rows");for(const i of s)u.appendChild(o("dt",null,i.label)),u.appendChild(o("dd",i.tone==="danger"?"is-danger":null,i.value));e.appendChild(u)}const r=Array.isArray(t.items)?t.items.slice(0,6):[];if(r.length){const u=o("ul","dm-badge-pop-items");for(const i of r){const c=o("li",i.tone==="danger"?"is-danger":null);c.appendChild(o("span","dm-badge-pop-text",i.text)),i.meta&&c.appendChild(o("span","dm-badge-pop-meta",i.meta)),u.appendChild(c)}e.appendChild(u)}else t.empty&&e.appendChild(o("p","dm-badge-pop-empty",t.empty))}function ft(e){let n=null,t=null;const o=()=>e.classList.contains("is-collapsed"),s=()=>{clearTimeout(t),n?.remove(),n=null},r=(d,l)=>{s(),t=setTimeout(()=>{n=document.createElement("div"),n.className="dm-help-pop dm-badge-pop",n.setAttribute("role","tooltip"),l(n),document.body.appendChild(n);const f=d.getBoundingClientRect(),h=n.getBoundingClientRect(),v=Math.min(f.right+10,innerWidth-h.width-8);n.style.left=`${Math.max(8,v)}px`,n.style.top=`${Math.max(8,Math.min(f.top+f.height/2-h.height/2,innerHeight-h.height-8))}px`},150)},u=d=>{const l=d?.dataset.badgeLabel;if(!l)return s();r(d,f=>he(f,l,R.get(d.dataset.countFor)))},i=d=>{const l=d.querySelector(":scope > .sidebar-text")?.textContent.trim()||"",f=d.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");r(d,h=>{const v=f&&R.get(f.dataset.countFor);if(v)return he(h,f.dataset.badgeLabel,{...v,title:v.title||l});if(!f){h.textContent=l;return}const k=document.createElement("strong");k.className="dm-badge-pop-title",k.textContent=l;const q=document.createElement("p");q.className="dm-badge-pop-sub",q.textContent=f.dataset.badgeLabel,h.append(k,q)})},c=d=>{const l=d.closest?.("a.sidebar-link, summary");return l&&e.contains(l)?l:null};e.addEventListener("mouseover",d=>{if(o()){const f=c(d.target);f&&!f.contains(d.relatedTarget)&&i(f);return}const l=d.target.closest?.(".sidebar-badge[data-badge-label]");l&&u(l)}),e.addEventListener("mouseout",d=>{if(o()){const l=c(d.target);l&&!l.contains(d.relatedTarget)&&s();return}d.target.closest?.(".sidebar-badge[data-badge-label]")&&s()}),e.addEventListener("focusin",d=>{const l=d.target.closest?.("a, summary");if(o()&&l&&e.contains(l)&&l.querySelector(":scope > .sidebar-text"))return i(l);const f=l?.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");f?u(f):s()}),e.addEventListener("focusout",s),e.addEventListener("click",s),window.addEventListener("scroll",s,!0),window.addEventListener("hashchange",s)}async function mt(e=[],n=null){if(n?.title||n?.enabled===!1)return n;if(!W(e,"settings"))return{title:"Domma CMS"};try{const t=await b.settings.get();return{...t?.adminBrand,title:t?.adminBrand?.title||t?.title||"Domma CMS"}}catch{return{title:"Domma CMS"}}}export async function renderAdminSidebar({mount:e,permissions:n,adminScope:t=null,brand:o=null}){const s=$(e).get(0);if(!s)return;I=je(t);const r=I?Promise.resolve():Ye(b,w()).catch(()=>{}),u=Promise.resolve().then(()=>H.get("/api/sidebar/registered-items")).catch(()=>[]),i=st(n);let c,d=null,l=null,f=null,h=null,v=null;try{const a=await b.get("/sidebar/menu");c=Array.isArray(a?.items)?a.items:null,d=a?.variant||null,l=a?.position||null,f=a?.style||null,h=a?.float||null,v=a?.highlight||null}catch{c=null}(!c||!c.some(a=>a&&(!a.hidden||a.restricted)))&&(console.warn("[admin-sidebar] No admin-sidebar menu found; using fallback tree"),c=nt.slice());let k=[];try{k=await u||[]}catch{}const q=await i;if(c=Re(c,k,{permissions:n,adminScope:t,beforeFilter:a=>{q.length&&ot(a,q)}}),await r,I)c=Ie(c);else{const a=Ve(c,Z(w()),{hidden:Xe(w())});a&&(c=[a,...c])}et(c);const A=k.filter(a=>W(n,a?.item?.permission));j=fe(A,t);const y=Le({user:w(),permissions:n,adminScope:t,registered:A,tree:c,actions:{linkItems:ye,folderItems:ve},fetcher:()=>rt(A,n,t)}),F=y.counts,L=await mt(n,o),P=d?` dm-admin-sidebar--${m(d)}`:"";function O(a,x="px"){if(a==null)return a;const p=String(a).trim();return/^\d+(\.\d+)?$/.test(p)?`${p}${x}`:p}let D="";if(f){const a=[];f.fontFamily&&a.push(`font-family: ${f.fontFamily}, sans-serif`),f.fontSize&&a.push(`font-size: ${O(f.fontSize)}`),f.fontWeight&&a.push(`font-weight: ${f.fontWeight}`),f.letterSpacing&&a.push(`letter-spacing: ${O(f.letterSpacing,"em")}`);const x=[];if(a.length&&x.push(`#admin-sidebar .dm-admin-sidebar, #admin-sidebar .dm-admin-sidebar .sidebar-link, #admin-sidebar .dm-admin-sidebar summary, #admin-sidebar .dm-admin-sidebar .sidebar-text { ${a.join("; ")} }`),f.iconSize){const p=O(f.iconSize);x.push(`#admin-sidebar .dm-admin-sidebar [data-icon], #admin-sidebar .dm-admin-sidebar [data-icon] svg { width: ${p} !important; height: ${p} !important; }`)}x.length&&(D=`<style data-admin-sidebar-style>${x.join(" ")}</style>`)}const V=_e(n)&&!I?Pe():"",_=String(L.logo||"").trim(),g=/^(?:\/(?!\/)|https?:\/\/)/i.test(_)?_:"",C=String(L.logoDark||"").trim(),T=/^(?:\/(?!\/)|https?:\/\/)/i.test(C)?C:"",X=g||T?`<img src="${m(g||T)}"${g?` data-logo-light="${m(g)}"`:""}${T?` data-logo-dark="${m(T)}"`:""} alt="" style="width:28px;height:28px;object-fit:contain;flex-shrink:0;">`:`<span data-icon="${m(L.icon||"layout")}"></span>`,xe=`<div class="dm-admin-sidebar-header">${L.enabled===!1?"":`${X}<span class="dm-admin-sidebar-title">${m(L.title)}</span>`}${V}${ze()}</div>`,$e=c.some(a=>a&&a.type==="spacer"&&a.size==="flex")?" dm-admin-sidebar--has-flex-spacer":"",we=`${D}<nav class="dm-admin-sidebar${P}${$e}">${xe}${c.map(a=>ue(a,F)).join("")}</nav>`,ee=document.createRange();ee.selectNodeContents(s);const ke=ee.createContextualFragment(we);s.replaceChildren(ke),qe(s),Domma.icons.scan(s),s.querySelector(".dm-admin-sidebar-arrange")?.addEventListener("click",()=>Ue(s));for(const a of j)Y.set(a.url,F[a.url]??null);ce(s),ut(s),y.refresh.then(a=>{if(!(!y.isActive()||!s.isConnected))for(const[x,p]of Object.entries(a))J(s,x,p)}),s.removeAttribute("data-menu-hover"),s.removeAttribute("data-menu-active"),s.style.removeProperty("--dm-menu-highlight"),He(s,{highlight:v});const B=document.querySelector(".dashboard-wrapper");["position","top","bottom","left","right","zIndex","maxHeight","transform"].forEach(a=>{s.style[a]=""}),s.classList.remove("dm-menu-floating"),B&&(B.style.paddingLeft="",B.style.paddingRight=""),s.__dmGutter=()=>{if(l!=="floating"||!B)return;const a=h&&h.anchor||"TL",x=Number.isFinite(Number(h?.offsetX))?Number(h.offsetX):16,p=s.classList.contains("is-collapsed")?We:parseInt(s.style.width,10)||s.getBoundingClientRect().width||260,N=Math.round(p+x*2)+"px";a==="R"||a==="TR"||a==="BR"?B.style.paddingRight=N:B.style.paddingLeft=N},l==="floating"&&Be(s,{position:"floating",float:h||{}}),s.querySelectorAll("details").forEach(a=>{a.addEventListener("toggle",function(){const x=this.getAttribute("data-state-key");x&&S.set(x,this.open);const p=this.querySelector(":scope > .sidebar-children");if(p)if(this.open){const N=p.scrollHeight;p.style.maxHeight="0",requestAnimationFrame(()=>{p.style.maxHeight=N+"px",p.addEventListener("transitionend",function Se(){p.style.maxHeight="none",p.removeEventListener("transitionend",Se)})})}else{const N=p.scrollHeight;p.style.maxHeight=N+"px",requestAnimationFrame(()=>{p.style.maxHeight="0"})}})}),De(s),ht(s),s.dataset.routeWired||(s.dataset.routeWired="1",M.subscribe("router:afterChange",()=>s.__dmSetActive?.()));function te(){const a=/^#\/(dashboards|my-dashboard)\b/.test(location.hash)?"#/":location.hash||"#/";$(s).find(".sidebar-link").removeClass("active"),$(s).find(`.sidebar-link[data-url="${a}"]`).addClass("active")}te(),s.__dmSetActive=te}let I=!1;function ge(){try{document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild"))}catch{}}function Q(e){return`${location.origin}${location.pathname}${e}`}function z(e,n){const t=w(),o=e(Z(t));if(!Ge(t,o)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}o.length&&ae(t,!1),be(t),n&&E.toast(n,{type:"success",duration:2500}),ge()}function be(e){Je(b,e).catch(()=>E.toast("Frequent is saved in this browser only - the server could not keep it.",{type:"warning"}))}function pt(e){if(!ae(w(),e)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}be(w()),E.toast(e?"Frequent hidden. Add a Tool to it from its right-click menu to bring it back.":"Frequent shown.",{type:"success",duration:3500}),ge()}function ye(e){const n=e.dataset.url;if(!n)return[];const t=e.querySelector(".sidebar-text")?.textContent.trim()||n,o=Z(w()),s=o.includes(n),r=!!e.closest("[data-frequent]"),u=o.indexOf(n),i=!s&&o.length>=oe;return[{header:t},{label:"Open",icon:"arrow-right",...re(n)&&{shortcut:tt(re(n))},action:()=>{location.hash=n}},{label:"Open in a new tab",icon:"external-link",action:()=>window.open(Q(n),"_blank","noopener")},...I?[]:[{type:"divider"},s?{label:"Remove from Frequent",icon:"star",action:()=>z(c=>Ze(c,n),`${t} removed from Frequent.`)}:{label:i?`Frequent is full (${oe})`:"Add to Frequent",icon:"star",disabled:i,action:()=>z(c=>Ke(c,n),`${t} added to Frequent.`)}],...r&&!I?[{label:"Move up",icon:"arrow-up",disabled:u<=0,action:()=>z(c=>ie(c,n,-1))},{label:"Move down",icon:"arrow-down",disabled:u<0||u>=o.length-1,action:()=>z(c=>ie(c,n,1))}]:[],{type:"divider"},{label:"Copy link",icon:"link",action:async()=>{try{await navigator.clipboard.writeText(Q(n)),E.toast("Link copied.",{type:"success",duration:2e3})}catch{E.toast(Q(n),{type:"info",duration:8e3})}}}]}function ve(e,n,t={}){const o=e.closest("details, [data-frequent]"),s=t.isOpen||(()=>!!o?.open),r=t.setOpen||(c=>{o&&(o.open=c)}),u=e.querySelector(".sidebar-text")?.textContent.trim()||"Folder",i=t.setAll||(c=>n.querySelectorAll("details").forEach(d=>{d.open!==c&&(d.open=c)}));return[{header:u},{label:s()?"Close":"Open",icon:s()?"chevron-up":"chevron-down",action:()=>r(!s())},...t.singleBranch?[]:[{label:"Open every folder",icon:"chevrons-down",action:()=>i(!0)}],{label:t.singleBranch?"Close all menus":"Close every folder",icon:"chevrons-up",action:()=>i(!1)},...o?.hasAttribute("data-frequent-empty")?[{type:"divider"},{label:"Hide Frequent until I add a Tool",icon:"eye-off",action:()=>pt(!0)}]:o?.hasAttribute("data-frequent")?[{type:"divider"},{label:"Clear Frequent",icon:"x",action:()=>z(()=>[],"Frequent cleared.")}]:[]]}function ht(e){e.dataset.ctxWired||typeof E>"u"||!E.contextMenu||(e.dataset.ctxWired="1",E.contextMenu(e,{match:"a.sidebar-link, details > summary",inherit:!1,density:"compact",items:n=>n.matches("summary")?ve(n,e):ye(n)}))}
|
|
4
|
+
</details>`}if(u){const y=se(e,t),A=S.get(y)!==!1,j=e.items.map(_=>ue(_,n,y,{inFrequent:!!e.frequent})).join(""),F=e.frequent?' data-frequent title="Your Frequent Tools - right-click any Tool to add or remove it"':"";return`<details data-state-key="${p(y)}"${A?" open":""}${F}>
|
|
5
|
+
<summary${b}${C}>${o} <span class="sidebar-text">${d}</span>${L}</summary>
|
|
6
|
+
<div class="sidebar-children">${j}</div>
|
|
7
|
+
</details>`}return`<a href="${r}" class="sidebar-link" data-url="${r}"${b}${f}${C}>${o} <span class="sidebar-text">${d}</span>${rt(e,n)}${L}</a>`}async function ct(e=[],n=[],t=null){const s=v=>v.then(x=>Array.isArray(x)?x.length:Array.isArray(x?.entries)?x.entries.length:0).catch(()=>0),i=fe(e,t),o=new Set(i.map(v=>v.url)),d={pages:"#/pages",media:"#/media",menus:"#/menus","context-menus":"#/context-menus",theme:"#/theme",collections:"#/collections",forms:"#/forms",views:"#/views",actions:"#/actions",blocks:"#/blocks",components:"#/components",users:"#/users",plugins:"#/plugins",notifications:"#/system/notifications"},r=(v,x)=>V(n,v)&&!o.has(d[v])?x():Promise.resolve(0),[u,a,c,f,m,b,q,C,L,y,A,j,F,_]=await Promise.all([r("pages",()=>s(g.pages.list())),r("media",()=>s(g.media.list())),r("menus",()=>s(g.menus.list())),r("context-menus",()=>s(g.contextMenus.list())),r("theme",()=>g.theme.get().then(v=>(v?.overrides||[]).length).catch(()=>0)),r("collections",()=>s(g.collections.list())),r("forms",()=>s(g.forms.list())),r("views",()=>s(g.views.list())),r("actions",()=>s(g.actions.list())),r("blocks",()=>s(g.blocks.list())),r("components",()=>s(g.components.list())),r("users",()=>s(g.users.list())),r("plugins",()=>s(g.plugins.list())),r("notifications",()=>g.system?.notifications?.unreadCount?.().then(v=>v?.count??0).catch(()=>0)??Promise.resolve(0))]),U=await pe(i),D={"#/pages":u,"#/media":a,"#/menus":c,"#/context-menus":f,"#/theme":m,"#/collections":b,"#/forms":q,"#/views":C,"#/actions":L,"#/blocks":y,"#/components":A,"#/users":j,"#/plugins":F,"#/system/notifications":_},W={};for(const[v,x]of Object.entries(D)){if(o.has(v))continue;const[K,T]=lt[v]??["item","items"],N=X(x);N&&(W[v]={...N,label:`${N.count} ${N.count===1?K:T}`})}return{...W,...U}}let O=[];const dt="dm:sidebar-count",ut=6e4,ft=Ae(4);function fe(e=[],n=null){const t=[],s=i=>{if(i&&!(n&&typeof i.url=="string"&&i.url.startsWith("#/")&&!je(n,i.url.slice(1)))){i.url&&typeof i.countUrl=="string"&&i.countUrl&&t.push({url:i.url,countUrl:i.countUrl,text:i.text||"",countLabel:i.countLabel||"",inventory:i.inventory===!0});for(const o of[...i.children||[],...i.items||[]])s(o)}};for(const i of e??[])s(i?.item??i);return t}async function me(e,{priority:n=!1}={}){try{const t=new Date,s=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,i=e.countUrl+(e.countUrl.includes("?")?"&":"?")+`today=${s}`,o=k()?.id,d=await ft(()=>!qe()||k()?.id!==o?null:H.get(i,{priority:"low"}),{key:JSON.stringify([o,i]),priority:n});return X(d,{fallbackLabel:e.countLabel||e.text})}catch{return null}}function J(e,n,t){Ee(n,t),t?.notify&&Be(k()?.id??null,n,t.notify);const s=[...e.querySelectorAll("a.sidebar-link")].filter(i=>i.dataset.url===n);if(s.length){for(const i of s){const o=i.querySelector(".sidebar-badge[data-count-for]");if(!t||!(t.count>0)&&!t.showZero)o?.remove();else{const d=document.createRange();d.selectNodeContents(i);const r=d.createContextualFragment(le(n,t)).firstElementChild;o?o.replaceWith(r):i.querySelector(".sidebar-text")?.after(r)}}Y.set(n,t),ce(e)}}const Y=new Map;async function pe(e){const n=await Fe(e,{legacy:async t=>{const s=await Promise.all(t.map(async i=>[i.url,await me(i)]));return Object.fromEntries(s)}});return Object.fromEntries(e.map(t=>[t.url,n[t.url]==null?null:X(n[t.url],{fallbackLabel:t.countLabel||t.text})]))}async function G(e,n=null){const t=k()?.id,s=O;try{const i=n?{[n]:await me(O.find(o=>o.url===n),{priority:!0})}:await pe(O);if(k()?.id!==t||O!==s)return;for(const[o,d]of Object.entries(i)){const r=Y.get(o);JSON.stringify(r??null)!==JSON.stringify(d)&&J(e,o,d)}}catch{}}function mt(e){e.dataset.liveCounts||(e.dataset.liveCounts="1",window.addEventListener(dt,n=>{const t=n.detail||{};if(t.url)if(t.count!==void 0){const s=O.find(i=>i.url===t.url);J(e,t.url,X(t,{fallbackLabel:s?.countLabel||s?.text||""}))}else G(e,t.url)}),setInterval(()=>{!document.hidden&&document.body.contains(e)&&G(e)},ut),document.addEventListener("visibilitychange",()=>{document.hidden||G(e)}),pt(e))}function he(e,n,t){const s=(d,r,u)=>{const a=document.createElement(d);return r&&(a.className=r),u!=null&&(a.textContent=String(u)),a};if(!t){e.textContent=n;return}e.appendChild(s("strong","dm-badge-pop-title",t.title||n)),(t.rows?.length||!t.items?.length)&&e.appendChild(s("p","dm-badge-pop-sub",n));const i=Array.isArray(t.rows)?t.rows.slice(0,6):[];if(i.length){const d=s("dl","dm-badge-pop-rows");for(const r of i)d.appendChild(s("dt",null,r.label)),d.appendChild(s("dd",r.tone==="danger"?"is-danger":null,r.value));e.appendChild(d)}const o=Array.isArray(t.items)?t.items.slice(0,6):[];if(o.length){const d=s("ul","dm-badge-pop-items");for(const r of o){const u=s("li",r.tone==="danger"?"is-danger":null);u.appendChild(s("span","dm-badge-pop-text",r.text)),r.meta&&u.appendChild(s("span","dm-badge-pop-meta",r.meta)),d.appendChild(u)}e.appendChild(d)}else t.empty&&e.appendChild(s("p","dm-badge-pop-empty",t.empty))}function pt(e){let n=null,t=null;const s=()=>e.classList.contains("is-collapsed"),i=()=>{clearTimeout(t),n?.remove(),n=null},o=(a,c)=>{i(),t=setTimeout(()=>{n=document.createElement("div"),n.className="dm-help-pop dm-badge-pop",n.setAttribute("role","tooltip"),c(n),document.body.appendChild(n);const f=a.getBoundingClientRect(),m=n.getBoundingClientRect(),b=Math.min(f.right+10,innerWidth-m.width-8);n.style.left=`${Math.max(8,b)}px`,n.style.top=`${Math.max(8,Math.min(f.top+f.height/2-m.height/2,innerHeight-m.height-8))}px`},150)},d=a=>{const c=a?.dataset.badgeLabel;if(!c)return i();o(a,f=>he(f,c,I.get(a.dataset.countFor)))},r=a=>{const c=a.querySelector(":scope > .sidebar-text")?.textContent.trim()||"",f=a.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");o(a,m=>{const b=f&&I.get(f.dataset.countFor);if(b)return he(m,f.dataset.badgeLabel,{...b,title:b.title||c});if(!f){m.textContent=c;return}const q=document.createElement("strong");q.className="dm-badge-pop-title",q.textContent=c;const C=document.createElement("p");C.className="dm-badge-pop-sub",C.textContent=f.dataset.badgeLabel,m.append(q,C)})},u=a=>{const c=a.closest?.("a.sidebar-link, summary");return c&&e.contains(c)?c:null};e.addEventListener("mouseover",a=>{if(s()){const f=u(a.target);f&&!f.contains(a.relatedTarget)&&r(f);return}const c=a.target.closest?.(".sidebar-badge[data-badge-label]");c&&d(c)}),e.addEventListener("mouseout",a=>{if(s()){const c=u(a.target);c&&!c.contains(a.relatedTarget)&&i();return}a.target.closest?.(".sidebar-badge[data-badge-label]")&&i()}),e.addEventListener("focusin",a=>{const c=a.target.closest?.("a, summary");if(s()&&c&&e.contains(c)&&c.querySelector(":scope > .sidebar-text"))return r(c);const f=c?.querySelector(":scope > .sidebar-badge[data-badge-label]:not([hidden])");f?d(f):i()}),e.addEventListener("focusout",i),e.addEventListener("click",i),window.addEventListener("scroll",i,!0),window.addEventListener("hashchange",i)}async function ht(e=[],n=null){if(n?.title||n?.enabled===!1)return n;if(!V(e,"settings"))return{title:"Domma CMS"};try{const t=await g.settings.get();return{...t?.adminBrand,title:t?.adminBrand?.title||t?.title||"Domma CMS"}}catch{return{title:"Domma CMS"}}}export async function renderAdminSidebar({mount:e,permissions:n,adminScope:t=null,brand:s=null,notificationsScreen:i=!0}){const o=$(e).get(0);if(!o)return;P=Oe(t);const d=P?Promise.resolve():Qe(g,k()).catch(()=>{}),r=Promise.resolve().then(()=>H.get("/api/sidebar/registered-items")).catch(()=>[]),u=it(n);let a,c=null,f=null,m=null,b=null,q=null;try{const l=await g.get("/sidebar/menu");a=Array.isArray(l?.items)?l.items:null,c=l?.variant||null,f=l?.position||null,m=l?.style||null,b=l?.float||null,q=l?.highlight||null}catch{a=null}(!a||!a.some(l=>l&&(!l.hidden||l.restricted)))&&(console.warn("[admin-sidebar] No admin-sidebar menu found; using fallback tree"),a=ot.slice());let C=[];try{C=await r||[]}catch{}const L=await u;if(a=Pe(a,C,{permissions:n,adminScope:t,beforeFilter:l=>{L.length&&at(l,L)}}),i||(a=Me(a,Te)),await d,P)a=_e(a);else{const l=Ze(a,Z(k()),{hidden:Je(k())});l&&(a=[l,...a])}nt(a);const y=C.filter(l=>V(n,l?.item?.permission));O=fe(y,t);const A=Le({user:k(),permissions:n,adminScope:t,registered:y,tree:a,actions:{linkItems:ye,folderItems:ve},fetcher:()=>ct(y,n,t)}),j=A.counts,F=await ht(n,s),_=c?` dm-admin-sidebar--${p(c)}`:"";function U(l,w="px"){if(l==null)return l;const h=String(l).trim();return/^\d+(\.\d+)?$/.test(h)?`${h}${w}`:h}let D="";if(m){const l=[];m.fontFamily&&l.push(`font-family: ${m.fontFamily}, sans-serif`),m.fontSize&&l.push(`font-size: ${U(m.fontSize)}`),m.fontWeight&&l.push(`font-weight: ${m.fontWeight}`),m.letterSpacing&&l.push(`letter-spacing: ${U(m.letterSpacing,"em")}`);const w=[];if(l.length&&w.push(`#admin-sidebar .dm-admin-sidebar, #admin-sidebar .dm-admin-sidebar .sidebar-link, #admin-sidebar .dm-admin-sidebar summary, #admin-sidebar .dm-admin-sidebar .sidebar-text { ${l.join("; ")} }`),m.iconSize){const h=U(m.iconSize);w.push(`#admin-sidebar .dm-admin-sidebar [data-icon], #admin-sidebar .dm-admin-sidebar [data-icon] svg { width: ${h} !important; height: ${h} !important; }`)}w.length&&(D=`<style data-admin-sidebar-style>${w.join(" ")}</style>`)}const W=ze(n)&&!P?Ue():"",v=String(F.logo||"").trim(),x=/^(?:\/(?!\/)|https?:\/\/)/i.test(v)?v:"",K=String(F.logoDark||"").trim(),T=/^(?:\/(?!\/)|https?:\/\/)/i.test(K)?K:"",N=x||T?`<img src="${p(x||T)}"${x?` data-logo-light="${p(x)}"`:""}${T?` data-logo-dark="${p(T)}"`:""} alt="" style="width:28px;height:28px;object-fit:contain;flex-shrink:0;">`:`<span data-icon="${p(F.icon||"layout")}"></span>`,xe=`<div class="dm-admin-sidebar-header">${F.enabled===!1?"":`${N}<span class="dm-admin-sidebar-title">${p(F.title)}</span>`}${W}${We()}</div>`,$e=a.some(l=>l&&l.type==="spacer"&&l.size==="flex")?" dm-admin-sidebar--has-flex-spacer":"",we=`${D}<nav class="dm-admin-sidebar${_}${$e}">${xe}${a.map(l=>ue(l,j)).join("")}</nav>`,ee=document.createRange();ee.selectNodeContents(o);const ke=ee.createContextualFragment(we);o.replaceChildren(ke),Ce(o),Domma.icons.scan(o),o.querySelector(".dm-admin-sidebar-arrange")?.addEventListener("click",()=>De(o));for(const l of O)Y.set(l.url,j[l.url]??null);ce(o),mt(o),A.refresh.then(l=>{if(!(!A.isActive()||!o.isConnected))for(const[w,h]of Object.entries(l))J(o,w,h)}),o.removeAttribute("data-menu-hover"),o.removeAttribute("data-menu-active"),o.style.removeProperty("--dm-menu-highlight"),Re(o,{highlight:q});const B=document.querySelector(".dashboard-wrapper");["position","top","bottom","left","right","zIndex","maxHeight","transform"].forEach(l=>{o.style[l]=""}),o.classList.remove("dm-menu-floating"),B&&(B.style.paddingLeft="",B.style.paddingRight=""),o.__dmGutter=()=>{if(f!=="floating"||!B)return;const l=b&&b.anchor||"TL",w=Number.isFinite(Number(b?.offsetX))?Number(b.offsetX):16,h=o.classList.contains("is-collapsed")?Ve:parseInt(o.style.width,10)||o.getBoundingClientRect().width||260,R=Math.round(h+w*2)+"px";l==="R"||l==="TR"||l==="BR"?B.style.paddingRight=R:B.style.paddingLeft=R},f==="floating"&&He(o,{position:"floating",float:b||{}}),o.querySelectorAll("details").forEach(l=>{l.addEventListener("toggle",function(){const w=this.getAttribute("data-state-key");w&&S.set(w,this.open);const h=this.querySelector(":scope > .sidebar-children");if(h)if(this.open){const R=h.scrollHeight;h.style.maxHeight="0",requestAnimationFrame(()=>{h.style.maxHeight=R+"px",h.addEventListener("transitionend",function Se(){h.style.maxHeight="none",h.removeEventListener("transitionend",Se)})})}else{const R=h.scrollHeight;h.style.maxHeight=R+"px",requestAnimationFrame(()=>{h.style.maxHeight="0"})}})}),Ke(o),bt(o),o.dataset.routeWired||(o.dataset.routeWired="1",M.subscribe("router:afterChange",()=>o.__dmSetActive?.()));function te(){const l=/^#\/(dashboards|my-dashboard)\b/.test(location.hash)?"#/":location.hash||"#/";$(o).find(".sidebar-link").removeClass("active"),$(o).find(`.sidebar-link[data-url="${l}"]`).addClass("active")}te(),o.__dmSetActive=te}let P=!1;function ge(){try{document.dispatchEvent(new CustomEvent("dm:sidebar-rebuild"))}catch{}}function Q(e){return`${location.origin}${location.pathname}${e}`}function z(e,n){const t=k(),s=e(Z(t));if(!et(t,s)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}s.length&&ae(t,!1),be(t),n&&E.toast(n,{type:"success",duration:2500}),ge()}function be(e){Ge(g,e).catch(()=>E.toast("Frequent is saved in this browser only - the server could not keep it.",{type:"warning"}))}function gt(e){if(!ae(k(),e)){E.toast("Frequent could not be saved - this browser is blocking storage.",{type:"error"});return}be(k()),E.toast(e?"Frequent hidden. Add a Tool to it from its right-click menu to bring it back.":"Frequent shown.",{type:"success",duration:3500}),ge()}function ye(e){const n=e.dataset.url;if(!n)return[];const t=e.querySelector(".sidebar-text")?.textContent.trim()||n,s=Z(k()),i=s.includes(n),o=!!e.closest("[data-frequent]"),d=s.indexOf(n),r=!i&&s.length>=oe;return[{header:t},{label:"Open",icon:"arrow-right",...re(n)&&{shortcut:st(re(n))},action:()=>{location.hash=n}},{label:"Open in a new tab",icon:"external-link",action:()=>window.open(Q(n),"_blank","noopener")},...P?[]:[{type:"divider"},i?{label:"Remove from Frequent",icon:"star",action:()=>z(u=>Ye(u,n),`${t} removed from Frequent.`)}:{label:r?`Frequent is full (${oe})`:"Add to Frequent",icon:"star",disabled:r,action:()=>z(u=>Xe(u,n),`${t} added to Frequent.`)}],...o&&!P?[{label:"Move up",icon:"arrow-up",disabled:d<=0,action:()=>z(u=>ie(u,n,-1))},{label:"Move down",icon:"arrow-down",disabled:d<0||d>=s.length-1,action:()=>z(u=>ie(u,n,1))}]:[],{type:"divider"},{label:"Copy link",icon:"link",action:async()=>{try{await navigator.clipboard.writeText(Q(n)),E.toast("Link copied.",{type:"success",duration:2e3})}catch{E.toast(Q(n),{type:"info",duration:8e3})}}}]}function ve(e,n,t={}){const s=e.closest("details, [data-frequent]"),i=t.isOpen||(()=>!!s?.open),o=t.setOpen||(u=>{s&&(s.open=u)}),d=e.querySelector(".sidebar-text")?.textContent.trim()||"Folder",r=t.setAll||(u=>n.querySelectorAll("details").forEach(a=>{a.open!==u&&(a.open=u)}));return[{header:d},{label:i()?"Close":"Open",icon:i()?"chevron-up":"chevron-down",action:()=>o(!i())},...t.singleBranch?[]:[{label:"Open every folder",icon:"chevrons-down",action:()=>r(!0)}],{label:t.singleBranch?"Close all menus":"Close every folder",icon:"chevrons-up",action:()=>r(!1)},...s?.hasAttribute("data-frequent-empty")?[{type:"divider"},{label:"Hide Frequent until I add a Tool",icon:"eye-off",action:()=>gt(!0)}]:s?.hasAttribute("data-frequent")?[{type:"divider"},{label:"Clear Frequent",icon:"x",action:()=>z(()=>[],"Frequent cleared.")}]:[]]}function bt(e){e.dataset.ctxWired||typeof E>"u"||!E.contextMenu||(e.dataset.ctxWired="1",E.contextMenu(e,{match:"a.sidebar-link, details > summary",inherit:!1,density:"compact",items:n=>n.matches("summary")?ve(n,e):ye(n)}))}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{api as
|
|
2
|
-
${
|
|
3
|
-
<a class="nt-menu-type" href="#/system/notifications?type=${
|
|
4
|
-
<span class="nt-menu-icon is-${
|
|
5
|
-
<span>${
|
|
1
|
+
import{api as q,apiRequest as O}from"../api.js";import{sidebarCount as T}from"./tool-kit.js";import{ago as P,severityOf as R}from"./notifications-arrange.js";import{ownNotifications as H}from"./admin-portal-arrange.js";import{wireNotificationCacheMenu as I}from"./topbar-cache.js";const U=[["critical","Critical","alert-circle","danger"],["warning","Warnings","alert-triangle","warn"],["info","Information","info","info"],["success","Success","check-circle","ok"]];export function notificationGroups(w=[]){return U.map(([g,C,i,l])=>{const f=w.filter(e=>R(e)===g);return{type:g,label:C,icon:i,tone:l,total:f.length,unread:f.filter(e=>e.unread).length}})}let A;export function wireNotificationMenu({refreshBadge:w,canRead:g=()=>!0,own:C=()=>!1}){A?.abort(),A=new AbortController;const{signal:i}=A,l=document.getElementById("topbar-notifications");if(!l)return;const f=l.querySelector("#topbar-bell"),e=l.querySelector("#topbar-notifications-menu"),p=document.createElement("div");p.dataset.notificationItems="";const S=e.querySelector(".topbar-sidebar-choice");e.replaceChildren(p,...S?[S]:[]),I();let v=0,h=!1;const m=()=>{v++,e.hidden=!0,f.setAttribute("aria-expanded","false")},$=t=>{const n=document.createElement("p");n.className="nt-menu-status",n.setAttribute("role","status"),n.textContent=t,p.replaceChildren(n)},D=t=>{const n=H(t),r=n.filter(c=>c.unread).length,a=document.createElement("div");a.className="nt-menu-heading",a.setAttribute("aria-live","polite"),a.append("Notifications ");const d=document.createElement("span");d.textContent=`${r} unread`,a.append(d);const s=n.map(c=>{const u=document.createElement(c.link?"a":"div");u.className="nt-own"+(c.unread?" is-unread":""),u.dataset.own=c.id,c.link&&(u.href=c.link,c.link.startsWith("#/")||(u.target="_blank",u.rel="noopener"));const L=document.createElement("strong");if(L.textContent=c.title,u.append(L),c.body){const b=document.createElement("span");b.textContent=c.body,u.append(b)}if(c.at){const b=document.createElement("small");b.textContent=P(c.at),u.append(b)}return u}),o=document.createElement("div");o.className="nt-menu-footer";const y=document.createElement("button");y.type="button",y.setAttribute("data-read-all",""),y.textContent="Mark all as read",y.disabled=h||!r,o.append(y);const k=document.createElement(s.length?"div":"p");k.className=s.length?"nt-own-list":"nt-menu-status",s.length?k.append(...s):k.textContent="No notifications - you're all caught up.",p.replaceChildren(a,k,o)},M=t=>{if(C())return D(t);const n=p.contains(document.activeElement)?document.activeElement:null,r=n?.dataset.dismiss,a=n?.getAttribute("href"),d=n?.hasAttribute("data-read-all"),s=notificationGroups(t);p.innerHTML=`<div class="nt-menu-heading" aria-live="polite">Notifications <span>${s.reduce((o,y)=>o+y.unread,0)} unread</span></div>
|
|
2
|
+
${s.map(o=>`<div class="nt-menu-row">
|
|
3
|
+
<a class="nt-menu-type" href="#/system/notifications?type=${o.type}">
|
|
4
|
+
<span class="nt-menu-icon is-${o.tone}"><span data-icon="${o.icon}"></span></span>
|
|
5
|
+
<span>${o.label}<small>${o.unread} unread / ${o.total} total</small></span>
|
|
6
6
|
</a>
|
|
7
|
-
<button type="button" class="nt-menu-dismiss" data-dismiss="${
|
|
7
|
+
<button type="button" class="nt-menu-dismiss" data-dismiss="${o.type}" data-count="${o.total}" aria-label="Dismiss ${o.total} ${o.label.toLowerCase()} notifications" ${!o.total||h?"disabled":""}>Dismiss</button>
|
|
8
8
|
</div>`).join("")}
|
|
9
9
|
${t.length?"":`<p class="nt-menu-status">No notifications - you're all caught up.</p>`}
|
|
10
10
|
<div class="nt-menu-footer"><a href="#/system/notifications?type=all">View all notifications</a>
|
|
11
|
-
<button type="button" data-read-all ${
|
|
11
|
+
<button type="button" data-read-all ${h||!t.some(o=>o.unread)?"disabled":""}>Mark all as read</button></div>`,Domma.icons.scan(e),r?(e.querySelector(`[data-dismiss="${r}"]:not(:disabled)`)||e.querySelector(`a[href$="type=${r}"]`))?.focus():a?[...e.querySelectorAll("a")].find(o=>o.getAttribute("href")===a)?.focus():d&&(e.querySelector("[data-read-all]:not(:disabled)")||e.querySelector(".nt-menu-footer a"))?.focus()},N=async()=>{if(!g()){$("Notifications are unavailable for this account.");return}const t=++v;try{const n=await q.system.notifications.list();if(i.aborted||t!==v||e.hidden)return;M(Array.isArray(n)?n:[])}catch{!i.aborted&&t===v&&!e.hidden&&$("Could not load notifications. Close and reopen to try again.")}},x=async t=>{document.dispatchEvent(new CustomEvent("dm:topbar-menu-open",{detail:{owner:l}})),e.hidden=!1,f.setAttribute("aria-expanded","true"),$("Loading notifications..."),await N(),t&&!e.hidden&&e.querySelector("a, input:not(:disabled), button:not(:disabled)")?.focus()};f.addEventListener("click",()=>e.hidden?x(!1):m(),{signal:i}),f.addEventListener("keydown",t=>{t.key==="ArrowDown"&&(t.preventDefault(),x(!0))},{signal:i}),e.addEventListener("click",async t=>{const n=t.target.closest("a"),r=t.target.closest("[data-own]");if(r){q.system.notifications.markRead(r.dataset.own).then(()=>(document.dispatchEvent(new CustomEvent("dm:notifications-changed")),w())).catch(()=>{}),m();return}if(n){const s=new URLSearchParams(n.hash.split("?")[1]||"").get("type");document.dispatchEvent(new CustomEvent("dm:notifications-filter",{detail:{type:s}})),m();return}const a=t.target.closest("button");if(!a||a.disabled||h||!a.hasAttribute("data-dismiss")&&!a.hasAttribute("data-read-all"))return;const d=a.dataset.dismiss;h=!0;try{if(d==="critical"&&!await E.confirm(`Dismiss all ${a.dataset.count} critical notifications? They are hidden for you only.`))return;p.querySelectorAll("button").forEach(s=>{s.disabled=!0}),await O(`/system/notifications/${d?"dismiss-all":"read-all"}`,{method:"POST",...d?{body:JSON.stringify({severity:d})}:{}}),document.dispatchEvent(new CustomEvent("dm:notifications-changed")),T("#/system/notifications"),await w()}catch(s){E.toast(`Could not update notifications: ${s.message||s}`,{type:"error"})}finally{h=!1,!i.aborted&&!e.hidden&&await N()}},{signal:i}),e.addEventListener("keydown",t=>{const n=[...e.querySelectorAll("a, input:not(:disabled), button:not(:disabled)")].filter(d=>!d.closest("[hidden]")),r=n.indexOf(document.activeElement);if(r<0)return;let a;t.key==="ArrowDown"&&(a=(r+1)%n.length),t.key==="ArrowUp"&&(a=(r-1+n.length)%n.length),t.key==="Home"&&(a=0),t.key==="End"&&(a=n.length-1),a!==void 0&&(t.preventDefault(),n[a].focus())},{signal:i}),document.addEventListener("click",t=>{l.contains(t.target)||m()},{signal:i}),document.addEventListener("focusin",t=>{l.contains(t.target)||m()},{signal:i}),document.addEventListener("dm:topbar-menu-open",t=>{t.detail.owner!==l&&m()},{signal:i}),document.addEventListener("keydown",t=>{!t.defaultPrevented&&t.key==="Escape"&&!e.hidden&&(m(),f.focus(),t.preventDefault())},{signal:i}),window.addEventListener("hashchange",m,{signal:i})}
|
|
@@ -89,4 +89,4 @@
|
|
|
89
89
|
</div>
|
|
90
90
|
</div>
|
|
91
91
|
|
|
92
|
-
<p><strong>
|
|
92
|
+
<p><strong>Character:</strong> give a chat launcher a character's name, portrait and animated poses: Della, Dash (her Job Board guise), Remy (her guise for health-care sites, in scrubs), Dot or Daisy. Control character visibility and animation in Site Settings > General > Builders and Bots. Your custom branding is kept when you choose No character.</p>
|
|
@@ -74,6 +74,14 @@
|
|
|
74
74
|
in the sidebar, and the server refuses their calls to any plugin API whose screens they
|
|
75
75
|
cannot open. A user is confined only when every role they hold is confined: one unconfined
|
|
76
76
|
role lifts it. The level-0 role is never confined.</p>
|
|
77
|
+
<p>When a confined user's home belongs to a Tool that offers a portal (the Job Board does), the admin
|
|
78
|
+
looks like that Tool's own app: no side menu, the Tool's sections along the top bar with a count on
|
|
79
|
+
each, and the Tool's name at the top left. The Tool decides which sections each person sees.</p>
|
|
80
|
+
|
|
81
|
+
<h3>Notifications: the admins' screen and everyone's bell</h3>
|
|
82
|
+
<p>The Notifications screen, with the site's own messages (critical, warnings, updates), is for Admins
|
|
83
|
+
and Super Admins. Everyone else's bell, top right beside Account, lists only the notifications
|
|
84
|
+
addressed to them, each opening where it points.</p>
|
|
77
85
|
|
|
78
86
|
<h3>Who can see what: the role ladder</h3>
|
|
79
87
|
<p>Pages, menu items, views and actions name the roles they are for. Two forms exist, and the
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
<p class="text-muted">A shared help and drafting panel for signed-in users. It follows their tool access and cannot save, publish or send. Uses the site's existing AI service and allowance.</p>
|
|
96
96
|
<div class="stx-grid" data-bind-hidden="!adminAssistantEnabled.value">
|
|
97
97
|
<div><label class="form-label" for="stx-admin-assistant-name">Assistant name</label><input id="stx-admin-assistant-name" class="form-input" maxlength="40" data-model="adminAssistantName.value"></div>
|
|
98
|
-
<div><label class="form-label" for="stx-admin-assistant-character">Character artwork</label><select id="stx-admin-assistant-character" class="form-select" data-model="adminAssistantCharacter.value"><option value="">No character</option><option value="della">Della</option><option value="dash">Dash</option><option value="dot">Dot</option><option value="daisy">Daisy</option></select></div>
|
|
98
|
+
<div><label class="form-label" for="stx-admin-assistant-character">Character artwork</label><select id="stx-admin-assistant-character" class="form-select" data-model="adminAssistantCharacter.value"><option value="">No character</option><option value="della">Della</option><option value="dash">Dash</option><option value="remy">Remy</option><option value="dot">Dot</option><option value="daisy">Daisy</option></select></div>
|
|
99
99
|
<div class="stx-wide"><label class="form-label" for="stx-admin-assistant-context">Admin assistant context</label><textarea id="stx-admin-assistant-context" class="form-input" rows="3" maxlength="4000" data-model="adminAssistantContext.value"></textarea></div>
|
|
100
100
|
<div class="stx-wide"><label class="form-label" for="stx-admin-assistant-rules">Admin assistant rules</label><textarea id="stx-admin-assistant-rules" class="form-input" rows="3" maxlength="2000" data-model="adminAssistantRules.value"></textarea></div>
|
|
101
101
|
</div>
|
package/docs/DommaFeatures.md
CHANGED
|
@@ -1240,7 +1240,7 @@ The four Tools below were plugins until 0.67.0 and are now part of the CMS. They
|
|
|
1240
1240
|
- Hand-over: with staff available (the Chats screen open and Available on - memory presence, 75s) the chat goes to `waiting` and staff are notified (source `core:chat`, admins); with nobody available the visitor leaves name and email (`message`) unless the launcher says never; `askDetails: always` asks before putting them through. A staff reply makes it `open` and the bot stays quiet. Hourly tidy-up closes quiet chats (bot 2h, waiting/open 24h) and deletes ended ones after `retentionDays` (90) - bot-only chats with no details after 7 days - with their messages and any orphan messages, one write per collection (adapters' `removeMany`). Chats in memory are an LRU of 2000; unknown tokens are remembered for a minute. A Launchers module that is missing refuses every chat.
|
|
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
|
-
- 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, 16,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. `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).
|
|
1243
|
+
- 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, 16,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).
|
|
1244
1244
|
- 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()`).
|
|
1245
1245
|
- 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.
|
|
1246
1246
|
- 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).
|
|
@@ -1286,6 +1286,8 @@ The four Tools below were plugins until 0.67.0 and are now part of the CMS. They
|
|
|
1286
1286
|
Plugins contribute their own resources on top. The role editor lists the groups in that order, Tools before Plugins (fixed in 0.93.0).
|
|
1287
1287
|
Where: `server/services/permissionRegistry.js`, `GET /api/auth/permissions-registry`.
|
|
1288
1288
|
- **Admin scope (confinement)** - A role can confine its holders to certain admin screens with `admin: {home, allow: [...]}`. A user is confined only if every role they hold is confined, and Super Admin is never confined. The server applies the scope to plugin APIs as well (fixed in 0.86.0).
|
|
1289
|
+
- **Tool portals** - A confined user whose home belongs to a plugin with `admin.portal` gets that Tool as an app: its sections on the top bar with count badges, no side menu, the Tool's name as the admin's title (`/api/auth/permissions` answers `adminPortal` and swaps `adminBrand.title`).
|
|
1290
|
+
- **Notifications screen for admins only** - `#/system/notifications` and its menu entries are for admin and super-admin (`notificationsScreen` in `/api/auth/permissions`); anyone else is routed home, and their bell lists their own notifications (title, text, when, link) instead of the severity groups. The API already returned only notifications addressed to them.
|
|
1289
1291
|
Where: Role editor > Admin area; `normaliseAdminScope` / `getAdminScope` in `roles.js`; `admin/js/lib/admin-scope.js` - Since: 0.71.0.
|
|
1290
1292
|
- **Plugin roles and permissions** - Plugins declare `permissions[]` in `plugin.json`, with `grant` to give them to existing roles, and ship `roles/*.json`. They can also create and remove roles from code with `hooks.registerRole()` and `unregisterRole()`. A plugin role is created once and then belongs to the admin. Disabling the plugin keeps the role, so user assignments survive, and uninstalling removes it.
|
|
1291
1293
|
Since: 0.71.0.
|
|
@@ -1600,6 +1602,7 @@ plugins/my-plugin/
|
|
|
1600
1602
|
| `name`, `displayName`, `version`, `description`, `author`, `date`, `icon` | Required. `name` must equal the folder name. |
|
|
1601
1603
|
| `admin.sidebar[]` | Sidebar entries `{text, url, icon, folder?, group?, permission?, visibility?, countUrl?, items?, section?}`. `folder` = default placement (`tools` unless `overview`, `projects`, `content`, `data`, `system`, `documentation`). `group` = an optional sub-folder of it (`Core` -> Tools > Core). |
|
|
1602
1604
|
| `admin.routes[]`, `admin.views{}` | SPA routes and view modules `{entry, exportName}`. |
|
|
1605
|
+
| `admin.portal` | `{title, nav}` - for a user confined to this plugin's screens (role `admin.home` is one of its routes): no side menu, the admin is named `title`, and the top bar's menus come from `nav` (a GET under `/api/plugins/<name>/` answering `{items: [{text, url: '#/...', icon?, count?, label?, tone?}]}` for the signed-in user; sections that do not fit go under More). `server/services/adminPortal.js`, `admin/js/lib/admin-portal.js`. |
|
|
1603
1606
|
| `admin.css[]` | Admin stylesheets (may include `../_lib/admin/ui/help.css`). |
|
|
1604
1607
|
| `inject.head`, `inject.headLate`, `inject.bodyEnd` | HTML snippets added to every public page (paths confined to the plugin folder). |
|
|
1605
1608
|
| `permissions[]` | Permission resources `{key, label, actions?, group?, icon?, grant?: ["admin"], collectionAction?}` - `grant` given once; `collectionAction` is the action the generic Collections API needs on the plugin's collections (default: every action). |
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Remy character pack
|
|
2
|
+
|
|
3
|
+
Remy is Della's medical guise, made for Regimen (EMR software for oncology and
|
|
4
|
+
infusion centres): teal scrubs, a navy cardigan and an ID lanyard, with a
|
|
5
|
+
tablet. She is drawn as a clinical informatics specialist, not a doctor: no
|
|
6
|
+
white coat, stethoscope or medicine. Her artwork is at
|
|
7
|
+
`/public/images/characters/remy-poses.png`, the same three columns by two rows
|
|
8
|
+
as the other packs: ready, greeting, working, thinking, success and help.
|
|
9
|
+
|
|
10
|
+
Choose **Remy** in a chat launcher's **Character** selector, or under **Site
|
|
11
|
+
Settings > General > Admin assistant > Character artwork**. An empty display
|
|
12
|
+
name uses Remy.
|
|
13
|
+
|
|
14
|
+
The pack is artwork only. It adds no AI behaviour: what Remy answers, and what
|
|
15
|
+
she refuses, comes from the launcher's own context and rules and the chat's
|
|
16
|
+
built-in safeguards, as for every character.
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CHARACTERS as p,builderCharacterState as f,normaliseCharacterSettings as w}from"./characters.mjs?v=20261111-
|
|
1
|
+
import{CHARACTERS as p,builderCharacterState as f,normaliseCharacterSettings as w}from"./characters.mjs?v=20261111-remy-character";import{mountCharacter as R,ensureCharacterCss as T}from"./character-view.mjs?v=20261111-remy-character";export async function mountBuilderCharacter(d,{id:e,getState:m=()=>({})}={}){const u={destroy(){}};if(!d||!["dot","daisy"].includes(e))return u;const{apiRequest:b}=await import("/admin/js/api.js");let i;try{i=await b("/characters",{method:"GET"})}catch{return u}if(!d.isConnected)return u;const t=M.observable(w(i.settings)),o=M.observable(t.peek()[e]),l=M.observable(!1),c={value:!0};T();const a=document.createElement("section");a.className="dm-builder-character",a.setAttribute("aria-label",`${p[e].name} presentation`),a.innerHTML=`<div class="dm-builder-character-toolbar"><label><input type="checkbox" class="form-switch" data-model="selected.value" data-bind-disabled="disabled.value"><span>Use ${p[e].name}</span></label><small data-bind-text="note.value"></small></div>
|
|
2
2
|
<div class="dm-builder-character-content" data-bind-hidden="!visible.value"><span class="dm-builder-character-stage"></span><div><strong>${p[e].name}</strong><span data-bind-text="words.value"></span></div></div>`,d.prepend(a);const k=()=>i.canUpdate?!t.value.enabled||!t.value.builders?"Character artwork is hidden in Site Settings.":"Saved for this site. Visibility and motion follow Site Settings.":"Only people who can change Site Settings can change this choice.",h=()=>o.value&&t.value.enabled&&t.value.builders,S={selected:o,disabled:M.computed(()=>l.value||!i.canUpdate),visible:M.computed(h),note:M.computed(k),words:M.computed(()=>{const s=m();return s.words?s.words:{greeting:"Ready when you are.",ready:"Here to help with your next step.",working:"Working on your request.",thinking:"Taking a moment to think.",help:"A little input or attention is needed.",success:"Ready for you to review."}[f(s)]})},C=M.applyBindings(S,a);let n=null;const x=M.effect(()=>{const s=m(),r=h(),g=t.value.animated;r&&!n&&(n=R(a.querySelector(".dm-builder-character-stage"),{id:e,animated:g})),!r&&n&&(n.destroy(),n=null),n?.setState(f(s),g)}),v=a.querySelector("input"),y=async()=>{if(l.peek()||!i.canUpdate)return;const s=v.checked;l.value=!0;try{const r=await b(`/characters/${e}`,{method:"PUT",body:JSON.stringify({enabled:s})});if(!c.value)return;t.value=w(r.settings),o.value=t.peek()[e]}catch(r){if(!c.value)return;o.value=t.peek()[e],E.toast(`Not saved: ${r.message||r}`,{type:"error"})}finally{c.value&&(l.value=!1)}};return v.addEventListener("change",y),{destroy(){c.value=!1,v.removeEventListener("change",y),x?.(),n?.destroy(),C?.dispose?.(),a.remove()}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CHARACTERS as i,characterId as
|
|
1
|
+
import{CHARACTERS as i,characterId as m}from"./characters.mjs?v=20261111-remy-character";export function ensureCharacterCss(){if(!document.querySelector("link[data-dm-character-css]")){const t=document.createElement("link");t.rel="stylesheet",t.href="/public/css/characters.css?v=20261111-remy-character",t.dataset.dmCharacterCss="",document.head.appendChild(t)}}export function mountCharacter(t,{id:a,portrait:n=!1,animated:r=!0}={}){if(!t||!m(a))return{setState(){},destroy(){}};ensureCharacterCss();const e=document.createElement("span");e.className=`dm-character${n?" dm-character--portrait":""}`,e.setAttribute("aria-hidden","true"),e.dataset.character=a,e.dataset.state="ready",e.dataset.animated=String(r),e.style.setProperty("--dm-character-art",`url("${i[a].artwork}")`);const c=document.createElement("span");return c.className="dm-character-sprite",e.appendChild(c),t.appendChild(e),{setState(s,d=r){e.dataset.state=["ready","greeting","working","thinking","success","help"].includes(s)?s:"ready",e.dataset.animated=String(d)},destroy(){e.remove()}}}
|
package/public/js/characters.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CHARACTERS=Object.freeze({dot:Object.freeze({id:"dot",name:"Dot",artwork:"/public/images/characters/dot-poses.png"}),daisy:Object.freeze({id:"daisy",name:"Daisy",artwork:"/public/images/characters/daisy-poses.png"}),della:Object.freeze({id:"della",name:"Della",artwork:"/public/images/characters/della-poses.png"}),dash:Object.freeze({id:"dash",name:"Dash",artwork:"/public/images/characters/dash-poses.png"})});export function characterId(e){return typeof e=="string"&&Object.hasOwn(CHARACTERS,e)?e:""}export function normaliseCharacterSettings(e){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{enabled:r.enabled!==!1,animated:r.animated!==!1,launchers:r.launchers!==!1,chats:r.chats!==!1,builders:r.builders!==!1,dot:r.dot!==!1,daisy:r.daisy!==!1}}export function builderCharacterState({working:e=!1,busy:r=!1,error:t="",status:a="",hasContent:s=!1}={}){return t||["waiting","failed","stopped"].includes(a)?"help":e||a==="building"?"working":r?"thinking":["ready","released"].includes(a)?"success":s||a==="review"?"ready":"greeting"}export function characterChat(e={},r){const t=characterId(e.character),a=typeof e.characterName=="string"?e.characterName.replace(/[\u0000-\u001f\u007f]/g," ").trim().slice(0,40):"";return{...e,character:t,...t?{botName:a||CHARACTERS[t].name}:{},characterOptions:normaliseCharacterSettings(r)}}export function chatCharacterState({busy:e=!1,error:r="",ended:t=!1,status:a="none",askDetails:s=!1,replied:i=!1}={}){return r||s?"help":e?"thinking":t||a==="message"?"success":i?"ready":"greeting"}
|
|
1
|
+
export const CHARACTERS=Object.freeze({dot:Object.freeze({id:"dot",name:"Dot",artwork:"/public/images/characters/dot-poses.png"}),daisy:Object.freeze({id:"daisy",name:"Daisy",artwork:"/public/images/characters/daisy-poses.png"}),della:Object.freeze({id:"della",name:"Della",artwork:"/public/images/characters/della-poses.png"}),dash:Object.freeze({id:"dash",name:"Dash",artwork:"/public/images/characters/dash-poses.png"}),remy:Object.freeze({id:"remy",name:"Remy",artwork:"/public/images/characters/remy-poses.png"})});export function characterId(e){return typeof e=="string"&&Object.hasOwn(CHARACTERS,e)?e:""}export function normaliseCharacterSettings(e){const r=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{enabled:r.enabled!==!1,animated:r.animated!==!1,launchers:r.launchers!==!1,chats:r.chats!==!1,builders:r.builders!==!1,dot:r.dot!==!1,daisy:r.daisy!==!1}}export function builderCharacterState({working:e=!1,busy:r=!1,error:t="",status:a="",hasContent:s=!1}={}){return t||["waiting","failed","stopped"].includes(a)?"help":e||a==="building"?"working":r?"thinking":["ready","released"].includes(a)?"success":s||a==="review"?"ready":"greeting"}export function characterChat(e={},r){const t=characterId(e.character),a=typeof e.characterName=="string"?e.characterName.replace(/[\u0000-\u001f\u007f]/g," ").trim().slice(0,40):"";return{...e,character:t,...t?{botName:a||CHARACTERS[t].name}:{},characterOptions:normaliseCharacterSettings(r)}}export function chatCharacterState({busy:e=!1,error:r="",ended:t=!1,status:a="none",askDetails:s=!1,replied:i=!1}={}){return r||s?"help":e?"thinking":t||a==="message"?"success":i?"ready":"greeting"}
|