This commit is contained in:
Bastian Wagner
2024-09-08 13:57:58 +02:00
parent c0b6a59bd2
commit 512160799e
8 changed files with 55 additions and 34 deletions

View File

@@ -7,7 +7,6 @@ DATABASE_PORT=3306
MYSQL_ROOT_PASSWORD=kjsdahflöijsdiu
# security
IGNORE_PASSWORDS=FALSE # hier kann man sich nur mit dem Username einloggen, nicht zu empfehlen ausser zum debuggen
JWT_SECRET=super-geheimes-secret
JWT_EXPIRES_IN=10m
JWT_REFRESH_EXPIRES_IN=1w
@@ -24,4 +23,5 @@ MAILER_PASSWORD=xxxxx
MAILER_FROM='"No Reply" <noreply@example.com>'
# Client
CLIENT_URL=http://localhost:4200
CLIENT_URL=http://localhost:4200
PRODUCTION=true

View File

@@ -8,7 +8,8 @@ export class UserService {
constructor(
private clientRepository: ClientRepository,
private logRepository: LogRepository,
) {}
) {
}
getUserClients(user: User): Promise<Client[]> {
return this.clientRepository.find({

View File

@@ -31,7 +31,10 @@ export class AuthController {
password,
clientId,
);
this.logger.log(`User ${username} logged in on client ${clientId}`);
this.logger.log(
`User ${username} logged in on client ${clientId}`,
clientId != null ? 'login' : 'systemlogin',
);
return token;
}

View File

@@ -1,4 +1,5 @@
import { LoggerService, Injectable, Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { InjectRepository } from '@nestjs/typeorm';
import { Log, LOGMESSAGETYPE } from 'src/model/log.entity';
import { Repository } from 'typeorm';
@@ -8,13 +9,19 @@ export class CustomLogger implements LoggerService {
private readonly logger = new Logger('CustomLogger');
// constructor(private readonly connection: Connection) {}
constructor(@InjectRepository(Log) private logRepository: Repository<Log>) {}
constructor(
@InjectRepository(Log) private logRepository: Repository<Log>,
private config: ConfigService,
) {}
private async logToDatabase(
level: string,
message: string,
type: LOGMESSAGETYPE = 'system',
) {
if (this.config.get('PRODUCTION') == 'false') {
return;
}
const logEntry = new Log();
logEntry.level = level;
logEntry.message = message;

View File

@@ -1,3 +1,4 @@
<div>
<canvas id="canvas">{{chart}}</canvas>
<h2>Logins</h2>
<canvas id="canvas" width="400px" >{{chart}}</canvas>
</div>

View File

@@ -0,0 +1,3 @@
h2 {
margin-top: 0;
}

View File

@@ -3,32 +3,31 @@
<div> {{ userName }} </div>
</div>
<div class="create-container">
<div class="flex-row">
<button mat-fab id="createClient" (click)="createClient()" [disabled]="clients.length == 10" >
<mat-icon>add</mat-icon>
</button>
<div class="flex-row body_design">
<div>
<div class="create-container">
<div class="flex-row">
<button mat-fab id="createClient" (click)="createClient()" [disabled]="clients.length == 10" >
<mat-icon>add</mat-icon>
</button>
<label for="createClient">
Client erstellen
</label>
</div>
<div class="flex-row" style="gap: 4px;">
<div class="chip"><span class="counter">{{ clients.length }}</span> von 10</div>
<div>Clients erstellt</div>
</div>
</div>
<div class="card-container">
<div class="card-container__list">
<ng-container #listSection />
</div>
</div>
</div>
<label for="createClient">
Client erstellen
</label>
</div>
<div class="flex-row" style="gap: 4px;">
<div class="chip"><span class="counter">{{ clients.length }}</span> von 10</div>
<div>Clients erstellt</div>
</div>
</div>
<div class="card-container">
<div class="card-container__list">
<ng-container #listSection>
</ng-container>
<!-- @for (client of clients; track $index) {
<app-card [client]="client" (onDelete)="openDeleteDialog($event)" ></app-card>
} -->
</div>
</div>
<app-chart-login></app-chart-login>
<app-chart-login />
</div>

View File

@@ -53,4 +53,11 @@
.title {
font-size: 1.5rem;
}
}
.body_design{
flex-wrap: wrap;
align-items: flex-start;
gap: 32px;
justify-content: center;
}