Skip to content
Draft
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
19 changes: 5 additions & 14 deletions api/src/main/kotlin/edu/wgu/osmt/api/model/ApiKeyword.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired
@JsonInclude(JsonInclude.Include.ALWAYS)
class ApiKeyword(
private val keyword: Keyword,
private val totalSkills: Long?,
private val appConfig: AppConfig
private val totalSkills: Long?
) {
@get:JsonProperty
val id: Long?
Expand All @@ -38,30 +37,22 @@ class ApiKeyword(
val skillCount: Long?
get() = totalSkills

@get:JsonProperty
val publicUrl: String
get() = "${appConfig.baseUrl}/api/metadata/keywords/${id}"

companion object {
fun fromDao(
keywordDao: KeywordDao,
appConfig: AppConfig
keywordDao: KeywordDao
): ApiKeyword {
return ApiKeyword(
keyword = keywordDao.toModel(),
totalSkills = keywordDao.skills.count(),
appConfig = appConfig
totalSkills = keywordDao.skills.count()
)
}

fun fromModel(
keyword: Keyword,
appConfig: AppConfig
keyword: Keyword
): ApiKeyword {
return ApiKeyword(
totalSkills = keyword.id?.let { KeywordDao.findById(it)?.skills?.count() ?: 0 },
keyword = keyword,
appConfig = appConfig
keyword = keyword
)
}
}
Expand Down
18 changes: 4 additions & 14 deletions api/src/main/kotlin/edu/wgu/osmt/keyword/KeywordController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class KeywordController @Autowired constructor(
val keywordEsRepo: KeywordEsRepo,
val richSkillEsRepo: RichSkillEsRepo,
val taskMessageService: TaskMessageService,
val appConfig: AppConfig,
val oAuthHelper: OAuthHelper,
) {

Expand All @@ -75,16 +74,7 @@ class KeywordController @Autowired constructor(

return ResponseEntity.status(200)
.headers(responseHeaders)
.body(searchResults.map { ApiKeyword.fromModel(it.content, appConfig) }.toList())
}

@RequestMapping(path = [
"${RoutePaths.API}${RoutePaths.UNVERSIONED}${RoutePaths.KEYWORD_DETAIL}"
],
produces = [MediaType.TEXT_HTML_VALUE])
fun byUUIDHtmlView(@PathVariable id: String): String {
System.out.println("here by uuid html view keyword")
return "forward:${RoutePaths.UNVERSIONED}/metadata/keywords/$id"
.body(searchResults.map { ApiKeyword.fromModel(it.content) }.toList())
}

@GetMapping(
Expand Down Expand Up @@ -114,7 +104,7 @@ class KeywordController @Autowired constructor(

return ResponseEntity
.status(HttpStatus.OK)
.body(keywordRepository.createFromApi(apiKeywordUpdate)?.let { ApiKeyword(it.toModel(), it.skills.count(), appConfig) })
.body(keywordRepository.createFromApi(apiKeywordUpdate)?.let { ApiKeyword(it.toModel(), it.skills.count()) })
}

@PostMapping(
Expand All @@ -136,7 +126,7 @@ class KeywordController @Autowired constructor(
oAuthHelper.readableUserName(user)
)
?.let {
ApiKeyword(it.toModel(), it.skills.count(), appConfig)
ApiKeyword(it.toModel(), it.skills.count())
}
)
}
Expand All @@ -159,7 +149,7 @@ class KeywordController @Autowired constructor(
private fun byId(
id: Long,
): ApiKeyword? {
val found = keywordRepository.findById(id)?.let { ApiKeyword(it.toModel(), it.skills.count(), appConfig) }
val found = keywordRepository.findById(id)?.let { ApiKeyword(it.toModel(), it.skills.count()) }
return found
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class SecurityConfig : WebSecurityConfigurerAdapter() {
.mvcMatchers(GET, "${RoutePaths.API}${RoutePaths.API_V3}${RoutePaths.SKILL_DETAIL}",
"${RoutePaths.API}${RoutePaths.API_V2}${RoutePaths.SKILL_DETAIL}",
"${RoutePaths.API}${RoutePaths.UNVERSIONED}${RoutePaths.SKILL_DETAIL}").permitAll()
.mvcMatchers(GET,"${RoutePaths.API}${RoutePaths.UNVERSIONED}${RoutePaths.KEYWORD_DETAIL}").permitAll()
.mvcMatchers(GET, "${RoutePaths.API}${RoutePaths.API_V3}${RoutePaths.COLLECTION_DETAIL}",
"${RoutePaths.API}${RoutePaths.API_V2}${RoutePaths.COLLECTION_DETAIL}",
"${RoutePaths.API}${RoutePaths.UNVERSIONED}${RoutePaths.COLLECTION_DETAIL}").permitAll()
Expand Down
4 changes: 1 addition & 3 deletions api/src/test/kotlin/edu/wgu/osmt/api/model/ApiKeywordTest.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package edu.wgu.osmt.api.model

import edu.wgu.osmt.config.AppConfig
import edu.wgu.osmt.keyword.Keyword
import edu.wgu.osmt.mockdata.MockData
import org.assertj.core.api.Assertions
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.springframework.beans.factory.annotation.Autowired

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal class ApiKeywordTest {
Expand All @@ -25,7 +23,7 @@ internal class ApiKeywordTest {
val kw: Keyword = mockData.getKeywords().first()

// Act
val api: ApiKeyword = ApiKeyword(kw, 7, mockData.appConfig)
val api: ApiKeyword = ApiKeyword(kw, 7)

// Assert
Assertions.assertThat(api.id).isEqualTo(kw.id)
Expand Down
9 changes: 5 additions & 4 deletions ui/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ const routes: Routes = [
component: MetadataPublicComponent,
canActivate: [AuthGuard]
},
{
path: "named-references/:id",
component: MetadataPublicComponent,
canActivate: [AuthGuard]
},
// admin metadata detail
{
path: "named-references/:id/manage",
Expand Down Expand Up @@ -248,10 +253,6 @@ const routes: Routes = [
{path: "collections/:uuid", component: CollectionPublicComponent},
{path: "api/skills/:uuid", component: RichSkillPublicComponent},
{path: "api/collections/:uuid", component: CollectionPublicComponent},
{
path: "api/metadata/keywords/:id",
component: MetadataPublicComponent
},

/* AUTHENTICATION REDIRECTS */
{path: "login", component: LoginComponent}, // redirect to oauth login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@
<span class="m-actionBarItem-x-text">Edit</span>
</button>

<button type="button" class="m-actionBarItem" (click)="handleCopyPublicURL()">
<span class="m-actionBarItem-x-icon">
<svg class="t-icon" aria-hidden="true">
<use [attr.xlink:href]="duplicateIcon"></use>
</svg>
</span>
<span class="m-actionBarItem-x-text">Copy Public URL</span>
<label>
<textarea class="t-visuallyHidden" #fullPath>{{metadataPublicUrl}}</textarea>
</label>
</button>
<button type="button" class="m-actionBarItem" (click)="handleDelete()" [disabled]="!canMetadataUpdate">
<span class="m-actionBarItem-x-icon">
<svg class="t-icon" aria-hidden="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ export class ManageMetadataActionBarVerticalComponent implements OnInit {
this.setEnableFlags();
}

handleCopyPublicURL(): void {
navigator.clipboard.writeText(this.metadataPublicUrl)
.then(
() => this.toastService.showToast("Success!", "URL copied to clipboard")
)
.catch(
() => this.toastService.showToast("Error", "Could not copy to clipboard")
);
}

setEnableFlags(): void {
this.canMetadataUpdate = this.authService.isEnabledByRoles(ButtonAction.MetadataUpdate);
this.canMetadataCreate = this.authService.isEnabledByRoles(ButtonAction.MetadataCreate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,6 @@
[showSkillCount]="false"
></app-metadata-card>
</div>

<div class="l-stickySidebar-x-sidebar">
<div class="l-stickySidebar-x-sidebarContent t-padding-medium t-padding-top">
<app-public-metadata-action-bar-vertical
[id]="getId()"
[metadataName]="getMetadataName()"
[metadataPublicUrl]="getPublicUrl()"
(reloadMetadata)="loadMetadata()"
></app-public-metadata-action-bar-vertical>

<nav class="m-quickLinks" aria-labelledby="save-quicklinks">
<h3 class="t-visuallyHidden" id="save-quicklinks">Quick Links</h3>
<a (click)="focusAndScrollIntoView(detailCard, 'h2')">Back to top</a>
</nav>
</div>
</div>
</div>

<div #titleHeading class="l-container">
Expand Down
2 changes: 0 additions & 2 deletions ui/src/app/metadata/named-reference/NamedReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export interface NamedReferenceInterface {
url: string
framework: string
skillCount: number
publicUrl: string
}

export class ApiNamedReference implements NamedReferenceInterface {
Expand All @@ -17,7 +16,6 @@ export class ApiNamedReference implements NamedReferenceInterface {
type?: MetadataType = MetadataType.Category
url = ""
skillCount: number = 0
publicUrl = ""

constructor(o?: NamedReferenceInterface) {
if (o !== undefined) {
Expand Down
3 changes: 1 addition & 2 deletions ui/test/resource/mock-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ export function createMockNamedReference2(
url = "http://url123",
framework = "Framework"
): NamedReferenceInterface {
return {id,name,type,url,framework, skillCount: 0, publicUrl: url
}
return {id,name,type,url,framework, skillCount: 0}
}

export const mockJobCodesParents: IJobCode[] = [
Expand Down