mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-07 20:38:43 +02:00
Add new connection page to support multiple server connection configs
This commit is contained in:
+38
-3
@@ -1,11 +1,13 @@
|
||||
import { registerPlugin } from '@capacitor/core';
|
||||
import { registerPlugin, Capacitor } from '@capacitor/core';
|
||||
|
||||
const DbManager = registerPlugin('DbManager');
|
||||
const isWeb = Capacitor.getPlatform() == 'web'
|
||||
const DbManager = registerPlugin('DbManager')
|
||||
|
||||
class DbService {
|
||||
constructor() { }
|
||||
|
||||
save(db, key, value) {
|
||||
if (isWeb) return
|
||||
return DbManager.saveFromWebview({ db, key, value }).then(() => {
|
||||
console.log('Saved data', db, key, JSON.stringify(value))
|
||||
}).catch((error) => {
|
||||
@@ -14,6 +16,7 @@ class DbService {
|
||||
}
|
||||
|
||||
load(db, key) {
|
||||
if (isWeb) return null
|
||||
return DbManager.loadFromWebview({ db, key }).then((data) => {
|
||||
console.log('Loaded data', db, key, JSON.stringify(data))
|
||||
return data
|
||||
@@ -23,7 +26,37 @@ class DbService {
|
||||
})
|
||||
}
|
||||
|
||||
loadFolders() {
|
||||
getDeviceData() {
|
||||
if (isWeb) return {}
|
||||
return DbManager.getDeviceData_WV().then((data) => {
|
||||
console.log('Loaded device data', JSON.stringify(data))
|
||||
return data
|
||||
})
|
||||
}
|
||||
|
||||
setServerConnectionConfig(serverConnectionConfig) {
|
||||
if (isWeb) return null
|
||||
return DbManager.setCurrentServerConnectionConfig_WV(serverConnectionConfig).then((data) => {
|
||||
console.log('Set server connection config', JSON.stringify(data))
|
||||
return data
|
||||
})
|
||||
}
|
||||
|
||||
removeServerConnectionConfig(serverConnectionConfigId) {
|
||||
if (isWeb) return null
|
||||
return DbManager.removeServerConnectionConfig_WV({ serverConnectionConfigId }).then((data) => {
|
||||
console.log('Removed server connection config', serverConnectionConfigId)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
logout() {
|
||||
if (isWeb) return null
|
||||
return DbManager.logout_WV()
|
||||
}
|
||||
|
||||
getLocalFolders() {
|
||||
if (isWeb) return []
|
||||
return DbManager.getLocalFolders_WV().then((data) => {
|
||||
console.log('Loaded local folders', JSON.stringify(data))
|
||||
if (data.folders && typeof data.folders == 'string') {
|
||||
@@ -37,6 +70,7 @@ class DbService {
|
||||
}
|
||||
|
||||
getLocalFolder(folderId) {
|
||||
if (isWeb) return null
|
||||
return DbManager.getLocalFolder_WV({ folderId }).then((data) => {
|
||||
console.log('Got local folder', JSON.stringify(data))
|
||||
return data
|
||||
@@ -44,6 +78,7 @@ class DbService {
|
||||
}
|
||||
|
||||
getLocalMediaItemsInFolder(folderId) {
|
||||
if (isWeb) return []
|
||||
return DbManager.getLocalMediaItemsInFolder_WV({ folderId }).then((data) => {
|
||||
console.log('Loaded local media items in folder', JSON.stringify(data))
|
||||
if (data.localMediaItems && typeof data.localMediaItems == 'string') {
|
||||
|
||||
Reference in New Issue
Block a user