diff --git a/package-lock.json b/package-lock.json index b8aa61f..9204c1d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@emp74ark/rss-angular", - "version": "0.0.1", + "version": "0.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@emp74ark/rss-angular", - "version": "0.0.1", + "version": "0.0.2", "license": "ISC", "dependencies": { "@angular/cdk": "^20.2.2", diff --git a/package.json b/package.json index ee91a6e..5123afa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@emp74ark/rss-angular", - "version": "0.0.1", + "version": "0.0.2", "description": "Frontend for RSS Feeds client", "author": "emp74ark", "private": true, diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 40c2bca..360a46b 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -24,16 +24,16 @@ export const routes: Routes = [ canMatch: [authGuard], }, { - path: 'subscriptions', + path: 'feeds', loadComponent: async () => { - const c = await import('./pages/subscriptions-page/subscriptions-page') - return c.SubscriptionsPage + const c = await import('./pages/feeds-page/feeds-page') + return c.FeedsPage }, - data: { title: 'Subscriptions' }, + data: { title: 'Feeds' }, canMatch: [authGuard], }, { - path: 'subscription/:subscriptionId/article/:articleId', + path: 'feed/:feedId/article/:articleId', loadComponent: async () => { const c = await import('./pages/article-page/article-page') return c.ArticlePage diff --git a/src/app/components/article-list/article-list.html b/src/app/components/article-list/article-list.html index afdd26c..ce995d8 100644 --- a/src/app/components/article-list/article-list.html +++ b/src/app/components/article-list/article-list.html @@ -32,7 +32,7 @@ link diff --git a/src/app/components/article-list/article-list.ts b/src/app/components/article-list/article-list.ts index 381780b..7ea7095 100644 --- a/src/app/components/article-list/article-list.ts +++ b/src/app/components/article-list/article-list.ts @@ -1,4 +1,12 @@ -import { ChangeDetectionStrategy, Component, DestroyRef, effect, inject, input, linkedSignal } from '@angular/core' +import { + ChangeDetectionStrategy, + Component, + DestroyRef, + effect, + inject, + input, + linkedSignal, +} from '@angular/core' import { AsyncPipe, DatePipe } from '@angular/common' import { MatCard, @@ -68,7 +76,7 @@ export class ArticleList { $display = this.pageService.$display async onArticleClick(article: Article) { - await this.router.navigate(['subscription', article.subscriptionId, 'article', article._id]) + await this.router.navigate(['feed', article.feedId, 'article', article._id]) } markAsRead(article: Article, event: MouseEvent) { diff --git a/src/app/components/bottom-error-sheet/bottom-error-sheet.ts b/src/app/components/bottom-error-sheet/bottom-error-sheet.ts index 2e2c883..5f5d087 100644 --- a/src/app/components/bottom-error-sheet/bottom-error-sheet.ts +++ b/src/app/components/bottom-error-sheet/bottom-error-sheet.ts @@ -6,7 +6,7 @@ import { MatError } from '@angular/material/form-field' selector: 'app-bottom-error-sheet', imports: [MatBottomSheetModule, MatError], templateUrl: './bottom-error-sheet.html', - styleUrl: './bottom-error-sheet.css' + styleUrl: './bottom-error-sheet.css', }) export class BottomErrorSheet { readonly data: { error?: string } = inject(MAT_BOTTOM_SHEET_DATA) diff --git a/src/app/components/subscription-add-form/subscription-add-form.css b/src/app/components/feed-add-form/feed-add-form.css similarity index 100% rename from src/app/components/subscription-add-form/subscription-add-form.css rename to src/app/components/feed-add-form/feed-add-form.css diff --git a/src/app/components/subscription-add-form/subscription-add-form.html b/src/app/components/feed-add-form/feed-add-form.html similarity index 86% rename from src/app/components/subscription-add-form/subscription-add-form.html rename to src/app/components/feed-add-form/feed-add-form.html index 169659e..8b7e95a 100644 --- a/src/app/components/subscription-add-form/subscription-add-form.html +++ b/src/app/components/feed-add-form/feed-add-form.html @@ -1,4 +1,4 @@ -

Add new subscription

+

Add new feed

Add new subscription Title @@ -33,7 +33,6 @@

Add new subscription

Enabled - Load full text @if (errorMessage()) { diff --git a/src/app/components/subscription-add-form/subscription-add-form.ts b/src/app/components/feed-add-form/feed-add-form.ts similarity index 84% rename from src/app/components/subscription-add-form/subscription-add-form.ts rename to src/app/components/feed-add-form/feed-add-form.ts index bcba3bc..4b09340 100644 --- a/src/app/components/subscription-add-form/subscription-add-form.ts +++ b/src/app/components/feed-add-form/feed-add-form.ts @@ -11,7 +11,7 @@ import { HttpErrorResponse } from '@angular/common/http' import { takeUntilDestroyed } from '@angular/core/rxjs-interop' @Component({ - selector: 'app-subscription-add-form', + selector: 'app-feed-add-form', imports: [ ReactiveFormsModule, MatFormFieldModule, @@ -20,15 +20,15 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop' MatDialogModule, MatButton, ], - templateUrl: './subscription-add-form.html', - styleUrl: './subscription-add-form.css', + templateUrl: './feed-add-form.html', + styleUrl: './feed-add-form.css', changeDetection: ChangeDetectionStrategy.OnPush, }) -export class SubscriptionAddForm { +export class FeedAddForm { private readonly fb = inject(NonNullableFormBuilder) private readonly feedService = inject(FeedService) private readonly destroyRef = inject(DestroyRef) - private readonly dialogRef = inject(MatDialogRef) + private readonly dialogRef = inject(MatDialogRef) readonly isLoading = signal(false) readonly errorMessage = signal(null) @@ -39,7 +39,6 @@ export class SubscriptionAddForm { link: ['', Validators.required], settings: this.fb.group({ enabled: [true], - loadFullText: [false], }), }) @@ -47,7 +46,7 @@ export class SubscriptionAddForm { this.isLoading.set(true) this.form.disable() this.feedService - .addOneSubscription({ subscription: this.form.getRawValue() }) + .addOneFeed({ feed: this.form.getRawValue() }) .pipe( catchError((error: HttpErrorResponse) => { this.errorMessage.set(error.error.message) diff --git a/src/app/components/subscription-edit-form/subscription-edit-form.css b/src/app/components/feed-edit-form/feed-edit-form.css similarity index 100% rename from src/app/components/subscription-edit-form/subscription-edit-form.css rename to src/app/components/feed-edit-form/feed-edit-form.css diff --git a/src/app/components/subscription-edit-form/subscription-edit-form.html b/src/app/components/feed-edit-form/feed-edit-form.html similarity index 86% rename from src/app/components/subscription-edit-form/subscription-edit-form.html rename to src/app/components/feed-edit-form/feed-edit-form.html index 169659e..8b7e95a 100644 --- a/src/app/components/subscription-edit-form/subscription-edit-form.html +++ b/src/app/components/feed-edit-form/feed-edit-form.html @@ -1,4 +1,4 @@ -

Add new subscription

+

Add new feed

Add new subscription Title @@ -33,7 +33,6 @@

Add new subscription

Enabled - Load full text @if (errorMessage()) { diff --git a/src/app/components/subscription-edit-form/subscription-edit-form.ts b/src/app/components/feed-edit-form/feed-edit-form.ts similarity index 80% rename from src/app/components/subscription-edit-form/subscription-edit-form.ts rename to src/app/components/feed-edit-form/feed-edit-form.ts index 9fafd9c..a2efe9a 100644 --- a/src/app/components/subscription-edit-form/subscription-edit-form.ts +++ b/src/app/components/feed-edit-form/feed-edit-form.ts @@ -1,4 +1,11 @@ -import { ChangeDetectionStrategy, Component, DestroyRef, inject, OnInit, signal } from '@angular/core' +import { + ChangeDetectionStrategy, + Component, + DestroyRef, + inject, + OnInit, + signal, +} from '@angular/core' import { NonNullableFormBuilder, ReactiveFormsModule, Validators } from '@angular/forms' import { MatFormFieldModule } from '@angular/material/form-field' import { MatInput } from '@angular/material/input' @@ -12,7 +19,7 @@ import { catchError, of } from 'rxjs' import { takeUntilDestroyed } from '@angular/core/rxjs-interop' @Component({ - selector: 'app-subscription-edit-form', + selector: 'app-feed-edit-form', imports: [ ReactiveFormsModule, MatFormFieldModule, @@ -21,15 +28,15 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop' MatDialogModule, MatButton, ], - templateUrl: './subscription-edit-form.html', - styleUrl: './subscription-edit-form.css', + templateUrl: './feed-edit-form.html', + styleUrl: './feed-edit-form.css', changeDetection: ChangeDetectionStrategy.OnPush, }) -export class SubscriptionEditForm implements OnInit { +export class FeedEditForm implements OnInit { private readonly fb = inject(NonNullableFormBuilder) private readonly feedService = inject(FeedService) private readonly destroyRef = inject(DestroyRef) - private readonly dialogRef = inject(MatDialogRef) + private readonly dialogRef = inject(MatDialogRef) readonly data: { feed: Feed; feedId: string } | null = inject(MAT_DIALOG_DATA) readonly isLoading = signal(false) @@ -41,7 +48,6 @@ export class SubscriptionEditForm implements OnInit { link: ['', Validators.required], settings: this.fb.group({ enabled: [false], - loadFullText: [false], }), }) @@ -52,7 +58,7 @@ export class SubscriptionEditForm implements OnInit { this.isLoading.set(true) this.form.disable() this.feedService - .changeOneSubscription({ id: this.data?.feed._id, dto: this.form.getRawValue() }) + .changeOneFeed({ id: this.data?.feed._id, dto: this.form.getRawValue() }) .pipe( catchError((error: HttpErrorResponse) => { this.errorMessage.set(error.error.message) @@ -78,7 +84,6 @@ export class SubscriptionEditForm implements OnInit { link: feed.link, settings: { enabled: feed.settings?.enabled || false, - loadFullText: feed.settings?.loadFullText || false, }, }) } diff --git a/src/app/components/login-form/login-form.ts b/src/app/components/login-form/login-form.ts index 7b2edb7..5ad06d0 100644 --- a/src/app/components/login-form/login-form.ts +++ b/src/app/components/login-form/login-form.ts @@ -1,4 +1,11 @@ -import { ChangeDetectionStrategy, Component, DestroyRef, inject, model, signal } from '@angular/core' +import { + ChangeDetectionStrategy, + Component, + DestroyRef, + inject, + model, + signal, +} from '@angular/core' import { AsyncPipe } from '@angular/common' import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { MatButton } from '@angular/material/button' diff --git a/src/app/components/nav/nav.component.ts b/src/app/components/nav/nav.component.ts index bb6e344..6eafcbd 100644 --- a/src/app/components/nav/nav.component.ts +++ b/src/app/components/nav/nav.component.ts @@ -1,4 +1,12 @@ -import { ChangeDetectionStrategy, Component, DestroyRef, inject, OnInit, signal, viewChild } from '@angular/core' +import { + ChangeDetectionStrategy, + Component, + DestroyRef, + inject, + OnInit, + signal, + viewChild, +} from '@angular/core' import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout' import { AsyncPipe } from '@angular/common' import { MatToolbarModule } from '@angular/material/toolbar' @@ -51,7 +59,7 @@ export class NavComponent implements OnInit { menuItems: { title: string; icon?: string; url: string }[] = [ { title: 'Articles', url: '/articles', icon: 'library_books' }, { title: 'Bookmarks', url: '/bookmarks', icon: 'bookmark' }, - { title: 'Subscriptions', url: '/subscriptions', icon: 'rss_feed' }, + { title: 'Feeds', url: '/feeds', icon: 'rss_feed' }, { title: 'Tags', url: '/tags', icon: 'tag' }, { title: 'User', url: '/user', icon: 'person' }, { title: 'Status', url: '/status', icon: 'memory' }, @@ -75,13 +83,11 @@ export class NavComponent implements OnInit { } ngOnInit(): void { - this.router.events - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((event) => { - if (event.type === EventType.ActivationStart) { - const title: string = event.snapshot.data?.['title'] - this.titleService.setTitle(title) - } - }) + this.router.events.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => { + if (event.type === EventType.ActivationStart) { + const title: string = event.snapshot.data?.['title'] + this.titleService.setTitle(title) + } + }) } } diff --git a/src/app/entities/article/article.types.ts b/src/app/entities/article/article.types.ts index cfa7a73..6859d84 100644 --- a/src/app/entities/article/article.types.ts +++ b/src/app/entities/article/article.types.ts @@ -11,5 +11,5 @@ export interface Article extends RssItem { read: boolean readonly fullText?: string readonly userId: string - readonly subscriptionId: string + readonly feedId: string } diff --git a/src/app/pages/article-page/article-page.ts b/src/app/pages/article-page/article-page.ts index f59d0ae..77f4b71 100644 --- a/src/app/pages/article-page/article-page.ts +++ b/src/app/pages/article-page/article-page.ts @@ -1,4 +1,12 @@ -import { ChangeDetectionStrategy, Component, computed, DestroyRef, inject, OnInit, signal } from '@angular/core' +import { + ChangeDetectionStrategy, + Component, + computed, + DestroyRef, + inject, + OnInit, + signal, +} from '@angular/core' import { FeedService } from '../../services/feed-service' import { ActivatedRoute } from '@angular/router' import { takeUntilDestroyed } from '@angular/core/rxjs-interop' @@ -88,14 +96,12 @@ export class ArticlePage implements OnInit { this.fullText.set(parsed) } this.titleService.setTitle(result?.title || '') - this.titleService.setSubtitle(null) + this.titleService.setSubtitle(null) }) - this.tagService.$defaultTags - .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe((tags) => { - this.favTagId.set(tags.find((t) => t.name === 'fav')?._id || '') - }) + this.tagService.$defaultTags.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((tags) => { + this.favTagId.set(tags.find((t) => t.name === 'fav')?._id || '') + }) } onMarkAsRead(): void { diff --git a/src/app/pages/articles-page/articles-page.ts b/src/app/pages/articles-page/articles-page.ts index be56217..1b8e97a 100644 --- a/src/app/pages/articles-page/articles-page.ts +++ b/src/app/pages/articles-page/articles-page.ts @@ -9,7 +9,7 @@ import { MatToolbarModule } from '@angular/material/toolbar' import { MatButtonToggleModule } from '@angular/material/button-toggle' import { MatIconModule } from '@angular/material/icon' import { RowSpacer } from '../../components/row-spacer/row-spacer' -import { ActivatedRoute, Router } from '@angular/router' +import { ActivatedRoute } from '@angular/router' import { Article } from '../../entities/article/article.types' import { MatPaginatorModule } from '@angular/material/paginator' import { TagService } from '../../services/tag-service' @@ -43,7 +43,6 @@ import { SortOrder } from '../../entities/base/base.enums' }) export class ArticlesPage implements OnInit { private readonly feedService = inject(FeedService) - private readonly router = inject(Router) private readonly route = inject(ActivatedRoute) private readonly destroyRef = inject(DestroyRef) private readonly tagService = inject(TagService) @@ -58,7 +57,7 @@ export class ArticlesPage implements OnInit { $readFilter = new BehaviorSubject(true) $favFilter = new BehaviorSubject(false) - $subscriptionFilter = new BehaviorSubject(null) + $feedFilter = new BehaviorSubject(null) $tagFilter = new BehaviorSubject(null) $dateOrder = new BehaviorSubject(SortOrder.Desc) @@ -94,11 +93,11 @@ export class ArticlesPage implements OnInit { this.pageService.$currentPage, this.$favFilter, this.$readFilter, - this.$subscriptionFilter, + this.$feedFilter, this.$tagFilter, this.$dateOrder, ]).pipe( - switchMap(([perPage, pageNumber, fav, read, subscription, tag, dateSort]) => { + switchMap(([perPage, pageNumber, fav, read, feed, tag, dateSort]) => { const filters: Record = {} if (read) { @@ -109,8 +108,8 @@ export class ArticlesPage implements OnInit { filters['tags'] = favTag } - if (subscription) { - filters['subscription'] = subscription + if (feed) { + filters['feed'] = feed } if (tag) { @@ -145,14 +144,17 @@ export class ArticlesPage implements OnInit { .pipe( takeUntilDestroyed(this.destroyRef), switchMap((params) => { - const subscriptionId: string = params['subscription'] + const feedId: string = params['feed'] const tagName: string = params['tag'] - const tag = this.userTags().find((t) => t.name === tagName) - if (!subscriptionId) { + if (tagName) { return forkJoin([of(null), this.tagService.getOne({ name: tagName })]) - } else { - return forkJoin([this.feedService.getOneSubscription({ subscriptionId }), of(null)]) } + + if (feedId) { + return forkJoin([this.feedService.getOneFeed({ feedId }), of(null)]) + } + + return forkJoin([of(null), of(null)]) }), catchError((e) => { console.error(e) @@ -168,15 +170,15 @@ export class ArticlesPage implements OnInit { if (feed) { this.titleService.setSubtitle(feed.title) - this.$subscriptionFilter.next(feed._id) + this.$feedFilter.next(feed._id) this.$tagFilter.next(null) } else if (tag) { this.titleService.setSubtitle(tag.name) - this.$subscriptionFilter.next(null) + this.$feedFilter.next(null) this.$tagFilter.next(tag._id) } else { this.titleService.setSubtitle(null) - this.$subscriptionFilter.next(null) + this.$feedFilter.next(null) this.$tagFilter.next(null) } }) @@ -231,7 +233,7 @@ export class ArticlesPage implements OnInit { onRefreshAll() { this.isRefreshingAll.set(true) this.feedService - .refreshAllSubscriptions() + .refreshAllFeeds() .pipe( takeUntilDestroyed(this.destroyRef), catchError((e) => { diff --git a/src/app/pages/subscriptions-page/subscriptions-page.css b/src/app/pages/feeds-page/feeds-page.css similarity index 100% rename from src/app/pages/subscriptions-page/subscriptions-page.css rename to src/app/pages/feeds-page/feeds-page.css diff --git a/src/app/pages/subscriptions-page/subscriptions-page.html b/src/app/pages/feeds-page/feeds-page.html similarity index 86% rename from src/app/pages/subscriptions-page/subscriptions-page.html rename to src/app/pages/feeds-page/feeds-page.html index f22ac50..ebf9186 100644 --- a/src/app/pages/subscriptions-page/subscriptions-page.html +++ b/src/app/pages/feeds-page/feeds-page.html @@ -26,7 +26,7 @@ {{ f.title }} @@ -53,15 +53,18 @@ - -

{{f.description}}

+ +

{{ f.description }}

library_books
} @empty { -

No subscriptions found

+

No feeds found

} } @loading (minimum 0.5s) { diff --git a/src/app/pages/subscriptions-page/subscriptions-page.ts b/src/app/pages/feeds-page/feeds-page.ts similarity index 80% rename from src/app/pages/subscriptions-page/subscriptions-page.ts rename to src/app/pages/feeds-page/feeds-page.ts index 2c971ed..7606309 100644 --- a/src/app/pages/subscriptions-page/subscriptions-page.ts +++ b/src/app/pages/feeds-page/feeds-page.ts @@ -9,7 +9,6 @@ import { MatIconModule } from '@angular/material/icon' import { MatIconButton } from '@angular/material/button' import { RowSpacer } from '../../components/row-spacer/row-spacer' import { MatDialog, MatDialogModule } from '@angular/material/dialog' -import { SubscriptionAddForm } from '../../components/subscription-add-form/subscription-add-form' import { Feed } from '../../entities/feed/feed.types' import { MatProgressBar } from '@angular/material/progress-bar' import { MatPaginatorModule } from '@angular/material/paginator' @@ -19,12 +18,15 @@ import { PageService } from '../../services/page-service' import { TitleService } from '../../services/title-service' import { scrollUp } from '../../../utils' import { RouterLink } from '@angular/router' -import { SubscriptionEditForm } from '../../components/subscription-edit-form/subscription-edit-form' import { MatBadgeModule } from '@angular/material/badge' import { ConfirmationDialog } from '../../components/confirmation-dialog/confirmation-dialog' +import { FeedAddForm } from '../../components/feed-add-form/feed-add-form' +import { FeedEditForm } from '../../components/feed-edit-form/feed-edit-form' +import { MatBottomSheet } from '@angular/material/bottom-sheet' +import { BottomErrorSheet } from '../../components/bottom-error-sheet/bottom-error-sheet' @Component({ - selector: 'app-subscriptions-page', + selector: 'app-feed-page', imports: [ MatCardModule, MatToolbarModule, @@ -39,10 +41,10 @@ import { ConfirmationDialog } from '../../components/confirmation-dialog/confirm RouterLink, MatBadgeModule, ], - templateUrl: './subscriptions-page.html', - styleUrl: './subscriptions-page.css', + templateUrl: './feeds-page.html', + styleUrl: './feeds-page.css', }) -export class SubscriptionsPage implements OnInit { +export class FeedsPage implements OnInit { constructor() { effect(() => { scrollUp({ trigger: !!this.feeds().length }) @@ -54,6 +56,7 @@ export class SubscriptionsPage implements OnInit { private readonly dialog = inject(MatDialog) private readonly destroyRef = inject(DestroyRef) private readonly titleService = inject(TitleService) + private readonly bottomError = inject(MatBottomSheet) readonly feeds = signal([]) readonly isRefreshing = signal>({}) @@ -64,7 +67,7 @@ export class SubscriptionsPage implements OnInit { .pipe( takeUntilDestroyed(this.destroyRef), switchMap(([perPage, pageNumber]) => { - return this.feedService.getAllSubscriptions({ + return this.feedService.getAllFeeds({ pagination: { perPage, pageNumber, @@ -77,13 +80,13 @@ export class SubscriptionsPage implements OnInit { this.pageService.setTotalResults(result.total) this.feeds.set(result.result) } - this.titleService.setTitle('Subscriptions') + this.titleService.setTitle('Feeds') this.titleService.setSubtitle(null) }) } onAdd(): void { - const dialogRef = this.dialog.open(SubscriptionAddForm) + const dialogRef = this.dialog.open(FeedAddForm) dialogRef.afterClosed().subscribe((result) => { console.log('The dialog was closed', result) @@ -91,21 +94,22 @@ export class SubscriptionsPage implements OnInit { }) } - onRefreshOne(e: MouseEvent, subscriptionId: string): void { + onRefreshOne(e: MouseEvent, feedId: string): void { e.stopPropagation() this.isRefreshing.update((prev) => ({ ...prev, - [subscriptionId]: true, + [feedId]: true, })) this.feedService - .refreshOneSubscription({ subscriptionId }) + .refreshOneFeed({ feedId }) .pipe( takeUntilDestroyed(this.destroyRef), catchError((e) => { this.isRefreshing.update((prev) => ({ ...prev, - [subscriptionId]: false, + [feedId]: false, })) + this.bottomError.open(BottomErrorSheet, { data: { error: e.error.message } }) console.error(e) return of(null) }), @@ -113,7 +117,7 @@ export class SubscriptionsPage implements OnInit { .subscribe(() => { this.isRefreshing.update((prev) => ({ ...prev, - [subscriptionId]: false, + [feedId]: false, })) }) } @@ -121,7 +125,7 @@ export class SubscriptionsPage implements OnInit { onRefreshAll(): void { this.isRefreshingAll.set(true) this.feedService - .refreshAllSubscriptions() + .refreshAllFeeds() .pipe( takeUntilDestroyed(this.destroyRef), catchError((e) => { @@ -140,8 +144,8 @@ export class SubscriptionsPage implements OnInit { const dialogRef = this.dialog.open(ConfirmationDialog, { data: { - title: 'Delete subscription?', - message: 'Are you sure you want to delete this subscription?', + title: 'Delete feed?', + message: 'Are you sure you want to delete this feed?', confirmButtonText: 'Delete', }, }) @@ -149,7 +153,7 @@ export class SubscriptionsPage implements OnInit { dialogRef.afterClosed().subscribe((agree) => { if (agree) { this.feedService - .deleteOneSubscription({ subscriptionId: id }) + .deleteOneFeed({ feedId: id }) .pipe( catchError((error: HttpErrorResponse) => { console.log(error) @@ -166,7 +170,7 @@ export class SubscriptionsPage implements OnInit { onEdit(e: MouseEvent, feed: Feed): void { e.stopPropagation() - const dialogRef = this.dialog.open(SubscriptionEditForm, { + const dialogRef = this.dialog.open(FeedEditForm, { data: { feed }, }) diff --git a/src/app/services/feed-service.ts b/src/app/services/feed-service.ts index 44d9902..9b3aae7 100644 --- a/src/app/services/feed-service.ts +++ b/src/app/services/feed-service.ts @@ -12,8 +12,8 @@ import { SortOrder } from '../entities/base/base.enums' export class FeedService { readonly httpClient = inject(HttpClient) - getAllSubscriptions({ pagination }: { pagination?: Partial }) { - return this.httpClient.get>(`${environment.api}/subscription`, { + getAllFeeds({ pagination }: { pagination?: Partial }) { + return this.httpClient.get>(`${environment.api}/feed`, { params: pagination, }) } @@ -36,18 +36,12 @@ export class FeedService { }) } - getOneSubscription({ subscriptionId }: { subscriptionId: string }) { - return this.httpClient.get(`${environment.api}/subscription/${subscriptionId}`) + getOneFeed({ feedId }: { feedId: string }) { + return this.httpClient.get(`${environment.api}/feed/${feedId}`) } - changeOneSubscription({ - id, - dto, - }: { - id: string - dto: Partial - }) { - return this.httpClient.patch(`${environment.api}/subscription/${id}`, dto) + changeOneFeed({ id, dto }: { id: string; dto: Partial }) { + return this.httpClient.patch(`${environment.api}/feed/${id}`, dto) } getOneArticle({ articleId }: { articleId: string }) { @@ -77,20 +71,20 @@ export class FeedService { }) } - addOneSubscription({ subscription }: { subscription: FeedDTO }) { - return this.httpClient.post(`${environment.api}/subscription`, subscription) + addOneFeed({ feed }: { feed: FeedDTO }) { + return this.httpClient.post(`${environment.api}/feed`, feed) } - deleteOneSubscription({ subscriptionId }: { subscriptionId: string }) { - return this.httpClient.delete(`${environment.api}/subscription/${subscriptionId}`) + deleteOneFeed({ feedId }: { feedId: string }) { + return this.httpClient.delete(`${environment.api}/feed/${feedId}`) } - refreshAllSubscriptions() { - return this.httpClient.get(`${environment.api}/subscription/refresh`) + refreshAllFeeds() { + return this.httpClient.get(`${environment.api}/feed/refresh`) } - refreshOneSubscription({ subscriptionId }: { subscriptionId: string }) { - return this.httpClient.get(`${environment.api}/subscription/${subscriptionId}/refresh`) + refreshOneFeed({ feedId }: { feedId: string }) { + return this.httpClient.get(`${environment.api}/feed/${feedId}/refresh`) } getFullText({ articleId }: { articleId: string }) {