mirror of
https://github.com/sissbruecker/linkding
synced 2024-11-25 21:00:18 +00:00
fec966f687
* Allow marking bookmarks as shared * Add basic share view * Ensure tag names in tag cloud are unique * Filter shared bookmarks by user * Add link for filtering by user * Prevent n+1 queries when rendering bookmark list * Prevent empty query params in return URL * Fix user select template tag name * Create shared bookmarks through API * List shared bookmarks through API * Show bookmark suggestions for shared view * Show unique tags in search suggestions * Sort user options * Add bookmark sharing feature flag * Add test for share setting default * Simplify settings view
32 lines
No EOL
977 B
JavaScript
32 lines
No EOL
977 B
JavaScript
export class ApiClient {
|
|
constructor(baseUrl) {
|
|
this.baseUrl = baseUrl
|
|
}
|
|
|
|
listBookmarks(filters, options = {limit: 100, offset: 0, path: ''}) {
|
|
const query = [
|
|
`limit=${options.limit}`,
|
|
`offset=${options.offset}`,
|
|
]
|
|
Object.keys(filters).forEach(key => {
|
|
const value = filters[key]
|
|
if (value) {
|
|
query.push(`${key}=${encodeURIComponent(value)}`)
|
|
}
|
|
})
|
|
const queryString = query.join('&')
|
|
const url = `${this.baseUrl}bookmarks${options.path}/?${queryString}`
|
|
|
|
return fetch(url)
|
|
.then(response => response.json())
|
|
.then(data => data.results)
|
|
}
|
|
|
|
getTags(options = {limit: 100, offset: 0}) {
|
|
const url = `${this.baseUrl}tags/?limit=${options.limit}&offset=${options.offset}`
|
|
|
|
return fetch(url)
|
|
.then(response => response.json())
|
|
.then(data => data.results)
|
|
}
|
|
} |