mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-26 19:21:39 +00:00
feat: Add global toggle
This commit is contained in:
parent
eecd1c714b
commit
1f2b1abee0
6 changed files with 36 additions and 19 deletions
|
|
@ -63,7 +63,7 @@
|
|||
<div v-show="isPodcastSearchPage" class="h-full w-0.5 bg-yellow-400 absolute top-0 left-0" />
|
||||
</nuxt-link>
|
||||
|
||||
<nuxt-link v-if="socialTrue" :to="`/social`" class="w-full h-20 flex flex-col items-center justify-center text-white text-opacity-80 border-b border-primary border-opacity-70 hover:bg-opacity-40 cursor-pointer relative" :class="isSocialPage ? 'bg-primary bg-opacity-80' : 'bg-bg bg-opacity-60'">
|
||||
<nuxt-link v-if="socialTrue && isGlobalSharing" :to="`/social`" class="w-full h-20 flex flex-col items-center justify-center text-white text-opacity-80 border-b border-primary border-opacity-70 hover:bg-opacity-40 cursor-pointer relative" :class="isSocialPage ? 'bg-primary bg-opacity-80' : 'bg-bg bg-opacity-60'">
|
||||
<span class="material-icons-outlined">connect_without_contact</span>
|
||||
|
||||
<p class="font-book pt-1.5" style="font-size: 0.9rem">Social</p>
|
||||
|
|
@ -148,14 +148,15 @@ export default {
|
|||
filterBy() {
|
||||
return this.$store.getters['user/getUserSetting']('filterBy')
|
||||
},
|
||||
isGlobalSharing() {
|
||||
return this.$store.getters['getServerSetting']('sharedListeningStats')
|
||||
},
|
||||
async socialTrue() {
|
||||
let listeningStats = await this.$axios.$get(`/api/social`).catch((err) => {
|
||||
console.error('Failed to load shared user listening sesions', err)
|
||||
return false
|
||||
})
|
||||
if (listeningStats != null) {
|
||||
return true
|
||||
} else {return false}
|
||||
return listeningStats != null ? true : false
|
||||
},
|
||||
showingIssues() {
|
||||
if (!this.$route.query) return false
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
<div class="w-full h-px bg-primary my-4" />
|
||||
|
||||
<div class="flex items-center py-1">
|
||||
<div v-if="isGlobalSharing" class="flex items-center py-1">
|
||||
<ui-toggle-switch v-model="isSharingActivity" @input="changeSharingSetting" />
|
||||
<ui-tooltip text="Share your latest listening activity with other users in the social tab">
|
||||
<p class="pl-4">
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
</ui-tooltip>
|
||||
</div>
|
||||
|
||||
<div class="w-full h-px bg-primary my-4" />
|
||||
<div v-if="isGlobalSharing" class="w-full h-px bg-primary my-4" />
|
||||
|
||||
<p v-if="!isGuest" class="mb-4 text-lg">Change Password</p>
|
||||
<form v-if="!isGuest" @submit.prevent="submitChangePassword">
|
||||
|
|
@ -78,6 +78,9 @@ export default {
|
|||
},
|
||||
isSharingActivity() {
|
||||
return this.$store.getters['user/getUserSetting']('shareListeningActivity')
|
||||
},
|
||||
isGlobalSharing() {
|
||||
return this.$store.getters['getServerSetting']('sharedListeningStats')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -128,8 +131,6 @@ export default {
|
|||
})
|
||||
},
|
||||
changeSharingSetting() {
|
||||
console.log('test')
|
||||
console.log(String(!this.isSharingActivity))
|
||||
this.$store.dispatch('user/updateUserSettings', { shareListeningActivity: !this.isSharingActivity })
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -48,6 +48,16 @@
|
|||
<p class="pl-4">Chromecast support</p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center py-2">
|
||||
<ui-toggle-switch v-model="newServerSettings.sharedListeningStats" :disabled="updatingServerSettings" @input="(val) => updateSettingsKey('sharedListeningStats', val)" />
|
||||
<ui-tooltip :text="tooltips.shareStats">
|
||||
<p class="pl-4">
|
||||
Shared Listening Stats
|
||||
<span class="material-icons icon-text text-sm">info_outlined</span>
|
||||
</p>
|
||||
</ui-tooltip>
|
||||
</div>
|
||||
|
||||
<div class="pt-4">
|
||||
<h2 class="font-semibold">Display</h2>
|
||||
</div>
|
||||
|
|
@ -268,7 +278,8 @@ export default {
|
|||
storeMetadataWithItem: 'By default metadata files are stored in /metadata/items, enabling this setting will store metadata files in your library item folders. Uses .abs file extension',
|
||||
coverAspectRatio: 'Prefer to use square covers over standard 1.6:1 book covers',
|
||||
enableEReader: 'E-reader is still a work in progress, but use this setting to open it up to all your users (or use the "Experimental Features" toggle just for use by you)',
|
||||
scannerPreferOverdriveMediaMarker: 'MP3 files from Overdrive come with chapter timings embedded as custom metadata. Enabling this will use these tags for chapter timings automatically'
|
||||
scannerPreferOverdriveMediaMarker: 'MP3 files from Overdrive come with chapter timings embedded as custom metadata. Enabling this will use these tags for chapter timings automatically',
|
||||
shareStats: 'Allow users to share latest listening activity with other users on an opt-in basis'
|
||||
},
|
||||
showConfirmPurgeCache: false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,12 +24,10 @@
|
|||
</ui-tooltip>
|
||||
</nuxt-link>
|
||||
<p class="text-lg px-2 font-book text-white">{{ user.username }} </p>
|
||||
<div class="">
|
||||
<p class="text-xs text-white text-opacity-50">{{user.latest.lastUpdate != null ? "Last listened " + $dateDistanceFromNow(user.latest.lastUpdate) : "Never listened" }}</p>
|
||||
</div>
|
||||
<p class="text-xs text-white text-opacity-50">{{ "Last listened " + $dateDistanceFromNow(user.latest.lastUpdate) }}</p>
|
||||
<div class="flex-grow" />
|
||||
<div class="w-30 text-right">
|
||||
<p class="text-sm font-bold">{{ user.minutesListened > 0 ? "Has listened for " + $elapsedPrettyExtended(user.minutesListened) : "No listening time" }}</p>
|
||||
<div class="w-30 pl-4 text-right">
|
||||
<p class="text-sm font-bold">{{ "Has listened for " + $elapsedPrettyExtended(user.minutesListened) }}</p>
|
||||
</div>
|
||||
<widgets-online-indicator class="mx-2" :value="!!usersOnline[user.id]" />
|
||||
</div>
|
||||
|
|
@ -64,7 +62,7 @@ export default {
|
|||
},
|
||||
users() {
|
||||
if (!this.listeningStats) return []
|
||||
return this.listeningStats.filter(c => c.latest)
|
||||
return this.listeningStats.sort(function(a, b) {return b.latest.lastUpdate - a.latest.lastUpdate})
|
||||
},
|
||||
userMediaProgress() {
|
||||
return this.user.mediaProgress || []
|
||||
|
|
@ -109,7 +107,6 @@ export default {
|
|||
})
|
||||
}
|
||||
}
|
||||
console.log('Loaded users shared listening data', listeningStats)
|
||||
this.listeningStats = listeningStats
|
||||
},
|
||||
async getLibraryItem(user) {
|
||||
|
|
@ -121,8 +118,6 @@ export default {
|
|||
})
|
||||
},
|
||||
changeSharingSetting() {
|
||||
console.log('test')
|
||||
console.log(String(!this.isSharingActivity))
|
||||
this.$store.dispatch('user/updateUserSettings', { shareListeningActivity: !this.isSharingActivity })
|
||||
this.init()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -265,6 +265,10 @@ class MiscController {
|
|||
}
|
||||
// GET: api/social
|
||||
async getSocialStats(req, res) {
|
||||
if (this.db.serverSettings.sharedListeningStats == false) {
|
||||
return res.sendStatus(404)
|
||||
}
|
||||
Logger.error(this.db.serverSettings.sharedListeningStats)
|
||||
var filteredUsers = this.db.users.filter(c => c.settings.shareListeningActivity == true)
|
||||
var userData = []
|
||||
for (let i = 0; i < filteredUsers.length; i++) {
|
||||
|
|
@ -281,7 +285,9 @@ class MiscController {
|
|||
minutesListened: listeningStats.totalTime || 0,
|
||||
daysListened: totalDays| 0,
|
||||
}
|
||||
userData.push(session)
|
||||
if (session.minutesListened && session.latest) {
|
||||
userData.push(session)
|
||||
}
|
||||
}
|
||||
res.json(userData)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class ServerSettings {
|
|||
|
||||
// Misc Flags
|
||||
this.chromecastEnabled = false
|
||||
this.sharedListeningStats = false
|
||||
this.enableEReader = false
|
||||
this.dateFormat = 'MM/dd/yyyy'
|
||||
|
||||
|
|
@ -95,6 +96,7 @@ class ServerSettings {
|
|||
this.sortingIgnorePrefix = !!settings.sortingIgnorePrefix
|
||||
this.sortingPrefixes = settings.sortingPrefixes || ['the', 'a']
|
||||
this.chromecastEnabled = !!settings.chromecastEnabled
|
||||
this.sharedListeningStats = !!settings.sharedListeningStats
|
||||
this.enableEReader = !!settings.enableEReader
|
||||
this.dateFormat = settings.dateFormat || 'MM/dd/yyyy'
|
||||
this.logLevel = settings.logLevel || Logger.logLevel
|
||||
|
|
@ -131,6 +133,7 @@ class ServerSettings {
|
|||
sortingIgnorePrefix: this.sortingIgnorePrefix,
|
||||
sortingPrefixes: [...this.sortingPrefixes],
|
||||
chromecastEnabled: this.chromecastEnabled,
|
||||
sharedListeningStats: this.sharedListeningStats,
|
||||
enableEReader: this.enableEReader,
|
||||
dateFormat: this.dateFormat,
|
||||
logLevel: this.logLevel,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue