console/behavior/index.sql

              SELECT 'dynamic' AS component, sqlpage.run_sql('shell/shell.sql') AS properties;
              SELECT 'breadcrumb' as component;
WITH RECURSIVE breadcrumbs AS (
    SELECT
        COALESCE(abbreviated_caption, caption) AS title,
        COALESCE(url, path) AS link,
        parent_path, 0 AS level,
        namespace
    FROM sqlpage_aide_navigation
    WHERE namespace = 'prime' AND path='console/behavior/index.sql'
    UNION ALL
    SELECT
        COALESCE(nav.abbreviated_caption, nav.caption) AS title,
        COALESCE(nav.url, nav.path) AS link,
        nav.parent_path, b.level + 1, nav.namespace
    FROM sqlpage_aide_navigation nav
    INNER JOIN breadcrumbs b ON nav.namespace = b.namespace AND nav.path = b.parent_path
)
SELECT title ,      
sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/'||link as link        
FROM breadcrumbs ORDER BY level DESC;
              -- not including page title from sqlpage_aide_navigation
              

              SELECT 'title' AS component, 'Behavior Configuration' AS contents;

SELECT 'text' AS component,
  'Behaviors are configuration presets that drive application operations at runtime, including ingest behaviors, file scanning configurations, and device-specific settings.' AS contents;

-- Summary cards
SELECT 'card' AS component, 3 AS columns;
SELECT
    'Total Behaviors' AS title,
    COUNT(*) AS description,
    'blue' AS color
FROM behavior
WHERE deleted_at IS NULL;

SELECT
    'Active Devices' AS title,
    COUNT(DISTINCT device_id) AS description,
    'green' AS color
FROM behavior
WHERE deleted_at IS NULL;

SELECT
    'Unique Behavior Types' AS title,
    COUNT(DISTINCT behavior_name) AS description,
    'orange' AS color
FROM behavior
WHERE deleted_at IS NULL;

-- Initialize pagination
SET total_rows = (SELECT COUNT(*) FROM behavior );
SET limit = COALESCE($limit, 50);
SET offset = COALESCE($offset, 0);
SET total_pages = ($total_rows + $limit - 1) / $limit;
SET current_page = ($offset / $limit) + 1;

-- Behavior table with pagination
SELECT 'title' AS component, 'Behavior Configurations' AS contents, 2 AS level;
SELECT 'table' AS component,
       'Behavior Name' as markdown,
       'Device' as markdown,
       TRUE as sort,
       TRUE as search;
SELECT
    '[' || b.behavior_name || '](behavior-detail.sql?behavior_id=' || b.behavior_id || ')' AS "Behavior Name",
    '[' || d.name || '](/console/info-schema/table.sql?name=device)' AS "Device",
    CASE
        WHEN LENGTH(b.behavior_conf_json) > 100
        THEN SUBSTR(b.behavior_conf_json, 1, 100) || '...'
        ELSE b.behavior_conf_json
    END AS "Configuration Preview",
    b.created_at AS "Created",
    CASE
        WHEN b.updated_at IS NOT NULL THEN b.updated_at
        ELSE b.created_at
    END AS "Last Modified"
FROM behavior b
LEFT JOIN device d ON b.device_id = d.device_id
WHERE b.deleted_at IS NULL
ORDER BY b.created_at DESC
LIMIT $limit
OFFSET $offset;

-- Pagination controls
SELECT 'text' AS component,
    (SELECT CASE WHEN $current_page > 1 THEN '[Previous](?limit=' || $limit || '&offset=' || ($offset - $limit) ||     ')' ELSE '' END) || ' ' ||
    '(Page ' || $current_page || ' of ' || $total_pages || ") " ||
    (SELECT CASE WHEN $current_page < $total_pages THEN '[Next](?limit=' || $limit || '&offset=' || ($offset + $limit) ||     ')' ELSE '' END)
    AS contents_md 
;