-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Style API Portal and add templating mechanism (#2965)
* Include Brian changes for the templating (#2956) * new styles initial commit * swagger cont * css changes * spacing * fix html * update token --------- Co-authored-by: Brian Lee <[email protected]> * revert back Signed-off-by: at670475 <[email protected]> * resolve conflicts Signed-off-by: at670475 <[email protected]> * flag the css for zowe and portal Signed-off-by: at670475 <[email protected]> * add backend parameters mapping Signed-off-by: at670475 <[email protected]> * cleanup Signed-off-by: at670475 <[email protected]> * fix conditional flag check Signed-off-by: at670475 <[email protected]> * wip - fix css Signed-off-by: at670475 <[email protected]> * wip Signed-off-by: at670475 <[email protected]> * adjust css Signed-off-by: at670475 <[email protected]> * wip Signed-off-by: at670475 <[email protected]> * add links Signed-off-by: at670475 <[email protected]> * define branding function Signed-off-by: at670475 <[email protected]> * footer links Signed-off-by: at670475 <[email protected]> * count number of footer content Signed-off-by: at670475 <[email protected]> * fix issues and add move footer Signed-off-by: at670475 <[email protected]> * fix css Signed-off-by: at670475 <[email protected]> * flag the css for zowe and portal Signed-off-by: at670475 <[email protected]> * fix test Signed-off-by: at670475 <[email protected]> * small fix Signed-off-by: at670475 <[email protected]> * fix bug with version dropdown menu empty Signed-off-by: at670475 <[email protected]> * open link on new tab Signed-off-by: at670475 <[email protected]> * small fix Signed-off-by: at670475 <[email protected]> * make rsponsiveness Signed-off-by: at670475 <[email protected]> * responsiveness Signed-off-by: at670475 <[email protected]> * responsive Signed-off-by: at670475 <[email protected]> * fix css Signed-off-by: at670475 <[email protected]> * put back toastify config Signed-off-by: at670475 <[email protected]> * fix status Signed-off-by: at670475 <[email protected]> * update schema, some test fix for locar run Signed-off-by: Pablo Hernán Carle <[email protected]> * fix tests Signed-off-by: at670475 <[email protected]> * add media icons Signed-off-by: at670475 <[email protected]> * wip Signed-off-by: at670475 <[email protected]> * add templating for logo and controller to retrieve it Signed-off-by: at670475 <[email protected]> * add doc link Signed-off-by: at670475 <[email protected]> * Add skeleton for the footer Signed-off-by: at670475 <[email protected]> * Add tests Signed-off-by: at670475 <[email protected]> * fix code smells Signed-off-by: at670475 <[email protected]> * add test Signed-off-by: at670475 <[email protected]> * Update schema and start.sh Signed-off-by: at670475 <[email protected]> * delete yarn and set specific version for sass Signed-off-by: at670475 <[email protected]> * fix bug Signed-off-by: at670475 <[email protected]> * Add tests Signed-off-by: at670475 <[email protected]> * improve tests Signed-off-by: at670475 <[email protected]> * define mock custom config in tests Signed-off-by: at670475 <[email protected]> * increase coverage Signed-off-by: at670475 <[email protected]> * fix Signed-off-by: at670475 <[email protected]> * address pr comments Signed-off-by: at670475 <[email protected]> * revert back Signed-off-by: at670475 <[email protected]> * fix tests Signed-off-by: at670475 <[email protected]> * fix e2e test Signed-off-by: at670475 <[email protected]> * fix css Signed-off-by: at670475 <[email protected]> * Address pr comment Signed-off-by: at670475 <[email protected]> * npm script standalone Signed-off-by: Pablo Hernán Carle <[email protected]> * fix font family config Signed-off-by: at670475 <[email protected]> * address PR comments Signed-off-by: at670475 <[email protected]> * remove return from arrow function Signed-off-by: at670475 <[email protected]> --------- Signed-off-by: at670475 <[email protected]> Signed-off-by: Pablo Hernán Carle <[email protected]> Co-authored-by: Brian Lee <[email protected]> Co-authored-by: Pablo Hernán Carle <[email protected]>
- Loading branch information
1 parent
a5a93d2
commit b286cef
Showing
103 changed files
with
4,364 additions
and
4,732 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...log-services/src/main/java/org/zowe/apiml/apicatalog/controllers/api/ImageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
package org.zowe.apiml.apicatalog.controllers.api; | ||
|
||
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.core.io.InputStreamResource; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
@RestController | ||
@RequestMapping("/") | ||
public class ImageController { | ||
|
||
@Value("${apiml.catalog.customStyle.logo:}") | ||
private String image; | ||
|
||
@GetMapping(value = "/custom-logo") | ||
@HystrixCommand() | ||
@ResponseBody | ||
public ResponseEntity<InputStreamResource> downloadImage() { | ||
try { | ||
File imageFile = new File(image); | ||
String extension = image.substring(image.lastIndexOf(".") + 1); | ||
MediaType mediaType; | ||
InputStream imageStream = new FileInputStream(imageFile); | ||
switch (extension.toLowerCase()) { | ||
case "png": | ||
mediaType = MediaType.IMAGE_PNG; | ||
break; | ||
case "jpg": | ||
case "jpeg": | ||
mediaType = MediaType.IMAGE_JPEG; | ||
break; | ||
case "svg": | ||
mediaType = MediaType.valueOf("image/svg+xml"); | ||
break; | ||
default: | ||
mediaType = MediaType.APPLICATION_OCTET_STREAM; | ||
break; | ||
} | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setContentType(mediaType); | ||
return ResponseEntity.ok() | ||
.headers(headers) | ||
.body(new InputStreamResource(imageStream)); | ||
} catch (IOException e) { | ||
return ResponseEntity.notFound().build(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
api-catalog-services/src/main/java/org/zowe/apiml/apicatalog/model/CustomStyleConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
package org.zowe.apiml.apicatalog.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; | ||
import lombok.Data; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.io.Serializable; | ||
|
||
@Data | ||
@Configuration | ||
@ConfigurationProperties(prefix = "apiml.catalog.custom-style", ignoreInvalidFields = true) | ||
@JsonAutoDetect(fieldVisibility = Visibility.NONE, getterVisibility = Visibility.PUBLIC_ONLY, setterVisibility = Visibility.PUBLIC_ONLY) | ||
public class CustomStyleConfig implements Serializable { | ||
|
||
private String logo = ""; | ||
private String fontFamily = ""; | ||
private String titlesColor = ""; | ||
private String headerColor = ""; | ||
private String backgroundColor = ""; | ||
private String textColor = ""; | ||
private String docLink = ""; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...services/src/test/java/org/zowe/apiml/apicatalog/controllers/api/ImageControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
package org.zowe.apiml.apicatalog.controllers.api; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.util.ReflectionTestUtils; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
import org.springframework.test.web.servlet.setup.MockMvcBuilders; | ||
|
||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ImageControllerTest { | ||
|
||
private MockMvc mockMvc; | ||
|
||
@InjectMocks | ||
private ImageController imageController; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
mockMvc = MockMvcBuilders.standaloneSetup(imageController).build(); | ||
} | ||
|
||
@Nested | ||
class GivenImageEndpointRequest { | ||
@Nested | ||
class WhenPngFormat { | ||
@Test | ||
void thenDownloadImage() throws Exception { | ||
ReflectionTestUtils.setField(imageController, "image", "src/test/resources/api-catalog.png"); | ||
|
||
mockMvc.perform(get("/custom-logo")) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().contentType(MediaType.IMAGE_PNG)) | ||
.andReturn(); | ||
} | ||
} | ||
|
||
@Nested | ||
class WhenJpegFormat { | ||
@Test | ||
void thenDownloadImage() throws Exception { | ||
ReflectionTestUtils.setField(imageController, "image", "src/test/resources/api-catalog.jpeg"); | ||
|
||
mockMvc.perform(get("/custom-logo")) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().contentType(MediaType.IMAGE_JPEG)) | ||
.andReturn(); | ||
ReflectionTestUtils.setField(imageController, "image", "src/test/resources/api-catalog.jpg"); | ||
|
||
mockMvc.perform(get("/custom-logo")) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().contentType(MediaType.IMAGE_JPEG)) | ||
.andReturn(); | ||
} | ||
} | ||
|
||
@Nested | ||
class WhenSvgFormat { | ||
@Test | ||
void thenDownloadImage() throws Exception { | ||
ReflectionTestUtils.setField(imageController, "image", "src/test/resources/api-catalog.svg"); | ||
|
||
mockMvc.perform(get("/custom-logo")) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().contentType(MediaType.valueOf("image/svg+xml"))) | ||
.andReturn(); | ||
} | ||
} | ||
|
||
@Test | ||
void thenReturnFileNotFound() throws Exception { | ||
ReflectionTestUtils.setField(imageController, "image", "wrong/path/img.png"); | ||
|
||
mockMvc.perform(get("/custom-logo")) | ||
.andExpect(status().isNotFound()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.