mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-07 18:58:30 +02:00
Avoid page reload when triggering actions in bookmark list (#506)
* Extract bookmark view contexts * Implement basic partial updates for bookmark list and tag cloud * Refactor confirm button JS into web component * Refactor bulk edit JS into web component * Refactor tag autocomplete JS into web component * Refactor bookmark page JS into web component * Refactor global shortcuts JS into web component * Update tests * Add E2E test for partial updates * Add partial updates for archived bookmarks * Add partial updates for shared bookmarks * Cleanup helpers * Improve naming in bulk edit * Refactor shared components into behaviors * Refactor bulk edit components into behaviors * Refactor bookmark list components into behaviors * Update tests * Combine all scripts into bundle * Fix E2E CI
This commit is contained in:
29
bookmarks/frontend/api.js
Normal file
29
bookmarks/frontend/api.js
Normal file
@@ -0,0 +1,29 @@
|
||||
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user