From 23d11096043e70925fe0bc28c8fbce195ba76680 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Sun, 19 Jan 2025 21:07:31 +0100 Subject: [PATCH] feat(dashboard): add LinkService to fetch dashboard links --- src/app/dashboard/dashboard.component.ts | 7 +++++++ src/app/service/link.service.ts | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/app/service/link.service.ts diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index 65db9aa..f9cae2b 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -1,4 +1,5 @@ import { Component } from '@angular/core'; +import { LinkService } from '../service/link.service'; @Component({ selector: 'app-dashboard', @@ -7,5 +8,11 @@ import { Component } from '@angular/core'; styleUrl: './dashboard.component.css' }) export class DashboardComponent { + constructor(private linkService: LinkService) { }; + ngOnInit(): void { + this.linkService.getLinks().then(links => { + console.log(links); + }); + } } diff --git a/src/app/service/link.service.ts b/src/app/service/link.service.ts new file mode 100644 index 0000000..8b4a4ea --- /dev/null +++ b/src/app/service/link.service.ts @@ -0,0 +1,15 @@ +import { Injectable } from "@angular/core"; +import { environment } from "../../environments/environment.development"; +import PocketBase, { RecordModel } from 'pocketbase'; + + +@Injectable({ + providedIn: 'root' +}) +export class LinkService { + private pb = new PocketBase(environment.POCKETBASE); + + getLinks(): Promise { + return this.pb.collection('links').getFullList(); + } +}