feat(dashboard): add user greeting to dashboard component
This commit is contained in:
parent
fdfe92a232
commit
311fd89c7b
3 changed files with 21 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
<div class="mx-auto container">
|
||||
<app-navbar></app-navbar>
|
||||
<h1>Hello {{user?.['name']}}!</h1>
|
||||
<div class="">
|
||||
<div class="flex flex-row">
|
||||
<button
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { LinkService } from '../service/link.service';
|
||||
import { RecordModel } from 'pocketbase';
|
||||
import { NavbarComponent } from '../navbar/navbar.component';
|
||||
import { Router, RouterLink } from '@angular/router';
|
||||
import { MatRow, MatTableModule } from '@angular/material/table';
|
||||
|
@ -11,7 +10,8 @@ import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
|||
import { ConfirmationModalComponent } from '../confirmation-modal/confirmation-modal.component';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { OptionsMenuComponent } from '../options-menu/options-menu.component';
|
||||
import { LogoutService } from '../service/logout.service';
|
||||
import { UserService } from '../service/user.service';
|
||||
import { AuthRecord } from 'pocketbase';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
|
@ -28,12 +28,14 @@ import { LogoutService } from '../service/logout.service';
|
|||
export class DashboardComponent {
|
||||
public links: Link[] = [];
|
||||
displayedColumns: string[] = ['id', 'name', 'link', 'shortLink', 'actions'];
|
||||
public user!: AuthRecord;
|
||||
|
||||
constructor(
|
||||
private linkService: LinkService,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private snackBar: MatSnackBar,
|
||||
private userService: UserService,
|
||||
) {}
|
||||
|
||||
copyLink(id: string) {
|
||||
|
@ -65,6 +67,8 @@ export class DashboardComponent {
|
|||
this.linkService.getLinks().then((links) => {
|
||||
this.links = links;
|
||||
});
|
||||
|
||||
this.user = this.userService.getUser();
|
||||
}
|
||||
|
||||
createLink() {
|
||||
|
|
14
src/app/service/user.service.ts
Normal file
14
src/app/service/user.service.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { Injectable } from "@angular/core";
|
||||
import PocketBase, { AuthRecord } from 'pocketbase';
|
||||
import { environment } from "../../environments/environment";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserService {
|
||||
private pb = new PocketBase(environment.POCKETBASE);
|
||||
|
||||
getUser(): AuthRecord {
|
||||
return this.pb.authStore.record;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue