mirror of
https://github.com/sissbruecker/linkding
synced 2024-11-10 06:04:15 +00:00
ffaaf0521d
* return updated HTML from bookmark actions * open details through URL * fix details update * improve modal behavior * use a frame * make behaviors properly destroy themselves * remove page and details params from tag urls * use separate behavior for details and tags * remove separate details view * make it work with other views * add asset actions * remove asset refresh for now * remove details partial * fix tests * remove old partials * update tests * cache and reuse tags * extract search autocomplete behavior * remove details param from pagination * fix tests * only return details modal when navigating in frame * fix link target * remove unused behaviors * use auto submit behavior for user select * fix import
32 lines
975 B
JavaScript
32 lines
975 B
JavaScript
export class Api {
|
|
constructor(baseUrl) {
|
|
this.baseUrl = baseUrl;
|
|
}
|
|
|
|
listBookmarks(search, options = { limit: 100, offset: 0, path: "" }) {
|
|
const query = [`limit=${options.limit}`, `offset=${options.offset}`];
|
|
Object.keys(search).forEach((key) => {
|
|
const value = search[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);
|
|
}
|
|
}
|
|
|
|
const apiBaseUrl = document.documentElement.dataset.apiBaseUrl || "";
|
|
export const api = new Api(apiBaseUrl);
|