many, MANY improvements to admin UI
This commit is contained in:
1 parent
eac0938ccf
commit
3b6ac1dcab
14 files changed
+2421
-99
No files matched your search
@@ -28,14 +28,20 @@ export class ArticleService {
|
||||
return this.http.get<Article[]>(`${this.apiUrl}?timestamp=${new Date().getTime()}`);
|
||||
}
|
||||
|
||||
getArticleBySlug(slug: string): Observable<Article |undefined> {
|
||||
return this.http.get<Article>(`${this.apiUrl}/slug/${slug}`).pipe(
|
||||
getArticleBySlug(slug: string, token?: string | null): Observable<Article |undefined> {
|
||||
const options = token
|
||||
? { headers: new HttpHeaders().set('Authorization', `Bearer ${token}`) }
|
||||
: {};
|
||||
return this.http.get<Article>(`${this.apiUrl}/slug/${slug}`, options).pipe(
|
||||
map(article => article)
|
||||
);
|
||||
}
|
||||
|
||||
getArticleById(id: number): Observable<Article |undefined> {
|
||||
return this.http.get<Article>(`${this.apiUrl}/id/${id}`).pipe(
|
||||
getArticleById(id: number, token?: string | null): Observable<Article |undefined> {
|
||||
const options = token
|
||||
? { headers: new HttpHeaders().set('Authorization', `Bearer ${token}`) }
|
||||
: {};
|
||||
return this.http.get<Article>(`${this.apiUrl}/id/${id}`, options).pipe(
|
||||
map(article => article)
|
||||
);
|
||||
}
|
||||
@@ -61,10 +67,12 @@ export class ArticleService {
|
||||
);
|
||||
}
|
||||
|
||||
editArticle(id: number, token: string | null, title: string, content: string): Observable<any> {
|
||||
editArticle(
|
||||
id: number,
|
||||
token: string | null,
|
||||
updates: { title?: string; content?: string }
|
||||
): Observable<any> {
|
||||
const headers = new HttpHeaders().set('Authorization', `Bearer ${token}`);
|
||||
const body = { title, content };
|
||||
|
||||
return this.http.put<any>(`${this.apiUrl}/${id}`, body, { headers });
|
||||
return this.http.put<any>(`${this.apiUrl}/${id}`, updates, { headers });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user