Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic frontend #31

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
.mvn/wrapper/maven-wrapper.jar

### Node ###
node_modules/
44 changes: 44 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "savethatsong",
"version": "1.0.0",
"description": "Application to save songs you're listening to",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/Migwel/SaveThatSong.git"
},
"author": "Miguel Gonzalez",
"license": "MIT",
"bugs": {
"url": "https://github.com/Migwel/SaveThatSong/issues"
},
"homepage": "https://github.com/Migwel/SaveThatSong#readme",
"dependencies": {
"bootstrap": "^5.3.2"
}
}
55 changes: 55 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@
<artifactId>IcyReader</artifactId>
<version>1.1-RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
<version>3.1.2.RELEASE</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down Expand Up @@ -185,6 +201,45 @@
</plugins>
</build>
</profile>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>io.github.cleydyr</groupId>
<artifactId>dart-sass-maven-plugin</artifactId>
<version>1.2.0</version>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>watch-sass</goal>
</goals>
<configuration>
<inputFolder>scss</inputFolder>
<outputFolder>src/main/resources/static/css</outputFolder>
</configuration>
</execution>
<execution>
<id>generate-css-using-sass</id>
<phase>generate-resources</phase>
<goals>
<goal>compile-sass</goal>
</goals>
<configuration>
<noSourceMap >true</noSourceMap >
<inputFolder>scss</inputFolder>
<outputFolder>src/main/resources/static/css</outputFolder>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
35 changes: 35 additions & 0 deletions scss/_custom_bootstrap.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 1. Include functions first (so you can manipulate colors, SVGs, calc, etc)
@import "../node_modules/bootstrap/scss/functions";

// 2. Include any default variable overrides here
$primary: #20c997;

// 3. Include remainder of required Bootstrap stylesheets (including any separate color mode stylesheets)
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/variables-dark";

// 4. Include any default map overrides here

// 5. Include remainder of required parts
@import "../node_modules/bootstrap/scss/maps";
@import "../node_modules/bootstrap/scss/mixins";
@import "../node_modules/bootstrap/scss/root";

// 6. Optionally include any other parts as needed
@import "../node_modules/bootstrap/scss/utilities";
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/containers";
@import "../node_modules/bootstrap/scss/grid";
@import "../node_modules/bootstrap/scss/helpers";
@import "../node_modules/bootstrap/scss/forms";
@import "../node_modules/bootstrap/scss/buttons";
@import "../node_modules/bootstrap/scss/nav";

// 7. Optionally include utilities API last to generate classes based on the Sass map in `_utilities.scss`
@import "../node_modules/bootstrap/scss/utilities/api";

// 8. Add additional custom code here

// @import "../node_modules/bootstrap/scss/bootstrap"
19 changes: 19 additions & 0 deletions scss/base.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import "custom_bootstrap";

html,
body {
height: 100%;
}

body {
align-items: center;
padding-top: 40px;
padding-bottom: 40px;
background-color: #f5f5f5;
}

header a,
header .nav-link {
color: $white;
text-decoration: none;
}
14 changes: 12 additions & 2 deletions src/main/java/dev/migwel/sts/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
Expand All @@ -16,13 +17,22 @@
@EnableWebSecurity
public class SecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
public SecurityFilterChain websiteSecurityFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(
authz ->
authz.requestMatchers("/error")
authz.requestMatchers("/", "/css/**", "/error", "/login")
.permitAll()
.anyRequest()
.authenticated())
.formLogin(login -> login.loginPage("/login"));
return http.build();
}

@Bean
@Order(1)
public SecurityFilterChain apiSecurityFilterChain(HttpSecurity http) throws Exception {
http.securityMatcher("api/**")
.authorizeHttpRequests(authz -> authz.anyRequest().authenticated())
.httpBasic(Customizer.withDefaults())
.oauth2Client(Customizer.withDefaults())
.csrf(AbstractHttpConfigurer::disable)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dev.migwel.sts.controller;
package dev.migwel.sts.controller.api;

import dev.migwel.sts.controller.dto.FromRadioRequest;
import dev.migwel.sts.controller.dto.FromRequest;
import dev.migwel.sts.controller.dto.FromSonosRequest;
import dev.migwel.sts.controller.dto.ToDatabaseRequest;
import dev.migwel.sts.controller.dto.ToRequest;
import dev.migwel.sts.controller.dto.ToSpotifyRequest;
import dev.migwel.sts.controller.api.dto.FromRadioRequest;
import dev.migwel.sts.controller.api.dto.FromRequest;
import dev.migwel.sts.controller.api.dto.FromSonosRequest;
import dev.migwel.sts.controller.api.dto.ToDatabaseRequest;
import dev.migwel.sts.controller.api.dto.ToRequest;
import dev.migwel.sts.controller.api.dto.ToSpotifyRequest;

import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller;
package dev.migwel.sts.controller.api;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.migwel.sts.controller;
package dev.migwel.sts.controller.api;

import dev.migwel.sts.controller.dto.SaveResponse;
import dev.migwel.sts.controller.dto.Song;
import dev.migwel.sts.controller.dto.ToResult;
import dev.migwel.sts.controller.api.dto.SaveResponse;
import dev.migwel.sts.controller.api.dto.Song;
import dev.migwel.sts.controller.api.dto.ToResult;
import dev.migwel.sts.domain.model.SaveResult;

import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dev.migwel.sts.controller;
package dev.migwel.sts.controller.api;

import dev.migwel.sts.controller.dto.FromRequest;
import dev.migwel.sts.controller.dto.SaveRequest;
import dev.migwel.sts.controller.dto.SaveResponse;
import dev.migwel.sts.controller.dto.ToRequest;
import dev.migwel.sts.controller.api.dto.FromRequest;
import dev.migwel.sts.controller.api.dto.SaveRequest;
import dev.migwel.sts.controller.api.dto.SaveResponse;
import dev.migwel.sts.controller.api.dto.ToRequest;
import dev.migwel.sts.domain.model.SaveResult;
import dev.migwel.sts.domain.service.SaveService;

Expand All @@ -21,7 +21,7 @@
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/save")
@RequestMapping("/api/save")
public class SaveController {

private static final Logger logger = LogManager.getLogger(SaveController.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller;
package dev.migwel.sts.controller.api;

import dev.migwel.sts.sonos.SonosAuthenticationService;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller;
package dev.migwel.sts.controller.api;

import dev.migwel.sts.spotify.SpotifyAuthenticationService;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller.dto;
package dev.migwel.sts.controller.api.dto;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller.dto;
package dev.migwel.sts.controller.api.dto;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller.dto;
package dev.migwel.sts.controller.api.dto;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller.dto;
package dev.migwel.sts.controller.api.dto;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dev.migwel.sts.controller.dto;
package dev.migwel.sts.controller.api.dto;

public record SaveResponse(Song song, ToResult toResult) {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dev.migwel.sts.controller.dto;
package dev.migwel.sts.controller.api.dto;

public record Song(String artist, String title, String rawData) {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller.dto;
package dev.migwel.sts.controller.api.dto;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller.dto;
package dev.migwel.sts.controller.api.dto;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller.dto;
package dev.migwel.sts.controller.api.dto;

import javax.annotation.CheckForNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller.dto;
package dev.migwel.sts.controller.api.dto;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller.error;
package dev.migwel.sts.controller.api.error;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller.error;
package dev.migwel.sts.controller.api.error;

public class FieldError {
private String field;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.migwel.sts.controller.error;
package dev.migwel.sts.controller.api.error;

import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.exc.InvalidTypeIdException;
Expand Down
Loading
Loading