Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 26 additions & 30 deletions jgclark.Dashboard/src/dataGeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,22 +301,20 @@ export function getThisMonthSectionData(config: TDashboardSettings, useDemoData:
}

// Add separate section (if there are any items found)
if (items.length > 0) {
const section: TSection = {
ID: sectionNumStr,
name: '>This Month',
showSettingName: 'showMonthSection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${dateStr}`,
FAIconClass: 'fa-light fa-calendar-range',
sectionTitleColorPart: 'sidebarMonthly',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(),
actionButtons: [],
}
sections.push(section)
const section: TSection = {
ID: sectionNumStr,
name: '>This Month',
showSettingName: 'showMonthSection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${dateStr}`,
FAIconClass: 'fa-light fa-calendar-range',
sectionTitleColorPart: 'sidebarMonthly',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(),
actionButtons: [],
}
sections.push(section)
}

logTimer('getDataForDashboard', startTime, `- found ${itemCount} monthly items from ${thisFilename}`)
Expand Down Expand Up @@ -498,22 +496,20 @@ export function getThisQuarterSectionData(config: TDashboardSettings, useDemoDat
}

// Add separate section (if there are any items found)
if (items.length > 0) {
const section: TSection = {
ID: sectionNumStr,
name: '>This Quarter',
showSettingName: 'showQuarterSection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${dateStr}`,
FAIconClass: 'fa-light fa-calendar-days',
sectionTitleColorPart: 'sidebarQuarterly',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(),
actionButtons: [],
}
sections.push(section)
const section: TSection = {
ID: sectionNumStr,
name: '>This Quarter',
showSettingName: 'showQuarterSection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${dateStr}`,
FAIconClass: 'fa-light fa-calendar-days',
sectionTitleColorPart: 'sidebarQuarterly',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(),
actionButtons: [],
}
sections.push(section)
}

logDebug('getDataForDashboard', `- found ${itemCount} quarterly items from ${dateStr} in ${timer(startTime)}`)
Expand Down
133 changes: 57 additions & 76 deletions jgclark.Dashboard/src/dataGenerationDays.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@

import moment from 'moment/min/moment-with-locales'
import pluginJson from '../plugin.json'
import type {
TDashboardSettings,
TParagraphForDashboard,
TSection,
TSectionItem,
TSettingItem,
} from './types'
import type { TDashboardSettings, TParagraphForDashboard, TSection, TSectionItem, TSettingItem } from './types'
import { getNumCompletedTasksTodayFromNote } from './countDoneTasks'
import {
createSectionItemObject,
Expand All @@ -23,18 +17,13 @@ import {
makeDashboardParas,
} from './dashboardHelpers'
import { openTodayItems, refTodayItems, openTomorrowParas, refTomorrowParas, openYesterdayParas, refYesterdayParas } from './demoData'
import {
getTodaysDateHyphenated, getTodaysDateUnhyphenated,
} from '@helpers/dateTime'
import { getTodaysDateHyphenated, getTodaysDateUnhyphenated } from '@helpers/dateTime'
import { clo, JSP, logDebug, logError, logInfo, logTimer, logWarn, timer } from '@helpers/dev'
import { toNPLocaleDateString } from '@helpers/NPdateTime'
import {
getHeadingsFromNote,
} from '@helpers/NPnote'
import { getHeadingsFromNote } from '@helpers/NPnote'
import { getCurrentTimeBlockPara, getTimeBlockDetails, isActiveOrFutureTimeBlockPara } from '@helpers/timeblocks'
import { isOpen } from '@helpers/utils'


//--------------------------------------------------------------------
/**
* Get open items from Today's note
Expand Down Expand Up @@ -241,22 +230,20 @@ export function getTodaySectionData(config: TDashboardSettings, useDemoData: boo
}

// Add separate section (if there are any items found)
if (items.length > 0) {
const section: TSection = {
ID: sectionNumStr,
name: '>Today',
showSettingName: 'showTodaySection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${todayDateLocale}`,
FAIconClass: 'fa-light fa-calendar-star',
sectionTitleColorPart: 'sidebarDaily',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(), // Note: this often gets stringified to a string, but isn't underneath
actionButtons: [],
}
sections.push(section)
const section: TSection = {
ID: sectionNumStr,
name: '>Today',
showSettingName: 'showTodaySection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${todayDateLocale}`,
FAIconClass: 'fa-light fa-calendar-star',
sectionTitleColorPart: 'sidebarDaily',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(), // Note: this often gets stringified to a string, but isn't underneath
actionButtons: [],
}
sections.push(section)
}

logTimer('getTodaySectionData', timer, `- found ${itemCount} daily items from ${filenameDateStr}`)
Expand Down Expand Up @@ -286,24 +273,22 @@ export function getTodaySectionData(config: TDashboardSettings, useDemoData: boo
}
}

if (timeBlockItems.length > 0) {
const section: TSection = {
ID: TBsectionNumStr,
sectionCode: 'TB',
name: 'Current time block',
showSettingName: 'showTimeBlockSection',
description: '',
FAIconClass: 'fa-light fa-calendar-clock',
sectionTitleColorPart: 'sidebarYearly',
sectionFilename: thisFilename,
sectionItems: timeBlockItems,
generatedDate: new Date(),
actionButtons: [],
}
clo(section)
logTimer('getTodaySectionData', timer, `- found ${String(timeBlockItems.length)} timeblock items from ${filenameDateStr}`)
sections.push(section)
const section: TSection = {
ID: TBsectionNumStr,
sectionCode: 'TB',
name: 'Current time block',
showSettingName: 'showTimeBlockSection',
description: '',
FAIconClass: 'fa-light fa-calendar-clock',
sectionTitleColorPart: 'sidebarYearly',
sectionFilename: thisFilename,
sectionItems: timeBlockItems,
generatedDate: new Date(),
actionButtons: [],
}
clo(section)
logTimer('getTodaySectionData', timer, `- found ${String(timeBlockItems.length)} timeblock items from ${filenameDateStr}`)
sections.push(section)
}

return sections
Expand Down Expand Up @@ -434,22 +419,20 @@ export function getYesterdaySectionData(config: TDashboardSettings, useDemoData:
}
}
// Add separate section (if there are any items found)
if (items.length > 0) {
const section: TSection = {
ID: sectionNumStr,
name: '>Yesterday',
showSettingName: 'showYesterdaySection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${yesterdayDateLocale}`,
FAIconClass: 'fa-light fa-calendar-star',
sectionTitleColorPart: 'sidebarDaily',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(),
actionButtons: [],
}
sections.push(section)
const section: TSection = {
ID: sectionNumStr,
name: '>Yesterday',
showSettingName: 'showYesterdaySection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${yesterdayDateLocale}`,
FAIconClass: 'fa-light fa-calendar-star',
sectionTitleColorPart: 'sidebarDaily',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(),
actionButtons: [],
}
sections.push(section)
}

logTimer('getDataForDashboard', startTime, `- found ${itemCount} yesterday items from ${filenameDateStr}`)
Expand Down Expand Up @@ -574,22 +557,20 @@ export function getTomorrowSectionData(config: TDashboardSettings, useDemoData:
}
}
// Add separate section (if there are any items found)
if (items.length > 0) {
const section: TSection = {
ID: sectionNumStr,
name: '>Tomorrow',
showSettingName: 'showTomorrowSection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${tomorrowDateLocale}`,
FAIconClass: 'fa-light fa-calendar-arrow-down',
sectionTitleColorPart: 'sidebarDaily',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(),
actionButtons: [],
}
sections.push(section)
const section: TSection = {
ID: sectionNumStr,
name: '>Tomorrow',
showSettingName: 'showTomorrowSection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${tomorrowDateLocale}`,
FAIconClass: 'fa-light fa-calendar-arrow-down',
sectionTitleColorPart: 'sidebarDaily',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(),
actionButtons: [],
}
sections.push(section)
}

logDebug('getDataForDashboard', `- found ${itemCount} Tomorrow items from ${filenameDateStr} in ${timer(startTime)}`)
Expand Down
61 changes: 27 additions & 34 deletions jgclark.Dashboard/src/dataGenerationWeeks.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ import {
// createSectionItemObject,
} from './dashboardHelpers'
import { openWeekParas, refWeekParas } from './demoData'
import {
getDateStringFromCalendarFilename,
getNPWeekStr,
} from '@helpers/dateTime'
import { getDateStringFromCalendarFilename, getNPWeekStr } from '@helpers/dateTime'
import { clo, JSP, logDebug, logError, logInfo, logTimer, logWarn, timer } from '@helpers/dev'
import { getHeadingsFromNote } from '@helpers/NPnote'

Expand Down Expand Up @@ -219,22 +216,20 @@ export function getThisWeekSectionData(config: TDashboardSettings, useDemoData:
}

// Add separate section (if there are any items found)
if (items.length > 0) {
const section: TSection = {
ID: sectionNumStr,
name: '>This Week',
showSettingName: 'showWeekSection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${dateStr}`,
FAIconClass: 'fa-light fa-calendar-week',
sectionTitleColorPart: 'sidebarWeekly',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(),
actionButtons: [],
}
sections.push(section)
const section: TSection = {
ID: sectionNumStr,
name: '>This Week',
showSettingName: 'showWeekSection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${dateStr}`,
FAIconClass: 'fa-light fa-calendar-week',
sectionTitleColorPart: 'sidebarWeekly',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(),
actionButtons: [],
}
sections.push(section)
}

logDebug('getDataForDashboard', `- found ${itemCount} weekly items from ${dateStr} in ${timer(startTime)}`)
Expand Down Expand Up @@ -351,22 +346,20 @@ export function getLastWeekSectionData(config: TDashboardSettings, useDemoData:
}

// Add separate section (if there are any items found)
if (items.length > 0) {
const section: TSection = {
ID: sectionNumStr,
name: '>Last Week',
showSettingName: 'showWeekSection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${dateStr}`,
FAIconClass: 'fa-light fa-calendar-week',
sectionTitleColorPart: 'sidebarWeekly',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(),
actionButtons: [],
}
sections.push(section)
const section: TSection = {
ID: sectionNumStr,
name: '>Last Week',
showSettingName: 'showWeekSection',
sectionCode: thisSectionCode,
description: `{count} scheduled to ${dateStr}`,
FAIconClass: 'fa-light fa-calendar-week',
sectionTitleColorPart: 'sidebarWeekly',
sectionFilename: thisFilename,
sectionItems: items,
generatedDate: new Date(),
actionButtons: [],
}
sections.push(section)
}

logDebug('getLastWeekSectionData', `- found ${itemCount} weekly items from ${thisFilename} in ${timer(startTime)}`)
Expand Down
19 changes: 9 additions & 10 deletions jgclark.Dashboard/src/react/components/Section/Section.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,18 @@ const Section = ({ section, onButtonClick }: SectionProps): React$Node => {
setItems(sectionItems)
}, [section, dashboardSettings])

const refresh = useCallback(() => {
logDebug('Section/TBTimer', `Refreshing section ${section.sectionCode}...`)
const detailsMessageObject = { actionType: 'refreshSomeSections', sectionCodes: ['TB'] }
sendActionToPlugin(detailsMessageObject.actionType, detailsMessageObject, 'TBTimer fired refreshSomeSections', true)
}, [section.sectionCode, sendActionToPlugin])

/**
* Set a timer to refresh the TB section every 1 minute.
* FIXME(dwerteimer): this is what Cursor added on my second attempt -- just trying to keep it all in this file. But doesn't work.
* FIXME(dwertheimer): this is what Cursor added on my second attempt -- just trying to keep it all in this file. But doesn't work.
*/
useEffect(() => {
const refreshInterval = 60000 // 1 minute
const refreshInterval = 50000 // A little less than 1 minute -- don't want it to collide with the IdleTimer if possible
let timerId

if (section.sectionCode === 'TB') {
Expand All @@ -119,14 +125,7 @@ const Section = ({ section, onButtonClick }: SectionProps): React$Node => {
logDebug('Section/TBTimer', `Section ${section.sectionCode} timer cleared`)
}
}
}, [section.sectionCode])

const refresh = useCallback(() => {
logDebug('Section/TBTimer', 'Refreshing section ${section.sectionCode}...')
// TEST: Add your refresh logic here
const detailsMessageObject = { actionType: 'refreshSomeSections', sectionCodes: ['TB'] }
sendActionToPlugin(detailsMessageObject.actionType, detailsMessageObject, 'TBTimer fired refreshSomeSections', true)
}, [])
}, [section.sectionCode, refresh])

//----------------------------------------------------------------------
// Hooks
Expand Down
Loading