diff --git a/api/application.properties b/api/application.properties index 1bcd6c9..67b7fe8 100644 --- a/api/application.properties +++ b/api/application.properties @@ -4,5 +4,8 @@ spring.datasource.username=applications spring.datasource.password=applications spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +# Disable the trace on the error responses +server.error.include-stacktrace=never + # spring.sql.init.schema-locations=classpath:schema.sql # spring.sql.init.mode=always diff --git a/api/src/main/kotlin/com/andr3h3nriqu3s/applications/Flair.kt b/api/src/main/kotlin/com/andr3h3nriqu3s/applications/Flair.kt index f97ae79..5afaa65 100644 --- a/api/src/main/kotlin/com/andr3h3nriqu3s/applications/Flair.kt +++ b/api/src/main/kotlin/com/andr3h3nriqu3s/applications/Flair.kt @@ -3,6 +3,7 @@ package com.andr3h3nriqu3s.applications import java.sql.ResultSet import java.util.UUID import org.springframework.http.MediaType +import org.springframework.http.HttpStatus import org.springframework.jdbc.core.JdbcTemplate import org.springframework.jdbc.core.RowMapper import org.springframework.stereotype.Service @@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestHeader import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController +import org.springframework.web.server.ResponseStatusException data class CreateFlair( var color: String, @@ -26,7 +28,11 @@ data class CreateFlair( @RestController @ControllerAdvice @RequestMapping("/api/flair") -class FlairController(val sessionService: SessionService, val flairService: FlairService) { +class FlairController( + val sessionService: SessionService, + val flairService: FlairService, + val applicationService: ApplicationService +) { @PutMapping(path = ["/"], produces = [MediaType.APPLICATION_JSON_VALUE]) public fun create( @@ -61,6 +67,16 @@ class FlairController(val sessionService: SessionService, val flairService: Flai return flairService.listUser(user) } + @GetMapping(path = ["/simple/{id}"], produces = [MediaType.APPLICATION_JSON_VALUE]) + public fun listSimple(@PathVariable id: String): List { + var application = applicationService.findApplicationByIdNoUser(id) + if (application == null) { + throw ResponseStatusException(HttpStatus.NOT_FOUND, "Application Not Found", null) + } + + return flairService.listUserId(application.user_id).map { it.toFlairSimple() } + } + @DeleteMapping(path = ["/{id}"], produces = [MediaType.APPLICATION_JSON_VALUE]) public fun delete(@PathVariable id: String, @RequestHeader("token") token: String): Flair { val user = sessionService.verifyTokenThrow(token) @@ -69,9 +85,9 @@ class FlairController(val sessionService: SessionService, val flairService: Flai } data class SimpleFlair( - val name: String, - val description: String, - val color: String, + val name: String, + val description: String, + val color: String, ) data class Flair( @@ -96,7 +112,7 @@ data class Flair( } fun toFlairSimple(): SimpleFlair { - return SimpleFlair(this.name, this.description, this.color); + return SimpleFlair(this.name, this.description, this.color) } } @@ -151,7 +167,20 @@ public class FlairService(val db: JdbcTemplate) { .toList() public fun listUser(user: UserDb): List = - db.query("select * from flair where user_id=? order by name asc;", arrayOf(user.id), Flair).toList() + db.query( + "select * from flair where user_id=? order by name asc;", + arrayOf(user.id), + Flair + ) + .toList() + + public fun listUserId(id: String): List = + db.query( + "select * from flair where user_id=? and description != '' order by name asc;", + arrayOf(id), + Flair + ) + .toList() public fun getById(user: UserDb, id: String): Flair? { val items = diff --git a/extensions/background-script.js b/extensions/background-script.js index fdb4d92..72e4a55 100644 --- a/extensions/background-script.js +++ b/extensions/background-script.js @@ -65,6 +65,7 @@ browser.runtime.onMessage.addListener(async (message, sender, sendResponse) => { }); async function startup() { + console.log("Exp startup application") await browser.storage.local.set({ windows: null, interesetWindows: [], diff --git a/site/src/routes/cv/+page.svelte b/site/src/routes/cv/+page.svelte index 573c279..26a6295 100644 --- a/site/src/routes/cv/+page.svelte +++ b/site/src/routes/cv/+page.svelte @@ -29,7 +29,7 @@ let application: Application | undefined = $state(undefined); async function loadData() { - if (!id) return; + if (!id) return; try { application = await get(`application/cv/${id}`); @@ -49,20 +49,34 @@ } return 0; }); + + loadFlairs(); } catch (e) { console.log('TODO show this to the user', e); } } + + // Other skills search + let otherSearch = $state(''); + let flairs: SimpleFlair[] = $state([]); + + async function loadFlairs() { + try { + flairs = await get(`flair/simple/${id ?? ''}`); + } catch (e) { + console.log('TODO inform the user', e); + } + } - {#if application && userStore.isLoggedIn} - - andre-henriques-{application.company.toLowerCase().split(' ')[0]} - - {:else} - CV - {/if} + {#if application && userStore.isLoggedIn} + + andre-henriques-{application.company.toLowerCase().split(' ')[0]} + + {:else} + CV + {/if}
@@ -74,11 +88,17 @@
  • - {#if id} - andr3h3nriqu3s.com - {:else} - andr3h3nriqu3s.com - {/if} + {#if id} + andr3h3nriqu3s.com + {:else} + andr3h3nriqu3s.com + {/if}
  • 0}
    -

    Your Ad & My skills

    +

    + Your Ad & My skills {#if flairs.length > 0} + Looking for other skills? + {/if} +

    - {#each application.flairs as flair} -
    - {#if flair.description} -
    + {#if otherSearch === ''} + {#each application.flairs as flair} +
    + {#if flair.description}
    +
    + {flair.name} +
    + +
    + {flair.description} +
    +
    + {:else} +
    {flair.name}
    - -
    - {flair.description} -
    + {/if} +
    + {/each} + {:else} + {@const filtered_list = flairs.filter((a) => + a.name.match(new RegExp(otherSearch, 'i')) + )} + {#if filtered_list.length == 0} +
    + Could not find the skill you are looking for. +
    + {:else} + {#each filtered_list as flair} +
    + {#if flair.description} +
    +
    + {flair.name} +
    + +
    + {flair.description} +
    +
    + {:else} +
    + {flair.name} +
    + {/if}
    - {:else} -
    - {flair.name} -
    - {/if} -
    - {/each} + {/each} + {/if} + {/if}
    {/if}