Feature/71 add leaflet to view tracks drawer (#72)

* adding leaflet

* adding tracks swiper

* adding tracks swiper

* adding tracks swiper

* adding tracks swiper

* adding tracks swiper

* adding tracks swiper
This commit was merged in pull request #72.
This commit is contained in:
2025-03-22 23:42:08 -05:00
committed by GitHub
parent 08498a64d8
commit 0f1e303c27
8 changed files with 857 additions and 785 deletions

View File

@@ -7,6 +7,20 @@ import { ConfigService } from '@nestjs/config';
private containerName: string;
private streamToBuffer(readableStream: NodeJS.ReadableStream) {
return new Promise<Buffer>((resolve, reject) => {
const chunks = [];
readableStream.on('data', (data) => {
chunks.push(data instanceof Buffer ? data : Buffer.from(data));
});
readableStream.on('end', () => {
resolve(Buffer.concat(chunks));
});
readableStream.on('error', reject)
})
}
async getBlobServiceInstance() {
const connectionString = this.configService.get<string>('azureStorageConnectionString');
const blobServiceClient: BlobServiceClient = await BlobServiceClient.fromConnectionString(connectionString)
@@ -23,7 +37,7 @@ import { ConfigService } from '@nestjs/config';
return blockBlobClient;
}
async uploadFile(file: Express.Multer.File, containerName: string, rowKey: string) {
async uploadFile(file: Express.Multer.File, containerName: string, rowKey: string): Promise<string> {
this.containerName = containerName;
const blockBlobClient = await this.getBlobClient(`${rowKey}/${file.originalname}`);
@@ -34,7 +48,17 @@ import { ConfigService } from '@nestjs/config';
return fileUrl;
}
async deleteFile(containerName: string, rowKey:string, fileName: string) {
async downloadFile(containerName: string, rowKey: string, fileName: string): Promise<string> {
this.containerName = containerName;
const blockBlobClient = await this.getBlobClient(`${rowKey}/${fileName}`);
const downloadBlockBlobResponse = await blockBlobClient.download();
const downloaded: string = (await this.streamToBuffer(downloadBlockBlobResponse.readableStreamBody)).toString()
return downloaded
}
async deleteFile(containerName: string, rowKey:string, fileName: string): Promise<void> {
this.containerName = containerName;
const blockBlobClient = await this.getBlobClient(`${rowKey}/${fileName}`);

View File

@@ -8,6 +8,7 @@ import {
Post,
Put,
Query,
StreamableFile,
UploadedFile,
UseGuards,
UseInterceptors
@@ -22,14 +23,15 @@ import { FileService } from '../file/file.service';
import { FileInterceptor } from '@nestjs/platform-express';
@Controller('logs')
@UseInterceptors(new LogInterceptor())
export class LogController {
constructor(
private readonly fileService: FileService,
private readonly logService: LogService
) {}
@Get(':partitionKey/:rowKey')
@UseInterceptors(new LogInterceptor())
async find(
@Param('partitionKey') partitionKey: string,
@Param('rowKey') rowKey: string
@@ -44,6 +46,7 @@ export class LogController {
}
@Get()
@UseInterceptors(new LogInterceptor())
async findAll(): Promise<Log[]> {
try {
return await this.logService.findAll();
@@ -121,11 +124,18 @@ export class LogController {
}
}
@Get(':partitionKey/:rowKey/track')
async downloadTrack(@Param('rowKey') rowKey: string, @Query('fileName') fileName: string): Promise<string> {
const containerName = 'tracks';
const downloadedFile: string = await this.fileService.downloadFile(containerName, rowKey, fileName)
return downloadedFile;
}
@UseGuards(AuthGuard)
@Delete(':partitionKey/:rowKey/track')
async deleteTrack(@Param('rowKey') rowKey: string, @Query('fileName') fileName: string): Promise<void> {
try {
console.log(fileName)
const containerName = 'tracks';
return await this.fileService.deleteFile(containerName, rowKey, fileName)