Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/article-list/article-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<mat-icon>link</mat-icon>
</a>
<a
routerLink="/subscription/{{ a.subscriptionId }}/article/{{ a._id }}"
routerLink="/feed/{{ a.feedId }}/article/{{ a._id }}"
matIconButton
title="Open the article"
>
Expand Down
12 changes: 10 additions & 2 deletions src/app/components/article-list/article-list.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2 matDialogTitle>Add new subscription</h2>
<h2 matDialogTitle>Add new feed</h2>
<form
matDialogContent
[formGroup]="form"
Expand All @@ -8,7 +8,7 @@ <h2 matDialogTitle>Add new subscription</h2>
<mat-label>Title</mat-label>
<input
matInput
placeholder="Subscription title"
placeholder="Feed title"
type="text"
formControlName="title"
/>
Expand All @@ -33,7 +33,6 @@ <h2 matDialogTitle>Add new subscription</h2>
</mat-form-field>
<ng-container formGroupName="settings">
<mat-slide-toggle formControlName="enabled">Enabled</mat-slide-toggle>
<mat-slide-toggle formControlName="loadFullText">Load full text</mat-slide-toggle>
</ng-container>

@if (errorMessage()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<SubscriptionAddForm>)
private readonly dialogRef = inject(MatDialogRef<FeedAddForm>)

readonly isLoading = signal<boolean>(false)
readonly errorMessage = signal<string | null>(null)
Expand All @@ -39,15 +39,14 @@ export class SubscriptionAddForm {
link: ['', Validators.required],
settings: this.fb.group({
enabled: [true],
loadFullText: [false],
}),
})

onSubmit(): void {
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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2 matDialogTitle>Add new subscription</h2>
<h2 matDialogTitle>Add new feed</h2>
<form
matDialogContent
[formGroup]="form"
Expand All @@ -8,7 +8,7 @@ <h2 matDialogTitle>Add new subscription</h2>
<mat-label>Title</mat-label>
<input
matInput
placeholder="Subscription title"
placeholder="Feed title"
type="text"
formControlName="title"
/>
Expand All @@ -33,7 +33,6 @@ <h2 matDialogTitle>Add new subscription</h2>
</mat-form-field>
<ng-container formGroupName="settings">
<mat-slide-toggle formControlName="enabled">Enabled</mat-slide-toggle>
<mat-slide-toggle formControlName="loadFullText">Load full text</mat-slide-toggle>
</ng-container>

@if (errorMessage()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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,
Expand All @@ -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<SubscriptionEditForm>)
private readonly dialogRef = inject(MatDialogRef<FeedEditForm>)

readonly data: { feed: Feed; feedId: string } | null = inject(MAT_DIALOG_DATA)
readonly isLoading = signal<boolean>(false)
Expand All @@ -41,7 +48,6 @@ export class SubscriptionEditForm implements OnInit {
link: ['', Validators.required],
settings: this.fb.group({
enabled: [false],
loadFullText: [false],
}),
})

Expand All @@ -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)
Expand All @@ -78,7 +84,6 @@ export class SubscriptionEditForm implements OnInit {
link: feed.link,
settings: {
enabled: feed.settings?.enabled || false,
loadFullText: feed.settings?.loadFullText || false,
},
})
}
Expand Down
9 changes: 8 additions & 1 deletion src/app/components/login-form/login-form.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
26 changes: 16 additions & 10 deletions src/app/components/nav/nav.component.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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' },
Expand All @@ -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)
}
})
}
}
2 changes: 1 addition & 1 deletion src/app/entities/article/article.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export interface Article extends RssItem {
read: boolean
readonly fullText?: string
readonly userId: string
readonly subscriptionId: string
readonly feedId: string
}
20 changes: 13 additions & 7 deletions src/app/pages/article-page/article-page.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 {
Expand Down
Loading