|
@ -36,6 +36,7 @@ export class TimeTrackerApp extends DtpApp { |
|
|
|
|
|
|
|
|
this.currentSessionStartTime = null; |
|
|
this.currentSessionStartTime = null; |
|
|
this.currentSessionDuration = document.querySelector('#current-session-duration'); |
|
|
this.currentSessionDuration = document.querySelector('#current-session-duration'); |
|
|
|
|
|
this.currentSessionBillable = document.querySelector('#current-session-billable'); |
|
|
|
|
|
|
|
|
window.addEventListener('dtp-load', this.onDtpLoad.bind(this)); |
|
|
window.addEventListener('dtp-load', this.onDtpLoad.bind(this)); |
|
|
window.addEventListener('focus', this.onWindowFocus.bind(this)); |
|
|
window.addEventListener('focus', this.onWindowFocus.bind(this)); |
|
@ -412,6 +413,9 @@ export class TimeTrackerApp extends DtpApp { |
|
|
await this.stopScreenCapture(); |
|
|
await this.stopScreenCapture(); |
|
|
this.closeTaskSession(); |
|
|
this.closeTaskSession(); |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
|
|
|
if (target.checked) { |
|
|
|
|
|
target.checked = false; |
|
|
|
|
|
} |
|
|
this.log.error('taskActivityToggle', 'failed to start task work session', { error }); |
|
|
this.log.error('taskActivityToggle', 'failed to start task work session', { error }); |
|
|
UIkit.modal.alert(`Failed to start work session: ${error.message}`); |
|
|
UIkit.modal.alert(`Failed to start work session: ${error.message}`); |
|
|
} |
|
|
} |
|
@ -468,7 +472,6 @@ export class TimeTrackerApp extends DtpApp { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async startScreenCapture ( ) { |
|
|
async startScreenCapture ( ) { |
|
|
try { |
|
|
|
|
|
this.captureStream = await navigator.mediaDevices.getDisplayMedia({ video: true, audio: false }); |
|
|
this.captureStream = await navigator.mediaDevices.getDisplayMedia({ video: true, audio: false }); |
|
|
this.capturePreview.srcObject = this.captureStream; |
|
|
this.capturePreview.srcObject = this.captureStream; |
|
|
this.capturePreview.play(); |
|
|
this.capturePreview.play(); |
|
@ -484,11 +487,6 @@ export class TimeTrackerApp extends DtpApp { |
|
|
this.captureCanvas.width = constraints.width; |
|
|
this.captureCanvas.width = constraints.width; |
|
|
this.captureCanvas.height = constraints.height; |
|
|
this.captureCanvas.height = constraints.height; |
|
|
this.captureContext = this.captureCanvas.getContext('2d'); |
|
|
this.captureContext = this.captureCanvas.getContext('2d'); |
|
|
} catch (error) { |
|
|
|
|
|
this.log.error('startTaskSession', 'failed to start task work session', { error }); |
|
|
|
|
|
UIkit.modal.alert(`Failed to start task work session: ${error.message}`); |
|
|
|
|
|
throw new Error('failed to start screen capture', { cause: error }); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async stopScreenCapture ( ) { |
|
|
async stopScreenCapture ( ) { |
|
@ -514,6 +512,7 @@ export class TimeTrackerApp extends DtpApp { |
|
|
const NOW = new Date(); |
|
|
const NOW = new Date(); |
|
|
const duration = dayjs(NOW).diff(this.currentSessionStartTime, 'second'); |
|
|
const duration = dayjs(NOW).diff(this.currentSessionStartTime, 'second'); |
|
|
this.currentSessionDuration.textContent = numeral(duration).format('HH:MM:SS'); |
|
|
this.currentSessionDuration.textContent = numeral(duration).format('HH:MM:SS'); |
|
|
|
|
|
this.currentSessionBillable.textContent = numeral(this.taskSession.hourlyRate * (duration / 60 / 60)).format('$0,0.00'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async captureScreenshot ( ) { |
|
|
async captureScreenshot ( ) { |
|
|