ur/uniform-resource-imap-mail-list.sql
SELECT 'dynamic' AS component, sqlpage.run_sql('shell/shell.sql') AS properties;
-- not including breadcrumbs from sqlpage_aide_navigation
-- not including page title from sqlpage_aide_navigation
SELECT
'breadcrumb' AS component;
SELECT
'Home' AS title,
sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/'
SELECT
'Uniform Resource' AS title,
sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/ur/index.sql' as link;
SELECT
'Uniform Resources (IMAP)' AS title,
sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/ur/uniform-resource-imap-account.sql' AS link;
SELECT
'Folder' AS title,
sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/ur/uniform-resource-imap-folder.sql?imap_account_id='|| ur_ingest_session_imap_account_id AS link
FROM uniform_resource_imap
WHERE ur_ingest_session_imap_acct_folder_id = $folder_id::TEXT GROUP BY ur_ingest_session_imap_acct_folder_id;
SELECT
folder_name AS title,
sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/ur/uniform-resource-imap-mail-list.sql?folder_id=' || ur_ingest_session_imap_acct_folder_id AS link
FROM uniform_resource_imap
WHERE ur_ingest_session_imap_acct_folder_id=$folder_id::TEXT GROUP BY ur_ingest_session_imap_acct_folder_id;
SELECT
'title' as component,
(SELECT email || ' (' || folder_name || ')' FROM uniform_resource_imap WHERE ur_ingest_session_imap_acct_folder_id=$folder_id::TEXT) as contents;
-- sets up $limit, $offset, and other variables (use pagination.debugVars() to see values in web-ui)
SET total_rows = (SELECT COUNT(*) FROM uniform_resource_imap );
SET limit = COALESCE($limit, 50);
SET offset = COALESCE($offset, 0);
SET total_pages = ($total_rows + $limit - 1) / $limit;
SET current_page = ($offset / $limit) + 1;
-- Display uniform_resource table with pagination
SELECT 'table' AS component,
'Uniform Resources' AS title,
"Size (bytes)" as align_right,
TRUE AS sort,
TRUE AS search,
TRUE AS hover,
TRUE AS striped_rows,
TRUE AS small,
'subject' AS markdown;;
SELECT
'[' || subject || '](uniform-resource-imap-mail-detail.sql?resource_id=' || uniform_resource_id || ')' AS "subject"
, "from",
CASE
WHEN ROUND(julianday('now') - julianday(date)) = 0 THEN 'Today'
WHEN ROUND(julianday('now') - julianday(date)) = 1 THEN '1 day ago'
WHEN ROUND(julianday('now') - julianday(date)) BETWEEN 2 AND 6 THEN CAST(ROUND(julianday('now') - julianday(date)) AS INT) || ' days ago'
WHEN ROUND(julianday('now') - julianday(date)) < 30 THEN CAST(ROUND(julianday('now') - julianday(date)) AS INT) || ' days ago'
WHEN ROUND(julianday('now') - julianday(date)) < 365 THEN CAST(ROUND((julianday('now') - julianday(date)) / 30) AS INT) || ' months ago'
ELSE CAST(ROUND((julianday('now') - julianday(date)) / 365) AS INT) || ' years ago'
END AS "Relative Time",
strftime('%Y-%m-%d', substr(date, 1, 19)) as date
FROM uniform_resource_imap
WHERE ur_ingest_session_imap_acct_folder_id=$folder_id::TEXT
ORDER BY uniform_resource_id
LIMIT $limit
OFFSET $offset;
SELECT 'text' AS component,
(SELECT CASE WHEN $current_page > 1 THEN '[Previous](?limit=' || $limit || '&offset=' || ($offset - $limit) || '&folder_id=' || $folder_id || ')' ELSE '' END) || ' ' ||
'(Page ' || $current_page || ' of ' || $total_pages || ") " ||
(SELECT CASE WHEN $current_page < $total_pages THEN '[Next](?limit=' || $limit || '&offset=' || ($offset + $limit) || '&folder_id=' || $folder_id || ')' ELSE '' END)
AS contents_md;