ui
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
<div class="header">{{ client.clientName }}</div>
|
||||
<div class="header flex-row">
|
||||
<span>{{ client.clientName }}</span>
|
||||
<div class="flex-row">
|
||||
<div class="flex-row" style=" gap: 0;"><mat-icon>shield_person</mat-icon><div style="line-height: 8px;">{{ client.admins.length }}</div></div>
|
||||
<div class="flex-row" style=" gap: 0;"><mat-icon>link</mat-icon><div style="line-height: 8px;">{{ client.redirectUris.length }}</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="body">
|
||||
{{ client.description }}
|
||||
</div>
|
||||
<div class="footer">
|
||||
<button mat-button >Admins</button>
|
||||
<button mat-button >Redirect URIs</button>
|
||||
<button mat-flat-button color="warn" (click)="deleteClient()">Löschen</button>
|
||||
<div class="flex-row footer">
|
||||
<div>{{ client.createdAt | date }}</div>
|
||||
<div class="flex-row">
|
||||
<button mat-button (click)="showAdmins()" >Admins</button>
|
||||
<button mat-button (click)="showUris()" >Redirect URIs</button>
|
||||
<button mat-flat-button color="warn" (click)="deleteClient()">Löschen</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -6,12 +6,13 @@
|
||||
}
|
||||
|
||||
.footer {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.header {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.body {
|
||||
margin-top: 12px;
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CardComponent } from './card.component';
|
||||
import { ClientCardComponent } from './card.component';
|
||||
|
||||
describe('CardComponent', () => {
|
||||
let component: CardComponent;
|
||||
let fixture: ComponentFixture<CardComponent>;
|
||||
let component: ClientCardComponent;
|
||||
let fixture: ComponentFixture<ClientCardComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [CardComponent]
|
||||
imports: [ClientCardComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(CardComponent);
|
||||
fixture = TestBed.createComponent(ClientCardComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
@@ -3,25 +3,47 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
import { Client } from '../../../model/client.interface';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HotToastService } from '@ngxpert/hot-toast';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { ClientAdminsComponent } from '../client-admins/client-admins.component';
|
||||
import { ClientRedirectUrisComponent } from '../client-redirect-uris/client-redirect-uris.component';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-card',
|
||||
standalone: true,
|
||||
imports: [MatButtonModule],
|
||||
imports: [MatButtonModule, MatDialogModule, MatIconModule, CommonModule],
|
||||
templateUrl: './card.component.html',
|
||||
styleUrl: './card.component.scss'
|
||||
})
|
||||
export class CardComponent {
|
||||
export class ClientCardComponent {
|
||||
|
||||
@Input() client: Client;
|
||||
@Output() onDelete = new EventEmitter<Client>();
|
||||
|
||||
private http = inject(HttpClient);
|
||||
private toast = inject(HotToastService);
|
||||
private dialog = inject(MatDialog);
|
||||
|
||||
|
||||
|
||||
deleteClient() {
|
||||
this.onDelete.emit(this.client);
|
||||
}
|
||||
|
||||
showAdmins() {
|
||||
const dialog = this.dialog.open(ClientAdminsComponent, {
|
||||
autoFocus: false
|
||||
});
|
||||
dialog.componentInstance.client = this.client;
|
||||
dialog.componentInstance.isDialog = true;
|
||||
}
|
||||
|
||||
showUris() {
|
||||
const dialog = this.dialog.open(ClientRedirectUrisComponent, {
|
||||
autoFocus: false
|
||||
});
|
||||
dialog.componentInstance.client = this.client;
|
||||
dialog.componentInstance.isDialog = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<h3 matDialogTitle>Client Admins</h3>
|
||||
<div mat-dialog-content class="content">
|
||||
@for (admin of client.admins; track $index) {
|
||||
<div class="admin__item flex-row">
|
||||
<span class="admin__name">{{ admin.firstName }} {{ admin.lastName }}</span>
|
||||
@if($index!= 0) {
|
||||
<button mat-raised-button color="warn" class="remove_btn" ><mat-icon>delete</mat-icon></button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (isDialog) {
|
||||
<div mat-dialog-actions>
|
||||
<button mat-stroked-button color="warn" mat-dialog-close >close</button>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
.admin__item {
|
||||
box-sizing: border-box;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.content{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
mat-icon {
|
||||
margin: 0 !important;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.remove_btn {
|
||||
min-width: 0;
|
||||
padding: 0 14px;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ClientAdminsComponent } from './client-admins.component';
|
||||
|
||||
describe('ClientAdminsComponent', () => {
|
||||
let component: ClientAdminsComponent;
|
||||
let fixture: ComponentFixture<ClientAdminsComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ClientAdminsComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ClientAdminsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
import { AfterViewInit, Component, Input } from '@angular/core';
|
||||
import { Client } from '../../../model/client.interface';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
|
||||
@Component({
|
||||
selector: 'app-client-admins',
|
||||
standalone: true,
|
||||
imports: [MatIconModule, MatDialogModule, MatButtonModule],
|
||||
templateUrl: './client-admins.component.html',
|
||||
styleUrl: './client-admins.component.scss'
|
||||
})
|
||||
export class ClientAdminsComponent {
|
||||
private _client: Client;
|
||||
|
||||
isDialog = false;
|
||||
|
||||
constructor(private dialogRef: MatDialogRef<ClientAdminsComponent>) {
|
||||
|
||||
}
|
||||
|
||||
@Input()
|
||||
set client(client: Client) {
|
||||
if (!client) { throw new Error('Client not set')}
|
||||
this._client = client;
|
||||
}
|
||||
|
||||
get client(): Client {
|
||||
return this._client;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<h3 matDialogTitle>Client Redirect-URIs</h3>
|
||||
<div mat-dialog-content class="content">
|
||||
@for (uri of client.redirectUris; track $index) {
|
||||
<div class="admin__item flex-row">
|
||||
<span class="admin__name">{{ uri.uri }}</span>
|
||||
@if(client.redirectUris.length > 1) {
|
||||
<button mat-raised-button color="warn" class="remove_btn" (click)="removeUri(uri)" ><mat-icon>delete</mat-icon></button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="add_entry flex-row">
|
||||
<input type="text" id="addURIInput" placeholder="URL" >
|
||||
<button (click)="addUri()" mat-button>Neu</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (isDialog) {
|
||||
<div mat-dialog-actions>
|
||||
<button mat-stroked-button color="warn" mat-dialog-close >close</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (isLoading) {
|
||||
<div class="global-spinner" >
|
||||
<mat-spinner></mat-spinner>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
.admin__item {
|
||||
box-sizing: border-box;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.content{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
mat-icon {
|
||||
margin: 0 !important;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.remove_btn {
|
||||
min-width: 0;
|
||||
padding: 0 14px;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ClientRedirectUrisComponent } from './client-redirect-uris.component';
|
||||
|
||||
describe('ClientRedirectUrisComponent', () => {
|
||||
let component: ClientRedirectUrisComponent;
|
||||
let fixture: ComponentFixture<ClientRedirectUrisComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ClientRedirectUrisComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ClientRedirectUrisComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { Client } from '../../../model/client.interface';
|
||||
import { ClientAdminsComponent } from '../client-admins/client-admins.component';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { RedirectUri } from '../../../model/redirect-uri.interface';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
|
||||
@Component({
|
||||
selector: 'app-client-redirect-uris',
|
||||
standalone: true,
|
||||
imports: [MatIconModule, MatDialogModule, MatButtonModule, MatProgressSpinnerModule],
|
||||
templateUrl: './client-redirect-uris.component.html',
|
||||
styleUrl: './client-redirect-uris.component.scss'
|
||||
})
|
||||
export class ClientRedirectUrisComponent {
|
||||
private _client: Client;
|
||||
private http: HttpClient = inject(HttpClient);
|
||||
|
||||
isDialog = false;
|
||||
isLoading = false;
|
||||
|
||||
constructor(private dialogRef: MatDialogRef<ClientAdminsComponent>) {
|
||||
|
||||
}
|
||||
|
||||
@Input()
|
||||
set client(client: Client) {
|
||||
if (!client) { throw new Error('Client not set')}
|
||||
this._client = client;
|
||||
}
|
||||
|
||||
get client(): Client {
|
||||
return this._client;
|
||||
}
|
||||
|
||||
addUri() {
|
||||
const val: HTMLInputElement = document.getElementById('addURIInput') as any;
|
||||
|
||||
console.log(val.value)
|
||||
|
||||
this.client.redirectUris.push({
|
||||
uri: val.value
|
||||
});
|
||||
|
||||
val.value = null;
|
||||
this.saveClient();
|
||||
};
|
||||
removeUri(u: RedirectUri) {
|
||||
this.client.redirectUris = this.client.redirectUris.filter(r => r != u);
|
||||
this.saveClient()
|
||||
}
|
||||
|
||||
saveClient() {
|
||||
this.isLoading = true;
|
||||
this.http.post<RedirectUri[]>(`api/app/user/clients/${this.client.id}/redirect`, this.client.redirectUris).subscribe(res => {
|
||||
this.client.redirectUris = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -40,13 +40,12 @@
|
||||
</mat-step>
|
||||
<mat-step [editable]="true">
|
||||
<ng-template matStepLabel>Admins und Redirect URLs</ng-template>
|
||||
<div style="flex: 1 1 auto">space</div>
|
||||
<div> {{ client?.clientName }}</div>
|
||||
<div class="admin_container">
|
||||
@if (client && client.admins) {
|
||||
<app-client-admins [client]="client" ></app-client-admins>
|
||||
}
|
||||
</div>
|
||||
</mat-step>
|
||||
</mat-stepper>
|
||||
|
||||
|
||||
|
||||
|
||||
</mat-dialog-content>
|
||||
|
||||
|
||||
@@ -11,11 +11,13 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import {MatStepper, MatStepperModule} from '@angular/material/stepper';
|
||||
import { HotToastService } from '@ngxpert/hot-toast';
|
||||
import { Client } from '../../../model/client.interface';
|
||||
import { User } from '../../../model/user.interface';
|
||||
import { ClientAdminsComponent } from '../client-admins/client-admins.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-create-client',
|
||||
standalone: true,
|
||||
imports: [ReactiveFormsModule, MatFormFieldModule, MatInputModule, MatIconModule, MatDialogModule, MatButtonModule, MatProgressSpinnerModule, CommonModule, MatStepperModule],
|
||||
imports: [ReactiveFormsModule, MatFormFieldModule, MatInputModule, MatIconModule, MatDialogModule, MatButtonModule, MatProgressSpinnerModule, CommonModule, MatStepperModule, ClientAdminsComponent],
|
||||
templateUrl: './create-client.component.html',
|
||||
styleUrl: './create-client.component.scss'
|
||||
})
|
||||
@@ -36,6 +38,7 @@ export class CreateClientComponent {
|
||||
client: Client;
|
||||
|
||||
|
||||
|
||||
create() {
|
||||
if (this.createClient.invalid) { return; }
|
||||
|
||||
@@ -52,6 +55,7 @@ export class CreateClientComponent {
|
||||
)
|
||||
.subscribe({
|
||||
next: data => {
|
||||
console.log(this.stepper)
|
||||
this.client = data;
|
||||
this.createClient.enable();
|
||||
this.stepper.next();
|
||||
|
||||
@@ -22,8 +22,11 @@
|
||||
|
||||
<div class="card-container">
|
||||
<div class="card-container__list">
|
||||
@for (client of clients; track $index) {
|
||||
<ng-container #listSection>
|
||||
|
||||
</ng-container>
|
||||
<!-- @for (client of clients; track $index) {
|
||||
<app-card [client]="client" (onDelete)="openDeleteDialog($event)" ></app-card>
|
||||
}
|
||||
} -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Component, inject, OnInit } from '@angular/core';
|
||||
import { Component, inject, Injector, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
|
||||
import { UserService } from '../auth/user.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { CardComponent } from './components/card/card.component';
|
||||
import { ClientCardComponent } from './components/card/card.component';
|
||||
import { Client } from '../model/client.interface';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -10,11 +10,12 @@ import { MatDialog, MatDialogModule } from '@angular/material/dialog';
|
||||
import { CreateClientComponent } from './components/create-client/create-client.component';
|
||||
import { CreateHotToastRef, HotToastService } from '@ngxpert/hot-toast';
|
||||
import {MatBottomSheet, MatBottomSheetModule, MatBottomSheetRef} from '@angular/material/bottom-sheet';
|
||||
import { ClientAdminsComponent } from './components/client-admins/client-admins.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
standalone: true,
|
||||
imports: [CardComponent, MatButtonModule, MatIconModule, MatDialogModule, MatBottomSheetModule],
|
||||
imports: [ClientCardComponent, MatButtonModule, MatIconModule, MatDialogModule, MatBottomSheetModule],
|
||||
templateUrl: './dashboard.component.html',
|
||||
styleUrl: './dashboard.component.scss'
|
||||
})
|
||||
@@ -26,7 +27,9 @@ export class DashboardComponent implements OnInit {
|
||||
private dialog: MatDialog = inject(MatDialog);
|
||||
private toast: HotToastService = inject(HotToastService);
|
||||
private bottomSheet = inject(MatBottomSheet);
|
||||
private injector: Injector = inject(Injector);
|
||||
|
||||
@ViewChild('listSection', { read: ViewContainerRef, static: true }) clientList!: ViewContainerRef;
|
||||
clients: Client[] = [];
|
||||
|
||||
|
||||
@@ -42,6 +45,18 @@ export class DashboardComponent implements OnInit {
|
||||
load() {
|
||||
this.http.get<Client[]>('api/app/user/clients').subscribe(res => {
|
||||
this.clients = res;
|
||||
this.createList();
|
||||
})
|
||||
}
|
||||
|
||||
createList() {
|
||||
this.clientList.clear();
|
||||
this.clients.forEach(c => {
|
||||
const ref = this.clientList.createComponent(ClientCardComponent);
|
||||
ref.instance.client = c;
|
||||
ref.instance.onDelete.subscribe(() => {
|
||||
this.openDeleteDialog(c)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -102,6 +117,7 @@ export class DashboardComponent implements OnInit {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@ import { RedirectUri } from "./redirect-uri.interface";
|
||||
import { User } from "./user.interface";
|
||||
|
||||
export interface Client {
|
||||
admins: User;
|
||||
clientName: string;
|
||||
id: string;
|
||||
description: string;
|
||||
redirectUris: RedirectUri[];
|
||||
admins: User[];
|
||||
createdAt?: string;
|
||||
}
|
||||
@@ -21,6 +21,7 @@ html, body {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.create-client__dialog{
|
||||
|
||||
Reference in New Issue
Block a user