Spaces:
Runtime error
Runtime error
File size: 1,026 Bytes
58faf93 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import type { AppConfig } from '@/lib/types'
const localStorageItemKey = 'chromadb-admin-config'
export function getConfig(): AppConfig {
const config = window.localStorage.getItem(localStorageItemKey)
if (config) {
return JSON.parse(config)
} else {
return {
connectionString: '',
currentCollection: '',
authType: 'no_auth',
token: '',
username: '',
password: '',
tenant: 'default_tenant',
database: 'default_database',
}
}
}
export function updateConfig(config: AppConfig) {
const stringValue = JSON.stringify(config)
return window.localStorage.setItem(localStorageItemKey, stringValue)
}
export function updateConnectionString(connectionString: string) {
const config = getConfig() || {
connectionString: '',
currentCollection: '',
authType: '',
token: '',
username: '',
password: '',
tenant: '',
database: '',
}
const newConfig = {
...config,
connectionString,
}
return updateConfig(newConfig)
}
|