Procházet zdrojové kódy

RIFFMASTER: add PDF generation (song summary)

Kuba před 3 roky
rodič
revize
16baea80e9
31 změnil soubory, kde provedl 174 přidání a 54 odebrání
  1. 27 21
      Backend/Spring/.idea/workspace.xml
  2. 1 0
      Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/configuration/SecurityConfiguration.java
  3. 3 0
      Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/controller/PdfController.java
  4. 25 0
      Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/controller/PdfRestController.java
  5. 0 16
      Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/controller/SongController.java
  6. 2 0
      Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/service/IPdfService.java
  7. 43 0
      Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/service/PdfService.java
  8. binární
      Backend/Spring/target/Spring-1.0-SNAPSHOT/WEB-INF/classes/pl/dmcs/jwoszczyk/configuration/SecurityConfiguration.class
  9. binární
      Backend/Spring/target/Spring-1.0-SNAPSHOT/WEB-INF/classes/pl/dmcs/jwoszczyk/controller/PdfRestController.class
  10. binární
      Backend/Spring/target/Spring-1.0-SNAPSHOT/WEB-INF/classes/pl/dmcs/jwoszczyk/controller/SongController.class
  11. binární
      Backend/Spring/target/Spring-1.0-SNAPSHOT/WEB-INF/classes/pl/dmcs/jwoszczyk/service/IPdfService.class
  12. binární
      Backend/Spring/target/Spring-1.0-SNAPSHOT/WEB-INF/classes/pl/dmcs/jwoszczyk/service/PdfService.class
  13. binární
      Backend/Spring/target/classes/pl/dmcs/jwoszczyk/configuration/SecurityConfiguration.class
  14. binární
      Backend/Spring/target/classes/pl/dmcs/jwoszczyk/controller/PdfRestController.class
  15. binární
      Backend/Spring/target/classes/pl/dmcs/jwoszczyk/controller/SongController.class
  16. binární
      Backend/Spring/target/classes/pl/dmcs/jwoszczyk/service/IPdfService.class
  17. binární
      Backend/Spring/target/classes/pl/dmcs/jwoszczyk/service/PdfService.class
  18. binární
      Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/1.pack
  19. binární
      Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/2.pack
  20. binární
      Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/7.pack
  21. binární
      Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/8.pack
  22. binární
      Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/9.pack
  23. binární
      Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/index.pack
  24. binární
      Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/index.pack.old
  25. 0 0
      Frontend/RiffMasterFront/.angular/cache/16.0.4/babel-webpack/83e278ffb076cba7b2320779ca09af21f8d521a92fca6b56cf8eed48549dd2c4.json
  26. 0 0
      Frontend/RiffMasterFront/.angular/cache/16.0.4/babel-webpack/a0a3ec5842afd812907295f66dee9049066c1b224c9d72b5edb1eee8ebafca67.json
  27. 7 3
      Frontend/RiffMasterFront/.idea/workspace.xml
  28. 29 9
      Frontend/RiffMasterFront/src/app/Services/song.service.ts
  29. 7 0
      Frontend/RiffMasterFront/src/app/main-page/main-page.component.css
  30. 1 1
      Frontend/RiffMasterFront/src/app/main-page/main-page.component.html
  31. 29 4
      Frontend/RiffMasterFront/src/app/main-page/main-page.component.ts

+ 27 - 21
Backend/Spring/.idea/workspace.xml

@@ -10,7 +10,12 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="8315de53-8c15-472c-a710-45938463dc02" name="Changes" comment="RIFFMASTER: add frontend files">
+      <change beforePath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/2.pack" beforeDir="false" afterPath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/2.pack" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/7.pack" beforeDir="false" afterPath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/7.pack" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/index.pack" beforeDir="false" afterPath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/index.pack" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/index.pack.old" beforeDir="false" afterPath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/index.pack.old" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/src/app/Services/song.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/src/app/Services/song.service.ts" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/src/app/main-page/main-page.component.css" beforeDir="false" afterPath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/src/app/main-page/main-page.component.css" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/src/app/main-page/main-page.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/src/app/main-page/main-page.component.html" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/src/app/main-page/main-page.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../../Frontend/RiffMasterFront/src/app/main-page/main-page.component.ts" afterDir="false" />
@@ -24,8 +29,8 @@
     <option name="RECENT_TEMPLATES">
       <list>
         <option value="Jsp File" />
-        <option value="Class" />
         <option value="Interface" />
+        <option value="Class" />
       </list>
     </option>
   </component>
@@ -52,26 +57,26 @@
     <option name="hideEmptyMiddlePackages" value="true" />
     <option name="showLibraryContents" value="true" />
   </component>
-  <component name="PropertiesComponent">{
-  &quot;keyToString&quot;: {
-    &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
-    &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
-    &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
-    &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
-    &quot;last_opened_file_path&quot;: &quot;C:/Users/Kuba/Desktop/studia/WPFt/RiffMaster web application/Backend/Spring&quot;,
-    &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
-    &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
-    &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
-    &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
-    &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
-    &quot;project.structure.last.edited&quot;: &quot;Artifacts&quot;,
-    &quot;project.structure.proportion&quot;: &quot;0.15&quot;,
-    &quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
-    &quot;settings.editor.selected.configurable&quot;: &quot;reference.settings.project.maven.repository.indices&quot;,
-    &quot;spring.configuration.checksum&quot;: &quot;38008dd81c2f4d7985ecf6e0ce8af1d1&quot;,
-    &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
+  <component name="PropertiesComponent"><![CDATA[{
+  "keyToString": {
+    "RunOnceActivity.OpenProjectViewOnStart": "true",
+    "RunOnceActivity.ShowReadmeOnStart": "true",
+    "SHARE_PROJECT_CONFIGURATION_FILES": "true",
+    "WebServerToolWindowFactoryState": "false",
+    "last_opened_file_path": "C:/Users/Kuba/Desktop/studia/WPFt/inne/oslo_boating_project-master/oslo_boating_project/boat-reservation-logic",
+    "node.js.detected.package.eslint": "true",
+    "node.js.detected.package.tslint": "true",
+    "node.js.selected.package.eslint": "(autodetect)",
+    "node.js.selected.package.tslint": "(autodetect)",
+    "nodejs_package_manager_path": "npm",
+    "project.structure.last.edited": "Artifacts",
+    "project.structure.proportion": "0.15",
+    "project.structure.side.proportion": "0.2",
+    "settings.editor.selected.configurable": "reference.settings.project.maven.repository.indices",
+    "spring.configuration.checksum": "38008dd81c2f4d7985ecf6e0ce8af1d1",
+    "vue.rearranger.settings.migration": "true"
   }
-}</component>
+}]]></component>
   <component name="RecentsManager">
     <key name="CopyFile.RECENT_KEYS">
       <recent name="C:\Users\Kuba\Desktop\studia\WPFt\RiffMaster web application\Backend\Spring\src\main\java\pl\dmcs\jwoszczyk\RiffMaster" />
@@ -217,7 +222,8 @@
       <workItem from="1686836941887" duration="14004000" />
       <workItem from="1686898654444" duration="1889000" />
       <workItem from="1686909268841" duration="15817000" />
-      <workItem from="1686937489475" duration="603000" />
+      <workItem from="1686937489475" duration="803000" />
+      <workItem from="1686986592460" duration="2993000" />
     </task>
     <task id="LOCAL-00001" summary="add basic hello world and transfering data to server">
       <created>1679575346987</created>

+ 1 - 0
Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/configuration/SecurityConfiguration.java

@@ -83,6 +83,7 @@ public class SecurityConfiguration {
                         .requestMatchers("/riffs/song/**").permitAll()
                         .requestMatchers("/song**").permitAll()
                         .requestMatchers("/riffs**").permitAll()
+                        .requestMatchers("/pdf/**").permitAll()
                         .requestMatchers("/appUsers*").hasAnyRole("ADMIN", "USER")
                         .requestMatchers("/appUserRole*").hasRole("ADMIN")
                         .requestMatchers("/exampleOne*").hasAuthority("ROLE_USER")

+ 3 - 0
Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/controller/PdfController.java

@@ -25,5 +25,8 @@ public class PdfController {
     public void generatePdf(@PathVariable Integer appUserId, HttpServletResponse response) {
         pdfService.generatePdf(appUserService.getAppUser(appUserId), response);
     }
+
+
+
 }
 

+ 25 - 0
Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/controller/PdfRestController.java

@@ -0,0 +1,25 @@
+package pl.dmcs.jwoszczyk.controller;
+
+import jakarta.servlet.http.HttpServletResponse;
+import org.springframework.web.bind.annotation.*;
+import pl.dmcs.jwoszczyk.domain.Song;
+import pl.dmcs.jwoszczyk.service.IPdfService;
+import pl.dmcs.jwoszczyk.service.ISongService;
+
+@RestController
+@CrossOrigin(origins = "http://localhost:4200")
+public class PdfRestController {
+    private IPdfService pdfService;
+    private ISongService songService;
+
+    public PdfRestController(IPdfService pdfService, ISongService songService) {
+        this.pdfService = pdfService;
+        this.songService = songService;
+    }
+
+    @GetMapping("/pdf/{songId}")
+    public void generatePdf(@PathVariable Long songId, HttpServletResponse response) {
+        Song song = songService.getSong(songId);
+        pdfService.generateSongSummaryPdf(song, response);
+    }
+}

+ 0 - 16
Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/controller/SongController.java

@@ -29,22 +29,6 @@ public class SongController {
 
 //#################################################################################_GET ALL SONGS
 
-//    @RequestMapping(value = "/song", method = RequestMethod.GET) //, produces = MediaType.APPLICATION_JSON_VALUE
-//    public ResponseEntity<List<Song>> getAllSongs()
-//    {
-//        List<Song> songs = songService.getAllSongs();
-//        System.out.println("getAllsongs get request works" + songs.size() );
-//
-//        // Print the riffs count for the first song
-//        if (!songs.isEmpty()) {
-//            Song firstSong = songs.get(0);
-//            int riffCount = firstSong.getRiffs().size();
-//            System.out.println("Riffs count for the first song: " + riffCount);
-//        }
-//
-//        return ResponseEntity.ok(songs);
-//    }
-
     @RequestMapping(value = "/song", method = RequestMethod.GET)
     public ResponseEntity<List<Song>> getAllSongs() {
         List<Song> songs = songService.getAllSongs();

+ 2 - 0
Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/service/IPdfService.java

@@ -2,9 +2,11 @@ package pl.dmcs.jwoszczyk.service;
 
 import jakarta.servlet.http.HttpServletResponse;
 import pl.dmcs.jwoszczyk.domain.AppUser;
+import pl.dmcs.jwoszczyk.domain.Song;
 
 public interface IPdfService {
     public void generatePdf(AppUser appUser, HttpServletResponse response);
+    public void generateSongSummaryPdf(Song song, HttpServletResponse response);
 }
 
 

+ 43 - 0
Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/service/PdfService.java

@@ -4,11 +4,14 @@ import com.itextpdf.text.Chunk;
 import com.itextpdf.text.Document;
 import com.itextpdf.text.DocumentException;
 import com.itextpdf.text.Paragraph;
+import com.itextpdf.text.pdf.PdfPCell;
 import com.itextpdf.text.pdf.PdfPTable;
 import com.itextpdf.text.pdf.PdfWriter;
 import jakarta.servlet.http.HttpServletResponse;
 import org.springframework.stereotype.Service;
 import pl.dmcs.jwoszczyk.domain.AppUser;
+import pl.dmcs.jwoszczyk.domain.Riff;
+import pl.dmcs.jwoszczyk.domain.Song;
 
 import java.io.IOException;
 import java.io.OutputStream;
@@ -47,5 +50,45 @@ public class PdfService implements IPdfService {
             e.printStackTrace();
         }
     }
+
+
+    public void generateSongSummaryPdf(Song song, HttpServletResponse response) {
+        try {
+            OutputStream o = response.getOutputStream();
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("application/pdf");
+            response.setHeader("Content-Disposition", "inline; filename=" + song.getName() + ".pdf");
+            Document pdf = new Document();
+            PdfWriter.getInstance(pdf, o);
+            pdf.open();
+            pdf.add(new Paragraph("Pdf example - Spring Framework & iText library"));
+            pdf.add(new Paragraph(Chunk.NEWLINE));
+            PdfPTable table = new PdfPTable(2);
+            table.addCell("Name");
+            table.addCell(song.getName());
+            table.addCell("Link");
+            table.addCell(song.getLink());
+            table.addCell("Duration (ms)");
+            table.addCell(String.valueOf(song.getDurationMs()));
+            table.addCell("Upload Date");
+            table.addCell(song.getUploadDate().toString());
+            // Add Riffs information
+            table.addCell("Riffs");
+            PdfPCell riffsCell = new PdfPCell();
+            for (Riff riff : song.getRiffs()) {
+                riffsCell.addElement(new Paragraph("Name: " + riff.getName()));
+                riffsCell.addElement(new Paragraph("StartMs: " + riff.getStartMs()));
+                riffsCell.addElement(new Paragraph("EndMs: " + riff.getEndMs()));
+                riffsCell.addElement(new Paragraph("Group Color: " + riff.getGroupColor()));
+            }
+            table.addCell(riffsCell);
+            pdf.add(table);
+            pdf.close();
+            o.close();
+        } catch (IOException | DocumentException e) {
+            e.printStackTrace();
+        }
+    }
+
 }
 

binární
Backend/Spring/target/Spring-1.0-SNAPSHOT/WEB-INF/classes/pl/dmcs/jwoszczyk/configuration/SecurityConfiguration.class


binární
Backend/Spring/target/Spring-1.0-SNAPSHOT/WEB-INF/classes/pl/dmcs/jwoszczyk/controller/PdfRestController.class


binární
Backend/Spring/target/Spring-1.0-SNAPSHOT/WEB-INF/classes/pl/dmcs/jwoszczyk/controller/SongController.class


binární
Backend/Spring/target/Spring-1.0-SNAPSHOT/WEB-INF/classes/pl/dmcs/jwoszczyk/service/IPdfService.class


binární
Backend/Spring/target/Spring-1.0-SNAPSHOT/WEB-INF/classes/pl/dmcs/jwoszczyk/service/PdfService.class


binární
Backend/Spring/target/classes/pl/dmcs/jwoszczyk/configuration/SecurityConfiguration.class


binární
Backend/Spring/target/classes/pl/dmcs/jwoszczyk/controller/PdfRestController.class


binární
Backend/Spring/target/classes/pl/dmcs/jwoszczyk/controller/SongController.class


binární
Backend/Spring/target/classes/pl/dmcs/jwoszczyk/service/IPdfService.class


binární
Backend/Spring/target/classes/pl/dmcs/jwoszczyk/service/PdfService.class


binární
Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/1.pack


binární
Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/2.pack


binární
Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/7.pack


binární
Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/8.pack


binární
Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/9.pack


binární
Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/index.pack


binární
Frontend/RiffMasterFront/.angular/cache/16.0.4/angular-webpack/9163ed2c587ff4665fb17ea4ebc8750a69df1e73/index.pack.old


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
Frontend/RiffMasterFront/.angular/cache/16.0.4/babel-webpack/83e278ffb076cba7b2320779ca09af21f8d521a92fca6b56cf8eed48549dd2c4.json


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
Frontend/RiffMasterFront/.angular/cache/16.0.4/babel-webpack/a0a3ec5842afd812907295f66dee9049066c1b224c9d72b5edb1eee8ebafca67.json


+ 7 - 3
Frontend/RiffMasterFront/.idea/workspace.xml

@@ -6,8 +6,11 @@
   <component name="ChangeListManager">
     <list default="true" id="d91bc08d-d968-4797-8fb3-ef602a37db2a" name="Changes" comment="RIFFMASTER: add frontend business logic (riff, song)">
       <change beforePath="$PROJECT_DIR$/../../Backend/Spring/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../Backend/Spring/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../Backend/Spring/target/Spring-1.0-SNAPSHOT/WEB-INF/classes/pl/dmcs/jwoszczyk/domain/Riff.class" beforeDir="false" afterPath="$PROJECT_DIR$/../../Backend/Spring/target/Spring-1.0-SNAPSHOT/WEB-INF/classes/pl/dmcs/jwoszczyk/domain/Riff.class" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/../../Backend/Spring/target/classes/pl/dmcs/jwoszczyk/domain/Riff.class" beforeDir="false" afterPath="$PROJECT_DIR$/../../Backend/Spring/target/classes/pl/dmcs/jwoszczyk/domain/Riff.class" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/../../Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/configuration/SecurityConfiguration.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/configuration/SecurityConfiguration.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/../../Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/controller/PdfController.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/controller/PdfController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/../../Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/controller/SongController.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/controller/SongController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/../../Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/service/IPdfService.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/service/IPdfService.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/../../Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/service/PdfService.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../Backend/Spring/src/main/java/pl/dmcs/jwoszczyk/service/PdfService.java" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -100,7 +103,8 @@
       <workItem from="1686836939723" duration="5206000" />
       <workItem from="1686898660229" duration="4682000" />
       <workItem from="1686909264196" duration="8471000" />
-      <workItem from="1686937499471" duration="774000" />
+      <workItem from="1686937499471" duration="1137000" />
+      <workItem from="1686989529474" duration="1409000" />
     </task>
     <task id="LOCAL-00001" summary="RIFFMASTER: add frontend project">
       <created>1685976235580</created>

+ 29 - 9
Frontend/RiffMasterFront/src/app/Services/song.service.ts

@@ -1,4 +1,4 @@
-import { HttpClient, HttpHeaders } from '@angular/common/http';
+import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
 import { Injectable } from '@angular/core';
 import { Observable } from 'rxjs';
 import { Song } from '../models/song';
@@ -10,7 +10,7 @@ import { Riff } from '../models/riff';
 })
 export class SongService {
   apiUrl = 'http://localhost:8080/song';
-
+  private pdfUrl = 'http://localhost:8080/pdf';
   constructor(private http: HttpClient) {}
 
   getAllSongs(): Observable<Song[]> {
@@ -87,13 +87,33 @@ export class SongService {
     return songXml.end({ pretty: true });
   }
 
-
-
-
-
-
-
-
+  // generatePdf(songId: number): void {
+  //   this.http.get(`${this.pdfUrl}/${songId}`, { responseType: 'blob' }).subscribe(
+  //     (response: Blob) => {
+  //       const filename = 'song.pdf'; // Provide a default filename
+  //       const blob = new Blob([response], { type: 'application/pdf' });
+  //       this.downloadFile(blob, filename);
+  //     },
+  //     (error: any) => {
+  //       console.error('Error generating PDF:', error);
+  //       // Handle error if needed
+  //     }
+  //   );
+  // }
+  //
+  //
+  // downloadFile(blob: Blob, filename: string): void {
+  //   const anchorElement = document.createElement('a');
+  //   anchorElement.href = window.URL.createObjectURL(blob);
+  //   anchorElement.download = filename;
+  //   anchorElement.click();
+  //   window.URL.revokeObjectURL(anchorElement.href);
+  // }
+
+
+  generatePdf(songId: number): Observable<Blob> {
+    return this.http.get(`${this.pdfUrl}/${songId}`, { responseType: 'blob' });
+  }
 
 
 

+ 7 - 0
Frontend/RiffMasterFront/src/app/main-page/main-page.component.css

@@ -93,9 +93,16 @@ body {
 }
 
 .color-box {
+  display: inline-block;
   width: 20px;
   height: 20px;
   margin-right: 5px;
 }
 
 
+.empty-color-box {
+  display: inline-block;
+  width: 20px;
+  height: 20px;
+  border: 1px solid #ccc;
+}

+ 1 - 1
Frontend/RiffMasterFront/src/app/main-page/main-page.component.html

@@ -113,7 +113,7 @@
           <th mat-header-cell *matHeaderCellDef>GroupColor</th>
           <td mat-cell *matCellDef="let riff">
             <div class="color-container">
-              <span class="color-box" [style.backgroundColor]="getValidColor(riff.groupColor)"></span>
+              <span [ngClass]="{'color-box': riff.groupColor !== 'Transparent', 'empty-color-box': riff.groupColor === 'Transparent'}" [style.backgroundColor]="riff.groupColor"></span>
               <span>{{ riff.groupColor }}</span>
             </div>
           </td>

+ 29 - 4
Frontend/RiffMasterFront/src/app/main-page/main-page.component.ts

@@ -115,12 +115,37 @@ export class MainPageComponent implements OnInit {
   }
 
   getValidColor(color: string): string {
-    const validColor = color.startsWith("#") ? color.slice(0, 7) : "";
-    return validColor;
+    if (color === 'Transparent') {
+      return '';
+    } else if (color.startsWith("#")) {
+      return color.slice(0, 7);
+    } else {
+      return '';
+    }
   }
 
 
-  generatePdf() {
-    // Implement your PDF generation logic here
+
+  generatePdf(): void {
+    if (this.selectedSong) {
+      this.songService.generatePdf(this.selectedSong.id).subscribe(
+        (response: Blob) => {
+          const blob = new Blob([response], { type: 'application/pdf' });
+          const url = window.URL.createObjectURL(blob);
+
+          const a = document.createElement('a');
+          a.href = url;
+          a.target = '_blank'; // Open the PDF in a new tab
+          a.click();
+
+          window.URL.revokeObjectURL(url);
+          a.remove();
+        },
+        (error: any) => {
+          console.error('Error generating PDF:', error);
+        }
+      );
+    }
   }
+
 }

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů