main #6
6 changed files with 52 additions and 0 deletions
|
@ -3,6 +3,7 @@ import { LoginComponent } from './login/login.component';
|
||||||
import { DashboardComponent } from './dashboard/dashboard.component';
|
import { DashboardComponent } from './dashboard/dashboard.component';
|
||||||
import { AuthGuard } from './service/auth.service';
|
import { AuthGuard } from './service/auth.service';
|
||||||
import { CreateLinkComponent } from './create-link/create-link.component';
|
import { CreateLinkComponent } from './create-link/create-link.component';
|
||||||
|
import { ViewLinkComponent } from './view-link/view-link.component';
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{
|
{
|
||||||
|
@ -19,6 +20,10 @@ export const routes: Routes = [
|
||||||
component: CreateLinkComponent,
|
component: CreateLinkComponent,
|
||||||
canActivate: [AuthGuard],
|
canActivate: [AuthGuard],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: ':link',
|
||||||
|
component: ViewLinkComponent,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "**",
|
path: "**",
|
||||||
redirectTo: "",
|
redirectTo: "",
|
||||||
|
|
|
@ -14,6 +14,10 @@ export class LinkService {
|
||||||
return this.pb.collection<Link>('links').getFullList<Link>();
|
return this.pb.collection<Link>('links').getFullList<Link>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLink(id: string): Promise<Link> {
|
||||||
|
return this.pb.collection('links').getOne<Link>(id);
|
||||||
|
}
|
||||||
|
|
||||||
deleteLink(id: string) {
|
deleteLink(id: string) {
|
||||||
this.pb.collection('links').delete(id);
|
this.pb.collection('links').delete(id);
|
||||||
}
|
}
|
||||||
|
|
0
src/app/view-link/view-link.component.css
Normal file
0
src/app/view-link/view-link.component.css
Normal file
1
src/app/view-link/view-link.component.html
Normal file
1
src/app/view-link/view-link.component.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<p>Your are being redirected.</p>
|
23
src/app/view-link/view-link.component.spec.ts
Normal file
23
src/app/view-link/view-link.component.spec.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ViewLinkComponent } from './view-link.component';
|
||||||
|
|
||||||
|
describe('ViewLinkComponent', () => {
|
||||||
|
let component: ViewLinkComponent;
|
||||||
|
let fixture: ComponentFixture<ViewLinkComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [ViewLinkComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ViewLinkComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
19
src/app/view-link/view-link.component.ts
Normal file
19
src/app/view-link/view-link.component.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { LinkService } from '../service/link.service';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-view-link',
|
||||||
|
imports: [],
|
||||||
|
templateUrl: './view-link.component.html',
|
||||||
|
styleUrl: './view-link.component.css'
|
||||||
|
})
|
||||||
|
export class ViewLinkComponent {
|
||||||
|
constructor(private linkService: LinkService, private route: ActivatedRoute, private router: Router) { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.linkService.getLink(this.route.snapshot.params['link']).then(link => {
|
||||||
|
window.location.href = link.link;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue