This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
<section class="grid grid-cols-1 gap-5 m-5">
|
||||
<article
|
||||
*ngFor="let post of posts()"
|
||||
class="p-5 grid grid-cols-5 grid-rows-3 items-start rounded-s bg-white drop-shadow-md hover:drop-shadow-lg"
|
||||
class="p-5 grid grid-cols-5 grid-rows-3 items-start rounded-s bg-white drop-shadow-md hover:drop-shadow-lg gap-5"
|
||||
>
|
||||
<h3 class="text-xl col-span-4">{{ post.title }}</h3>
|
||||
<p class="col-start-1 col-span-4 row-start-2 row-span-2">
|
||||
@@ -31,5 +31,14 @@
|
||||
>
|
||||
Delete
|
||||
</app-button>
|
||||
@if (post.secret !== undefined) {
|
||||
<app-button
|
||||
(click)="getPath(post.secret)"
|
||||
class="col-start-5 row-start-2"
|
||||
color="yellow"
|
||||
>
|
||||
Copy Link
|
||||
</app-button>
|
||||
}
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -17,4 +17,8 @@ export class DashboardComponent {
|
||||
delete(id: number) {
|
||||
this.postsService.deletePost(id);
|
||||
}
|
||||
getPath(secret: string) {
|
||||
const url = document.URL.replaceAll('/dashboard', '');
|
||||
navigator.clipboard.writeText(`${url}/post/secret/${secret}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { PostsService } from '../../shared/services/posts.service';
|
||||
import { JsonPipe, NgIf } from '@angular/common';
|
||||
import { MarkdownComponent } from '../../components/markdown/markdown.component';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<h2 class="text-3xl">{{ post()?.title }}</h2>
|
||||
<p class="mb-5 italic text-sm">TL;DR; {{ post()?.tldr }}</p>
|
||||
|
||||
<app-markdown
|
||||
class="todo"
|
||||
[markdown]="post()?.content || 'this post is empty'"
|
||||
/>
|
||||
28
web/src/app/routes/post/secret-post/secret-post.component.ts
Normal file
28
web/src/app/routes/post/secret-post/secret-post.component.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import {
|
||||
Component,
|
||||
inject,
|
||||
Input,
|
||||
OnInit,
|
||||
signal,
|
||||
WritableSignal,
|
||||
} from '@angular/core';
|
||||
import { PostsService } from '../../../shared/services/posts.service';
|
||||
import { Post } from '../../../shared/interfaces/post';
|
||||
import { MarkdownComponent } from '../../../components/markdown/markdown.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-secret-post',
|
||||
imports: [MarkdownComponent],
|
||||
templateUrl: './secret-post.component.html',
|
||||
})
|
||||
export class SecretPostComponent implements OnInit {
|
||||
@Input() secret!: string;
|
||||
private postsService = inject(PostsService);
|
||||
post: WritableSignal<Post | undefined> = signal(undefined);
|
||||
|
||||
ngOnInit(): void {
|
||||
this.postsService.getPostBySecret(this.secret).subscribe((post) => {
|
||||
this.post.set(post);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user