feat(dashboard): add user greeting to dashboard component
This commit is contained in:
parent
aa6127a4e2
commit
8474d3001b
3 changed files with 21 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
<div class="mx-auto container">
|
<div class="mx-auto container">
|
||||||
<app-navbar></app-navbar>
|
<app-navbar></app-navbar>
|
||||||
|
<h1>Hello {{user?.['name']}}!</h1>
|
||||||
<div class="">
|
<div class="">
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { LinkService } from '../service/link.service';
|
import { LinkService } from '../service/link.service';
|
||||||
import { RecordModel } from 'pocketbase';
|
|
||||||
import { NavbarComponent } from '../navbar/navbar.component';
|
import { NavbarComponent } from '../navbar/navbar.component';
|
||||||
import { Router, RouterLink } from '@angular/router';
|
import { Router, RouterLink } from '@angular/router';
|
||||||
import { MatRow, MatTableModule } from '@angular/material/table';
|
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 { ConfirmationModalComponent } from '../confirmation-modal/confirmation-modal.component';
|
||||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
import { OptionsMenuComponent } from '../options-menu/options-menu.component';
|
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({
|
@Component({
|
||||||
selector: 'app-dashboard',
|
selector: 'app-dashboard',
|
||||||
|
@ -28,12 +28,14 @@ import { LogoutService } from '../service/logout.service';
|
||||||
export class DashboardComponent {
|
export class DashboardComponent {
|
||||||
public links: Link[] = [];
|
public links: Link[] = [];
|
||||||
displayedColumns: string[] = ['id', 'name', 'link', 'shortLink', 'actions'];
|
displayedColumns: string[] = ['id', 'name', 'link', 'shortLink', 'actions'];
|
||||||
|
public user!: AuthRecord;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private linkService: LinkService,
|
private linkService: LinkService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private snackBar: MatSnackBar,
|
private snackBar: MatSnackBar,
|
||||||
|
private userService: UserService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
copyLink(id: string) {
|
copyLink(id: string) {
|
||||||
|
@ -65,6 +67,8 @@ export class DashboardComponent {
|
||||||
this.linkService.getLinks().then((links) => {
|
this.linkService.getLinks().then((links) => {
|
||||||
this.links = links;
|
this.links = links;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.user = this.userService.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
createLink() {
|
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