auth
This commit is contained in:
@@ -19,35 +19,31 @@ import { Key } from 'src/model/entitites';
|
|||||||
import { KeyHandoverPDFDataDto } from 'src/model/dto/key-handover.dto';
|
import { KeyHandoverPDFDataDto } from 'src/model/dto/key-handover.dto';
|
||||||
|
|
||||||
|
|
||||||
|
@UseGuards(AuthGuard)
|
||||||
@Controller('key')
|
@Controller('key')
|
||||||
export class KeyController {
|
export class KeyController {
|
||||||
constructor(private service: KeyService) {}
|
constructor(private service: KeyService) {}
|
||||||
|
|
||||||
@UseGuards(AuthGuard)
|
|
||||||
@Get()
|
@Get()
|
||||||
getKeys(@Req() req: AuthenticatedRequest) {
|
getKeys(@Req() req: AuthenticatedRequest) {
|
||||||
return this.service.getUsersKeys(req.user);
|
return this.service.getUsersKeys(req.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(AuthGuard)
|
|
||||||
@Get('lost')
|
@Get('lost')
|
||||||
getLostKeys(@Req() req: AuthenticatedRequest) {
|
getLostKeys(@Req() req: AuthenticatedRequest) {
|
||||||
return this.service.getLostKeys(req.user);
|
return this.service.getLostKeys(req.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(AuthGuard)
|
|
||||||
@Post()
|
@Post()
|
||||||
postKey(@Req() req: AuthenticatedRequest, @Body() key: Key) {
|
postKey(@Req() req: AuthenticatedRequest, @Body() key: Key) {
|
||||||
return this.service.createKey(req.user, key);
|
return this.service.createKey(req.user, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(AuthGuard)
|
|
||||||
@Put()
|
@Put()
|
||||||
updateKey(@Req() req: AuthenticatedRequest, @Body() key: Key) {
|
updateKey(@Req() req: AuthenticatedRequest, @Body() key: Key) {
|
||||||
return this.service.updateKey(req.user, key);
|
return this.service.updateKey(req.user, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(AuthGuard)
|
|
||||||
@Put(':id/restore')
|
@Put(':id/restore')
|
||||||
restoreKey(@Req() req: AuthenticatedRequest, @Param('id') id: string) {
|
restoreKey(@Req() req: AuthenticatedRequest, @Param('id') id: string) {
|
||||||
return this.service.restoreKey(req.user, id);
|
return this.service.restoreKey(req.user, id);
|
||||||
@@ -56,7 +52,6 @@ export class KeyController {
|
|||||||
|
|
||||||
@Get(':id/handover/pdf')
|
@Get(':id/handover/pdf')
|
||||||
async getHandoverPDF(@Param('id') id: string, @Res() res: Response) {
|
async getHandoverPDF(@Param('id') id: string, @Res() res: Response) {
|
||||||
console.log("GET PDF")
|
|
||||||
const { pdf, response } = await this.service.getPdf(id);
|
const { pdf, response } = await this.service.getPdf(id);
|
||||||
res.setHeader(
|
res.setHeader(
|
||||||
'Content-Type',
|
'Content-Type',
|
||||||
@@ -76,7 +71,6 @@ export class KeyController {
|
|||||||
res.end(pdf);
|
res.end(pdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(AuthGuard)
|
|
||||||
@Post(':id/handover')
|
@Post(':id/handover')
|
||||||
handoutKey(
|
handoutKey(
|
||||||
@Req() req: AuthenticatedRequest,
|
@Req() req: AuthenticatedRequest,
|
||||||
@@ -86,13 +80,11 @@ export class KeyController {
|
|||||||
return this.service.handoverKey(req.user, body, id);
|
return this.service.handoverKey(req.user, body, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(AuthGuard)
|
|
||||||
@Get(':id/handover')
|
@Get(':id/handover')
|
||||||
getKeyHandouts(@Req() req: AuthenticatedRequest, @Param('id') id: string) {
|
getKeyHandouts(@Req() req: AuthenticatedRequest, @Param('id') id: string) {
|
||||||
return this.service.getKeyHandovers(req.user, id);
|
return this.service.getKeyHandovers(req.user, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(AuthGuard)
|
|
||||||
@Get('archive')
|
@Get('archive')
|
||||||
getArchive(@Req() req: AuthenticatedRequest) {
|
getArchive(@Req() req: AuthenticatedRequest) {
|
||||||
return this.service.getDeletedKeys(req.user);
|
return this.service.getDeletedKeys(req.user);
|
||||||
@@ -100,7 +92,6 @@ export class KeyController {
|
|||||||
|
|
||||||
@Post('pdf')
|
@Post('pdf')
|
||||||
async generatePdf(@Body() dto: KeyHandoverPDFDataDto, @Res() res: Response) {
|
async generatePdf(@Body() dto: KeyHandoverPDFDataDto, @Res() res: Response) {
|
||||||
console.log("GENERATE PDF")
|
|
||||||
const { pdf, response } = await this.service.createPdf(dto);
|
const { pdf, response } = await this.service.createPdf(dto);
|
||||||
|
|
||||||
res.setHeader(
|
res.setHeader(
|
||||||
@@ -121,7 +112,6 @@ export class KeyController {
|
|||||||
res.end(pdf);
|
res.end(pdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(AuthGuard)
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
deleteKey(@Req() req: AuthenticatedRequest, @Param('id') id: string) {
|
deleteKey(@Req() req: AuthenticatedRequest, @Param('id') id: string) {
|
||||||
return this.service.deleteKey(req.user, id);
|
return this.service.deleteKey(req.user, id);
|
||||||
|
|||||||
@@ -29,11 +29,8 @@ export class KeyService {
|
|||||||
private readonly configService: ConfigService,
|
private readonly configService: ConfigService,
|
||||||
private readonly mailService: MailService,
|
private readonly mailService: MailService,
|
||||||
private readonly sseService: SseService,
|
private readonly sseService: SseService,
|
||||||
private readonly httpService: HttpService,
|
|
||||||
private readonly pdfService: PdfService
|
private readonly pdfService: PdfService
|
||||||
) {
|
) { }
|
||||||
console.log("INIT KEYSERVICE")
|
|
||||||
}
|
|
||||||
|
|
||||||
get isDevelopMode(): boolean {
|
get isDevelopMode(): boolean {
|
||||||
return (this.configService.get('DEVELOP_MODE') || '').toLowerCase() == 'true';
|
return (this.configService.get('DEVELOP_MODE') || '').toLowerCase() == 'true';
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ export class PdfService {
|
|||||||
public async generatePDF(dto: KeyHandoverPDFDataDto): Promise<{ pdf: Buffer, response: AxiosResponse}> {
|
public async generatePDF(dto: KeyHandoverPDFDataDto): Promise<{ pdf: Buffer, response: AxiosResponse}> {
|
||||||
const h = await this.handoverRepo.findOneByOrFail({ id: dto.handoverId });
|
const h = await this.handoverRepo.findOneByOrFail({ id: dto.handoverId });
|
||||||
const response = await this.post(`${this.STORAGESERVER}/pdf/keyhandover`, dto);
|
const response = await this.post(`${this.STORAGESERVER}/pdf/keyhandover`, dto);
|
||||||
console.log(response)
|
|
||||||
if (response?.data == null) { return; }
|
if (response?.data == null) { return; }
|
||||||
h.pdfFormKey = response.data;
|
h.pdfFormKey = response.data;
|
||||||
await this.handoverRepo.save(h);
|
await this.handoverRepo.save(h);
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { ConfigService } from '@nestjs/config';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class StorageService {
|
export class StorageService {
|
||||||
constructor(private readonly configService: ConfigService) {
|
constructor() {}
|
||||||
console.log(configService.get('STORAGE_HOST'))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,5 @@ export class CreateKeyComponent {
|
|||||||
async setEditKey(key: IKey) {
|
async setEditKey(key: IKey) {
|
||||||
this.createForm.patchValue(key as any);
|
this.createForm.patchValue(key as any);
|
||||||
this.createForm.controls.cylinder.patchValue(this.cylinders.filter(c => key.cylinder.some(v => v.id == c.id)));
|
this.createForm.controls.cylinder.patchValue(this.cylinders.filter(c => key.cylinder.some(v => v.id == c.id)));
|
||||||
console.log(this.createForm.value)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ export class SystemComponent extends AgGridContainerComponent {
|
|||||||
await this.api.refreshSystems();
|
await this.api.refreshSystems();
|
||||||
this.gridApi.setGridOption("loading", false);
|
this.gridApi.setGridOption("loading", false);
|
||||||
const a = await this.api.getSystemArchive();
|
const a = await this.api.getSystemArchive();
|
||||||
console.log(a)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onGridReady(params: GridReadyEvent) {
|
onGridReady(params: GridReadyEvent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user