mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-06-04 18:00:45 +02:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e678fe6e2f | |||
| 3845940245 | |||
| 6c63e2131c | |||
| e25e2b238f | |||
| 99110f587a | |||
| b553e959e2 |
@@ -81,7 +81,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="w-full md:w-1/3">
|
<div class="w-full md:w-1/3">
|
||||||
<p v-if="!isMediaItemShareSession" class="font-semibold uppercase text-xs text-gray-400 tracking-wide mb-2 mt-6 md:mt-0">{{ $strings.LabelUser }}</p>
|
<p v-if="!isMediaItemShareSession" class="font-semibold uppercase text-xs text-gray-400 tracking-wide mb-2 mt-6 md:mt-0">{{ $strings.LabelUser }}</p>
|
||||||
<p v-if="!isMediaItemShareSession" class="mb-1 text-xs">{{ _session.userId }}</p>
|
<p v-if="!isMediaItemShareSession" class="mb-1 text-xs">{{ username }}</p>
|
||||||
|
|
||||||
<p class="font-semibold uppercase text-xs text-gray-400 tracking-wide mt-6 mb-2">{{ $strings.LabelMediaPlayer }}</p>
|
<p class="font-semibold uppercase text-xs text-gray-400 tracking-wide mt-6 mb-2">{{ $strings.LabelMediaPlayer }}</p>
|
||||||
<p class="mb-1">{{ playMethodName }}</p>
|
<p class="mb-1">{{ playMethodName }}</p>
|
||||||
@@ -132,6 +132,9 @@ export default {
|
|||||||
_session() {
|
_session() {
|
||||||
return this.session || {}
|
return this.session || {}
|
||||||
},
|
},
|
||||||
|
username() {
|
||||||
|
return this._session.user?.username || this._session.userId || ''
|
||||||
|
},
|
||||||
deviceInfo() {
|
deviceInfo() {
|
||||||
return this._session.deviceInfo || {}
|
return this._session.deviceInfo || {}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
<p class="text-xs truncate" v-html="getDeviceInfoString(session.deviceInfo)" />
|
<p class="text-xs truncate" v-html="getDeviceInfoString(session.deviceInfo)" />
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center w-24 min-w-24 sm:w-32 sm:min-w-32">
|
<td class="text-center w-24 min-w-24 sm:w-32 sm:min-w-32">
|
||||||
<p class="text-xs font-mono">{{ $elapsedPretty(session.timeListening) }}</p>
|
<p class="text-xs font-mono">{{ $elapsedPrettyLocalized(session.timeListening) }}</p>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center hover:underline w-24 min-w-24" @click.stop="clickCurrentTime(session)">
|
<td class="text-center hover:underline w-24 min-w-24" @click.stop="clickCurrentTime(session)">
|
||||||
<p class="text-xs font-mono">{{ $secondsToTimestamp(session.currentTime) }}</p>
|
<p class="text-xs font-mono">{{ $secondsToTimestamp(session.currentTime) }}</p>
|
||||||
|
|||||||
@@ -13,8 +13,10 @@
|
|||||||
<widgets-online-indicator :value="!!userOnline" />
|
<widgets-online-indicator :value="!!userOnline" />
|
||||||
<h1 class="text-xl pl-2">{{ username }}</h1>
|
<h1 class="text-xl pl-2">{{ username }}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="legacyToken" class="flex text-xs mt-4">
|
<div v-if="legacyToken" class="text-xs space-y-2 mt-4">
|
||||||
<ui-text-input-with-label label="Legacy API Token" :value="legacyToken" readonly show-copy />
|
<ui-text-input-with-label label="Legacy API Token" :value="legacyToken" readonly show-copy />
|
||||||
|
|
||||||
|
<p class="text-warning" v-html="$strings.MessageAuthenticationLegacyTokenWarning" />
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full h-px bg-white/10 my-2" />
|
<div class="w-full h-px bg-white/10 my-2" />
|
||||||
<div class="py-2">
|
<div class="py-2">
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
<p class="text-xs truncate" v-html="getDeviceInfoString(session.deviceInfo)" />
|
<p class="text-xs truncate" v-html="getDeviceInfoString(session.deviceInfo)" />
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<p class="text-xs font-mono">{{ $elapsedPretty(session.timeListening) }}</p>
|
<p class="text-xs font-mono">{{ $elapsedPrettyLocalized(session.timeListening) }}</p>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center hover:underline" @click.stop="clickCurrentTime(session)">
|
<td class="text-center hover:underline" @click.stop="clickCurrentTime(session)">
|
||||||
<p class="text-xs font-mono">{{ $secondsToTimestamp(session.currentTime) }}</p>
|
<p class="text-xs font-mono">{{ $secondsToTimestamp(session.currentTime) }}</p>
|
||||||
|
|||||||
@@ -37,6 +37,48 @@ Vue.prototype.$elapsedPretty = (seconds, useFullNames = false, useMilliseconds =
|
|||||||
return `${hours} ${useFullNames ? `hour${hours === 1 ? '' : 's'}` : 'hr'} ${minutes} ${useFullNames ? `minute${minutes === 1 ? '' : 's'}` : 'min'}`
|
return `${hours} ${useFullNames ? `hour${hours === 1 ? '' : 's'}` : 'hr'} ${minutes} ${useFullNames ? `minute${minutes === 1 ? '' : 's'}` : 'min'}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vue.prototype.$elapsedPrettyLocalized = (seconds, useFullNames = false, useMilliseconds = false) => {
|
||||||
|
if (isNaN(seconds) || seconds === null) return ''
|
||||||
|
|
||||||
|
try {
|
||||||
|
const df = new Intl.DurationFormat(Vue.prototype.$languageCodes.current, {
|
||||||
|
style: useFullNames ? 'long' : 'short'
|
||||||
|
})
|
||||||
|
|
||||||
|
const duration = {}
|
||||||
|
|
||||||
|
if (seconds < 60) {
|
||||||
|
if (useMilliseconds && seconds < 1) {
|
||||||
|
duration.milliseconds = Math.floor(seconds * 1000)
|
||||||
|
} else {
|
||||||
|
duration.seconds = Math.floor(seconds)
|
||||||
|
}
|
||||||
|
} else if (seconds < 3600) {
|
||||||
|
// 1 hour
|
||||||
|
duration.minutes = Math.floor(seconds / 60)
|
||||||
|
} else if (seconds < 86400) {
|
||||||
|
// 1 day
|
||||||
|
duration.hours = Math.floor(seconds / 3600)
|
||||||
|
const minutes = Math.floor((seconds % 3600) / 60)
|
||||||
|
if (minutes > 0) {
|
||||||
|
duration.minutes = minutes
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
duration.days = Math.floor(seconds / 86400)
|
||||||
|
const hours = Math.floor((seconds % 86400) / 3600)
|
||||||
|
if (hours > 0) {
|
||||||
|
duration.hours = hours
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return df.format(duration)
|
||||||
|
} catch (error) {
|
||||||
|
// Handle not supported
|
||||||
|
console.warn('Intl.DurationFormat not supported, not localizing duration')
|
||||||
|
return Vue.prototype.$elapsedPretty(seconds, useFullNames, useMilliseconds)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Vue.prototype.$secondsToTimestamp = (seconds, includeMs = false, alwaysIncludeHours = false) => {
|
Vue.prototype.$secondsToTimestamp = (seconds, includeMs = false, alwaysIncludeHours = false) => {
|
||||||
if (!seconds) {
|
if (!seconds) {
|
||||||
return alwaysIncludeHours ? '00:00:00' : '0:00'
|
return alwaysIncludeHours ? '00:00:00' : '0:00'
|
||||||
|
|||||||
@@ -723,6 +723,7 @@
|
|||||||
"MessageAddToPlayerQueue": "Add to player queue",
|
"MessageAddToPlayerQueue": "Add to player queue",
|
||||||
"MessageAppriseDescription": "To use this feature you will need to have an instance of <a href=\"https://github.com/caronc/apprise-api\" target=\"_blank\">Apprise API</a> running or an api that will handle those same requests. <br />The Apprise API Url should be the full URL path to send the notification, e.g., if your API instance is served at <code>http://192.168.1.1:8337</code> then you would put <code>http://192.168.1.1:8337/notify</code>.",
|
"MessageAppriseDescription": "To use this feature you will need to have an instance of <a href=\"https://github.com/caronc/apprise-api\" target=\"_blank\">Apprise API</a> running or an api that will handle those same requests. <br />The Apprise API Url should be the full URL path to send the notification, e.g., if your API instance is served at <code>http://192.168.1.1:8337</code> then you would put <code>http://192.168.1.1:8337/notify</code>.",
|
||||||
"MessageAsinCheck": "Ensure you are using the ASIN from the correct Audible region, not Amazon.",
|
"MessageAsinCheck": "Ensure you are using the ASIN from the correct Audible region, not Amazon.",
|
||||||
|
"MessageAuthenticationLegacyTokenWarning": "Legacy API tokens will be removed in the future. Use <a href=\"/config/api-keys\">API Keys</a> instead.",
|
||||||
"MessageAuthenticationOIDCChangesRestart": "Restart your server after saving to apply OIDC changes.",
|
"MessageAuthenticationOIDCChangesRestart": "Restart your server after saving to apply OIDC changes.",
|
||||||
"MessageAuthenticationSecurityMessage": "Authentication has been improved for security. All users are required to re-login.",
|
"MessageAuthenticationSecurityMessage": "Authentication has been improved for security. All users are required to re-login.",
|
||||||
"MessageBackupsDescription": "Backups include users, user progress, library item details, server settings, and images stored in <code>/metadata/items</code> & <code>/metadata/authors</code>. Backups <strong>do not</strong> include any files stored in your library folders.",
|
"MessageBackupsDescription": "Backups include users, user progress, library item details, server settings, and images stored in <code>/metadata/items</code> & <code>/metadata/authors</code>. Backups <strong>do not</strong> include any files stored in your library folders.",
|
||||||
|
|||||||
+1
-1
@@ -240,7 +240,7 @@ class Server {
|
|||||||
* Running in development allows cors to allow testing the mobile apps in the browser
|
* Running in development allows cors to allow testing the mobile apps in the browser
|
||||||
* or env variable ALLOW_CORS = '1'
|
* or env variable ALLOW_CORS = '1'
|
||||||
*/
|
*/
|
||||||
if (Logger.isDev || req.path.match(/\/api\/items\/([a-z0-9-]{36})\/(ebook|cover)(\/[0-9]+)?/)) {
|
if (global.AllowCors || Logger.isDev || req.path.match(/\/api\/items\/([a-z0-9-]{36})\/(ebook|cover)(\/[0-9]+)?/)) {
|
||||||
const allowedOrigins = ['capacitor://localhost', 'http://localhost']
|
const allowedOrigins = ['capacitor://localhost', 'http://localhost']
|
||||||
if (global.AllowCors || Logger.isDev || allowedOrigins.some((o) => o === req.get('origin'))) {
|
if (global.AllowCors || Logger.isDev || allowedOrigins.some((o) => o === req.get('origin'))) {
|
||||||
res.header('Access-Control-Allow-Origin', req.get('origin'))
|
res.header('Access-Control-Allow-Origin', req.get('origin'))
|
||||||
|
|||||||
@@ -57,26 +57,24 @@ class SessionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let where = null
|
let where = null
|
||||||
const include = [
|
|
||||||
{
|
|
||||||
model: Database.models.device
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
if (userId) {
|
if (userId) {
|
||||||
where = {
|
where = {
|
||||||
userId
|
userId
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
include.push({
|
|
||||||
model: Database.userModel,
|
|
||||||
attributes: ['id', 'username']
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rows, count } = await Database.playbackSessionModel.findAndCountAll({
|
const { rows, count } = await Database.playbackSessionModel.findAndCountAll({
|
||||||
where,
|
where,
|
||||||
include,
|
include: [
|
||||||
|
{
|
||||||
|
model: Database.deviceModel
|
||||||
|
},
|
||||||
|
{
|
||||||
|
model: Database.userModel,
|
||||||
|
attributes: ['id', 'username']
|
||||||
|
}
|
||||||
|
],
|
||||||
order: [[orderKey, orderDesc]],
|
order: [[orderKey, orderDesc]],
|
||||||
limit: itemsPerPage,
|
limit: itemsPerPage,
|
||||||
offset: itemsPerPage * page
|
offset: itemsPerPage * page
|
||||||
|
|||||||
@@ -439,7 +439,16 @@ class UserController {
|
|||||||
const page = toNumber(req.query.page, 0)
|
const page = toNumber(req.query.page, 0)
|
||||||
|
|
||||||
const start = page * itemsPerPage
|
const start = page * itemsPerPage
|
||||||
const sessions = listeningSessions.slice(start, start + itemsPerPage)
|
// Map user to sessions to match the format of the sessions endpoint
|
||||||
|
const sessions = listeningSessions.slice(start, start + itemsPerPage).map((session) => {
|
||||||
|
return {
|
||||||
|
...session,
|
||||||
|
user: {
|
||||||
|
id: req.reqUser.id,
|
||||||
|
username: req.reqUser.username
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
total: listeningSessions.length,
|
total: listeningSessions.length,
|
||||||
|
|||||||
Reference in New Issue
Block a user