Skip to content

Commit

Permalink
Merge branch 'main' of github.com:relievers/relive
Browse files Browse the repository at this point in the history
  • Loading branch information
mtte committed Oct 29, 2023
2 parents 577e494 + 0f26696 commit 16bc992
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 5 deletions.
16 changes: 16 additions & 0 deletions backend/src/main/java/ch/relievers/relive/WebSecurityConfig.java
Expand Up @@ -17,6 +17,11 @@
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

import java.util.Arrays;


@Configuration
Expand Down Expand Up @@ -68,4 +73,15 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

return http.build();
}

@Bean
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Arrays.asList("*"));
configuration.setAllowedMethods(Arrays.asList("*"));
configuration.setAllowedHeaders(Arrays.asList("*"));
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
}
5 changes: 3 additions & 2 deletions face-recognition/README.md
Expand Up @@ -15,8 +15,9 @@ flask run
## Usage
### Find user images in event images
`POST /find-user-imgs-in-event-imgs`
```plaintext

Request body:
```plaintext
{
'event_paths': ['event_path1', 'event_path2', ...],
'user_paths': ['user_path1', 'user_path2', ...]
Expand All @@ -25,7 +26,6 @@ Request body:

Response body:
```plaintext
Response body:
{
'event_path1': [
'user_path1': {
Expand All @@ -41,3 +41,4 @@ Response body:
], ...
}
```

21 changes: 21 additions & 0 deletions frontend/src/lib/api.ts
@@ -0,0 +1,21 @@
const DATABASE_URL = 'http://localhost:8080/';

function get(path: string) {
return fetch(DATABASE_URL + path, { method: 'GET' }).then((res) => {
if (!res.ok) {
throw res;
}
return res;
});
}

function post(path: string, body) {
return fetch(DATABASE_URL + path, { method: 'POST', body: body }).then((res) => {
if (!res.ok) {
throw res;
}
return res;
});
}

export default { get, post };
73 changes: 70 additions & 3 deletions frontend/src/routes/events/join/[eventId]/+page.svelte
@@ -1,6 +1,73 @@
<script>
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import api from '$lib/api';
import { getUser } from '$lib/user-service';
import { onMount } from 'svelte';
let user;
let name = '';
onMount(() => {
user = getUser();
if (!user) return;
joinEvent();
});
async function joinEvent() {
const eventId = $page.params.eventId;
try {
const response = await api.post(`events/${eventId}/participations`, {});
console.log(response);
goto('/');
} catch (e) {
alert(e);
}
}
async function createUser() {
try {
const response = await api.post('users', { name: name });
console.log(response);
} catch (e) {
alert(e);
}
}
</script>
<main>
<p class="text-white">{$page.params.eventId}</p>
</main>

<main
class="flex-grow bg-background text-center flex flex-col justify-between items-center text-white px-16 py-8 relative"
>
<button
on:click={createUser}
class="bg-accent h-14 w-14 rounded-full absolute bottom-10 mb-4 right-8 flex justify-center items-center"
>
<i class="fa fa-arrow-right" />
</button>
<!-- <h1 class="text-4xl">Name</h1> -->
<div />

<div class="flex flex-col gap-10">
<h2 class="text-accent text-3xl">What should we call you?</h2>
<input
class="bg-background w-full border-b-2 border-accent text-2xl placeholder:text-accent"
placeholder="Your Name..."
minlength="2"
bind:value={name}
/>
</div>

<div />

<!-- {#if step === 1}
<Step1 />
{:else if step === 2}
<Step2 />
{/if} -->

<!-- <div class="w-full h-1 flex justify-between gap-3">
<div class="w-full bg-accent" class:bg-purple-500={step == 1} />
<div class="w-full bg-accent" class:bg-purple-500={step == 1} />
</div> -->
</main>
9 changes: 9 additions & 0 deletions frontend/src/routes/register/Step1.svelte
@@ -0,0 +1,9 @@
<!-- <h1 class="text-4xl">Name</h1> -->
<div></div>

<div class="flex flex-col gap-10">
<h2 class="text-accent text-3xl">What should we call you?</h2>
<input class="bg-background w-full border-b-2 border-accent text-2xl placeholder:text-accent" placeholder="Your Name..." />
</div>

<div />
8 changes: 8 additions & 0 deletions frontend/src/routes/register/Step2.svelte
@@ -0,0 +1,8 @@
<h1 class="text-4xl">Step 2</h1>

<div class="flex flex-col gap-10">
<h2 class="text-accent text-3xl">What should we call you?</h2>
<input class="bg-background w-full border-b-2 border-accent text-2xl placeholder:text-accent" placeholder="Your Name..." />
</div>

<div />

0 comments on commit 16bc992

Please sign in to comment.