feat: Added redirect after login for users. Closes #17
This commit is contained in:
14
src/app/app-view/personal/extra/extra.component.html
Normal file
14
src/app/app-view/personal/extra/extra.component.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<h1 mat-dialog-title>Dodatkowe ustawienia</h1>
|
||||
<mat-dialog-content>
|
||||
<mat-action-list>
|
||||
@for (link of LINKS; track link) {
|
||||
<button mat-list-item (click)="open(link.component)">
|
||||
<mat-icon matListItemIcon *ngIf="link.icon">{{link.icon}}</mat-icon>
|
||||
<div matListItemTitle>{{link.title}}</div>
|
||||
</button>
|
||||
}
|
||||
</mat-action-list>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-dialog-close mat-button>Zamknij</button>
|
||||
</mat-dialog-actions>
|
||||
23
src/app/app-view/personal/extra/extra.component.spec.ts
Normal file
23
src/app/app-view/personal/extra/extra.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ExtraComponent } from './extra.component';
|
||||
|
||||
describe('ExtraComponent', () => {
|
||||
let component: ExtraComponent;
|
||||
let fixture: ComponentFixture<ExtraComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ExtraComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ExtraComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
29
src/app/app-view/personal/extra/extra.component.ts
Normal file
29
src/app/app-view/personal/extra/extra.component.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { ComponentType } from '@angular/cdk/portal';
|
||||
import { Component } from '@angular/core';
|
||||
import { Link } from 'src/app/types/link';
|
||||
import { RedirectComponent } from './redirect/redirect.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
|
||||
@Component({
|
||||
selector: 'app-extra',
|
||||
templateUrl: './extra.component.html',
|
||||
styleUrl: './extra.component.scss'
|
||||
})
|
||||
export class ExtraComponent {
|
||||
|
||||
constructor (private dialog: MatDialog) {}
|
||||
|
||||
private readonly _LINKS: (Omit<Link, "href"> & {component: ComponentType<any>})[] = [
|
||||
{ title: "Domyślna strona po logowaniu", component: RedirectComponent, enabled: true, icon: "home" }
|
||||
]
|
||||
|
||||
public get LINKS() {
|
||||
return this._LINKS.filter((v) => {
|
||||
return v.enabled
|
||||
});
|
||||
}
|
||||
|
||||
open(component: ComponentType<any>) {
|
||||
this.dialog.open(component)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<h1>Domyślna strona po logowaniu</h1>
|
||||
<mat-dialog-content>
|
||||
<p>Wpisz link względem /ipwa/ w poniższym polu.</p>
|
||||
<p>Przykład: /app/menu</p>
|
||||
<mat-form-field>
|
||||
<input matInput type="text" [(ngModel)]="redirect">
|
||||
<mat-label>Link</mat-label>
|
||||
</mat-form-field>
|
||||
</mat-dialog-content>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-dialog-close mat-button>Anuluj</button>
|
||||
<button (click)="save()" mat-flat-button>Zapisz</button>
|
||||
</mat-dialog-actions>
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { RedirectComponent } from './redirect.component';
|
||||
|
||||
describe('RedirectComponent', () => {
|
||||
let component: RedirectComponent;
|
||||
let fixture: ComponentFixture<RedirectComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [RedirectComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(RedirectComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
import { AuthClient } from 'src/app/services/auth.client';
|
||||
|
||||
@Component({
|
||||
selector: 'app-redirect',
|
||||
templateUrl: './redirect.component.html',
|
||||
styleUrl: './redirect.component.scss'
|
||||
})
|
||||
export class RedirectComponent {
|
||||
protected redirect = ""
|
||||
constructor (public dialogRef: MatDialogRef<RedirectComponent>, private ac: AuthClient) {
|
||||
this.redirect = ac.redirect
|
||||
}
|
||||
|
||||
protected save() {
|
||||
this.ac.redirect = this.redirect
|
||||
this.dialogRef.close()
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,10 @@
|
||||
<div matListItemTitle>Panel administracyjny</div>
|
||||
<div matListItemLine>Poprzednio Tryb edycji</div>
|
||||
</button>
|
||||
<button mat-list-item (click)="openExtra()">
|
||||
<mat-icon matListItemIcon>settings_applications</mat-icon>
|
||||
<div matListItemTitle>Dodatkowe ustawienia</div>
|
||||
</button>
|
||||
<button mat-list-item (click)="openAbout()">
|
||||
<mat-icon matListItemIcon>info</mat-icon>
|
||||
<div matListItemTitle>O programie</div>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { LocalStorageService } from 'src/app/services/local-storage.service';
|
||||
import { KeyComponent } from './key/key.component';
|
||||
import { CleanComponent } from './clean/clean.component';
|
||||
import { AboutComponent } from './about/about.component';
|
||||
import { ExtraComponent } from './extra/extra.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-personal',
|
||||
@@ -63,6 +64,10 @@ export class PersonalComponent {
|
||||
this.ac.check()
|
||||
}
|
||||
|
||||
protected openExtra() {
|
||||
this.dialog.open(ExtraComponent)
|
||||
}
|
||||
|
||||
protected openAbout() {
|
||||
this.dialog.open(AboutComponent)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user