main #13
7 changed files with 84 additions and 20 deletions
|
@ -1,14 +1,15 @@
|
||||||
<div class="mx-auto container">
|
<div class="mx-auto container">
|
||||||
<app-navbar></app-navbar>
|
<app-navbar></app-navbar>
|
||||||
<div class="overflow-x-auto">
|
<div class="">
|
||||||
<button
|
<div class="flex flex-row">
|
||||||
mat-flat-button
|
<button mat-flat-button color="secondary" class="my-3" (click)="createLink()">
|
||||||
color="secondary"
|
Create new Link
|
||||||
class="my-3"
|
</button>
|
||||||
(click)="createLink()"
|
|
||||||
>
|
<div class="ml-auto my-3">
|
||||||
Create new Link
|
<app-options-menu></app-options-menu>
|
||||||
</button>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<mat-card appearance="outlined">
|
<mat-card appearance="outlined">
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
|
@ -42,11 +43,7 @@
|
||||||
<ng-container matColumnDef="shortLink">
|
<ng-container matColumnDef="shortLink">
|
||||||
<th mat-header-cell *matHeaderCellDef>Short link</th>
|
<th mat-header-cell *matHeaderCellDef>Short link</th>
|
||||||
<td mat-cell *matCellDef="let element">
|
<td mat-cell *matCellDef="let element">
|
||||||
<button
|
<button mat-flat-button class="my-3" (click)="copyLink(element.id)">
|
||||||
mat-flat-button
|
|
||||||
class="my-3"
|
|
||||||
(click)="copyLink(element.id)"
|
|
||||||
>
|
|
||||||
Copy short link
|
Copy short link
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
|
@ -55,11 +52,7 @@
|
||||||
<ng-container matColumnDef="actions">
|
<ng-container matColumnDef="actions">
|
||||||
<th mat-header-cell *matHeaderCellDef>Actions</th>
|
<th mat-header-cell *matHeaderCellDef>Actions</th>
|
||||||
<td mat-cell *matCellDef="let element">
|
<td mat-cell *matCellDef="let element">
|
||||||
<button
|
<button mat-flat-button color="warn" (click)="deleteLink(element)">
|
||||||
mat-flat-button
|
|
||||||
color="warn"
|
|
||||||
(click)="deleteLink(element)"
|
|
||||||
>
|
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -10,10 +10,12 @@ import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
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 { LogoutService } from '../service/logout.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dashboard',
|
selector: 'app-dashboard',
|
||||||
imports: [NavbarComponent, MatTableModule, MatCardModule, MatButtonModule],
|
imports: [NavbarComponent, MatTableModule, MatCardModule, MatButtonModule, OptionsMenuComponent],
|
||||||
templateUrl: './dashboard.component.html',
|
templateUrl: './dashboard.component.html',
|
||||||
styleUrl: './dashboard.component.css',
|
styleUrl: './dashboard.component.css',
|
||||||
})
|
})
|
||||||
|
|
0
src/app/options-menu/options-menu.component.css
Normal file
0
src/app/options-menu/options-menu.component.css
Normal file
9
src/app/options-menu/options-menu.component.html
Normal file
9
src/app/options-menu/options-menu.component.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<button mat-icon-button [matMenuTriggerFor]="menu" aria-label="Example icon-button with a menu">
|
||||||
|
<mat-icon>more_vert</mat-icon>
|
||||||
|
</button>
|
||||||
|
<mat-menu #menu="matMenu">
|
||||||
|
<button (click)="logout()" mat-menu-item>
|
||||||
|
<mat-icon>logout</mat-icon>
|
||||||
|
<span>Logout</span>
|
||||||
|
</button>
|
||||||
|
</mat-menu>
|
23
src/app/options-menu/options-menu.component.spec.ts
Normal file
23
src/app/options-menu/options-menu.component.spec.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { OptionsMenuComponent } from './options-menu.component';
|
||||||
|
|
||||||
|
describe('OptionsMenuComponent', () => {
|
||||||
|
let component: OptionsMenuComponent;
|
||||||
|
let fixture: ComponentFixture<OptionsMenuComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [OptionsMenuComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(OptionsMenuComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
19
src/app/options-menu/options-menu.component.ts
Normal file
19
src/app/options-menu/options-menu.component.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import {MatIconModule} from '@angular/material/icon';
|
||||||
|
import {MatMenuModule} from '@angular/material/menu';
|
||||||
|
import {MatButtonModule} from '@angular/material/button';
|
||||||
|
import { LogoutService } from '../service/logout.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-options-menu',
|
||||||
|
imports: [MatIconModule, MatMenuModule, MatButtonModule],
|
||||||
|
templateUrl: './options-menu.component.html',
|
||||||
|
styleUrl: './options-menu.component.css'
|
||||||
|
})
|
||||||
|
export class OptionsMenuComponent {
|
||||||
|
constructor(private logoutService: LogoutService) {}
|
||||||
|
|
||||||
|
logout() {
|
||||||
|
this.logoutService.logout();
|
||||||
|
}
|
||||||
|
}
|
18
src/app/service/logout.service.ts
Normal file
18
src/app/service/logout.service.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
import PocketBase from 'pocketbase';
|
||||||
|
import { environment } from "../../environments/environment";
|
||||||
|
import { Router } from "@angular/router";
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class LogoutService {
|
||||||
|
private pb = new PocketBase(environment.POCKETBASE);
|
||||||
|
|
||||||
|
constructor(private router: Router) { }
|
||||||
|
|
||||||
|
logout() {
|
||||||
|
this.pb.authStore.clear();
|
||||||
|
this.router.navigate(['']);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue