MediaItemHistory and history page

This commit is contained in:
advplyr
2023-01-14 18:01:12 -06:00
parent b1805875b9
commit 297eca6a86
22 changed files with 651 additions and 98 deletions
+126
View File
@@ -217,6 +217,132 @@ class AbsDatabaseWeb extends WebPlugin {
localStorage.setItem('device', JSON.stringify(deviceData))
return deviceData
}
async getMediaItemHistory({ mediaId }) {
console.log('Get media item history', mediaId)
return {
id: mediaId,
mediaDisplayTitle: 'Test Book',
libraryItemId: mediaId,
episodeId: null,
isLocal: false,
serverConnectionConfigId: null,
serverAddress: null,
createdAt: Date.now(),
events: [
{
name: 'Pause',
type: 'Playback',
description: null,
currentTime: 81,
serverSyncAttempted: true,
serverSyncSuccess: true,
serverSyncMessage: null,
timestamp: Date.now() - (1000 * 60 * 22) + 13000 // 22 mins ago + 13s
},
{
name: 'Play',
type: 'Playback',
description: null,
currentTime: 68,
serverSyncAttempted: false,
serverSyncSuccess: null,
serverSyncMessage: null,
timestamp: Date.now() - (1000 * 60 * 22) // 22 mins ago
},
{
name: 'Pause',
type: 'Playback',
description: null,
currentTime: 68,
serverSyncAttempted: true,
serverSyncSuccess: false,
serverSyncMessage: null,
timestamp: Date.now() - (1000 * 60 * 60) + (58000) // 1 hour ago + 58s
},
{
name: 'Save',
type: 'Playback',
description: null,
currentTime: 55,
serverSyncAttempted: true,
serverSyncSuccess: true,
serverSyncMessage: null,
timestamp: Date.now() - (1000 * 60 * 60) + (45000) // 1 hour ago + 45s
},
{
name: 'Save',
type: 'Playback',
description: null,
currentTime: 40,
serverSyncAttempted: true,
serverSyncSuccess: true,
serverSyncMessage: null,
timestamp: Date.now() - (1000 * 60 * 60) + (30000) // 1 hour ago + 30s
},
{
name: 'Save',
type: 'Playback',
description: null,
currentTime: 25,
serverSyncAttempted: true,
serverSyncSuccess: true,
serverSyncMessage: null,
timestamp: Date.now() - (1000 * 60 * 60) + (15000) // 1 hour ago + 15s
},
{
name: 'Play',
type: 'Playback',
description: null,
currentTime: 10,
serverSyncAttempted: false,
serverSyncSuccess: null,
serverSyncMessage: null,
timestamp: Date.now() - (1000 * 60 * 60) // 1 hour ago
},
{
name: 'Stop',
type: 'Playback',
description: null,
currentTime: 10,
serverSyncAttempted: true,
serverSyncSuccess: true,
serverSyncMessage: null,
timestamp: Date.now() - (1000 * 60 * 60 * 25) + 10000 // 25 hours ago + 10s
},
{
name: 'Seek',
type: 'Playback',
description: null,
currentTime: 6,
serverSyncAttempted: true,
serverSyncSuccess: true,
serverSyncMessage: null,
timestamp: Date.now() - (1000 * 60 * 60 * 25) + 2000 // 25 hours ago + 2s
},
{
name: 'Play',
type: 'Playback',
description: null,
currentTime: 0,
serverSyncAttempted: false,
serverSyncSuccess: null,
serverSyncMessage: null,
timestamp: Date.now() - (1000 * 60 * 60 * 25) // 25 hours ago
},
{
name: 'Play',
type: 'Playback',
description: null,
currentTime: 0,
serverSyncAttempted: false,
serverSyncSuccess: null,
serverSyncMessage: null,
timestamp: Date.now() - (1000 * 60 * 60 * 50) // 50 hours ago
}
]
}
}
}
const AbsDatabase = registerPlugin('AbsDatabase', {
+4
View File
@@ -86,6 +86,10 @@ class DbService {
updateDeviceSettings(payload) {
return AbsDatabase.updateDeviceSettings(payload)
}
getMediaItemHistory(mediaId) {
return AbsDatabase.getMediaItemHistory({ mediaId })
}
}
export default ({ app, store }, inject) => {
+13 -3
View File
@@ -91,10 +91,10 @@ Vue.prototype.$elapsedPrettyExtended = (seconds, useDays = true) => {
}
Vue.prototype.$secondsToTimestamp = (seconds) => {
var _seconds = seconds
var _minutes = Math.floor(seconds / 60)
let _seconds = seconds
let _minutes = Math.floor(seconds / 60)
_seconds -= _minutes * 60
var _hours = Math.floor(_minutes / 60)
let _hours = Math.floor(_minutes / 60)
_minutes -= _hours * 60
_seconds = Math.floor(_seconds)
if (!_hours) {
@@ -103,6 +103,16 @@ Vue.prototype.$secondsToTimestamp = (seconds) => {
return `${_hours}:${_minutes.toString().padStart(2, '0')}:${_seconds.toString().padStart(2, '0')}`
}
Vue.prototype.$secondsToTimestampFull = (seconds) => {
let _seconds = seconds
let _minutes = Math.floor(seconds / 60)
_seconds -= _minutes * 60
let _hours = Math.floor(_minutes / 60)
_minutes -= _hours * 60
_seconds = Math.floor(_seconds)
return `${_hours.toString().padStart(2, '0')}:${_minutes.toString().padStart(2, '0')}:${_seconds.toString().padStart(2, '0')}`
}
Vue.prototype.$sanitizeFilename = (input, colonReplacement = ' - ') => {
if (typeof input !== 'string') {
return false